PROTON-1830: [ruby] fix bug in test_container_work_queue_stop Previously was scheduling tasks with a delay, so all tasks had different times. For test to work reliably, must schedule tasks with the same absolute time.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/99564eb3 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/99564eb3 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/99564eb3 Branch: refs/heads/master Commit: 99564eb3cbbb700cb59843ecbf1ac08165c826d1 Parents: 57a22ca Author: Alan Conway <[email protected]> Authored: Fri Apr 13 14:51:51 2018 -0400 Committer: Alan Conway <[email protected]> Committed: Fri Apr 13 15:02:17 2018 -0400 ---------------------------------------------------------------------- ruby/tests/test_container.rb | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/99564eb3/ruby/tests/test_container.rb ---------------------------------------------------------------------- diff --git a/ruby/tests/test_container.rb b/ruby/tests/test_container.rb index 2c460aa..46ad495 100644 --- a/ruby/tests/test_container.rb +++ b/ruby/tests/test_container.rb @@ -349,15 +349,24 @@ class ContainerTest < MiniTest::Test def test_container_work_queue_stop q = Queue.new c = Container.new __method__ - t = Thread.new { c.run } - [0.1, 0.2, 0.2, 0.2, 1.0].each { |d| c.schedule(d) { q << d } } - assert_equal 0.1, q.pop - assert_equal 0.2, q.pop + thread = Thread.new { c.run } + time = Time.now + 0.01 + # Mix good scheduled tasks at time and bad tasks scheduled after 10 secs + 10.times do + c.schedule(time) { q << true } + c.schedule(10) { q << false } + end + assert_same true, q.pop # First task processed, all others at same time are due + # Mix in some immediate tasks + 5.times do + c.work_queue.add { q << true } # Immediate + c.schedule(time) { q << true } + c.schedule(10) { q << false } + end c.stop - t.join - assert_equal 0.2, q.pop - assert_equal 0.2, q.pop - assert_empty q + thread.join + 19.times { assert_same true, q.pop } + assert_equal 0, q.size # Tasks with 10 sec delay should be dropped end # Chain schedule calls from other schedule calls --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
