Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_out_exec: Try to fix a randomly failed test #3574

Merged
merged 1 commit into from
Dec 21, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 6 additions & 4 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 All @@ -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
Expand All @@ -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