-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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_filter: add a sleep to ensure the stream is emitted #4755
Conversation
Thanks for this fix! d.run(default_tag: 'test', expect_emits: 1, ...
d.run(default_tag: 'test', expect_emits: 2, ...
d.run(default_tag: 'test', expect_emits: 3, ...
d.run(default_tag: 'test', expect_emits: 4, ... The following would avoid the need to manage start and shutdown. diff --git a/test/plugin/test_out_exec_filter.rb b/test/plugin/test_out_exec_filter.rb
index 5a7dc710..c808eda0 100644
--- a/test/plugin/test_out_exec_filter.rb
+++ b/test/plugin/test_out_exec_filter.rb
@@ -500,10 +500,15 @@ class ExecFilterOutputTest < Test::Unit::TestCase
d = create_driver(conf)
time = event_time('2011-01-02 13:14:15')
- d.run(default_tag: 'test', expect_emits: 1, timeout: 10, start: true, shutdown: false){ d.feed(time, {"k1" => 0}) }
- d.run(default_tag: 'test', expect_emits: 1, timeout: 10, start: false, shutdown: false){ d.feed(time, {"k1" => 1}) }
- d.run(default_tag: 'test', expect_emits: 1, timeout: 10, start: false, shutdown: false){ d.feed(time, {"k1" => 2}) }
- d.run(default_tag: 'test', expect_emits: 1, timeout: 10, start: false, shutdown: false){ d.feed(time, {"k1" => 3}) }
+ d.run(default_tag: 'test', expect_emits: 4) do
+ d.feed(time, {"k1" => 0})
+ d.flush
+ d.feed(time, {"k1" => 1})
+ d.flush
+ d.feed(time, {"k1" => 2})
+ d.flush
+ d.feed(time, {"k1" => 3})
+ end
assert_equal "2011-01-02 13:14:15\ttest\t0\n", d.formatted[0]
assert_equal "2011-01-02 13:14:15\ttest\t1\n", d.formatted[1]
@@ -524,9 +529,6 @@ class ExecFilterOutputTest < Test::Unit::TestCase
assert_equal pid_list[1], events[1][2]['child_pid']
assert_equal pid_list[0], events[2][2]['child_pid']
assert_equal pid_list[1], events[3][2]['child_pid']
-
- ensure
- d.run(start: false, shutdown: true)
end
# child process exits per 3 lines |
@daipom I tried your suggession. However, unfortunatry it causes failure as following...
|
Hmm, I can't reproduce it. Ubuntu focal, Ruby 3.2.2 data(
'with sections' => CONFIG_ROUND_ROBIN,
'traditional' => CONFIG_ROUND_ROBIN_COMPAT,
)
test 'using child processes by round robin' do |conf|
d = create_driver(conf)
time = event_time('2011-01-02 13:14:15')
d.run(default_tag: 'test', expect_emits: 4) do
d.feed(time, {"k1" => 0})
d.flush
d.feed(time, {"k1" => 1})
d.flush
d.feed(time, {"k1" => 2})
d.flush
d.feed(time, {"k1" => 3})
end
assert_equal "2011-01-02 13:14:15\ttest\t0\n", d.formatted[0]
assert_equal "2011-01-02 13:14:15\ttest\t1\n", d.formatted[1]
assert_equal "2011-01-02 13:14:15\ttest\t2\n", d.formatted[2]
assert_equal "2011-01-02 13:14:15\ttest\t3\n", d.formatted[3]
events = d.events
assert_equal 4, events.length
pid_list = []
events.each do |event|
pid = event[2]['child_pid']
pid_list << pid unless pid_list.include?(pid)
end
assert_equal 2, pid_list.size, "the number of pids should be same with number of child processes: #{pid_list.inspect}"
assert_equal pid_list[0], events[0][2]['child_pid']
assert_equal pid_list[1], events[1][2]['child_pid']
assert_equal pid_list[0], events[2][2]['child_pid']
assert_equal pid_list[1], events[3][2]['child_pid']
end |
In my environment, it fails with 5 ~ 10 %. I tryed on Windows on virtual machine when I got the error. |
Thanks! d.run(default_tag: 'test', expect_emits: 4) do
d.feed(time, {"k1" => 0})
d.flush
sleep 0.5
d.feed(time, {"k1" => 1})
d.flush
sleep 0.5
d.feed(time, {"k1" => 2})
d.flush
sleep 0.5
d.feed(time, {"k1" => 3})
end |
Signed-off-by: Shizuo Fujita <fujita@clear-code.com>
d39f3c7
to
a4e733a
Compare
Thanks. I updated this PR with your suggession. |
Thanks!! Waiting CI... Note: The reason why we need
fluentd/lib/fluent/test/driver/output.rb Lines 68 to 81 in 46372dd
It waits for fluentd/lib/fluent/plugin/output.rb Lines 1188 to 1189 in 46372dd
So, it does not wait This test depends on the order of the flushes. Therefore, this makes the test unstable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks!
) **Which issue(s) this PR fixes**: Fixes #4754 **What this PR does / why we need it**: This PR will stable the tests. **Docs Changes**: **Release Note**: Signed-off-by: Shizuo Fujita <fujita@clear-code.com> Signed-off-by: Kentaro Hayashi <hayashi@clear-code.com>
…m is emitted (#4755) (#4801) **Which issue(s) this PR fixes**: Backport #4755 **What this PR does / why we need it**: This PR will stable the tests. **Docs Changes**: **Release Note**: Signed-off-by: Shizuo Fujita <fujita@clear-code.com> Signed-off-by: Kentaro Hayashi <hayashi@clear-code.com> Co-authored-by: Shizuo Fujita <fujita@clear-code.com>
Which issue(s) this PR fixes:
Fixes #4754
What this PR does / why we need it:
This PR will stable the tests.
Docs Changes:
Release Note: