summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cpp/test/Ice/timeout/AllTests.cpp62
-rw-r--r--csharp/test/Ice/timeout/AllTests.cs50
-rw-r--r--java-compat/test/src/main/java/test/Ice/timeout/AllTests.java51
-rw-r--r--java/test/src/main/java/test/Ice/timeout/AllTests.java50
-rw-r--r--php/test/Ice/timeout/Client.php65
-rw-r--r--python/test/Ice/timeout/AllTests.py38
-rw-r--r--ruby/test/Ice/timeout/AllTests.rb40
7 files changed, 166 insertions, 190 deletions
diff --git a/cpp/test/Ice/timeout/AllTests.cpp b/cpp/test/Ice/timeout/AllTests.cpp
index 34b393e16d3..e88ec8a2bcc 100644
--- a/cpp/test/Ice/timeout/AllTests.cpp
+++ b/cpp/test/Ice/timeout/AllTests.cpp
@@ -15,6 +15,9 @@
using namespace std;
using namespace Test;
+namespace
+{
+
class CallbackBase : public IceUtil::Monitor<IceUtil::Mutex>
{
public:
@@ -80,6 +83,33 @@ public:
};
typedef IceUtil::Handle<Callback> CallbackPtr;
+Ice::ConnectionPtr
+connect(const Ice::ObjectPrxPtr& 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
+ //
+ int nRetry = 5;
+ while(--nRetry > 0)
+ {
+ try
+ {
+ prx->ice_getConnection(); // Establish connection
+ break;
+ }
+ catch(const Ice::ConnectTimeoutException&)
+ {
+ // Can sporadically occur with slow machines
+ }
+ }
+ return prx->ice_getConnection();
+}
+
+}
+
TimeoutPrxPtr
allTests(const Ice::CommunicatorPtr& communicator)
{
@@ -291,20 +321,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
cout << "testing close timeout... " << flush;
{
TimeoutPrxPtr to = ICE_CHECKED_CAST(TimeoutPrx, obj->ice_timeout(250));
- int nRetry = 5;
- while(--nRetry > 0)
- {
- try
- {
- to->ice_getConnection(); // Establish connection
- break;
- }
- catch(const Ice::ConnectTimeoutException&)
- {
- // Can sporadically occur with slow machines
- }
- }
- Ice::ConnectionPtr connection = to->ice_getConnection();
+ Ice::ConnectionPtr connection = connect(to);
timeout->holdAdapter(600);
connection->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait));
try
@@ -341,6 +358,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
initData.properties->setProperty("Ice.Override.Timeout", "250");
Ice::CommunicatorHolder ich(initData);
TimeoutPrxPtr to = ICE_CHECKED_CAST(TimeoutPrx, ich->stringToProxy(sref));
+ connect(to);
timeout->holdAdapter(700);
try
{
@@ -357,6 +375,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
//
timeout->op(); // Ensure adapter is active.
to = ICE_CHECKED_CAST(TimeoutPrx, to->ice_timeout(1000));
+ connect(to);
timeout->holdAdapter(500);
try
{
@@ -407,20 +426,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
//
timeout->op(); // Ensure adapter is active.
to = ICE_UNCHECKED_CAST(TimeoutPrx, to->ice_timeout(250));
- int nRetry = 5;
- while(--nRetry > 0)
- {
- try
- {
- to->ice_getConnection(); // Establish connection
- break;
- }
- catch(const Ice::ConnectTimeoutException&)
- {
- // Can sporadically occur with slow machines
- }
- }
- to->ice_getConnection(); // Establish connection
+ connect(to);
timeout->holdAdapter(750);
try
{
diff --git a/csharp/test/Ice/timeout/AllTests.cs b/csharp/test/Ice/timeout/AllTests.cs
index 8eeb1643b42..29287339cb6 100644
--- a/csharp/test/Ice/timeout/AllTests.cs
+++ b/csharp/test/Ice/timeout/AllTests.cs
@@ -45,6 +45,24 @@ public class AllTests : TestCommon.AllTests
private bool _called;
}
+ private static Ice.Connection connect(Ice.ObjectPrx prx)
+ {
+ int nRetry = 5;
+ while(--nRetry > 0)
+ {
+ try
+ {
+ prx.ice_getConnection();
+ break;
+ }
+ catch(Ice.ConnectTimeoutException)
+ {
+ // Can sporadically occur with slow machines
+ }
+ }
+ return prx.ice_getConnection();
+ }
+
public static Test.TimeoutPrx allTests(TestCommon.Application app)
{
Ice.Communicator communicator = app.communicator();
@@ -245,20 +263,7 @@ public class AllTests : TestCommon.AllTests
Flush();
{
Test.TimeoutPrx to = Test.TimeoutPrxHelper.checkedCast(obj.ice_timeout(250));
- int nRetry = 5;
- while(--nRetry > 0)
- {
- try
- {
- to.ice_getConnection();
- break;
- }
- catch(Ice.ConnectTimeoutException)
- {
- // Can sporadically occur with slow machines
- }
- }
- Ice.Connection connection = to.ice_getConnection();
+ Ice.Connection connection = connect(to);
timeout.holdAdapter(600);
connection.close(Ice.ConnectionClose.GracefullyWithWait);
try
@@ -297,6 +302,7 @@ public class AllTests : TestCommon.AllTests
initData.properties.setProperty("Ice.Override.Timeout", "250");
Ice.Communicator comm = Ice.Util.initialize(ref args, initData);
Test.TimeoutPrx to = Test.TimeoutPrxHelper.checkedCast(comm.stringToProxy(sref));
+ connect(to);
timeout.holdAdapter(700);
try
{
@@ -312,6 +318,7 @@ public class AllTests : TestCommon.AllTests
//
timeout.op(); // Ensure adapter is active.
to = Test.TimeoutPrxHelper.checkedCast(to.ice_timeout(1000));
+ connect(to);
timeout.holdAdapter(500);
try
{
@@ -364,20 +371,7 @@ public class AllTests : TestCommon.AllTests
//
timeout.op(); // Ensure adapter is active.
to = Test.TimeoutPrxHelper.uncheckedCast(to.ice_timeout(250));
- int nRetry = 5;
- while(--nRetry > 0)
- {
- try
- {
- to.ice_getConnection();
- break;
- }
- catch(Ice.ConnectTimeoutException)
- {
- // Can sporadically occur with slow machines
- }
- }
- to.ice_getConnection(); // Establish connection.
+ connect(to);
timeout.holdAdapter(750);
try
{
diff --git a/java-compat/test/src/main/java/test/Ice/timeout/AllTests.java b/java-compat/test/src/main/java/test/Ice/timeout/AllTests.java
index bb5e159da2e..d60279ed271 100644
--- a/java-compat/test/src/main/java/test/Ice/timeout/AllTests.java
+++ b/java-compat/test/src/main/java/test/Ice/timeout/AllTests.java
@@ -132,6 +132,25 @@ public class AllTests
private Callback callback = new Callback();
}
+ public static Ice.Connection
+ connect(Ice.ObjectPrx prx)
+ {
+ int nRetry = 5;
+ while(--nRetry > 0)
+ {
+ try
+ {
+ prx.ice_getConnection();
+ break;
+ }
+ catch(Ice.ConnectTimeoutException ex)
+ {
+ // Can sporadically occur with slow machines
+ }
+ }
+ return prx.ice_getConnection(); // Establish connection
+ }
+
public static TimeoutPrx
allTests(test.Util.Application app)
{
@@ -326,20 +345,7 @@ public class AllTests
out.flush();
{
TimeoutPrx to = TimeoutPrxHelper.checkedCast(obj.ice_timeout(250 * mult));
- int nRetry = 5;
- while(--nRetry > 0)
- {
- try
- {
- to.ice_getConnection();
- break;
- }
- catch(Ice.ConnectTimeoutException ex)
- {
- // Can sporadically occur with slow machines
- }
- }
- Ice.Connection connection = to.ice_getConnection();
+ Ice.Connection connection = connect(to);
timeout.holdAdapter(600);
connection.close(Ice.ConnectionClose.GracefullyWithWait);
try
@@ -383,6 +389,7 @@ public class AllTests
initData.properties.setProperty("Ice.Override.Timeout", "250");
Ice.Communicator comm = app.initialize(initData);
TimeoutPrx to = TimeoutPrxHelper.checkedCast(comm.stringToProxy(sref));
+ connect(to);
timeout.holdAdapter(700 * mult);
try
{
@@ -398,6 +405,7 @@ public class AllTests
//
timeout.op(); // Ensure adapter is active.
to = TimeoutPrxHelper.checkedCast(to.ice_timeout(1000 * mult));
+ connect(to);
timeout.holdAdapter(500 * mult);
try
{
@@ -457,20 +465,7 @@ public class AllTests
//
timeout.op(); // Ensure adapter is active.
to = TimeoutPrxHelper.uncheckedCast(to.ice_timeout(250));
- int nRetry = 5;
- while(--nRetry > 0)
- {
- try
- {
- to.ice_getConnection();
- break;
- }
- catch(Ice.ConnectTimeoutException ex)
- {
- // Can sporadically occur with slow machines
- }
- }
- to.ice_getConnection(); // Establish connection
+ connect(to);
timeout.holdAdapter(750 * mult);
try
{
diff --git a/java/test/src/main/java/test/Ice/timeout/AllTests.java b/java/test/src/main/java/test/Ice/timeout/AllTests.java
index 39de9939fa7..732838fab90 100644
--- a/java/test/src/main/java/test/Ice/timeout/AllTests.java
+++ b/java/test/src/main/java/test/Ice/timeout/AllTests.java
@@ -57,6 +57,24 @@ public class AllTests
private boolean _called;
}
+ public static com.zeroc.Ice.Connection connect(com.zeroc.Ice.ObjectPrx prx)
+ {
+ int nRetry = 5;
+ while(--nRetry > 0)
+ {
+ try
+ {
+ prx.ice_getConnection();
+ break;
+ }
+ catch(com.zeroc.Ice.ConnectTimeoutException ex)
+ {
+ // Can sporadically occur with slow machines
+ }
+ }
+ return prx.ice_getConnection(); // Establish connection
+ }
+
public static TimeoutPrx allTests(test.Util.Application app)
{
com.zeroc.Ice.Communicator communicator = app.communicator();
@@ -259,20 +277,7 @@ public class AllTests
out.flush();
{
TimeoutPrx to = TimeoutPrx.checkedCast(obj.ice_timeout(250 * mult));
- int nRetry = 5;
- while(--nRetry > 0)
- {
- try
- {
- to.ice_getConnection();
- break;
- }
- catch(com.zeroc.Ice.ConnectTimeoutException ex)
- {
- // Can sporadically occur with slow machines
- }
- }
- com.zeroc.Ice.Connection connection = to.ice_getConnection();
+ com.zeroc.Ice.Connection connection = connect(to);
timeout.holdAdapter(600);
connection.close(com.zeroc.Ice.ConnectionClose.GracefullyWithWait);
try
@@ -316,6 +321,7 @@ public class AllTests
initData.properties.setProperty("Ice.Override.Timeout", "250");
com.zeroc.Ice.Communicator comm = app.initialize(initData);
TimeoutPrx to = TimeoutPrx.checkedCast(comm.stringToProxy(sref));
+ connect(to);
timeout.holdAdapter(700 * mult);
try
{
@@ -331,6 +337,7 @@ public class AllTests
//
timeout.op(); // Ensure adapter is active.
to = TimeoutPrx.checkedCast(to.ice_timeout(1000 * mult));
+ connect(to);
timeout.holdAdapter(500 * mult);
try
{
@@ -390,20 +397,7 @@ public class AllTests
//
timeout.op(); // Ensure adapter is active.
to = to.ice_timeout(250);
- int nRetry = 5;
- while(--nRetry > 0)
- {
- try
- {
- to.ice_getConnection();
- break;
- }
- catch(com.zeroc.Ice.ConnectTimeoutException ex)
- {
- // Can sporadically occur with slow machines
- }
- }
- to.ice_getConnection(); // Establish connection
+ connect(to);
timeout.holdAdapter(750 * mult);
try
{
diff --git a/php/test/Ice/timeout/Client.php b/php/test/Ice/timeout/Client.php
index db4c4ca321f..df2e15f9c81 100644
--- a/php/test/Ice/timeout/Client.php
+++ b/php/test/Ice/timeout/Client.php
@@ -36,6 +36,29 @@ function test($b)
}
}
+function connect($prx)
+{
+ $nRetry = 5;
+ while(--$nRetry > 0)
+ {
+ try
+ {
+ $prx->ice_getConnection(); // Establish connection.
+ break;
+ }
+ catch(Exception $ex)
+ {
+ if($ex instanceof $ConnectTimeoutException)
+ {
+ // Can sporadically occur with slow machines
+ }
+ echo($ex);
+ test(false);
+ }
+ }
+ return $prx->ice_getConnection(); // Establish connection.
+}
+
function allTests($communicator)
{
global $NS;
@@ -208,25 +231,7 @@ function allTests($communicator)
flush();
{
$to = $timeout->ice_timeout(250)->ice_uncheckedCast("::Test::Timeout");
- $nRetry = 5;
- while(--$nRetry > 0)
- {
- try
- {
- $to->ice_getConnection(); // Establish connection.
- break;
- }
- catch(Exception $ex)
- {
- if($ex instanceof $ConnectTimeoutException)
- {
- // Can sporadically occur with slow machines
- }
- echo($ex);
- test(false);
- }
- }
- $connection = $to->ice_getConnection();
+ $connection = connect($to);
$timeout->holdAdapter(600);
$connection->close($CloseGracefullyAndWait);
try
@@ -264,6 +269,7 @@ function allTests($communicator)
$initData->properties->setProperty("Ice.Override.Timeout", "150");
$comm = eval($NS ? "return Ice\\initialize(\$initData);" : "return Ice_initialize(\$initData);");
$to = $comm->stringToProxy($sref)->ice_checkedCast("::Test::Timeout");
+ connect($to);
$timeout->holdAdapter(800);
try
{
@@ -284,6 +290,7 @@ function allTests($communicator)
//
$timeout->op(); // Ensure adapter is active.
$to = $to->ice_timeout(1000)->ice_checkedCast("::Test::Timeout");
+ connect($to);
$timeout->holdAdapter(800);
try
{
@@ -351,25 +358,7 @@ function allTests($communicator)
//
$timeout->op(); // Ensure adapter is active.
$to = $to->ice_timeout(250)->ice_uncheckedCast("::Test::Timeout");
- $nRetry = 5;
- while(--$nRetry > 0)
- {
- try
- {
- $to->ice_getConnection(); // Establish connection.
- break;
- }
- catch(Exception $ex)
- {
- if($ex instanceof $ConnectTimeoutException)
- {
- // Can sporadically occur with slow machines
- }
- echo($ex);
- test(false);
- }
- }
- $to->ice_getConnection(); // Establish connection.
+ connect($to);
$timeout->holdAdapter(750);
try
{
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)
diff --git a/ruby/test/Ice/timeout/AllTests.rb b/ruby/test/Ice/timeout/AllTests.rb
index 4b62a9b1712..746191bf588 100644
--- a/ruby/test/Ice/timeout/AllTests.rb
+++ b/ruby/test/Ice/timeout/AllTests.rb
@@ -7,6 +7,20 @@
#
# **********************************************************************
+def connect(prx)
+ nRetry = 5
+ while nRetry > 0 do
+ nRetry -=1
+ begin
+ prx.ice_getConnection() # Establish connection.
+ break
+ rescue Ice::ConnectTimeoutException
+ # Can sporadically occur with slow machines
+ end
+ end
+ return prx.ice_getConnection()
+end
+
def allTests(communicator)
sref = "timeout:default -p 12010"
obj = communicator.stringToProxy(sref)
@@ -96,17 +110,7 @@ def allTests(communicator)
print "testing close timeout... "
STDOUT.flush
to = Test::TimeoutPrx.checkedCast(obj.ice_timeout(250))
- nRetry = 5
- while nRetry > 0 do
- nRetry -=1
- begin
- to.ice_getConnection() # Establish connection.
- break
- rescue Ice::ConnectTimeoutException
- # Can sporadically occur with slow machines
- end
- end
- connection = to.ice_getConnection()
+ connection = connect(to);
timeout.holdAdapter(600)
connection.close(Ice::ConnectionClose::GracefullyWithWait)
begin
@@ -136,6 +140,7 @@ def allTests(communicator)
initData.properties.setProperty("Ice.Override.Timeout", "100")
comm = Ice.initialize(initData)
to = Test::TimeoutPrx::checkedCast(comm.stringToProxy(sref))
+ connect(to)
timeout.holdAdapter(500)
begin
to.sendData(seq)
@@ -148,6 +153,7 @@ def allTests(communicator)
#
timeout.op() # Ensure adapter is active.
to = Test::TimeoutPrx::checkedCast(to.ice_timeout(1000))
+ connect(to)
timeout.holdAdapter(500)
begin
to.sendData(seq)
@@ -191,17 +197,7 @@ def allTests(communicator)
#
timeout.op() # Ensure adapter is active.
to = Test::TimeoutPrx::uncheckedCast(to.ice_timeout(250))
- nRetry = 5
- while nRetry > 0 do
- nRetry -=1
- begin
- to.ice_getConnection() # Establish connection.
- break
- rescue Ice::ConnectTimeoutException
- # Can sporadically occur with slow machines
- end
- end
- to.ice_getConnection() # Establish connection.
+ connect(to)
timeout.holdAdapter(750)
begin
to.sendData(seq)