@@ -276,6 +276,25 @@ def create_driver(conf=base_config)
276276 assert_equal ( records , d . events )
277277 end
278278
279+ test 'metadata attached logs type in entries array' do
280+ @d = d = create_driver
281+
282+ time = event_time ( "2011-01-02 13:14:15 UTC" )
283+ metadata = { }
284+
285+ records = [
286+ { "a" => 1 } ,
287+ { "a" => 2 }
288+ ]
289+
290+ d . run ( expect_records : records . length , timeout : 20 ) do
291+ entries = records . map { |record | [ [ time , metadata ] , record ] }
292+ send_data packer . write ( [ "tag1" , entries , { "fluent_signal" => 0 } ] ) . to_s
293+ end
294+ assert_equal ( [ "tag1" , "tag1" ] , d . events . map { |tag , _time , _record | tag } )
295+ assert_equal ( records , d . events . map { |_tag , _time , record | record } )
296+ end
297+
279298 data ( tag : {
280299 param : "tag new_tag" ,
281300 result : "new_tag"
@@ -407,6 +426,28 @@ def create_driver(conf=base_config)
407426 assert_equal ( records , d . events )
408427 end
409428
429+ test 'metadata attached logs type in packed entries' do
430+ @d = d = create_driver
431+
432+ time = event_time ( "2011-01-02 13:14:15 UTC" )
433+ metadata = { }
434+
435+ records = [
436+ { "a" => 1 } ,
437+ { "a" => 2 } ,
438+ ]
439+
440+ d . run ( expect_records : records . length , timeout : 20 ) do
441+ entries = ''
442+ records . each { |record |
443+ packer ( entries ) . write ( [ [ time , metadata ] , record ] ) . flush
444+ }
445+ send_data packer . write ( [ "tag1" , entries , { "fluent_signal" => 0 } ] ) . to_s
446+ end
447+ assert_equal ( [ "tag1" , "tag1" ] , d . events . map { |tag , _time , _record | tag } )
448+ assert_equal ( records , d . events . map { |_tag , _time , record | record } )
449+ end
450+
410451 data ( tag : {
411452 param : "tag new_tag" ,
412453 result : "new_tag"
0 commit comments