summaryrefslogtreecommitdiff
path: root/cpp/test
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2019-09-03 16:54:16 +0200
committerBenoit Foucher <benoit@zeroc.com>2019-09-03 16:54:28 +0200
commit3a0366354071a3acfdf93158732938f943339d65 (patch)
treeaf319b72556ba9736063447f48dc5324a0c57c81 /cpp/test
parentFixes for slice2py forward declarations - Close #490 (diff)
downloadice-3a0366354071a3acfdf93158732938f943339d65.tar.bz2
ice-3a0366354071a3acfdf93158732938f943339d65.tar.xz
ice-3a0366354071a3acfdf93158732938f943339d65.zip
Fixed retry bug with -2 invocation timeout, fixes #501
Diffstat (limited to 'cpp/test')
-rw-r--r--cpp/test/Ice/retry/AllTests.cpp77
-rw-r--r--cpp/test/Ice/retry/Test.ice2
-rw-r--r--cpp/test/Ice/retry/TestI.cpp6
-rw-r--r--cpp/test/Ice/retry/TestI.h1
4 files changed, 57 insertions, 29 deletions
diff --git a/cpp/test/Ice/retry/AllTests.cpp b/cpp/test/Ice/retry/AllTests.cpp
index 7b9fa9d375f..5384a8639cd 100644
--- a/cpp/test/Ice/retry/AllTests.cpp
+++ b/cpp/test/Ice/retry/AllTests.cpp
@@ -302,37 +302,56 @@ allTests(const Ice::CommunicatorPtr& communicator, const Ice::CommunicatorPtr& c
cout << "ok" << endl;
}
- cout << "testing invocation timeout and retries... " << flush;
- retry2 = ICE_CHECKED_CAST(RetryPrx, communicator2->stringToProxy(retry1->ice_toString()));
- try
- {
- retry2->ice_invocationTimeout(500)->opIdempotent(4); // No more than 2 retries before timeout kicks-in
- test(false);
- }
- catch(const Ice::InvocationTimeoutException&)
- {
- testRetryCount(2);
- retry2->opIdempotent(-1); // Reset the counter
- testRetryCount(-1);
- }
- try
- {
- // No more than 2 retries before timeout kicks-in
- RetryPrxPtr prx = retry2->ice_invocationTimeout(500);
-#ifdef ICE_CPP11_MAPPING
- prx->opIdempotentAsync(4).get();
-#else
- prx->end_opIdempotent(prx->begin_opIdempotent(4));
-#endif
- test(false);
- }
- catch(const Ice::InvocationTimeoutException&)
{
- testRetryCount(2);
- retry2->opIdempotent(-1);
- testRetryCount(-1);
+ cout << "testing invocation timeout and retries... " << flush;
+ retry2 = ICE_CHECKED_CAST(RetryPrx, communicator2->stringToProxy(retry1->ice_toString()));
+ try
+ {
+ retry2->ice_invocationTimeout(500)->opIdempotent(4); // No more than 2 retries before timeout kicks-in
+ test(false);
+ }
+ catch(const Ice::InvocationTimeoutException&)
+ {
+ testRetryCount(2);
+ retry2->opIdempotent(-1); // Reset the counter
+ testRetryCount(-1);
+ }
+ try
+ {
+ // No more than 2 retries before timeout kicks-in
+ RetryPrxPtr prx = retry2->ice_invocationTimeout(500);
+ #ifdef ICE_CPP11_MAPPING
+ prx->opIdempotentAsync(4).get();
+ #else
+ prx->end_opIdempotent(prx->begin_opIdempotent(4));
+ #endif
+ test(false);
+ }
+ catch(const Ice::InvocationTimeoutException&)
+ {
+ testRetryCount(2);
+ retry2->opIdempotent(-1);
+ testRetryCount(-1);
+ }
+ cout << "ok" << endl;
+
+ if(retry1->ice_getConnection())
+ {
+ // The timeout might occur on connection establishment or because of the sleep. What's
+ // important here is to make sure there are 4 retries and that no calls succeed to
+ // ensure retries with the old connection timeout semantics work.
+ RetryPrxPtr retryWithTimeout = retry1->ice_invocationTimeout(-2)->ice_timeout(200);
+ try
+ {
+ retryWithTimeout->sleep(300);
+ test(false);
+ }
+ catch(const Ice::ConnectionTimeoutException&)
+ {
+ }
+ testRetryCount(4);
+ }
}
- cout << "ok" << endl;
return retry1;
}
diff --git a/cpp/test/Ice/retry/Test.ice b/cpp/test/Ice/retry/Test.ice
index d64ebef31b8..de03d65aaf5 100644
--- a/cpp/test/Ice/retry/Test.ice
+++ b/cpp/test/Ice/retry/Test.ice
@@ -15,6 +15,8 @@ interface Retry
void opNotIdempotent();
void opSystemException();
+ idempotent void sleep(int delay);
+
idempotent void shutdown();
}
diff --git a/cpp/test/Ice/retry/TestI.cpp b/cpp/test/Ice/retry/TestI.cpp
index 03a38780ba3..a05620b7943 100644
--- a/cpp/test/Ice/retry/TestI.cpp
+++ b/cpp/test/Ice/retry/TestI.cpp
@@ -58,6 +58,12 @@ RetryI::opSystemException(const Ice::Current&)
}
void
+RetryI::sleep(int delay, const Ice::Current&)
+{
+ IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(delay));
+}
+
+void
RetryI::shutdown(const Ice::Current& current)
{
current.adapter->getCommunicator()->shutdown();
diff --git a/cpp/test/Ice/retry/TestI.h b/cpp/test/Ice/retry/TestI.h
index 93e842907ad..40ad4a87683 100644
--- a/cpp/test/Ice/retry/TestI.h
+++ b/cpp/test/Ice/retry/TestI.h
@@ -17,6 +17,7 @@ public:
virtual int opIdempotent(int, const Ice::Current&);
virtual void opNotIdempotent(const Ice::Current&);
virtual void opSystemException(const Ice::Current&);
+ virtual void sleep(int, const Ice::Current&);
virtual void shutdown(const Ice::Current&);
private: