From 6a8af90051064e10cd62492be3ddd0a02aad917d Mon Sep 17 00:00:00 2001 From: Takuro Ashie Date: Thu, 16 Dec 2021 15:38:42 +0900 Subject: [PATCH] test_out_exec: Try to fix a randomly failed test e.g.) https://cloud.drone.io/fluent/fluentd/1934/1/2 Failure: test: flushed chunk will be committed after child process successfully exits(ExecOutputTest::when executed process dies unexpectedly) /drone/src/test/plugin/test_out_exec.rb:279:in `block (2 levels) in ' 276: expect_data = 277: %[2011-01-02 13:14:15\ttest\tv1\n] + 278: %[2011-01-02 13:14:15\ttest\tv2\n] => 279: assert_equal expect_data, data 280: 281: assert{ d.instance.buffer.queue.empty? } 282: assert{ d.instance.dequeued_chunks.empty? } <"2011-01-02 13:14:15\ttest\tv1\n" + "2011-01-02 13:14:15\ttest\tv2\n">(UTF-8) expected but was <"">(ASCII-8BIT) diff: - 2011-01-02 13:14:15 test v1 - 2011-01-02 13:14:15 test v2 ? Encoding: UTF -8 ? ASCII BIT ? ??? +++ Although `wait_flush_completion: false` was specified, it seems that the test expects flushing the buffer. Signed-off-by: Takuro Ashie --- test/plugin/test_out_exec.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/plugin/test_out_exec.rb b/test/plugin/test_out_exec.rb index fb3eb0abde..c81498c986 100644 --- a/test/plugin/test_out_exec.rb +++ b/test/plugin/test_out_exec.rb @@ -243,7 +243,7 @@ def create_test_data sub_test_case 'when executed process dies unexpectedly' do setup do @gen_config = ->(num){ <#{TMP_DIR}/fail_out + command ruby -e "ARGV.first.to_i == 0 ? open(ARGV[1]){|f| STDOUT.write(f.read); STDOUT.flush} : (sleep 1 ; exit ARGV.first.to_i)" #{num} >#{TMP_DIR}/fail_out tag_key tag time_key time @@ -265,7 +265,7 @@ def create_test_data expect_path = "#{TMP_DIR}/fail_out" d.end_if{ File.exist?(expect_path) } - d.run(default_tag: 'test', flush: true, wait_flush_completion: false, shutdown: false) do + d.run(default_tag: 'test', flush: true, wait_flush_completion: true, shutdown: false) do d.feed(time, records[0]) d.feed(time, records[1]) end @@ -281,7 +281,8 @@ def create_test_data assert{ d.instance.buffer.queue.empty? } assert{ d.instance.dequeued_chunks.empty? } - d.instance_shutdown + ensure + d.instance_shutdown if d && d.instance end test 'flushed chunk will be taken back after child process unexpectedly exits' do @@ -304,7 +305,8 @@ def create_test_data assert{ File.exist?(expect_path) && File.size(expect_path) == 0 } - d.instance_shutdown + ensure + d.instance_shutdown if d && d.instance end end end