diff options
author | Benoit Foucher <benoit@zeroc.com> | 2017-05-26 12:28:36 +0200 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2017-05-26 12:28:36 +0200 |
commit | 9247e49f5bb67b0cad705b1ffd607e6202224bef (patch) | |
tree | 3621088fcd8dcb77233c7d66867b3ee915829b0d /python | |
parent | Fixed ICE-7922 - Review retry/network tracing (diff) | |
download | ice-9247e49f5bb67b0cad705b1ffd607e6202224bef.tar.bz2 ice-9247e49f5bb67b0cad705b1ffd607e6202224bef.tar.xz ice-9247e49f5bb67b0cad705b1ffd607e6202224bef.zip |
Improved timeout test to better deal with slow VMs
Diffstat (limited to 'python')
-rw-r--r-- | python/test/Ice/timeout/AllTests.py | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/python/test/Ice/timeout/AllTests.py b/python/test/Ice/timeout/AllTests.py index 8711502eb3d..a706cc33cca 100644 --- a/python/test/Ice/timeout/AllTests.py +++ b/python/test/Ice/timeout/AllTests.py @@ -44,7 +44,23 @@ class Callback(CallbackBase): test(isinstance(ex, Ice.TimeoutException)) self.called() +def connect(prx): + # Establish connection with the given proxy (which might have a timeout + # set and might sporadically fail on connection establishment if it's + # too slow). The loop ensures that the connection is established by retrying + # in case we can a ConnectTimeoutException + nRetry = 5 + while --nRetry > 0: + try: + prx.ice_getConnection(); + break + except Ice.ConnectTimeoutException: + # Can sporadically occur with slow machines + pass + return prx.ice_getConnection(); # Establish connection + def allTests(communicator): + sref = "timeout:default -p 12010" obj = communicator.stringToProxy(sref) test(obj != None) @@ -153,15 +169,7 @@ def allTests(communicator): sys.stdout.write("testing close timeout... ") sys.stdout.flush() to = Test.TimeoutPrx.checkedCast(obj.ice_timeout(250)) - nRetry = 5 - while --nRetry > 0: - try: - to.ice_getConnection(); - break - except Ice.ConnectTimeoutException: - # Can sporadically occur with slow machines - pass - connection = to.ice_getConnection() + connection = connect(to) timeout.holdAdapter(600) connection.close(Ice.ConnectionClose.GracefullyWithWait) try: @@ -190,6 +198,7 @@ def allTests(communicator): initData.properties.setProperty("Ice.Override.Timeout", "250") comm = Ice.initialize(initData) to = Test.TimeoutPrx.checkedCast(comm.stringToProxy(sref)) + connect(to) timeout.holdAdapter(700) try: to.sendData(seq) @@ -201,6 +210,7 @@ def allTests(communicator): # timeout.op() # Ensure adapter is active. to = Test.TimeoutPrx.checkedCast(to.ice_timeout(1000)) + connect(to) timeout.holdAdapter(500) try: to.sendData(seq) @@ -238,15 +248,7 @@ def allTests(communicator): # timeout.op() # Ensure adapter is active. to = Test.TimeoutPrx.uncheckedCast(to.ice_timeout(250)) - nRetry = 5 - while --nRetry > 0: - try: - to.ice_getConnection(); - break - except Ice.ConnectTimeoutException: - # Can sporadically occur with slow machines - pass - to.ice_getConnection(); # Establish connection + connect(to) timeout.holdAdapter(750) try: to.sendData(seq) |