From 87c06961aae4a094c956983fdf3d595542d94f2d Mon Sep 17 00:00:00 2001 From: Yuta Iwama Date: Fri, 27 Dec 2019 15:05:24 +0900 Subject: [PATCH 1/5] Suppress noisy stacktrace and exception Signed-off-by: Yuta Iwama --- lib/fluent/test/driver/base.rb | 7 ++++--- test/plugin/test_out_http.rb | 10 ++++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) 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/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 From 7584cfef1f5f64bd3130f47ccb1382bd13e3d786 Mon Sep 17 00:00:00 2001 From: Yuta Iwama Date: Fri, 27 Dec 2019 15:11:03 +0900 Subject: [PATCH 2/5] suppress warning by ruby 2.7 /home/travis/build/fluent/fluentd/test/config/test_system_config.rb:101: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call /home/travis/build/fluent/fluentd/lib/fluent/system_config.rb:132: warning: The called method `overwrite_variables' is defined here Signed-off-by: Yuta Iwama --- lib/fluent/supervisor.rb | 2 +- test/config/test_system_config.rb | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) 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/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 From 07dcfce921c3973b590dec9fb0f78b70d88abcf6 Mon Sep 17 00:00:00 2001 From: Yuta Iwama Date: Fri, 27 Dec 2019 15:15:37 +0900 Subject: [PATCH 3/5] Suppress warning calling URI.open via Kernel#open is deprecated, call URI.open directly or use URI#open Signed-off-by: Yuta Iwama --- lib/fluent/command/plugin_generator.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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] From 45c94eab23d8899c21dd96ac6a4318d634ea61b7 Mon Sep 17 00:00:00 2001 From: Yuta Iwama Date: Fri, 27 Dec 2019 15:19:09 +0900 Subject: [PATCH 4/5] initialize @timeout_checker warning: instance variable @timeout_checker not initialized Signed-off-by: Yuta Iwama --- lib/fluent/plugin/parser.rb | 6 ++++++ 1 file changed, 6 insertions(+) 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 From 0f933a5f55efb4ea017aac120b4689e394955396 Mon Sep 17 00:00:00 2001 From: Yuta Iwama Date: Fri, 27 Dec 2019 15:20:44 +0900 Subject: [PATCH 5/5] Omit deprecated feature test Signed-off-by: Yuta Iwama --- test/test_supervisor.rb | 2 ++ 1 file changed, 2 insertions(+) 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)