summaryrefslogtreecommitdiff
path: root/python/test/Ice/acm
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2017-01-30 13:45:21 -0800
committerMark Spruiell <mes@zeroc.com>2017-01-30 13:45:21 -0800
commit61270a10f980933cf582edb766f10c8ac6d86e8a (patch)
tree45ab4a7c2986954054fce613bc3c8f7967e7951e /python/test/Ice/acm
parentFix slice2cpp build failure (diff)
downloadice-61270a10f980933cf582edb766f10c8ac6d86e8a.tar.bz2
ice-61270a10f980933cf582edb766f10c8ac6d86e8a.tar.xz
ice-61270a10f980933cf582edb766f10c8ac6d86e8a.zip
merging IceBridge into master
Diffstat (limited to 'python/test/Ice/acm')
-rw-r--r--python/test/Ice/acm/AllTests.py23
-rw-r--r--python/test/Ice/acm/Test.ice3
-rw-r--r--python/test/Ice/acm/TestI.py42
3 files changed, 44 insertions, 24 deletions
diff --git a/python/test/Ice/acm/AllTests.py b/python/test/Ice/acm/AllTests.py
index c10edd1de77..1c7bb57709b 100644
--- a/python/test/Ice/acm/AllTests.py
+++ b/python/test/Ice/acm/AllTests.py
@@ -294,6 +294,25 @@ def allTests(communicator):
with self.m:
test(self._heartbeat >= 3)
+ class HeartbeatManualTest(TestCase):
+ def __init__(self, com):
+ TestCase.__init__(self, "manual heartbeats", com)
+ #
+ # Disable heartbeats.
+ #
+ self.setClientACM(10, -1, 0)
+ self.setServerACM(10, -1, 0)
+
+ def runTestCase(self, adapter, proxy):
+ proxy.startHeartbeatCount()
+ con = proxy.ice_getConnection()
+ con.heartbeat()
+ con.heartbeat()
+ con.heartbeat()
+ con.heartbeat()
+ con.heartbeat()
+ proxy.waitForHeartbeatCount(5)
+
class SetACMTest(TestCase):
def __init__(self, com):
TestCase.__init__(self, "setACM/getACM", com)
@@ -318,7 +337,8 @@ def allTests(communicator):
test(acm.close == Ice.ACMClose.CloseOnInvocationAndIdle)
test(acm.heartbeat == Ice.ACMHeartbeat.HeartbeatAlways)
- proxy.waitForHeartbeat(2)
+ proxy.startHeartbeatCount()
+ proxy.waitForHeartbeatCount(2)
tests.append(InvocationHeartbeatTest(com))
tests.append(InvocationHeartbeatOnHoldTest(com))
@@ -332,6 +352,7 @@ def allTests(communicator):
tests.append(HeartbeatOnIdleTest(com))
tests.append(HeartbeatAlwaysTest(com))
+ tests.append(HeartbeatManualTest(com))
tests.append(SetACMTest(com))
for p in tests:
diff --git a/python/test/Ice/acm/Test.ice b/python/test/Ice/acm/Test.ice
index 5ab98180dd3..d78abd6eb0f 100644
--- a/python/test/Ice/acm/Test.ice
+++ b/python/test/Ice/acm/Test.ice
@@ -17,7 +17,8 @@ interface TestIntf
void sleep(int seconds);
void sleepAndHold(int seconds);
void interruptSleep();
- void waitForHeartbeat(int count);
+ void startHeartbeatCount();
+ void waitForHeartbeatCount(int count);
};
interface RemoteObjectAdapter
diff --git a/python/test/Ice/acm/TestI.py b/python/test/Ice/acm/TestI.py
index 10565ca9540..41f5afe93eb 100644
--- a/python/test/Ice/acm/TestI.py
+++ b/python/test/Ice/acm/TestI.py
@@ -9,6 +9,21 @@
import Ice, Test, threading
+class ConnectionCallbackI():
+ def __init__(self):
+ self.m = threading.Condition()
+ self.count = 0
+
+ def heartbeat(self, con):
+ with self.m:
+ self.count += 1
+ self.m.notifyAll()
+
+ def waitForCount(self, count):
+ with self.m:
+ while self.count < count:
+ self.m.wait()
+
class RemoteCommunicatorI(Test._RemoteCommunicatorDisp):
def createObjectAdapter(self, timeout, close, heartbeat, current=None):
com = current.adapter.getCommunicator()
@@ -68,26 +83,9 @@ class TestIntfI(Test._TestIntfDisp):
with self.m:
self.m.notifyAll()
- def waitForHeartbeat(self, count, current=None):
-
- class ConnectionCallbackI():
-
- def __init__(self):
- self.m = threading.Condition()
- self.count = 0
-
- def heartbeat(self, con):
- with self.m:
- self.count -= 1
- self.m.notifyAll()
-
- def waitForCount(self, count):
- with self.m:
- self.count = count
- while self.count > 0:
- self.m.wait()
-
- callback = ConnectionCallbackI()
- current.con.setHeartbeatCallback(lambda con: callback.heartbeat(con))
- callback.waitForCount(2)
+ def startHeartbeatCount(self, current=None):
+ self.callback = ConnectionCallbackI()
+ current.con.setHeartbeatCallback(lambda con: self.callback.heartbeat(con))
+ def waitForHeartbeatCount(self, count, current=None):
+ self.callback.waitForCount(2)