summaryrefslogtreecommitdiff
path: root/cpp/test/Ice/faultTolerance/Server.cpp
diff options
context:
space:
mode:
authorMichi Henning <michi@zeroc.com>2004-07-05 02:02:39 +0000
committerMichi Henning <michi@zeroc.com>2004-07-05 02:02:39 +0000
commit970d5853f5b51c007ec50ca2fc41fa1a03598084 (patch)
treed66312f64467a294c39a8eaef86a8ba3e2358806 /cpp/test/Ice/faultTolerance/Server.cpp
parentChanged Instance.cpp to print process ID only once if there are multiple (diff)
downloadice-970d5853f5b51c007ec50ca2fc41fa1a03598084.tar.bz2
ice-970d5853f5b51c007ec50ca2fc41fa1a03598084.tar.xz
ice-970d5853f5b51c007ec50ca2fc41fa1a03598084.zip
Updated fault tolerance tests to correctly destroy the communicator created
by the client. This has exposed a bug in the Ice run time. With the way the test now works, the client receives a ConnectionRefusedException whereas, previously, the adapter was deactivated on the server side. Depending on how endpoints are shuffled in Reference.cpp, this occasionally causes a test failure. It appears that we need to change the run time to - recognize when an endpoint has gone dead and react correctly - avoid re-trying endpoints that have previously failed As is, the test gets slower and slower towards the end because it keeps trying endpoints of servers that were killed in previous iterations.
Diffstat (limited to 'cpp/test/Ice/faultTolerance/Server.cpp')
-rw-r--r--cpp/test/Ice/faultTolerance/Server.cpp35
1 files changed, 34 insertions, 1 deletions
diff --git a/cpp/test/Ice/faultTolerance/Server.cpp b/cpp/test/Ice/faultTolerance/Server.cpp
index 94ffbdb6448..3793ad15671 100644
--- a/cpp/test/Ice/faultTolerance/Server.cpp
+++ b/cpp/test/Ice/faultTolerance/Server.cpp
@@ -21,6 +21,12 @@ usage(const char* n)
int
run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
{
+ if(argc != 2)
+ {
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
+
int port = 0;
for(int i = 1; i < argc; ++i)
{
@@ -48,14 +54,41 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
return EXIT_FAILURE;
}
+ CleanerPtr cleaner = new CleanerI(communicator);
+
ostringstream endpts;
endpts << "default -p " << port;
communicator->getProperties()->setProperty("TestAdapter.Endpoints", endpts.str());
Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter");
- Ice::ObjectPtr object = new TestI(adapter);
+ Ice::ObjectPtr object = new TestI(adapter, cleaner);
adapter->add(object, Ice::stringToIdentity("test"));
+
+ int dummyArgc = 0;
+ char* dummyArgv[] = { 0 };
+
+ Ice::CommunicatorPtr cleanupCommunicator = Ice::initialize(dummyArgc, dummyArgv);
+
+ ostringstream str;
+ str << (port + 1);
+ string cleanupPort = str.str();
+ cleanupCommunicator->getProperties()->setProperty("CleanupAdapter.Endpoints", "default -p " + cleanupPort);
+
+ Ice::ObjectAdapterPtr cleanupAdapter = cleanupCommunicator->createObjectAdapter("CleanupAdapter");
+ cleanupAdapter->add(cleaner, Ice::stringToIdentity("Cleaner"));
+
+ string adapterReady = cleanupCommunicator->getProperties()->getProperty("Ice.PrintAdapterReady");
+ cleanupCommunicator->getProperties()->setProperty("Ice.PrintAdapterReady", "0");
+
+ cleanupAdapter->activate();
+ cleanupCommunicator->getProperties()->setProperty("Ice.PrintAdapterReady", adapterReady);
+
adapter->activate();
communicator->waitForShutdown();
+
+ cleaner->cleanup();
+
+ cleanupCommunicator->destroy();
+
return EXIT_SUCCESS;
}