Skip to content

Commit 5c88fdf

Browse files
authored
Increase timeout used in test_await_latch_with_timeout (#469)
* Increase timeout used in `test_await_latch_with_timeout` Increased the timeout from 0.1 second to 1 second. Also, in Windows due to low time resolution, we lowered the compared value slightly. With increased timeout, comparing to a slightly lower value should be OK since it shows that we are in fact waiting for the timeout. Note that, the miscalculation comes from the fact that, the calculation for the time passed in the Python side is precise to +-16ms. See https://bugs.python.org/issue44328 and the Windows documentation for the methods used by the CPython for more information. * correctly print the message
1 parent 0aa4353 commit 5c88fdf

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

tests/integration/backward_compatible/proxy/cp/count_down_latch_test.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
from threading import Thread
23

34
from hazelcast.errors import DistributedObjectDestroyedError, OperationTimeoutError
@@ -44,14 +45,23 @@ def test_await_latch_zero_timeout(self):
4445
self.assertFalse(latch.await_latch(0))
4546

4647
def test_await_latch_with_timeout(self):
47-
timeout = 0.1
48+
timeout = 1
4849
latch = self.get_latch(1)
4950
start = get_current_timestamp()
5051
self.assertFalse(latch.await_latch(timeout))
5152
time_passed = get_current_timestamp() - start
53+
54+
expected_time_passed = timeout
55+
if os.name == "nt":
56+
# On Windows, we were getting random test failures due to expected
57+
# time passed being slightly less than the timeout. This is due to
58+
# the low time resolution there (15-16ms). If we are on Windows, we
59+
# lower our expectations and settle for a slightly lower value.
60+
expected_time_passed *= 0.95
61+
5262
self.assertTrue(
53-
time_passed >= timeout,
54-
"Time passed is less than %s, which is %s" % (timeout, time_passed),
63+
time_passed >= expected_time_passed,
64+
"Time passed is less than %s, which is %s" % (expected_time_passed, time_passed),
5565
)
5666

5767
def test_await_latch_multiple_waiters(self):

0 commit comments

Comments
 (0)