fluentd 1.13.3 → 1.16.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (179) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE/{bug_report.yaml → bug_report.yml} +2 -0
  3. data/.github/ISSUE_TEMPLATE/config.yml +2 -2
  4. data/.github/ISSUE_TEMPLATE/{feature_request.yaml → feature_request.yml} +1 -0
  5. data/.github/workflows/stale-actions.yml +11 -9
  6. data/.github/workflows/test.yml +32 -0
  7. data/CHANGELOG.md +490 -10
  8. data/CONTRIBUTING.md +2 -2
  9. data/MAINTAINERS.md +7 -5
  10. data/README.md +3 -23
  11. data/Rakefile +1 -1
  12. data/SECURITY.md +14 -0
  13. data/fluentd.gemspec +7 -8
  14. data/lib/fluent/command/cat.rb +13 -3
  15. data/lib/fluent/command/ctl.rb +6 -3
  16. data/lib/fluent/command/fluentd.rb +73 -65
  17. data/lib/fluent/command/plugin_config_formatter.rb +1 -1
  18. data/lib/fluent/compat/output.rb +9 -6
  19. data/lib/fluent/config/dsl.rb +1 -1
  20. data/lib/fluent/config/error.rb +12 -0
  21. data/lib/fluent/config/literal_parser.rb +2 -2
  22. data/lib/fluent/config/parser.rb +1 -1
  23. data/lib/fluent/config/v1_parser.rb +3 -3
  24. data/lib/fluent/config/yaml_parser/fluent_value.rb +47 -0
  25. data/lib/fluent/config/yaml_parser/loader.rb +108 -0
  26. data/lib/fluent/config/yaml_parser/parser.rb +166 -0
  27. data/lib/fluent/config/yaml_parser/section_builder.rb +107 -0
  28. data/lib/fluent/config/yaml_parser.rb +56 -0
  29. data/lib/fluent/config.rb +14 -1
  30. data/lib/fluent/counter/server.rb +1 -1
  31. data/lib/fluent/counter/validator.rb +3 -3
  32. data/lib/fluent/daemon.rb +2 -4
  33. data/lib/fluent/engine.rb +1 -1
  34. data/lib/fluent/env.rb +4 -0
  35. data/lib/fluent/error.rb +3 -0
  36. data/lib/fluent/event.rb +8 -4
  37. data/lib/fluent/event_router.rb +47 -2
  38. data/lib/fluent/file_wrapper.rb +137 -0
  39. data/lib/fluent/log/console_adapter.rb +66 -0
  40. data/lib/fluent/log.rb +44 -5
  41. data/lib/fluent/match.rb +1 -1
  42. data/lib/fluent/msgpack_factory.rb +6 -1
  43. data/lib/fluent/oj_options.rb +1 -2
  44. data/lib/fluent/plugin/bare_output.rb +49 -8
  45. data/lib/fluent/plugin/base.rb +26 -9
  46. data/lib/fluent/plugin/buf_file.rb +34 -5
  47. data/lib/fluent/plugin/buf_file_single.rb +32 -3
  48. data/lib/fluent/plugin/buffer/file_chunk.rb +1 -1
  49. data/lib/fluent/plugin/buffer.rb +216 -70
  50. data/lib/fluent/plugin/filter.rb +35 -1
  51. data/lib/fluent/plugin/filter_record_transformer.rb +1 -1
  52. data/lib/fluent/plugin/in_forward.rb +2 -2
  53. data/lib/fluent/plugin/in_http.rb +39 -10
  54. data/lib/fluent/plugin/in_monitor_agent.rb +4 -2
  55. data/lib/fluent/plugin/in_sample.rb +1 -1
  56. data/lib/fluent/plugin/in_syslog.rb +13 -1
  57. data/lib/fluent/plugin/in_tail/group_watch.rb +204 -0
  58. data/lib/fluent/plugin/in_tail/position_file.rb +33 -33
  59. data/lib/fluent/plugin/in_tail.rb +216 -84
  60. data/lib/fluent/plugin/in_tcp.rb +47 -2
  61. data/lib/fluent/plugin/input.rb +39 -1
  62. data/lib/fluent/plugin/metrics.rb +119 -0
  63. data/lib/fluent/plugin/metrics_local.rb +96 -0
  64. data/lib/fluent/plugin/multi_output.rb +43 -6
  65. data/lib/fluent/plugin/out_copy.rb +1 -1
  66. data/lib/fluent/plugin/out_exec_filter.rb +2 -2
  67. data/lib/fluent/plugin/out_file.rb +20 -2
  68. data/lib/fluent/plugin/out_forward/ack_handler.rb +19 -4
  69. data/lib/fluent/plugin/out_forward/socket_cache.rb +2 -0
  70. data/lib/fluent/plugin/out_forward.rb +17 -9
  71. data/lib/fluent/plugin/out_secondary_file.rb +39 -22
  72. data/lib/fluent/plugin/output.rb +167 -78
  73. data/lib/fluent/plugin/parser.rb +3 -4
  74. data/lib/fluent/plugin/parser_apache2.rb +1 -1
  75. data/lib/fluent/plugin/parser_json.rb +1 -1
  76. data/lib/fluent/plugin/parser_syslog.rb +1 -1
  77. data/lib/fluent/plugin/storage_local.rb +3 -5
  78. data/lib/fluent/plugin.rb +10 -1
  79. data/lib/fluent/plugin_helper/child_process.rb +3 -0
  80. data/lib/fluent/plugin_helper/event_emitter.rb +8 -1
  81. data/lib/fluent/plugin_helper/event_loop.rb +2 -2
  82. data/lib/fluent/plugin_helper/http_server/server.rb +2 -1
  83. data/lib/fluent/plugin_helper/metrics.rb +129 -0
  84. data/lib/fluent/plugin_helper/record_accessor.rb +1 -1
  85. data/lib/fluent/plugin_helper/retry_state.rb +14 -4
  86. data/lib/fluent/plugin_helper/server.rb +35 -6
  87. data/lib/fluent/plugin_helper/service_discovery.rb +2 -2
  88. data/lib/fluent/plugin_helper/socket.rb +13 -2
  89. data/lib/fluent/plugin_helper/thread.rb +3 -3
  90. data/lib/fluent/plugin_helper.rb +1 -0
  91. data/lib/fluent/plugin_id.rb +3 -2
  92. data/lib/fluent/registry.rb +2 -1
  93. data/lib/fluent/root_agent.rb +6 -0
  94. data/lib/fluent/rpc.rb +4 -3
  95. data/lib/fluent/supervisor.rb +283 -259
  96. data/lib/fluent/system_config.rb +13 -3
  97. data/lib/fluent/test/driver/base.rb +11 -5
  98. data/lib/fluent/test/driver/filter.rb +4 -0
  99. data/lib/fluent/test/startup_shutdown.rb +6 -8
  100. data/lib/fluent/time.rb +21 -20
  101. data/lib/fluent/version.rb +1 -1
  102. data/lib/fluent/win32api.rb +38 -0
  103. data/lib/fluent/winsvc.rb +5 -8
  104. data/templates/new_gem/test/helper.rb.erb +0 -1
  105. data/test/command/test_cat.rb +31 -2
  106. data/test/command/test_ctl.rb +1 -2
  107. data/test/command/test_fluentd.rb +209 -24
  108. data/test/command/test_plugin_config_formatter.rb +0 -1
  109. data/test/compat/test_parser.rb +6 -6
  110. data/test/config/test_system_config.rb +13 -11
  111. data/test/config/test_types.rb +1 -1
  112. data/test/log/test_console_adapter.rb +110 -0
  113. data/test/plugin/in_tail/test_io_handler.rb +26 -8
  114. data/test/plugin/in_tail/test_position_file.rb +48 -59
  115. data/test/plugin/out_forward/test_ack_handler.rb +39 -0
  116. data/test/plugin/out_forward/test_socket_cache.rb +26 -1
  117. data/test/plugin/test_bare_output.rb +14 -1
  118. data/test/plugin/test_base.rb +133 -1
  119. data/test/plugin/test_buf_file.rb +62 -23
  120. data/test/plugin/test_buf_file_single.rb +65 -0
  121. data/test/plugin/test_buffer.rb +267 -3
  122. data/test/plugin/test_buffer_chunk.rb +11 -0
  123. data/test/plugin/test_filter.rb +12 -1
  124. data/test/plugin/test_filter_parser.rb +1 -1
  125. data/test/plugin/test_filter_stdout.rb +2 -2
  126. data/test/plugin/test_in_forward.rb +9 -11
  127. data/test/plugin/test_in_http.rb +65 -3
  128. data/test/plugin/test_in_monitor_agent.rb +216 -11
  129. data/test/plugin/test_in_object_space.rb +9 -3
  130. data/test/plugin/test_in_syslog.rb +35 -0
  131. data/test/plugin/test_in_tail.rb +1393 -385
  132. data/test/plugin/test_in_tcp.rb +87 -2
  133. data/test/plugin/test_in_udp.rb +28 -0
  134. data/test/plugin/test_in_unix.rb +2 -2
  135. data/test/plugin/test_input.rb +12 -1
  136. data/test/plugin/test_metrics.rb +294 -0
  137. data/test/plugin/test_metrics_local.rb +96 -0
  138. data/test/plugin/test_multi_output.rb +25 -1
  139. data/test/plugin/test_out_exec.rb +6 -4
  140. data/test/plugin/test_out_exec_filter.rb +6 -2
  141. data/test/plugin/test_out_file.rb +34 -17
  142. data/test/plugin/test_out_forward.rb +78 -77
  143. data/test/plugin/test_out_http.rb +1 -0
  144. data/test/plugin/test_out_stdout.rb +2 -2
  145. data/test/plugin/test_output.rb +297 -12
  146. data/test/plugin/test_output_as_buffered.rb +44 -44
  147. data/test/plugin/test_output_as_buffered_compress.rb +32 -18
  148. data/test/plugin/test_output_as_buffered_retries.rb +54 -7
  149. data/test/plugin/test_output_as_buffered_secondary.rb +4 -4
  150. data/test/plugin/test_parser_regexp.rb +1 -6
  151. data/test/plugin/test_parser_syslog.rb +1 -1
  152. data/test/plugin_helper/test_cert_option.rb +1 -1
  153. data/test/plugin_helper/test_child_process.rb +38 -16
  154. data/test/plugin_helper/test_event_emitter.rb +29 -0
  155. data/test/plugin_helper/test_http_server_helper.rb +1 -1
  156. data/test/plugin_helper/test_metrics.rb +137 -0
  157. data/test/plugin_helper/test_retry_state.rb +602 -38
  158. data/test/plugin_helper/test_server.rb +78 -6
  159. data/test/plugin_helper/test_timer.rb +2 -2
  160. data/test/test_config.rb +191 -24
  161. data/test/test_event_router.rb +17 -0
  162. data/test/test_file_wrapper.rb +53 -0
  163. data/test/test_formatter.rb +24 -21
  164. data/test/test_log.rb +122 -40
  165. data/test/test_msgpack_factory.rb +32 -0
  166. data/test/test_plugin_classes.rb +102 -0
  167. data/test/test_root_agent.rb +30 -1
  168. data/test/test_supervisor.rb +477 -257
  169. data/test/test_time_parser.rb +22 -0
  170. metadata +55 -34
  171. data/.drone.yml +0 -35
  172. data/.github/workflows/issue-auto-closer.yml +0 -12
  173. data/.github/workflows/linux-test.yaml +0 -36
  174. data/.github/workflows/macos-test.yaml +0 -30
  175. data/.github/workflows/windows-test.yaml +0 -46
  176. data/.gitlab-ci.yml +0 -103
  177. data/lib/fluent/plugin/file_wrapper.rb +0 -187
  178. data/test/plugin/test_file_wrapper.rb +0 -126
  179. data/test/test_logger_initializer.rb +0 -46
