diff --git a/lib/fluent/command/plugin_generator.rb b/lib/fluent/command/plugin_generator.rb index 6e03e7f5fd..e020c8998e 100644 --- a/lib/fluent/command/plugin_generator.rb +++ b/lib/fluent/command/plugin_generator.rb @@ -281,7 +281,7 @@ def initialize @text = "" @preamble_source = "" @preamble = nil - open(LICENSE_URL) do |io| + URI.open(LICENSE_URL) do |io| @text = io.read end @preamble_source = @text[/^(\s*Copyright.+)/m, 1] diff --git a/lib/fluent/plugin/parser.rb b/lib/fluent/plugin/parser.rb index acf3cc6d58..9a6d20a849 100644 --- a/lib/fluent/plugin/parser.rb +++ b/lib/fluent/plugin/parser.rb @@ -105,6 +105,12 @@ def parser_type :text_per_line end + def initialize + super + + @timeout_checker = nil + end + def configure(conf) super diff --git a/lib/fluent/supervisor.rb b/lib/fluent/supervisor.rb index 40e3b66f67..f26e248854 100644 --- a/lib/fluent/supervisor.rb +++ b/lib/fluent/supervisor.rb @@ -794,7 +794,7 @@ def build_system_config(conf) opt[param] = @cl_opt[param] end end - system_config.overwrite_variables(opt) + system_config.overwrite_variables(**opt) system_config end end diff --git a/lib/fluent/test/driver/base.rb b/lib/fluent/test/driver/base.rb index 6f5aa18e31..dfd56ac1a9 100644 --- a/lib/fluent/test/driver/base.rb +++ b/lib/fluent/test/driver/base.rb @@ -22,6 +22,7 @@ require 'serverengine/socket_manager' require 'fileutils' require 'timeout' +require 'logger' module Fluent module Test @@ -135,16 +136,16 @@ def instance_hook_before_stopped # same with above end - def instance_shutdown + def instance_shutdown(log: Logger.new($stdout)) instance_hook_before_stopped show_errors_if_exists = ->(label, block){ begin block.call rescue => e - puts "unexpected error while #{label}, #{e.class}:#{e.message}" + log.error "unexpected error while #{label}, #{e.class}:#{e.message}" e.backtrace.each do |bt| - puts "\t#{bt}" + log.error "\t#{bt}" end end } diff --git a/test/config/test_system_config.rb b/test/config/test_system_config.rb index 32dea77540..b347ae5a2b 100644 --- a/test/config/test_system_config.rb +++ b/test/config/test_system_config.rb @@ -68,7 +68,7 @@ def parse_text(text) EOS s = FakeSupervisor.new sc = Fluent::SystemConfig.new(conf) - sc.overwrite_variables(s.for_system_config) + sc.overwrite_variables(**s.for_system_config) assert_equal(1, sc.workers) assert_nil(sc.root_dir) assert_equal(Fluent::Log::LEVEL_INFO, sc.log_level) @@ -98,7 +98,7 @@ def parse_text(text) EOS s = FakeSupervisor.new sc = Fluent::SystemConfig.new(conf) - sc.overwrite_variables(s.for_system_config) + sc.overwrite_variables(**s.for_system_config) if k == 'log_level' assert_equal(Fluent::Log::LEVEL_ERROR, sc.__send__(k)) else @@ -117,7 +117,7 @@ def parse_text(text) EOS s = FakeSupervisor.new sc = Fluent::SystemConfig.new(conf) - sc.overwrite_variables(s.for_system_config) + sc.overwrite_variables(**s.for_system_config) assert_equal(:json, sc.log.format) assert_equal('%Y', sc.log.time_format) end @@ -136,7 +136,7 @@ def parse_text(text) EOS s = FakeSupervisor.new(log_level: level) sc = Fluent::SystemConfig.new(conf) - sc.overwrite_variables(s.for_system_config) + sc.overwrite_variables(**s.for_system_config) assert_equal(level, sc.log_level) end end diff --git a/test/plugin/test_out_http.rb b/test/plugin/test_out_http.rb index b755dfdfd4..718cd8319e 100644 --- a/test/plugin/test_out_http.rb +++ b/test/plugin/test_out_http.rb @@ -117,7 +117,7 @@ def run_http_server Fluent::Test.setup FileUtils.rm_rf(TMP_DIR) - @@result = Result.new(nil, nil, {}, nil) + @@result = Result.new(nil, nil, {}, nil) @@http_server_thread ||= Thread.new do run_http_server end @@ -230,6 +230,9 @@ def test_write_with_headers end def test_write_with_retryable_response + old_report_on_exception = Thread.report_on_exception + Thread.report_on_exception = false # thread finished as invalid state since RetryableResponse raises. + d = create_driver("endpoint #{base_endpoint}/503") assert_raise(Fluent::Plugin::HTTPOutput::RetryableResponse) do d.run(default_tag: 'test.http', shutdown: false) do @@ -238,7 +241,10 @@ def test_write_with_retryable_response } end end - d.instance_shutdown + + d.instance_shutdown(log: $log) + ensure + Thread.report_on_exception = old_report_on_exception end def test_write_with_disabled_unrecoverable diff --git a/test/test_supervisor.rb b/test/test_supervisor.rb index 7808cca6b4..48d87fec9d 100644 --- a/test/test_supervisor.rb +++ b/test/test_supervisor.rb @@ -409,6 +409,8 @@ def test_logger_with_rotate_age_and_rotate_size(rotate_age) end def test_inline_config + omit 'this feature is deprecated. see https://github.com/fluent/fluentd/issues/2711' + opts = Fluent::Supervisor.default_options opts[:inline_config] = '-' sv = Fluent::Supervisor.new(opts)