summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2017-05-26 12:28:36 +0200
committerBenoit Foucher <benoit@zeroc.com>2017-05-26 12:28:36 +0200
commit9247e49f5bb67b0cad705b1ffd607e6202224bef (patch)
tree3621088fcd8dcb77233c7d66867b3ee915829b0d /cpp
parentFixed ICE-7922 - Review retry/network tracing (diff)
downloadice-9247e49f5bb67b0cad705b1ffd607e6202224bef.tar.bz2
ice-9247e49f5bb67b0cad705b1ffd607e6202224bef.tar.xz
ice-9247e49f5bb67b0cad705b1ffd607e6202224bef.zip
Improved timeout test to better deal with slow VMs
Diffstat (limited to 'cpp')
-rw-r--r--cpp/test/Ice/timeout/AllTests.cpp62
1 files changed, 34 insertions, 28 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
{