@@ -5,6 +5,7 @@ require 'fileutils'
5
5
  require 'time'
6
6
  require 'timecop'
7
7
  require 'zlib'
8
+ require 'fluent/file_wrapper'
8
9
 
9
10
  class FileOutputTest < Test::Unit::TestCase
10
11
  def setup
@@ -263,8 +264,8 @@ class FileOutputTest < Test::Unit::TestCase
263
264
  assert !(Dir.exist?("#{TMP_DIR}/my.data/a"))
264
265
  assert !(Dir.exist?("#{TMP_DIR}/your.data/a"))
265
266
  buffer_files = Dir.entries("#{TMP_DIR}/buf_full").reject{|e| e =~ /^\.+$/ }
266
- assert_equal 2, buffer_files.select{|n| n.end_with?('.meta') }.size
267
- assert_equal 2, buffer_files.select{|n| !n.end_with?('.meta') }.size
267
+ assert_equal 2, buffer_files.count{|n| n.end_with?('.meta') }
268
+ assert_equal 2, buffer_files.count{|n| !n.end_with?('.meta') }
268
269
 
269
270
  m1 = d.instance.metadata('my.data', t1, {"type" => "a"})
270
271
  m2 = d.instance.metadata('your.data', t3, {"type" => "a"})
@@ -394,6 +395,11 @@ class FileOutputTest < Test::Unit::TestCase
394
395
  assert_equal expect, result
