diff options
author | Benoit Foucher <benoit@zeroc.com> | 2018-02-21 10:06:13 +0100 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2018-02-21 10:06:26 +0100 |
commit | e87539db1e174953aa16633d2e47fff2744da6b6 (patch) | |
tree | a4f78d94e35abd6643b5dbf11291f6600861b86d /python/test/Ice/acm | |
parent | Missing .gitignore file (diff) | |
download | ice-e87539db1e174953aa16633d2e47fff2744da6b6.tar.bz2 ice-e87539db1e174953aa16633d2e47fff2744da6b6.tar.xz ice-e87539db1e174953aa16633d2e47fff2744da6b6.zip |
Fixed python Ice/acm test to wait for connection closure like other mappings (ICE-8565)
Diffstat (limited to 'python/test/Ice/acm')
-rw-r--r-- | python/test/Ice/acm/AllTests.py | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/python/test/Ice/acm/AllTests.py b/python/test/Ice/acm/AllTests.py index 758417cccb9..8a694efbe67 100644 --- a/python/test/Ice/acm/AllTests.py +++ b/python/test/Ice/acm/AllTests.py @@ -74,7 +74,7 @@ class TestCase(threading.Thread): self._heartbeat = 0 self._closed = False self._msg = "" - self.m = threading.Lock() + self.m = threading.Condition() def init(self): self._adapter = \ @@ -127,6 +127,15 @@ class TestCase(threading.Thread): def closed(self, con): with self.m: self._closed = True + self.m.notify() + + def waitForClosed(self): + with self.m: + while not self._closed: + now = time.time() + self.m.wait(2.0) # Wait 2s + if time.time() - now > 2: + test(False) def runTestCase(self, adapter, proxy): test(False) @@ -173,9 +182,7 @@ def allTests(communicator): except Ice.ConnectionTimeoutException: adapter.activate() proxy.interruptSleep() - - with self.m: - test(self._closed) + self.waitForClosed() class InvocationNoHeartbeatTest(TestCase): def __init__(self, com): @@ -191,10 +198,10 @@ def allTests(communicator): test(False) except Ice.ConnectionTimeoutException: proxy.interruptSleep() + self.waitForClosed() with self.m: test(self._heartbeat == 0) - test(self._closed) class InvocationHeartbeatCloseOnIdleTest(TestCase): def __init__(self, com): @@ -218,9 +225,10 @@ def allTests(communicator): def runTestCase(self, adapter, proxy): time.sleep(3) # Idle for 3 seconds + self.waitForClosed() + with self.m: test(self._heartbeat == 0) - test(self._closed) class CloseOnInvocationTest(TestCase): def __init__(self, com): @@ -255,8 +263,7 @@ def allTests(communicator): adapter.activate() time.sleep(1) - with self.m: - test(self._closed) # Connection should be closed this time. + self.waitForClosed() class ForcefulCloseOnIdleAndInvocationTest(TestCase): def __init__(self, com): @@ -267,9 +274,10 @@ def allTests(communicator): adapter.hold() time.sleep(3) # Idle for 3 seconds + self.waitForClosed() + with self.m: test(self._heartbeat == 0) - test(self._closed) # Connection closed forcefully by ACM. class HeartbeatOnIdleTest(TestCase): def __init__(self, com): |