qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acon...@apache.org
Subject [1/3] qpid-proton git commit: NO-JIRA: [ruby] sporadic failure of time-sensitive test
Date Thu, 05 Jul 2018 15:58:28 GMT
Repository: qpid-proton
Updated Branches:
  refs/heads/master e6a3e5c8a -> 71ef37bfc


NO-JIRA: [ruby] sporadic failure of time-sensitive test

Made the time checks less fine-grained and increased the acceptable error to 0.1
seconds.


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/71ef37bf
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/71ef37bf
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/71ef37bf

Branch: refs/heads/master
Commit: 71ef37bfcceac6d6db90e3b6bd8e3b1f5828982c
Parents: bb35f8c
Author: Alan Conway <aconway@redhat.com>
Authored: Thu Jul 5 11:56:17 2018 -0400
Committer: Alan Conway <aconway@redhat.com>
Committed: Thu Jul 5 11:58:06 2018 -0400

----------------------------------------------------------------------
 ruby/tests/test_container.rb | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/71ef37bf/ruby/tests/test_container.rb
----------------------------------------------------------------------
diff --git a/ruby/tests/test_container.rb b/ruby/tests/test_container.rb
index 0a22dcd..ae4e5d2 100644
--- a/ruby/tests/test_container.rb
+++ b/ruby/tests/test_container.rb
@@ -334,6 +334,11 @@ class ContainerTest < MiniTest::Test
     assert_raises(Container::StoppedError) { cont.listen "" }
   end
 
+  # Check if two time values are "close enough" to be reasonable.
+  def assert_equalish(x, y, delta=0.1)
+    assert_in_delta(x, y, delta)
+  end
+
   # Test container doesn't stops only when schedule work is done
   def test_container_work_queue
     c = Container.new __method__
@@ -345,8 +350,8 @@ class ContainerTest < MiniTest::Test
     delays.sort.each do |d|
       x = a.shift
       assert_equal d, x[0]
-      assert_in_delta  start + d, x[1], 0.01
     end
+    assert_equalish delays.sum, Time.now-start
   end
 
   # Test container work queue finishes due tasks on external stop, drops future tasks
@@ -384,11 +389,7 @@ class ContainerTest < MiniTest::Test
     start = Time.now
     c.run
     assert_equal 3, a.size
-    delays.inject(0) do |d,sum|
-      x = a.shift
-      assert_in_delta  start + d + sum, x, 0.01
-      sum + d
-    end
+    assert_equalish delays.sum, Time.now-start
   end
 
   # Schedule calls from handlers
@@ -447,11 +448,10 @@ class ContainerTest < MiniTest::Test
 
     assert_equal [1, t], q.pop
     assert_equal [2, t], q.pop
-    assert_in_delta  0.0, Time.now - start, 0.01
+    assert_equalish 0.0, Time.now-start
     assert_equal [3, t], q.pop
-    assert_in_delta  0.02, Time.now - start, 0.01
     assert_equal [4, t], q.pop
-    assert_in_delta  0.04, Time.now - start, 0.01
+    assert_equalish 0.02 + 0.04, Time.now-start
 
     c.work_queue.add { c.close }
     t.join


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message