395
396
  end
396
397
 
398
+ def check_result(path, expect)
399
+ result = File.read(path, mode: "rb")
400
+ assert_equal expect, result
401
+ end
402
+
397
403
  sub_test_case 'write' do
398
404
  test 'basic case' do
399
405
  d = create_driver
@@ -535,20 +541,27 @@ class FileOutputTest < Test::Unit::TestCase
535
541
  assert_equal 3, Dir.glob("#{TMP_DIR}/out_file_test.*").size
536
542
  end
537
543
 
538
- test 'append' do
544
+ data(
545
+ "with compression" => true,
546
+ "without compression" => false,
547
+ )
548
+ test 'append' do |compression|
539
549
  time = event_time("2011-01-02 13:14:15 UTC")
540
550
  formatted_lines = %[2011-01-02T13:14:15Z\ttest\t{"a":1}#{@default_newline}] + %[2011-01-02T13:14:15Z\ttest\t{"a":2}#{@default_newline}]
541
551
 
542
552
  write_once = ->(){
543
- d = create_driver %[
553
+ config = %[
544
554
  path #{TMP_DIR}/out_file_test
545
- compress gz
546
555
  utc
547
556
  append true
548
557
  <buffer>
549
558
  timekey_use_utc true
550
559
  </buffer>
551
560
  ]
561
+ if compression
562
+ config << " compress gz"
563
+ end
564
+ d = create_driver(config)
552
565
  d.run(default_tag: 'test'){
553
566
  d.feed(time, {"a"=>1})
554
567
  d.feed(time, {"a"=>2})
@@ -556,17 +569,21 @@ class FileOutputTest < Test::Unit::TestCase
556
569
  d.instance.last_written_path
557
570
  }
558
571
 
559
- path = write_once.call
560
- assert_equal "#{TMP_DIR}/out_file_test.20110102.log.gz", path
561
- check_gzipped_result(path, formatted_lines)
562
-
563
- path = write_once.call
564
- assert_equal "#{TMP_DIR}/out_file_test.20110102.log.gz", path
565
- check_gzipped_result(path, formatted_lines * 2)
572
+ log_file_name = "out_file_test.20110102.log"
573
+ if compression
574
+ log_file_name << ".gz"
575
+ end
566
576
 
567
- path = write_once.call
568
- assert_equal "#{TMP_DIR}/out_file_test.20110102.log.gz", path
569
- check_gzipped_result(path, formatted_lines * 3)
577
+ 1.upto(3) do |i|
578
+ path = write_once.call
579
+ assert_equal "#{TMP_DIR}/#{log_file_name}", path
580
+ expect = formatted_lines * i
581
+ if compression
582
+ check_gzipped_result(path, expect)
583
+ else
584
+ check_result(path, expect)
585
+ end
586
+ end
570
587
  end
571
588
 
572
589
  test 'append when JST' do
@@ -1000,7 +1017,7 @@ class FileOutputTest < Test::Unit::TestCase
1000
1017
 
1001
1018
  test 'returns filepath with index which does not exist yet' do
1002
1019
  5.times do |i|
1003
- File.open(File.join(@tmp, "exist_#{i}.log"), 'a'){|f| } # open(create) and close
1020
+ Fluent::FileWrapper.open(File.join(@tmp, "exist_#{i}.log"), 'a'){|f| } # open(create) and close
1004
1021
  end
1005
1022
  @i.find_filepath_available(File.join(@tmp, "exist_**.log")) do |path|
1006
1023
  assert_equal File.join(@tmp, "exist_5.log"), path
@@ -1009,7 +1026,7 @@ class FileOutputTest < Test::Unit::TestCase
1009
1026
 
1010
1027
  test 'creates lock directory when with_lock is true to exclude operations of other worker process' do
1011
1028
  5.times do |i|
1012
- File.open(File.join(@tmp, "exist_#{i}.log"), 'a')
1029
+ Fluent::FileWrapper.open(File.join(@tmp, "exist_#{i}.log"), 'a')
1013
1030
  end
1014
1031
  Dir.mkdir(File.join(@tmp, "exist_5.log.lock"))
1015
1032
  @i.find_filepath_available(File.join(@tmp, "exist_**.log"), with_lock: true) do |path|
@@ -156,7 +156,14 @@ EOL
156
156
  normal_conf = config_element('match', '**', {}, [
157
157
  config_element('server', '', {'name' => 'test', 'host' => 'unexisting.yaaaaaaaaaaaaaay.host.example.com'})
158
158
  ])
159
- assert_raise SocketError do
159
+
160
+ if Socket.const_defined?(:ResolutionError) # as of Ruby 3.3
161
+ error_class = Socket::ResolutionError
162
+ else
163
+ error_class = SocketError
164
+ end
165
+
166
+ assert_raise error_class do
160
167
  create_driver(normal_conf)
161
168
  end
162
169
 
@@ -165,7 +172,7 @@ EOL
165
172
  ])
166
173
  @d = d = create_driver(conf)
167
174
  expected_log = "failed to resolve node name when configured"
168
- expected_detail = 'server="test" error_class=SocketError'
175
+ expected_detail = "server=\"test\" error_class=#{error_class.name}"
169
176
  logs = d.logs
170
177
  assert{ logs.any?{|log| log.include?(expected_log) && log.include?(expected_detail) } }
171
178
  end
@@ -431,10 +438,12 @@ EOL
431
438
  ]
