From 8cff8f32a5889678b98c4b6895f729851e365a89 Mon Sep 17 00:00:00 2001 From: Yuta Iwama Date: Fri, 31 Jan 2020 15:05:43 +0900 Subject: [PATCH] debug Signed-off-by: Yuta Iwama --- Rakefile | 3 ++- lib/fluent/supervisor.rb | 4 ++++ test/command/test_fluentd.rb | 20 ++++++++++++++++++-- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/Rakefile b/Rakefile index 82a1a53541..984504aac6 100755 --- a/Rakefile +++ b/Rakefile @@ -34,7 +34,8 @@ Rake::TestTask.new(:base_test) do |t| t.test_files = if ENV["WIN_RAPID"] ["test/test_event.rb", "test/test_supervisor.rb", "test/plugin_helper/test_event_loop.rb"] else - tests = Dir["test/**/test_*.rb"].sort + # tests = Dir["test/**/test_*.rb"].sort + tests = Dir["test/command/test_fluentd.rb"].sort if Process.uid.zero? puts "test_file_util.rb for non-root user env. Disable this test on root environment" tests.delete("test/plugin/test_file_util.rb") diff --git a/lib/fluent/supervisor.rb b/lib/fluent/supervisor.rb index 10865c1ab4..6d8ad1cdfd 100644 --- a/lib/fluent/supervisor.rb +++ b/lib/fluent/supervisor.rb @@ -668,6 +668,10 @@ def supervise fluentd_spawn_cmd += $fluentdargv fluentd_spawn_cmd << "--under-supervisor" + puts nil, '<============================================================ OUTPUT START HERE' + p fluentd_spawn_cmd + puts '<============================================================ OUTPUT CLOSE HERE', nil + $log.info "spawn command to main: ", cmdline: fluentd_spawn_cmd params = { diff --git a/test/command/test_fluentd.rb b/test/command/test_fluentd.rb index 74d43dc104..9d5a5df961 100644 --- a/test/command/test_fluentd.rb +++ b/test/command/test_fluentd.rb @@ -54,10 +54,10 @@ def execute_command(cmdline, chdir=TMP_DIR, env = {}) null_stream = File.open(File::NULL, 'w') gemfile_path = File.expand_path(File.dirname(__FILE__) + "../../../Gemfile") - env = { "BUNDLE_GEMFILE" => gemfile_path }.merge(env) + env.merge!({ "BUNDLE_GEMFILE" => gemfile_path }) cmdname = cmdline.shift arg0 = "testing-fluentd" - # p(here: "executing process", env: env, cmdname: cmdname, arg0: arg0, args: cmdline) + p(here: "executing process", env: env, cmdname: cmdname, arg0: arg0, args: cmdline) IO.popen(env, [[cmdname, arg0], *cmdline], chdir: chdir, err: [:child, :out]) do |io| pid = io.pid begin @@ -116,6 +116,10 @@ def assert_log_matches(cmdline, *pattern_list, patterns_not_match: [], timeout: assert_error_msg = "unexpected error in launching fluentd: #{e.inspect}\n" + stdio_buf end + puts nil, '<============================================================ OUTPUT START HERE' + p stdio_buf + puts '<============================================================ OUTPUT CLOSE HERE', nil + if matched assert matched, assert_error_msg else @@ -784,6 +788,9 @@ def multi_workers_ready? end test "multiple values are set to RUBYOPT" do + require 'logger' + lo = ServerEngine::DaemonLogger.new(STDOUT, log_level: ServerEngine::DaemonLogger::INFO) + $log = Fluent::Log.new(lo) conf = < @type dummy @@ -793,7 +800,16 @@ def multi_workers_ready? @type null CONF + v = ["exec", "ruby", '-e', 'pp ENV["RUBYOPT"]'] + + IO.popen({ 'RUBYOPT' => '-ruri -rjson'}, [['bundle', 'hihi'], *v]) do |io| + puts nil, '<============================================================ OUTPUT START HERE' + puts io.readpartial(1024) + puts '<============================================================ OUTPUT CLOSE HERE', nil + end + conf_path = create_conf_file('rubyopt_test.conf', conf) + assert_log_matches( create_cmdline(conf_path), '#0 fluentd worker is now running worker=0',