@@ -327,6 +327,46 @@ def write_metadata(path, chunk_id, metadata, size, ctime, mtime)
327
327
plugin . stop ; plugin . before_shutdown ; plugin . shutdown ; plugin . after_shutdown ; plugin . close ; plugin . terminate
328
328
FileUtils . rm_r bufdir
329
329
end
330
+
331
+ test '#generate_chunk generates blank file chunk with specified permission with system_config' do
332
+ omit "NTFS doesn't support UNIX like permissions" if Fluent . windows?
333
+
334
+ begin
335
+ plugin = Fluent ::Plugin ::FileBuffer . new
336
+ plugin . owner = @d
337
+ rand_num = rand ( 0 ..100 )
338
+ bufpath = File . join ( File . expand_path ( "../../tmp/buffer_file_#{ rand_num } " , __FILE__ ) , 'testbuf.*.log' )
339
+ bufdir = File . dirname ( bufpath )
340
+
341
+ FileUtils . rm_r bufdir if File . exist? ( bufdir )
342
+ assert !File . exist? ( bufdir )
343
+
344
+ plugin . configure ( config_element ( 'buffer' , '' , { 'path' => bufpath } ) )
345
+
346
+ assert !File . exist? ( bufdir )
347
+ plugin . start
348
+
349
+ m = metadata ( )
350
+ c = nil
351
+ Fluent ::SystemConfig . overwrite_system_config ( "file_permission" => "700" ) do
352
+ c = plugin . generate_chunk ( m )
353
+ end
354
+
355
+ assert c . is_a? Fluent ::Plugin ::Buffer ::FileChunk
356
+ assert_equal m , c . metadata
357
+ assert c . empty?
358
+ assert_equal :unstaged , c . state
359
+ assert_equal 0700 , c . permission
360
+ assert_equal bufpath . gsub ( '.*.' , ".b#{ Fluent ::UniqueId . hex ( c . unique_id ) } ." ) , c . path
361
+ assert { File . stat ( c . path ) . mode . to_s ( 8 ) . end_with? ( '700' ) }
362
+
363
+ c . purge
364
+
365
+ plugin . stop ; plugin . before_shutdown ; plugin . shutdown ; plugin . after_shutdown ; plugin . close ; plugin . terminate
366
+ ensure
367
+ FileUtils . rm_r bufdir
368
+ end
369
+ end
330
370
end
331
371
332
372
sub_test_case 'configured with system root directory and plugin @id' do
0 commit comments