Skip to content

Commit

Permalink
test_out_exec: Try to fix randomly failed test
Browse files Browse the repository at this point in the history
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 <class:ExecOutputTest>'
     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
?           ???  +++

Signed-off-by: Takuro Ashie <[email protected]>
  • Loading branch information
ashie committed Dec 17, 2021
1 parent 30132e1 commit 5d08d1a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions test/plugin/test_out_exec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def create_test_data
sub_test_case 'when executed process dies unexpectedly' do
setup do
@gen_config = ->(num){ <<EOC
command ruby -e "ARGV.first.to_i == 0 ? open(ARGV[1]){|f| STDOUT.write f.read} : (sleep 1 ; exit ARGV.first.to_i)" #{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
<inject>
tag_key tag
time_key time
Expand All @@ -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
Expand Down

0 comments on commit 5d08d1a

Please sign in to comment.