432
439
 
433
440
  stub(d.instance.ack_handler).read_ack_from_sock(anything).never
434
- target_input_driver.run(expect_records: 2) do
435
- d.run do
436
- emit_events.each do |tag, t, record|
437
- d.feed(tag, t, record)
441
+ assert_rr do
442
+ target_input_driver.run(expect_records: 2) do
443
+ d.run do
444
+ emit_events.each do |tag, t, record|
445
+ d.feed(tag, t, record)
446
+ end
438
447
  end
439
448
  end
440
449
  end
@@ -461,10 +470,12 @@ EOL
461
470
  ]
462
471
 
463
472
  stub(d.instance.ack_handler).read_ack_from_sock(anything).never
464
- target_input_driver.run(expect_records: 2) do
465
- d.run(default_tag: 'test') do
466
- records.each do |record|
467
- d.feed(time, record)
473
+ assert_rr do
474
+ target_input_driver.run(expect_records: 2) do
475
+ d.run(default_tag: 'test') do
476
+ records.each do |record|
477
+ d.feed(time, record)
478
+ end
468
479
  end
469
480
  end
470
481
  end
@@ -491,10 +502,12 @@ EOL
491
502
  {"a" => 2}
492
503
  ]
493
504
  stub(d.instance.ack_handler).read_ack_from_sock(anything).never
