diff options
Diffstat (limited to 'python/test/Ice')
-rw-r--r-- | python/test/Ice/acm/AllTests.py | 23 | ||||
-rw-r--r-- | python/test/Ice/acm/Test.ice | 3 | ||||
-rw-r--r-- | python/test/Ice/acm/TestI.py | 42 | ||||
-rw-r--r-- | python/test/Ice/ami/AllTests.py | 170 | ||||
-rwxr-xr-x | python/test/Ice/ami/Client.py | 1 | ||||
-rwxr-xr-x | python/test/Ice/ami/Server.py | 4 | ||||
-rw-r--r-- | python/test/Ice/ami/Test.ice | 10 | ||||
-rw-r--r-- | python/test/Ice/ami/TestI.py | 9 | ||||
-rw-r--r-- | python/test/Ice/binding/AllTests.py | 26 | ||||
-rw-r--r-- | python/test/Ice/location/AllTests.py | 74 | ||||
-rw-r--r-- | python/test/Ice/operations/BatchOneways.py | 4 | ||||
-rw-r--r-- | python/test/Ice/operations/BatchOnewaysAMI.py | 4 | ||||
-rw-r--r-- | python/test/Ice/operations/BatchOnewaysFuture.py | 4 | ||||
-rw-r--r-- | python/test/Ice/timeout/AllTests.py | 76 |
14 files changed, 267 insertions, 183 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) diff --git a/python/test/Ice/ami/AllTests.py b/python/test/Ice/ami/AllTests.py index 549915ee12e..71d6237b61a 100644 --- a/python/test/Ice/ami/AllTests.py +++ b/python/test/Ice/ami/AllTests.py @@ -769,7 +769,7 @@ def allTests(communicator, collocated): test(p.opBatchCount() == 0) b1 = p.ice_batchOneway() b1.opBatch() - b1.ice_getConnection().close(False) + b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) cb = FlushCallback() r = b1.begin_ice_flushBatchRequests(cb.exception, cb.sent) cb.check() @@ -783,7 +783,7 @@ def allTests(communicator, collocated): test(p.opBatchCount() == 0) b1 = p.ice_batchOneway() b1.opBatch() - b1.ice_getConnection().close(False) + b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) cb = FlushCallback(cookie) r = b1.begin_ice_flushBatchRequests(lambda ex: cb.exceptionWC(ex, cookie), lambda ss: cb.sentWC(ss, cookie)) cb.check() @@ -830,7 +830,7 @@ def allTests(communicator, collocated): test(p.opBatchCount() == 0) b1 = Test.TestIntfPrx.uncheckedCast(p.ice_getConnection().createProxy(p.ice_getIdentity()).ice_batchOneway()) b1.opBatch() - b1.ice_getConnection().close(False) + b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) cb = FlushExCallback() r = b1.ice_getConnection().begin_flushBatchRequests(cb.exception, cb.sent) cb.check() @@ -844,7 +844,7 @@ def allTests(communicator, collocated): test(p.opBatchCount() == 0) b1 = Test.TestIntfPrx.uncheckedCast(p.ice_getConnection().createProxy(p.ice_getIdentity()).ice_batchOneway()) b1.opBatch() - b1.ice_getConnection().close(False) + b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) cb = FlushExCallback(cookie) r = b1.ice_getConnection().begin_flushBatchRequests(lambda ex: cb.exceptionWC(ex, cookie), lambda ss: cb.sentWC(ss, cookie)) @@ -876,7 +876,7 @@ def allTests(communicator, collocated): test(p.opBatchCount() == 0) b1 = Test.TestIntfPrx.uncheckedCast(p.ice_getConnection().createProxy(p.ice_getIdentity()).ice_batchOneway()) b1.opBatch() - b1.ice_getConnection().close(False) + b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) cb = FlushCallback() r = communicator.begin_flushBatchRequests(cb.exception, cb.sent) cb.check() @@ -916,7 +916,7 @@ def allTests(communicator, collocated): b2.ice_getConnection() # Ensure connection is established. b1.opBatch() b2.opBatch() - b1.ice_getConnection().close(False) + b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) cb = FlushCallback() r = communicator.begin_flushBatchRequests(cb.exception, cb.sent) cb.check() @@ -936,8 +936,8 @@ def allTests(communicator, collocated): b2.ice_getConnection() # Ensure connection is established. b1.opBatch() b2.opBatch() - b1.ice_getConnection().close(False) - b2.ice_getConnection().close(False) + b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) + b2.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) cb = FlushCallback() r = communicator.begin_flushBatchRequests(cb.exception, cb.sent) cb.check() @@ -1120,9 +1120,27 @@ def allTests(communicator, collocated): print("ok") if p.ice_getConnection(): - sys.stdout.write("testing close connection with sending queue... ") + sys.stdout.write("testing graceful close connection with wait... ") sys.stdout.flush() + # + # Local case: begin several requests, close the connection gracefully, and make sure it waits + # for the requests to complete. + # + results = [] + for i in range(0, 3): + results.append(p.begin_sleep(50)) + p.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) + for r in results: + r.waitForCompleted() + try: + r.throwLocalException() + except: + test(False) + + # + # Remote case. + # if sys.version_info[0] == 2: b = [chr(random.randint(0, 255)) for x in range(0, 10*1024)] seq = ''.join(b) @@ -1143,7 +1161,7 @@ def allTests(communicator, collocated): results = [] for i in range(0, maxQueue): results.append(p.begin_opWithPayload(seq)) - if not p.begin_close(False).isSent(): + if not p.begin_close(Test.CloseMode.CloseGracefullyAndWait).isSent(): for i in range(0, maxQueue): r = p.begin_opWithPayload(seq) results.append(r) @@ -1163,6 +1181,83 @@ def allTests(communicator, collocated): print("ok") + sys.stdout.write("testing graceful close connection without wait... ") + sys.stdout.flush() + + # + # Local case: start a lengthy operation and then close the connection gracefully on the client side + # without waiting for the pending invocation to complete. There will be no retry and we expect the + # invocation to fail with ConnectionManuallyClosedException. + # + # This test requires two threads in the server's thread pool: one will block in sleep() and the other + # will process the CloseConnection message. + # + p.ice_ping() + con = p.ice_getConnection() + r = p.begin_sleep(1000) + con.close(Ice.ConnectionClose.CloseGracefully) + r.waitForCompleted() + try: + r.throwLocalException() + test(False) + except Ice.ConnectionManuallyClosedException, ex: + test(ex.graceful) + + # + # Remote case: the server closes the connection gracefully. Our call to TestIntf::close() + # completes successfully and then the connection should be closed immediately afterward, + # despite the fact that there's a pending call to sleep(). The call to sleep() should be + # automatically retried and complete successfully. + # + p.ice_ping() + con = p.ice_getConnection() + cb = CallbackBase() + con.setCloseCallback(lambda c: cb.called()) + r = p.begin_sleep(250) + p.close(Test.CloseMode.CloseGracefully) + cb.check() + r.waitForCompleted() + try: + r.throwLocalException() + except: + test(false) + p.ice_ping() + test(p.ice_getConnection() != con) + + print("ok") + + sys.stdout.write("testing forceful close connection... ") + sys.stdout.flush() + + # + # Local case: start a lengthy operation and then close the connection forcefully on the client side. + # There will be no retry and we expect the invocation to fail with ConnectionManuallyClosedException. + # + p.ice_ping() + con = p.ice_getConnection() + r = p.begin_sleep(100) + con.close(Ice.ConnectionClose.CloseForcefully) + r.waitForCompleted() + try: + r.throwLocalException() + test(False) + except Ice.ConnectionManuallyClosedException, ex: + test(not ex.graceful) + + # + # Remote case: the server closes the connection forcefully. This causes the request to fail + # with a ConnectionLostException. Since the close() operation is not idempotent, the client + # will not retry. + # + try: + p.close(Test.CloseMode.CloseForcefully) + test(False) + except Ice.ConnectionLostException: + # Expected. + pass + + print("ok") + def allTestsFuture(communicator, collocated): sref = "test:default -p 12010" obj = communicator.stringToProxy(sref) @@ -1404,7 +1499,7 @@ def allTestsFuture(communicator, collocated): test(p.opBatchCount() == 0) b1 = p.ice_batchOneway() b1.opBatch() - b1.ice_getConnection().close(False) + b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) cb = FutureFlushCallback() f = b1.ice_flushBatchRequestsAsync() f.add_sent_callback(cb.sent) @@ -1436,7 +1531,7 @@ def allTestsFuture(communicator, collocated): test(p.opBatchCount() == 0) b1 = Test.TestIntfPrx.uncheckedCast(p.ice_getConnection().createProxy(p.ice_getIdentity()).ice_batchOneway()) b1.opBatch() - b1.ice_getConnection().close(False) + b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) cb = FutureFlushExCallback() f = b1.ice_getConnection().flushBatchRequestsAsync() f.add_done_callback(cb.exception) @@ -1473,7 +1568,7 @@ def allTestsFuture(communicator, collocated): test(p.opBatchCount() == 0) b1 = Test.TestIntfPrx.uncheckedCast(p.ice_getConnection().createProxy(p.ice_getIdentity()).ice_batchOneway()) b1.opBatch() - b1.ice_getConnection().close(False) + b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) cb = FutureFlushCallback() f = communicator.flushBatchRequestsAsync() f.add_sent_callback(cb.sent) @@ -1517,7 +1612,7 @@ def allTestsFuture(communicator, collocated): b2.ice_getConnection() # Ensure connection is established. b1.opBatch() b2.opBatch() - b1.ice_getConnection().close(False) + b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) cb = FutureFlushCallback() f = communicator.flushBatchRequestsAsync() f.add_sent_callback(cb.sent) @@ -1539,8 +1634,8 @@ def allTestsFuture(communicator, collocated): b2.ice_getConnection() # Ensure connection is established. b1.opBatch() b2.opBatch() - b1.ice_getConnection().close(False) - b2.ice_getConnection().close(False) + b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) + b2.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) cb = FutureFlushCallback() f = communicator.flushBatchRequestsAsync() f.add_sent_callback(cb.sent) @@ -1723,47 +1818,4 @@ def allTestsFuture(communicator, collocated): print("ok") - if p.ice_getConnection(): - sys.stdout.write("testing close connection with sending queue... ") - sys.stdout.flush() - - if sys.version_info[0] == 2: - b = [chr(random.randint(0, 255)) for x in range(0, 10*1024)] - seq = ''.join(b) - else: - b = [random.randint(0, 255) for x in range(0, 10*1024)] - seq = bytes(b) - - # - # Send multiple opWithPayload, followed by a close and followed by multiple opWithPaylod. - # The goal is to make sure that none of the opWithPayload fail even if the server closes - # the connection gracefully in between. - # - maxQueue = 2 - done = False - while not done and maxQueue < 50: - done = True - p.ice_ping() - results = [] - for i in range(0, maxQueue): - results.append(p.opWithPayloadAsync(seq)) - if not p.closeAsync(False).is_sent(): - for i in range(0, maxQueue): - f = p.opWithPayloadAsync(seq) - results.append(f) - if f.is_sent(): - done = False - maxQueue = maxQueue * 2 - break - else: - maxQueue = maxQueue * 2 - done = False - for f in results: - try: - f.result() - except Ice.LocalException: - test(False) - - print("ok") - p.shutdown() diff --git a/python/test/Ice/ami/Client.py b/python/test/Ice/ami/Client.py index 1966ff4bd6d..6fa2db022ca 100755 --- a/python/test/Ice/ami/Client.py +++ b/python/test/Ice/ami/Client.py @@ -33,6 +33,7 @@ try: initData = Ice.InitializationData() initData.properties = Ice.createProperties(sys.argv) initData.properties.setProperty('Ice.Warn.AMICallback', '0') + initData.properties.setProperty('Ice.Warn.Connections', '0') # # Limit the send buffer size, this test relies on the socket diff --git a/python/test/Ice/ami/Server.py b/python/test/Ice/ami/Server.py index 1872276ecb0..a042727fc01 100755 --- a/python/test/Ice/ami/Server.py +++ b/python/test/Ice/ami/Server.py @@ -44,13 +44,13 @@ try: # # This test kills connections, so we don't want warnings. # - initData.properties.setProperty("Ice.Warn.Connections", "0"); + initData.properties.setProperty("Ice.Warn.Connections", "0") # # Limit the recv buffer size, this test relies on the socket # send() blocking after sending a given amount of data. # - initData.properties.setProperty("Ice.TCP.RcvSize", "50000"); + initData.properties.setProperty("Ice.TCP.RcvSize", "50000") with Ice.initialize(sys.argv, initData) as communicator: status = run(sys.argv, communicator) diff --git a/python/test/Ice/ami/Test.ice b/python/test/Ice/ami/Test.ice index 4bda44b5c41..9787dd9a1fc 100644 --- a/python/test/Ice/ami/Test.ice +++ b/python/test/Ice/ami/Test.ice @@ -19,6 +19,13 @@ exception TestIntfException { }; +enum CloseMode +{ + CloseForcefully, + CloseGracefully, + CloseGracefullyAndWait +}; + interface TestIntf { void op(); @@ -29,7 +36,8 @@ interface TestIntf void opBatch(); int opBatchCount(); bool waitForBatch(int count); - void close(bool force); + void close(CloseMode mode); + void sleep(int ms); void shutdown(); bool supportsFunctionalTests(); diff --git a/python/test/Ice/ami/TestI.py b/python/test/Ice/ami/TestI.py index 3770a2c6101..53585189f29 100644 --- a/python/test/Ice/ami/TestI.py +++ b/python/test/Ice/ami/TestI.py @@ -7,7 +7,7 @@ # # ********************************************************************** -import Ice, Test, threading +import Ice, Test, threading, time class TestIntfI(Test._TestIntfDisp): def __init__(self): @@ -43,8 +43,11 @@ class TestIntfI(Test._TestIntfDisp): self._batchCount = 0 return result - def close(self, force, current=None): - current.con.close(force) + def close(self, mode, current=None): + current.con.close(Ice.ConnectionClose.valueOf(mode.value)) + + def sleep(self, ms, current=None): + time.sleep(ms / 1000.0) def shutdown(self, current=None): current.adapter.getCommunicator().shutdown() diff --git a/python/test/Ice/binding/AllTests.py b/python/test/Ice/binding/AllTests.py index b877fc78ac5..5bf5a02a801 100644 --- a/python/test/Ice/binding/AllTests.py +++ b/python/test/Ice/binding/AllTests.py @@ -110,7 +110,7 @@ def allTests(communicator): name = test1.getAdapterName() if names.count(name) > 0: names.remove(name) - test1.ice_getConnection().close(False) + test1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) # # Ensure that the proxy correctly caches the connection (we @@ -128,7 +128,7 @@ def allTests(communicator): test(i == nRetry) for a in adapters: - a.getTestIntf().ice_getConnection().close(False) + a.getTestIntf().ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) # # Deactivate an adapter and ensure that we can still @@ -152,7 +152,7 @@ def allTests(communicator): name = test1.getAdapterName() if names.count(name) > 0: names.remove(name) - test1.ice_getConnection().close(False) + test1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) # # Deactivate an adapter and ensure that we can still @@ -194,7 +194,7 @@ def allTests(communicator): name = getAdapterNameWithAMI(test1) if names.count(name) > 0: names.remove(name) - test1.ice_getConnection().close(False) + test1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) # # Ensure that the proxy correctly caches the connection (we @@ -212,7 +212,7 @@ def allTests(communicator): test(i == nRetry) for a in adapters: - a.getTestIntf().ice_getConnection().close(False) + a.getTestIntf().ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) # # Deactivate an adapter and ensure that we can still @@ -236,7 +236,7 @@ def allTests(communicator): name = getAdapterNameWithAMI(test1) if names.count(name) > 0: names.remove(name) - test1.ice_getConnection().close(False) + test1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) # # Deactivate an adapter and ensure that we can still @@ -266,7 +266,7 @@ def allTests(communicator): name = t.getAdapterName() if names.count(name) > 0: names.remove(name) - t.ice_getConnection().close(False) + t.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) t = Test.TestIntfPrx.uncheckedCast(t.ice_endpointSelection(Ice.EndpointSelectionType.Random)) test(t.ice_getEndpointSelection() == Ice.EndpointSelectionType.Random) @@ -278,7 +278,7 @@ def allTests(communicator): name = t.getAdapterName() if names.count(name) > 0: names.remove(name) - t.ice_getConnection().close(False) + t.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) deactivate(com, adapters) @@ -337,13 +337,13 @@ def allTests(communicator): while i < nRetry and t.getAdapterName() == "Adapter36": i = i + 1 test(i == nRetry) - t.ice_getConnection().close(False) + t.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) adapters.append(com.createObjectAdapter("Adapter35", endpoints[1].toString())) i = 0 while i < nRetry and t.getAdapterName() == "Adapter35": i = i + 1 test(i == nRetry) - t.ice_getConnection().close(False) + t.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) adapters.append(com.createObjectAdapter("Adapter34", endpoints[0].toString())) i = 0 while i < nRetry and t.getAdapterName() == "Adapter34": @@ -618,7 +618,7 @@ def allTests(communicator): t = createTestIntfPrx(adapters) for i in range(0, 5): test(t.getAdapterName() == "Adapter82") - t.ice_getConnection().close(False) + t.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) testSecure = Test.TestIntfPrx.uncheckedCast(t.ice_secure(True)) test(testSecure.ice_isSecure()) @@ -632,13 +632,13 @@ def allTests(communicator): for i in range(0, 5): test(t.getAdapterName() == "Adapter81") - t.ice_getConnection().close(False) + t.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) com.createObjectAdapter("Adapter83", (t.ice_getEndpoints()[1]).toString()) # Reactive tcp OA. for i in range(0, 5): test(t.getAdapterName() == "Adapter83") - t.ice_getConnection().close(False) + t.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) com.deactivateObjectAdapter(adapters[0]) try: diff --git a/python/test/Ice/location/AllTests.py b/python/test/Ice/location/AllTests.py index dc0fb5afe5d..205ae91329d 100644 --- a/python/test/Ice/location/AllTests.py +++ b/python/test/Ice/location/AllTests.py @@ -22,8 +22,8 @@ def allTests(communicator, ref): locator = communicator.getDefaultLocator() test(manager) - registry = Test.TestLocatorRegistryPrx.checkedCast(locator.getRegistry()); - test(registry); + registry = Test.TestLocatorRegistryPrx.checkedCast(locator.getRegistry()) + test(registry) sys.stdout.write("testing stringToProxy... ") sys.stdout.flush() @@ -36,34 +36,34 @@ def allTests(communicator, ref): sys.stdout.write("testing ice_locator and ice_getLocator... ") sys.stdout.flush() - test(Ice.proxyIdentityEqual(base.ice_getLocator(), communicator.getDefaultLocator())); - anotherLocator = Ice.LocatorPrx.uncheckedCast(communicator.stringToProxy("anotherLocator")); - base = base.ice_locator(anotherLocator); - test(Ice.proxyIdentityEqual(base.ice_getLocator(), anotherLocator)); - communicator.setDefaultLocator(None); - base = communicator.stringToProxy("test @ TestAdapter"); - test(not base.ice_getLocator()); - base = base.ice_locator(anotherLocator); - test(Ice.proxyIdentityEqual(base.ice_getLocator(), anotherLocator)); - communicator.setDefaultLocator(locator); - base = communicator.stringToProxy("test @ TestAdapter"); - test(Ice.proxyIdentityEqual(base.ice_getLocator(), communicator.getDefaultLocator())); + test(Ice.proxyIdentityEqual(base.ice_getLocator(), communicator.getDefaultLocator())) + anotherLocator = Ice.LocatorPrx.uncheckedCast(communicator.stringToProxy("anotherLocator")) + base = base.ice_locator(anotherLocator) + test(Ice.proxyIdentityEqual(base.ice_getLocator(), anotherLocator)) + communicator.setDefaultLocator(None) + base = communicator.stringToProxy("test @ TestAdapter") + test(not base.ice_getLocator()) + base = base.ice_locator(anotherLocator) + test(Ice.proxyIdentityEqual(base.ice_getLocator(), anotherLocator)) + communicator.setDefaultLocator(locator) + base = communicator.stringToProxy("test @ TestAdapter") + test(Ice.proxyIdentityEqual(base.ice_getLocator(), communicator.getDefaultLocator())) # # We also test ice_router/ice_getRouter (perhaps we should add a # test/Ice/router test?) # - test(not base.ice_getRouter()); - anotherRouter = Ice.RouterPrx.uncheckedCast(communicator.stringToProxy("anotherRouter")); - base = base.ice_router(anotherRouter); - test(Ice.proxyIdentityEqual(base.ice_getRouter(), anotherRouter)); - router = Ice.RouterPrx.uncheckedCast(communicator.stringToProxy("dummyrouter")); - communicator.setDefaultRouter(router); - base = communicator.stringToProxy("test @ TestAdapter"); - test(Ice.proxyIdentityEqual(base.ice_getRouter(), communicator.getDefaultRouter())); - communicator.setDefaultRouter(None); - base = communicator.stringToProxy("test @ TestAdapter"); - test(not base.ice_getRouter()); + test(not base.ice_getRouter()) + anotherRouter = Ice.RouterPrx.uncheckedCast(communicator.stringToProxy("anotherRouter")) + base = base.ice_router(anotherRouter) + test(Ice.proxyIdentityEqual(base.ice_getRouter(), anotherRouter)) + router = Ice.RouterPrx.uncheckedCast(communicator.stringToProxy("dummyrouter")) + communicator.setDefaultRouter(router) + base = communicator.stringToProxy("test @ TestAdapter") + test(Ice.proxyIdentityEqual(base.ice_getRouter(), communicator.getDefaultRouter())) + communicator.setDefaultRouter(None) + base = communicator.stringToProxy("test @ TestAdapter") + test(not base.ice_getRouter()) print("ok") sys.stdout.write("starting server... ") @@ -200,7 +200,7 @@ def allTests(communicator, ref): sys.stdout.flush() hello = Test.HelloPrx.checkedCast(communicator.stringToProxy("hello")) obj.migrateHello() - hello.ice_getConnection().close(False); + hello.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) hello.sayHello() obj.migrateHello() hello.sayHello() @@ -237,21 +237,21 @@ def allTests(communicator, ref): # sys.stdout.write("testing indirect references to collocated objects... ") sys.stdout.flush() - properties = communicator.getProperties(); - properties.setProperty("Ice.PrintAdapterReady", "0"); - adapter = communicator.createObjectAdapterWithEndpoints("Hello", "default"); - adapter.setLocator(locator); + properties = communicator.getProperties() + properties.setProperty("Ice.PrintAdapterReady", "0") + adapter = communicator.createObjectAdapterWithEndpoints("Hello", "default") + adapter.setLocator(locator) assert(adapter.getLocator() == locator) - id = Ice.Identity(); - id.name = Ice.generateUUID(); - registry.addObject(adapter.add(HelloI(), id)); - adapter.activate(); + id = Ice.Identity() + id.name = Ice.generateUUID() + registry.addObject(adapter.add(HelloI(), id)) + adapter.activate() - helloPrx = Test.HelloPrx.checkedCast(communicator.stringToProxy(communicator.identityToString(id))); - test(not helloPrx.ice_getConnection()); + helloPrx = Test.HelloPrx.checkedCast(communicator.stringToProxy(Ice.identityToString(id))) + test(not helloPrx.ice_getConnection()) - adapter.deactivate(); + adapter.deactivate() print("ok") sys.stdout.write("shutdown server manager... ") diff --git a/python/test/Ice/operations/BatchOneways.py b/python/test/Ice/operations/BatchOneways.py index 5878ff7f7af..ea0fc26c29c 100644 --- a/python/test/Ice/operations/BatchOneways.py +++ b/python/test/Ice/operations/BatchOneways.py @@ -82,7 +82,7 @@ def batchOneways(p): batch1.ice_ping() batch2.ice_ping() batch1.ice_flushBatchRequests() - batch1.ice_getConnection().close(False) + batch1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) batch1.ice_ping() batch2.ice_ping() @@ -90,7 +90,7 @@ def batchOneways(p): batch2.ice_getConnection() batch1.ice_ping() - batch1.ice_getConnection().close(False) + batch1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) batch1.ice_ping() batch2.ice_ping() diff --git a/python/test/Ice/operations/BatchOnewaysAMI.py b/python/test/Ice/operations/BatchOnewaysAMI.py index cd53ee94470..f750b3eb02d 100644 --- a/python/test/Ice/operations/BatchOnewaysAMI.py +++ b/python/test/Ice/operations/BatchOnewaysAMI.py @@ -61,14 +61,14 @@ def batchOneways(p): batch1.end_ice_ping(batch1.begin_ice_ping()) batch2.end_ice_ping(batch2.begin_ice_ping()) batch1.end_ice_flushBatchRequests(batch1.begin_ice_flushBatchRequests()) - batch1.ice_getConnection().close(False) + batch1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) batch1.end_ice_ping(batch1.begin_ice_ping()) batch2.end_ice_ping(batch2.begin_ice_ping()) batch1.ice_getConnection() batch2.ice_getConnection() - batch1.ice_getConnection().close(False) + batch1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) batch1.end_ice_ping(batch1.begin_ice_ping()) batch2.end_ice_ping(batch2.begin_ice_ping()) diff --git a/python/test/Ice/operations/BatchOnewaysFuture.py b/python/test/Ice/operations/BatchOnewaysFuture.py index ccf84220aa1..ea1c70bcf94 100644 --- a/python/test/Ice/operations/BatchOnewaysFuture.py +++ b/python/test/Ice/operations/BatchOnewaysFuture.py @@ -63,14 +63,14 @@ def batchOneways(p): batch1.ice_pingAsync() batch2.ice_pingAsync() batch1.ice_flushBatchRequestsAsync().result() - batch1.ice_getConnection().close(False) + batch1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) batch1.ice_pingAsync() batch2.ice_pingAsync() batch1.ice_getConnection() batch2.ice_getConnection() - batch1.ice_getConnection().close(False) + batch1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait) test(not batch1.ice_pingAsync().done()) test(not batch2.ice_pingAsync().done()) diff --git a/python/test/Ice/timeout/AllTests.py b/python/test/Ice/timeout/AllTests.py index 16d3d0484f8..391c6b23ca5 100644 --- a/python/test/Ice/timeout/AllTests.py +++ b/python/test/Ice/timeout/AllTests.py @@ -116,58 +116,58 @@ def allTests(communicator): sys.stdout.write("testing invocation timeout... ") sys.stdout.flush() - connection = obj.ice_getConnection(); - to = Test.TimeoutPrx.uncheckedCast(obj.ice_invocationTimeout(100)); - test(connection == to.ice_getConnection()); + connection = obj.ice_getConnection() + to = Test.TimeoutPrx.uncheckedCast(obj.ice_invocationTimeout(100)) + test(connection == to.ice_getConnection()) try: - to.sleep(750); - test(False); + to.sleep(750) + test(False) except Ice.InvocationTimeoutException: pass - obj.ice_ping(); - to = Test.TimeoutPrx.uncheckedCast(obj.ice_invocationTimeout(500)); - test(connection == to.ice_getConnection()); + obj.ice_ping() + to = Test.TimeoutPrx.uncheckedCast(obj.ice_invocationTimeout(500)) + test(connection == to.ice_getConnection()) try: - to.sleep(250); + to.sleep(250) except Ice.InvocationTimeoutException: - test(False); - test(connection == to.ice_getConnection()); + test(False) + test(connection == to.ice_getConnection()) # # # # Expect InvocationTimeoutException. # # - # to = Test.TimeoutPrx.uncheckedCast(obj.ice_invocationTimeout(250)); - # cb = new Callback(); - # to.begin_sleep(750, newCallback_Timeout_sleep(cb, &Callback.responseEx, &Callback.exceptionEx)); - # cb.check(); + # to = Test.TimeoutPrx.uncheckedCast(obj.ice_invocationTimeout(250)) + # cb = new Callback() + # to.begin_sleep(750, newCallback_Timeout_sleep(cb, &Callback.responseEx, &Callback.exceptionEx)) + # cb.check() # # # # Expect success. # # - # to = Test.TimeoutPrx.uncheckedCast(obj.ice_invocationTimeout(500)); - # cb = new Callback(); - # to.begin_sleep(250, newCallback_Timeout_sleep(cb, &Callback.response, &Callback.exception)); - # cb.check(); + # to = Test.TimeoutPrx.uncheckedCast(obj.ice_invocationTimeout(500)) + # cb = new Callback() + # to.begin_sleep(250, newCallback_Timeout_sleep(cb, &Callback.response, &Callback.exception)) + # cb.check() print("ok") sys.stdout.write("testing close timeout... ") sys.stdout.flush() - to = Test.TimeoutPrx.checkedCast(obj.ice_timeout(100)); - connection = to.ice_getConnection(); - timeout.holdAdapter(500); - connection.close(False); + to = Test.TimeoutPrx.checkedCast(obj.ice_timeout(100)) + connection = to.ice_getConnection() + timeout.holdAdapter(500) + connection.close(Ice.ConnectionClose.CloseGracefullyAndWait) try: connection.getInfo(); # getInfo() doesn't throw in the closing state. except Ice.LocalException: - test(False); - time.sleep(0.5); + test(False) + time.sleep(0.5) try: - connection.getInfo(); - test(False); - except Ice.CloseConnectionException: + connection.getInfo() + test(False) + except Ice.ConnectionManuallyClosedException, ex: # Expected. - pass - timeout.op(); # Ensure adapter is active. + test(ex.graceful) + timeout.op() # Ensure adapter is active. print("ok") sys.stdout.write("testing timeout overrides... ") @@ -193,7 +193,7 @@ def allTests(communicator): # timeout.op() # Ensure adapter is active. to = Test.TimeoutPrx.checkedCast(to.ice_timeout(1000)) - timeout.holdAdapter(500); + timeout.holdAdapter(500) try: to.sendData(seq) test(False) @@ -229,9 +229,9 @@ def allTests(communicator): # Verify that timeout set via ice_timeout() is still used for requests. # timeout.op() # Ensure adapter is active. - to = Test.TimeoutPrx.uncheckedCast(to.ice_timeout(250)); + to = Test.TimeoutPrx.uncheckedCast(to.ice_timeout(250)) to.ice_getConnection(); # Establish connection - timeout.holdAdapter(750); + timeout.holdAdapter(750) try: to.sendData(seq) test(False) @@ -246,11 +246,11 @@ def allTests(communicator): initData.properties = communicator.getProperties().clone() initData.properties.setProperty("Ice.Override.CloseTimeout", "100") comm = Ice.initialize(initData) - connection = comm.stringToProxy(sref).ice_getConnection(); - timeout.holdAdapter(800); - now = time.clock(); - comm.destroy(); - test((time.clock() - now) < 0.7); + connection = comm.stringToProxy(sref).ice_getConnection() + timeout.holdAdapter(800) + now = time.clock() + comm.destroy() + test((time.clock() - now) < 0.7) print("ok") |