@@ -57,20 +57,30 @@ def write_metadata(path, chunk_id, metadata, size, ctime, mtime)
57
57
assert_equal File . join ( @dir , 'buffer.*.file' ) , p . path
58
58
end
59
59
60
- test 'existing directory will be used with additional default file name' do
60
+ data ( 'default' => [ nil , 'log' ] ,
61
+ 'conf' => [ '.buf' , 'buf' ] )
62
+ test 'existing directory will be used with additional default file name' do |params |
63
+ conf , suffix = params
61
64
d = FluentPluginFileBufferTest ::DummyOutputPlugin . new
62
65
p = Fluent ::Plugin ::FileBuffer . new
63
66
p . owner = d
64
- p . configure ( config_element ( 'buffer' , '' , { 'path' => @dir } ) )
65
- assert_equal File . join ( @dir , 'buffer.*.log' ) , p . path
67
+ c = { 'path' => @dir }
68
+ c [ 'path_suffix' ] = conf if conf
69
+ p . configure ( config_element ( 'buffer' , '' , c ) )
70
+ assert_equal File . join ( @dir , "buffer.*.#{ suffix } " ) , p . path
66
71
end
67
72
68
- test 'unexisting path without * handled as directory' do
73
+ data ( 'default' => [ nil , 'log' ] ,
74
+ 'conf' => [ '.buf' , 'buf' ] )
75
+ test 'unexisting path without * handled as directory' do |params |
76
+ conf , suffix = params
69
77
d = FluentPluginFileBufferTest ::DummyOutputPlugin . new
70
78
p = Fluent ::Plugin ::FileBuffer . new
71
79
p . owner = d
72
- p . configure ( config_element ( 'buffer' , '' , { 'path' => File . join ( @dir , 'buffer' ) } ) )
73
- assert_equal File . join ( @dir , 'buffer' , 'buffer.*.log' ) , p . path
80
+ c = { 'path' => File . join ( @dir , 'buffer' ) }
81
+ c [ 'path_suffix' ] = conf if conf
82
+ p . configure ( config_element ( 'buffer' , '' , c ) )
83
+ assert_equal File . join ( @dir , 'buffer' , "buffer.*.#{ suffix } " ) , p . path
74
84
end
75
85
end
76
86
@@ -312,10 +322,6 @@ def write_metadata(path, chunk_id, metadata, size, ctime, mtime)
312
322
@d = FluentPluginFileBufferTest ::DummyOutputPlugin . new
313
323
@p = Fluent ::Plugin ::FileBuffer . new
314
324
@p . owner = @d
315
- Fluent ::SystemConfig . overwrite_system_config ( 'root_dir' => @root_dir ) do
316
- @d . configure ( config_element ( 'ROOT' , '' , { '@id' => 'dummy_output_with_buf' } ) )
317
- @p . configure ( config_element ( 'buffer' , '' ) )
318
- end
319
325
end
320
326
321
327
teardown do
@@ -329,8 +335,18 @@ def write_metadata(path, chunk_id, metadata, size, ctime, mtime)
329
335
end
330
336
end
331
337
332
- test '#start creates directory for buffer chunks' do
333
- expected_buffer_path = File . join ( @root_dir , 'worker0' , 'dummy_output_with_buf' , 'buffer' , 'buffer.*.log' )
338
+ data ( 'default' => [ nil , 'log' ] ,
339
+ 'conf' => [ '.buf' , 'buf' ] )
340
+ test '#start creates directory for buffer chunks' do |params |
341
+ conf , suffix = params
342
+ c = { }
343
+ c [ 'path_suffix' ] = conf if conf
344
+ Fluent ::SystemConfig . overwrite_system_config ( 'root_dir' => @root_dir ) do
345
+ @d . configure ( config_element ( 'ROOT' , '' , { '@id' => 'dummy_output_with_buf' } ) )
346
+ @p . configure ( config_element ( 'buffer' , '' , c ) )
347
+ end
348
+
349
+ expected_buffer_path = File . join ( @root_dir , 'worker0' , 'dummy_output_with_buf' , 'buffer' , "buffer.*.#{ suffix } " )
334
350
expected_buffer_dir = File . dirname ( expected_buffer_path )
335
351
assert_equal expected_buffer_path , @p . path
336
352
assert_false Dir . exist? ( expected_buffer_dir )
0 commit comments