494
- target_input_driver.run(expect_records: 2) do
495
- d.run(default_tag: 'test') do
496
- records.each do |record|
497
- d.feed(time, record)
505
+ assert_rr do
506
+ target_input_driver.run(expect_records: 2) do
507
+ d.run(default_tag: 'test') do
508
+ records.each do |record|
509
+ d.feed(time, record)
510
+ end
498
511
  end
499
512
  end
500
513
  end
@@ -549,10 +562,12 @@ EOL
549
562
  ]
550
563
  # not attempt to receive responses
551
564
  stub(d.instance.ack_handler).read_ack_from_sock(anything).never
552
- target_input_driver.run(expect_records: 2) do
553
- d.run(default_tag: 'test') do
554
- records.each do |record|
555
- d.feed(time, record)
565
+ assert_rr do
566
+ target_input_driver.run(expect_records: 2) do
567
+ d.run(default_tag: 'test') do
568
+ records.each do |record|
569
+ d.feed(time, record)
570
+ end
556
571
  end
557
572
  end
558
573
  end
@@ -575,10 +590,12 @@ EOL
575
590
  ]
576
591
  # not attempt to receive responses
577
592
  stub(d.instance.ack_handler).read_ack_from_sock(anything).never
578
- target_input_driver.run(expect_records: 2) do
579
- d.run(default_tag: 'test') do
580
- records.each do |record|
581
- d.feed(time, record)
593
+ assert_rr do
594
+ target_input_driver.run(expect_records: 2) do
595
+ d.run(default_tag: 'test') do
596
+ records.each do |record|
597
+ d.feed(time, record)
598
+ end
582
599
  end
