diff options
author | Benoit Foucher <benoit@zeroc.com> | 2017-09-15 12:18:41 +0200 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2017-09-15 12:18:41 +0200 |
commit | a4fb9c391caabef6de9cfbd126f4fe10755ece49 (patch) | |
tree | 36dfe5b0a110dddd09f49882649d8c2de825f4b4 /ruby | |
parent | Removed Eclipse .launch files (diff) | |
download | ice-a4fb9c391caabef6de9cfbd126f4fe10755ece49.tar.bz2 ice-a4fb9c391caabef6de9cfbd126f4fe10755ece49.tar.xz ice-a4fb9c391caabef6de9cfbd126f4fe10755ece49.zip |
Fixed timeout tests to be less time sensitive
The tests now use a controller to hold/activate the adapter instead of relying
on a timer. Fixes ICE-8312.
Diffstat (limited to 'ruby')
-rw-r--r-- | ruby/test/Ice/timeout/AllTests.rb | 66 | ||||
-rwxr-xr-x | ruby/test/Ice/timeout/Client.rb | 4 | ||||
-rw-r--r-- | ruby/test/Ice/timeout/Test.ice | 5 |
3 files changed, 46 insertions, 29 deletions
diff --git a/ruby/test/Ice/timeout/AllTests.rb b/ruby/test/Ice/timeout/AllTests.rb index 5aa15bdc739..06625c13b85 100644 --- a/ruby/test/Ice/timeout/AllTests.rb +++ b/ruby/test/Ice/timeout/AllTests.rb @@ -29,26 +29,30 @@ def allTests(communicator) timeout = Test::TimeoutPrx::checkedCast(obj) test(timeout) + controller = Test::ControllerPrx::checkedCast(communicator.stringToProxy("controller:default -p 12011")) + test(controller) + print "testing connect timeout... " STDOUT.flush # # Expect ConnectTimeoutException. # to = Test::TimeoutPrx::uncheckedCast(obj.ice_timeout(100)) - timeout.holdAdapter(500) + controller.holdAdapter(-1) begin to.op() test(false) rescue Ice::ConnectTimeoutException # Expected. end + controller.resumeAdapter() + timeout.op() # Ensure adapter is active. # # Expect success. # - timeout.op() # Ensure adapter is active. to = Test::TimeoutPrx::uncheckedCast(obj.ice_timeout(1000)) - timeout.holdAdapter(500) + controller.holdAdapter(200) begin to.op() rescue Ice::ConnectTimeoutException @@ -64,19 +68,20 @@ def allTests(communicator) seq = "\0" * 10000000 # 10,000,000 entries to = Test::TimeoutPrx::uncheckedCast(obj.ice_timeout(250)) connect(to) - timeout.holdAdapter(750) + controller.holdAdapter(-1) begin to.sendData(seq) test(false) rescue Ice::TimeoutException # Expected. end + controller.resumeAdapter() + timeout.op() # Ensure adapter is active. # # Expect success. # - timeout.op() # Ensure adapter is active. to = Test::TimeoutPrx::uncheckedCast(obj.ice_timeout(1000)) - timeout.holdAdapter(500) + controller.holdAdapter(200) begin seq2 = "\0" * 1000000 # 1,000,000 entries to.sendData(seq2) @@ -91,7 +96,7 @@ def allTests(communicator) to = Test::TimeoutPrx.uncheckedCast(obj.ice_invocationTimeout(100)) test(connection == to.ice_getConnection()) begin - to.sleep(750) + to.sleep(500) test(false) rescue Ice::InvocationTimeoutException # Expected @@ -112,21 +117,24 @@ def allTests(communicator) STDOUT.flush to = Test::TimeoutPrx.uncheckedCast(obj.ice_timeout(250)) connection = connect(to); - timeout.holdAdapter(600) + controller.holdAdapter(-1) connection.close(Ice::ConnectionClose::GracefullyWithWait) begin connection.getInfo() # getInfo() doesn't throw in the closing state. rescue Ice::LocalException test(false) end - sleep(0.65) - begin - connection.getInfo() - test(false) - rescue Ice::ConnectionManuallyClosedException => ex - # Expected. - test(ex.graceful) + while(true) + begin + connection.getInfo() + sleep(0.01) + rescue Ice::ConnectionManuallyClosedException => ex + # Expected. + test(ex.graceful) + break + end end + controller.resumeAdapter() timeout.op() # Ensure adapter is active. puts "ok" @@ -143,26 +151,29 @@ def allTests(communicator) comm = Ice.initialize(initData) to = Test::TimeoutPrx::uncheckedCast(comm.stringToProxy(sref)) connect(to) - timeout.holdAdapter(700) + controller.holdAdapter(-1) begin to.sendData(seq) test(false) rescue Ice::TimeoutException # expected end + controller.resumeAdapter() + timeout.op() # Ensure adapter is active. # # Calling ice_timeout() should have no effect. # - timeout.op() # Ensure adapter is active. to = Test::TimeoutPrx::uncheckedCast(to.ice_timeout(1000)) connect(to) - timeout.holdAdapter(500) + controller.holdAdapter(-1) begin to.sendData(seq) test(false) rescue Ice::TimeoutException # Expected. end + controller.resumeAdapter() + timeout.op() # Ensure adapter is active. comm.destroy() # @@ -172,7 +183,7 @@ def allTests(communicator) initData.properties = communicator.getProperties().clone() initData.properties.setProperty("Ice.Override.ConnectTimeout", "250") comm = Ice.initialize(initData) - timeout.holdAdapter(750) + controller.holdAdapter(-1) to = Test::TimeoutPrx::uncheckedCast(comm.stringToProxy(sref)) begin to.op() @@ -180,12 +191,13 @@ def allTests(communicator) rescue Ice::ConnectTimeoutException # expected end + controller.resumeAdapter() + timeout.op() # Ensure adapter is active. # # Calling ice_timeout() should have no effect on the connect timeout. # - timeout.op() # Ensure adapter is active. - timeout.holdAdapter(750) + controller.holdAdapter(-1) to = Test::TimeoutPrx::uncheckedCast(to.ice_timeout(1000)) begin to.op() @@ -193,20 +205,23 @@ def allTests(communicator) rescue Ice::ConnectTimeoutException # expected end + controller.resumeAdapter() + timeout.op() # Ensure adapter is active. # # 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)) connect(to) - timeout.holdAdapter(750) + controller.holdAdapter(-1) begin to.sendData(seq) test(false) rescue Ice::TimeoutException # Expected. end + controller.resumeAdapter() + timeout.op() # Ensure adapter is active. comm.destroy() # @@ -217,12 +232,13 @@ def allTests(communicator) initData.properties.setProperty("Ice.Override.CloseTimeout", "100") comm = Ice.initialize(initData) connection = comm.stringToProxy(sref).ice_getConnection(); - timeout.holdAdapter(800); + controller.holdAdapter(-1); now = Time.now comm.destroy(); test((Time.now - now) < 0.7); + controller.resumeAdapter() puts "ok" - return timeout + controller.shutdown() end diff --git a/ruby/test/Ice/timeout/Client.rb b/ruby/test/Ice/timeout/Client.rb index 452ae4f47e5..7b9faf1f960 100755 --- a/ruby/test/Ice/timeout/Client.rb +++ b/ruby/test/Ice/timeout/Client.rb @@ -25,9 +25,7 @@ def test(b) end def run(args, communicator) - myClass = allTests(communicator) - - myClass.shutdown() + allTests(communicator) return true end diff --git a/ruby/test/Ice/timeout/Test.ice b/ruby/test/Ice/timeout/Test.ice index aad831a9993..d611817c1ac 100644 --- a/ruby/test/Ice/timeout/Test.ice +++ b/ruby/test/Ice/timeout/Test.ice @@ -19,9 +19,12 @@ interface Timeout void op(); void sendData(ByteSeq seq); void sleep(int to); +} +interface Controller +{ void holdAdapter(int to); - + void resumeAdapter(); void shutdown(); } |