583
600
  end
584
601
  end
@@ -1231,27 +1248,22 @@ EOL
1231
1248
  target_input_driver = create_target_input_driver(conf: target_config)
1232
1249
  output_conf = config
1233
1250
  d = create_driver(output_conf)
1234
- d.instance_start
1235
1251
 
1236
- begin
1237
- chunk = Fluent::Plugin::Buffer::MemoryChunk.new(Fluent::Plugin::Buffer::Metadata.new(nil, nil, nil))
1238
- mock.proxy(d.instance).socket_create_tcp(TARGET_HOST, @target_port,
1239
- linger_timeout: anything,
1240
- send_timeout: anything,
1241
- recv_timeout: anything,
1242
- connect_timeout: anything
1243
- ) { |sock| mock(sock).close.once; sock }.twice
1252
+ chunk = Fluent::Plugin::Buffer::MemoryChunk.new(Fluent::Plugin::Buffer::Metadata.new(nil, nil, nil))
1253
+ mock.proxy(d.instance).socket_create_tcp(TARGET_HOST, @target_port,
1254
+ linger_timeout: anything,
1255
+ send_timeout: anything,
1256
+ recv_timeout: anything,
1257
+ connect_timeout: anything
1258
+ ) { |sock| mock(sock).close.once; sock }.twice
1244
1259
 
1245
- target_input_driver.run(timeout: 15) do
1246
- d.run(shutdown: false) do
1247
- node = d.instance.nodes.first
1248
- 2.times do
1249
- node.send_data('test', chunk) rescue nil
1250
- end
1260
+ target_input_driver.run(timeout: 15) do
1261
+ d.run do
1262
+ node = d.instance.nodes.first
1263
+ 2.times do
1264
+ node.send_data('test', chunk) rescue nil
1251
1265
  end
1252
1266
  end
1253
- ensure
1254
- d.instance_shutdown
1255
1267
  end
1256
1268
  end
1257
1269
 
@@ -1265,7 +1277,6 @@ EOL
1265
1277
  port #{@target_port}
1266
1278
  </server>
1267
1279
  ])
1268
- d.instance_start
1269
1280
  assert_nothing_raised { d.run }
1270
1281
  end
1271
1282
 
@@ -1277,33 +1288,28 @@ EOL
1277
1288
  keepalive_timeout 2
1278
1289
  ]
1279
1290
  d = create_driver(output_conf)
1280
- d.instance_start
1281
1291
 
1282
- begin
1283
- chunk = Fluent::Plugin::Buffer::MemoryChunk.new(Fluent::Plugin::Buffer::Metadata.new(nil, nil, nil))
1284
- mock.proxy(d.instance).socket_create_tcp(TARGET_HOST, @target_port,
1285
- linger_timeout: anything,
1286
- send_timeout: anything,
1287
- recv_timeout: anything,
1288
- connect_timeout: anything
1289
- ) { |sock| mock(sock).close.once; sock }.once
1292
+ chunk = Fluent::Plugin::Buffer::MemoryChunk.new(Fluent::Plugin::Buffer::Metadata.new(nil, nil, nil))
1293
+ mock.proxy(d.instance).socket_create_tcp(TARGET_HOST, @target_port,
1294
+ linger_timeout: anything,
1295
+ send_timeout: anything,
1296
+ recv_timeout: anything,
1297
+ connect_timeout: anything
1298
+ ) { |sock| mock(sock).close.once; sock }.once
1290
1299
 
1291
- target_input_driver.run(timeout: 15) do
1292
- d.run(shutdown: false) do
1293
- node = d.instance.nodes.first
1294
- 2.times do
1295
- node.send_data('test', chunk) rescue nil
1296
- end
1300
+ target_input_driver.run(timeout: 15) do
1301
+ d.run do
1302
+ node = d.instance.nodes.first
1303
+ 2.times do
1304
+ node.send_data('test', chunk) rescue nil
1297
1305
  end
1298
1306
  end
1299
- ensure
1300
- d.instance_shutdown
1301
1307
  end
1302
1308
  end
1303
1309
 
1304
1310
  test 'create timer of purging obsolete sockets' do
1305
1311
  output_conf = config + %[keepalive true]
1306
- d = create_driver(output_conf)
1312
+ @d = d = create_driver(output_conf)
1307
1313
 
1308
1314
  mock(d.instance).timer_execute(:out_forward_heartbeat_request, 1).once
1309
1315
  mock(d.instance).timer_execute(:out_forward_keep_alived_socket_watcher, 5).once
@@ -1319,28 +1325,23 @@ EOL
1319
1325
  keepalive_timeout 2
1320
1326
  ]
1321
1327
  d = create_driver(output_conf)
1322
- d.instance_start
1323
1328
 
1324
- begin
1325
- chunk = Fluent::Plugin::Buffer::MemoryChunk.new(Fluent::Plugin::Buffer::Metadata.new(nil, nil, nil))
1326
- mock.proxy(d.instance).socket_create_tcp(TARGET_HOST, @target_port,
1327
- linger_timeout: anything,
1328
- send_timeout: anything,
1329
- recv_timeout: anything,
1330
- connect_timeout: anything) { |sock|
1331
- mock(sock).close.once; sock
1332
- }.twice
1333
-
1334
- target_input_driver.run(timeout: 15) do
1335
- d.run(shutdown: false) do
1336
- node = d.instance.nodes.first
1337
- 2.times do
1338
- node.send_data('test', chunk) rescue nil
1339
- end
1329
+ chunk = Fluent::Plugin::Buffer::MemoryChunk.new(Fluent::Plugin::Buffer::Metadata.new(nil, nil, nil))
1330
+ mock.proxy(d.instance).socket_create_tcp(TARGET_HOST, @target_port,
1331
+ linger_timeout: anything,
1332
+ send_timeout: anything,
1333
+ recv_timeout: anything,
1334
+ connect_timeout: anything) { |sock|
1335
+ mock(sock).close.once; sock
1336
+ }.twice
1337
+
1338
+ target_input_driver.run(timeout: 15) do
1339
+ d.run do
1340
+ node = d.instance.nodes.first
1341
+ 2.times do
1342
+ node.send_data('test', chunk) rescue nil
1340
1343
  end
1341
1344
  end
1342
- ensure
1343
- d.instance_shutdown
1344
1345
  end
1345
1346
  end
1346
1347
  end
@@ -378,6 +378,7 @@ class HTTPOutputTest < Test::Unit::TestCase
378
378
  password hello?
379
379
  </auth>
380
380
  ])
381
+ d.instance.system_config_override(root_dir: TMP_DIR) # Backup files are generated in TMP_DIR.
381
382
  d.run(default_tag: 'test.http', shutdown: false) do
382
383
  test_events.each { |event|
383
384
  d.feed(event)
@@ -32,7 +32,7 @@ class StdoutOutputTest < Test::Unit::TestCase
32
32
  assert_kind_of Fluent::Plugin::StdoutFormatter, d.instance.formatter
33
33
  assert_equal 'hash', d.instance.formatter.output_type
34
34
 
35
- assert_raise(Fluent::ConfigError) do
35
+ assert_raise(Fluent::NotFoundPluginError) do
36
36
  d = create_driver(CONFIG + "\noutput_type foo")
37
37
  end
38
38
  end
@@ -126,7 +126,7 @@ class StdoutOutputTest < Test::Unit::TestCase
126
126
  assert_kind_of Fluent::Plugin::StdoutFormatter, d.instance.formatter
127
127
  assert_equal 'hash', d.instance.formatter.output_type
128
128
 
129
- assert_raise(Fluent::ConfigError) do
129
+ assert_raise(Fluent::NotFoundPluginError) do
130
130
  create_driver(config_element("ROOT", "", {"output_type" => "foo"}, [config_element("buffer")]))
131
131
  end
132
132
  end