diff options
Diffstat (limited to 'cpp/test/IceGrid')
29 files changed, 5576 insertions, 5576 deletions
diff --git a/cpp/test/IceGrid/activation/AllTests.cpp b/cpp/test/IceGrid/activation/AllTests.cpp index 26460fe700f..8777ab9cba7 100644 --- a/cpp/test/IceGrid/activation/AllTests.cpp +++ b/cpp/test/IceGrid/activation/AllTests.cpp @@ -23,14 +23,14 @@ waitForServerState(const IceGrid::AdminPrx& admin, const std::string& server, Ic int nRetry = 0; while(admin->getServerState(server) != state && nRetry < 15) { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - ++nRetry; + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + ++nRetry; } if(admin->getServerState(server) != state) { - cerr << "server state change timed out:" << endl; - cerr << "server: " << server << endl; - cerr << "state: " << state << endl; + cerr << "server state change timed out:" << endl; + cerr << "server: " << server << endl; + cerr << "state: " << state << endl; } } @@ -39,42 +39,42 @@ class PingThread : public IceUtil::Thread, IceUtil::Monitor<IceUtil::Mutex> public: PingThread(const Ice::ObjectPrx& proxy, int nRepetitions) : - _proxy(proxy), _finished(false), _nRepetitions(nRepetitions) + _proxy(proxy), _finished(false), _nRepetitions(nRepetitions) { } virtual void run() { - for(int i = 0; i < _nRepetitions; ++i) - { - try - { - _proxy->ice_ping(); - } - catch(const Ice::LocalException& ex) - { - _exception.reset(dynamic_cast<Ice::LocalException*>(ex.ice_clone())); - } - catch(...) - { - assert(false); - } - } - - Lock sync(*this); - _finished = true; - notifyAll(); + for(int i = 0; i < _nRepetitions; ++i) + { + try + { + _proxy->ice_ping(); + } + catch(const Ice::LocalException& ex) + { + _exception.reset(dynamic_cast<Ice::LocalException*>(ex.ice_clone())); + } + catch(...) + { + assert(false); + } + } + + Lock sync(*this); + _finished = true; + notifyAll(); } auto_ptr<Ice::LocalException> waitUntilFinished() { - Lock sync(*this); - while(!_finished) - { - wait(); - } - return _exception; + Lock sync(*this); + while(!_finished) + { + wait(); + } + return _exception; } private: @@ -91,7 +91,7 @@ class SessionKeepAliveThread : public IceUtil::Thread, public IceUtil::Monitor<I public: SessionKeepAliveThread(const IceGrid::AdminSessionPrx& session, long timeout) : - _session(session), + _session(session), _timeout(IceUtil::Time::seconds(timeout)), _destroy(false) { @@ -106,15 +106,15 @@ public: timedWait(_timeout); if(_destroy) { - break; - } + break; + } try { _session->keepAlive(); } catch(const Ice::Exception&) { - break; + break; } } } @@ -155,220 +155,220 @@ allTests(const Ice::CommunicatorPtr& communicator) int nRetry = 0; while(!admin->pingNode("node-1") && nRetry < 15) { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(200)); - ++nRetry; + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(200)); + ++nRetry; } nRetry = 0; while(!admin->pingNode("node-2") && nRetry < 15) { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(200)); - ++nRetry; + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(200)); + ++nRetry; } cout << "testing on-demand activation... " << flush; try { - test(admin->getServerState("server") == IceGrid::Inactive); - TestIntfPrx obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server")); - waitForServerState(admin, "server", IceGrid::Active); - obj->shutdown(); - waitForServerState(admin, "server", IceGrid::Inactive); - nRetry = 4; - while(--nRetry > 0) - { - obj->shutdown(); - } - waitForServerState(admin, "server", IceGrid::Inactive); + test(admin->getServerState("server") == IceGrid::Inactive); + TestIntfPrx obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server")); + waitForServerState(admin, "server", IceGrid::Active); + obj->shutdown(); + waitForServerState(admin, "server", IceGrid::Inactive); + nRetry = 4; + while(--nRetry > 0) + { + obj->shutdown(); + } + waitForServerState(admin, "server", IceGrid::Inactive); } catch(const Ice::LocalException& ex) { - cerr << ex << endl; - test(false); + cerr << ex << endl; + test(false); } cout << "ok" << endl; cout << "testing manual activation... " << flush; try { - test(admin->getServerState("server-manual") == IceGrid::Inactive); - TestIntfPrx obj; - try - { - obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server-manual")); - test(false); - } - catch(const Ice::NoEndpointException&) - { - } - test(admin->getServerState("server-manual") == IceGrid::Inactive); - admin->startServer("server-manual"); - test(admin->getServerState("server-manual") == IceGrid::Active); - obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server-manual")); - test(admin->getServerState("server-manual") == IceGrid::Active); - obj->shutdown(); - waitForServerState(admin, "server-manual", IceGrid::Inactive); + test(admin->getServerState("server-manual") == IceGrid::Inactive); + TestIntfPrx obj; + try + { + obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server-manual")); + test(false); + } + catch(const Ice::NoEndpointException&) + { + } + test(admin->getServerState("server-manual") == IceGrid::Inactive); + admin->startServer("server-manual"); + test(admin->getServerState("server-manual") == IceGrid::Active); + obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server-manual")); + test(admin->getServerState("server-manual") == IceGrid::Active); + obj->shutdown(); + waitForServerState(admin, "server-manual", IceGrid::Inactive); } catch(const Ice::LocalException& ex) { - cerr << ex << endl; - test(false); + cerr << ex << endl; + test(false); } cout << "ok" << endl; cout << "testing always activation... " << flush; try { - waitForServerState(admin, "server-always", IceGrid::Active); - TestIntfPrx obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server-always")); - admin->stopServer("server-always"); - waitForServerState(admin, "server-always", IceGrid::Active); - obj->shutdown(); - waitForServerState(admin, "server-always", IceGrid::Active); - nRetry = 4; - while(--nRetry > 0) - { - obj->shutdown(); - } - waitForServerState(admin, "server-always", IceGrid::Active); + waitForServerState(admin, "server-always", IceGrid::Active); + TestIntfPrx obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server-always")); + admin->stopServer("server-always"); + waitForServerState(admin, "server-always", IceGrid::Active); + obj->shutdown(); + waitForServerState(admin, "server-always", IceGrid::Active); + nRetry = 4; + while(--nRetry > 0) + { + obj->shutdown(); + } + waitForServerState(admin, "server-always", IceGrid::Active); } catch(const Ice::LocalException& ex) { - cerr << ex << endl; - test(false); + cerr << ex << endl; + test(false); } cout << "ok" << endl; cout << "testing session activation... " << flush; try { - IceGrid::SessionPrx session = registry->createSession("test", ""); - - test(admin->getServerState("server-session") == IceGrid::Inactive); - TestIntfPrx obj = TestIntfPrx::uncheckedCast(communicator->stringToProxy("server-session")); - try - { - obj->ice_ping(); - test(false); - } - catch(const Ice::NoEndpointException&) - { - } - session->allocateObjectById(obj->ice_getIdentity()); - obj->ice_ping(); - waitForServerState(admin, "server-session", IceGrid::Active); - obj->shutdown(); - waitForServerState(admin, "server-session", IceGrid::Inactive); - obj->ice_ping(); - waitForServerState(admin, "server-session", IceGrid::Active); - nRetry = 4; - while(--nRetry > 0) - { - obj->shutdown(); - } - obj->ice_ping(); - waitForServerState(admin, "server-session", IceGrid::Active); - session->releaseObject(obj->ice_getIdentity()); - try - { - obj->ice_ping(); - test(false); - } - catch(const Ice::NoEndpointException&) - { - } - waitForServerState(admin, "server-session", IceGrid::Inactive); - - session->allocateObjectById(obj->ice_getIdentity()); - obj->ice_ping(); - waitForServerState(admin, "server-session", IceGrid::Active); - session->destroy(); - try - { - obj->ice_ping(); - test(false); - } - catch(const Ice::NoEndpointException&) - { - } - waitForServerState(admin, "server-session", IceGrid::Inactive); + IceGrid::SessionPrx session = registry->createSession("test", ""); + + test(admin->getServerState("server-session") == IceGrid::Inactive); + TestIntfPrx obj = TestIntfPrx::uncheckedCast(communicator->stringToProxy("server-session")); + try + { + obj->ice_ping(); + test(false); + } + catch(const Ice::NoEndpointException&) + { + } + session->allocateObjectById(obj->ice_getIdentity()); + obj->ice_ping(); + waitForServerState(admin, "server-session", IceGrid::Active); + obj->shutdown(); + waitForServerState(admin, "server-session", IceGrid::Inactive); + obj->ice_ping(); + waitForServerState(admin, "server-session", IceGrid::Active); + nRetry = 4; + while(--nRetry > 0) + { + obj->shutdown(); + } + obj->ice_ping(); + waitForServerState(admin, "server-session", IceGrid::Active); + session->releaseObject(obj->ice_getIdentity()); + try + { + obj->ice_ping(); + test(false); + } + catch(const Ice::NoEndpointException&) + { + } + waitForServerState(admin, "server-session", IceGrid::Inactive); + + session->allocateObjectById(obj->ice_getIdentity()); + obj->ice_ping(); + waitForServerState(admin, "server-session", IceGrid::Active); + session->destroy(); + try + { + obj->ice_ping(); + test(false); + } + catch(const Ice::NoEndpointException&) + { + } + waitForServerState(admin, "server-session", IceGrid::Inactive); } catch(const Ice::LocalException& ex) { - cerr << ex << endl; - test(false); + cerr << ex << endl; + test(false); } cout << "ok" << endl; cout << "testing server disable... " << flush; try { - test(admin->getServerState("server") == IceGrid::Inactive); - admin->enableServer("server", false); - try - { - communicator->stringToProxy("server")->ice_ping(); - test(false); - } - catch(const Ice::NoEndpointException&) - { - } - try - { - admin->startServer("server"); - test(false); - } - catch(const IceGrid::ServerStartException&) - { - } - test(admin->getServerState("server") == IceGrid::Inactive); - - test(admin->getServerState("server-manual") == IceGrid::Inactive); - admin->enableServer("server-manual", false); - try - { - communicator->stringToProxy("server-manual")->ice_ping(); - test(false); - } - catch(const Ice::NoEndpointException&) - { - } - try - { - admin->startServer("server-manual"); - test(false); - } - catch(const IceGrid::ServerStartException&) - { - } - test(admin->getServerState("server-manual") == IceGrid::Inactive); - - test(admin->getServerState("server-always") == IceGrid::Active); - admin->enableServer("server-always", false); - admin->stopServer("server-always"); - test(admin->getServerState("server-always") == IceGrid::Inactive); - try - { - communicator->stringToProxy("server-always")->ice_ping(); - test(false); - } - catch(const Ice::NoEndpointException&) - { - } - try - { - admin->startServer("server-always"); - test(false); - } - catch(const IceGrid::ServerStartException&) - { - } - test(admin->getServerState("server-always") == IceGrid::Inactive); + test(admin->getServerState("server") == IceGrid::Inactive); + admin->enableServer("server", false); + try + { + communicator->stringToProxy("server")->ice_ping(); + test(false); + } + catch(const Ice::NoEndpointException&) + { + } + try + { + admin->startServer("server"); + test(false); + } + catch(const IceGrid::ServerStartException&) + { + } + test(admin->getServerState("server") == IceGrid::Inactive); + + test(admin->getServerState("server-manual") == IceGrid::Inactive); + admin->enableServer("server-manual", false); + try + { + communicator->stringToProxy("server-manual")->ice_ping(); + test(false); + } + catch(const Ice::NoEndpointException&) + { + } + try + { + admin->startServer("server-manual"); + test(false); + } + catch(const IceGrid::ServerStartException&) + { + } + test(admin->getServerState("server-manual") == IceGrid::Inactive); + + test(admin->getServerState("server-always") == IceGrid::Active); + admin->enableServer("server-always", false); + admin->stopServer("server-always"); + test(admin->getServerState("server-always") == IceGrid::Inactive); + try + { + communicator->stringToProxy("server-always")->ice_ping(); + test(false); + } + catch(const Ice::NoEndpointException&) + { + } + try + { + admin->startServer("server-always"); + test(false); + } + catch(const IceGrid::ServerStartException&) + { + } + test(admin->getServerState("server-always") == IceGrid::Inactive); } catch(const Ice::LocalException& ex) { - cerr << ex << endl; - test(false); + cerr << ex << endl; + test(false); } cout << "ok" << endl; @@ -376,277 +376,277 @@ allTests(const Ice::CommunicatorPtr& communicator) cout << "testing server enable... " << flush; try { - test(admin->getServerState("server") == IceGrid::Inactive); - admin->enableServer("server", true); - communicator->stringToProxy("server")->ice_ping(); - admin->stopServer("server"); - test(admin->getServerState("server") == IceGrid::Inactive); - admin->startServer("server"); - test(admin->getServerState("server") == IceGrid::Active); - admin->stopServer("server"); - test(admin->getServerState("server") == IceGrid::Inactive); - - test(admin->getServerState("server-manual") == IceGrid::Inactive); - admin->enableServer("server-manual", true); - try - { - communicator->stringToProxy("server-manual")->ice_ping(); - test(false); - } - catch(const Ice::NoEndpointException&) - { - } - test(admin->getServerState("server-manual") == IceGrid::Inactive); - admin->startServer("server-manual"); - test(admin->getServerState("server-manual") == IceGrid::Active); - admin->stopServer("server-manual"); - test(admin->getServerState("server-manual") == IceGrid::Inactive); - - test(admin->getServerState("server-always") == IceGrid::Inactive); - admin->enableServer("server-always", true); - waitForServerState(admin, "server-always", IceGrid::Active); - admin->stopServer("server-always"); - try - { - admin->startServer("server-always"); -// test(false); - } - catch(const IceGrid::ServerStartException&) - { - } - test(admin->getServerState("server-always") == IceGrid::Active); + test(admin->getServerState("server") == IceGrid::Inactive); + admin->enableServer("server", true); + communicator->stringToProxy("server")->ice_ping(); + admin->stopServer("server"); + test(admin->getServerState("server") == IceGrid::Inactive); + admin->startServer("server"); + test(admin->getServerState("server") == IceGrid::Active); + admin->stopServer("server"); + test(admin->getServerState("server") == IceGrid::Inactive); + + test(admin->getServerState("server-manual") == IceGrid::Inactive); + admin->enableServer("server-manual", true); + try + { + communicator->stringToProxy("server-manual")->ice_ping(); + test(false); + } + catch(const Ice::NoEndpointException&) + { + } + test(admin->getServerState("server-manual") == IceGrid::Inactive); + admin->startServer("server-manual"); + test(admin->getServerState("server-manual") == IceGrid::Active); + admin->stopServer("server-manual"); + test(admin->getServerState("server-manual") == IceGrid::Inactive); + + test(admin->getServerState("server-always") == IceGrid::Inactive); + admin->enableServer("server-always", true); + waitForServerState(admin, "server-always", IceGrid::Active); + admin->stopServer("server-always"); + try + { + admin->startServer("server-always"); +// test(false); + } + catch(const IceGrid::ServerStartException&) + { + } + test(admin->getServerState("server-always") == IceGrid::Active); } catch(const Ice::LocalException& ex) { - cerr << ex << endl; - test(false); + cerr << ex << endl; + test(false); } - cout << "ok" << endl; + cout << "ok" << endl; cout << "testing activation failure... " << flush; try { - int i; - const int nThreads = 3; - Ice::ObjectPrx invalid = communicator->stringToProxy("invalid-exe"); - - vector<PingThreadPtr> threads; - threads.reserve(nThreads); - vector<PingThreadPtr>::const_iterator p; - for(i = 0; i < nThreads; i++) - { - threads.push_back(new PingThread(invalid, 10)); - } - for(p = threads.begin(); p != threads.end(); ++p) - { - (*p)->start(); - } - for(p = threads.begin(); p != threads.end(); ++p) - { - auto_ptr<Ice::LocalException> ex((*p)->waitUntilFinished()); - test(dynamic_cast<Ice::NoEndpointException*>(ex.get())); - } - threads.resize(0); - - invalid = communicator->stringToProxy("invalid-pwd"); - for(i = 0; i < nThreads; i++) - { - threads.push_back(new PingThread(invalid, 10)); - } - for(p = threads.begin(); p != threads.end(); ++p) - { - (*p)->start(); - } - for(p = threads.begin(); p != threads.end(); ++p) - { - auto_ptr<Ice::LocalException> ex((*p)->waitUntilFinished()); - test(dynamic_cast<Ice::NoEndpointException*>(ex.get())); - } - threads.resize(0); - - invalid = communicator->stringToProxy("fail-on-startup"); - for(i = 0; i < nThreads; i++) - { - threads.push_back(new PingThread(invalid, 5)); - } - for(p = threads.begin(); p != threads.end(); ++p) - { - (*p)->start(); - } - for(p = threads.begin(); p != threads.end(); ++p) - { - auto_ptr<Ice::LocalException> ex((*p)->waitUntilFinished()); - test(dynamic_cast<Ice::NoEndpointException*>(ex.get())); - } - threads.resize(0); + int i; + const int nThreads = 3; + Ice::ObjectPrx invalid = communicator->stringToProxy("invalid-exe"); + + vector<PingThreadPtr> threads; + threads.reserve(nThreads); + vector<PingThreadPtr>::const_iterator p; + for(i = 0; i < nThreads; i++) + { + threads.push_back(new PingThread(invalid, 10)); + } + for(p = threads.begin(); p != threads.end(); ++p) + { + (*p)->start(); + } + for(p = threads.begin(); p != threads.end(); ++p) + { + auto_ptr<Ice::LocalException> ex((*p)->waitUntilFinished()); + test(dynamic_cast<Ice::NoEndpointException*>(ex.get())); + } + threads.resize(0); + + invalid = communicator->stringToProxy("invalid-pwd"); + for(i = 0; i < nThreads; i++) + { + threads.push_back(new PingThread(invalid, 10)); + } + for(p = threads.begin(); p != threads.end(); ++p) + { + (*p)->start(); + } + for(p = threads.begin(); p != threads.end(); ++p) + { + auto_ptr<Ice::LocalException> ex((*p)->waitUntilFinished()); + test(dynamic_cast<Ice::NoEndpointException*>(ex.get())); + } + threads.resize(0); + + invalid = communicator->stringToProxy("fail-on-startup"); + for(i = 0; i < nThreads; i++) + { + threads.push_back(new PingThread(invalid, 5)); + } + for(p = threads.begin(); p != threads.end(); ++p) + { + (*p)->start(); + } + for(p = threads.begin(); p != threads.end(); ++p) + { + auto_ptr<Ice::LocalException> ex((*p)->waitUntilFinished()); + test(dynamic_cast<Ice::NoEndpointException*>(ex.get())); + } + threads.resize(0); } catch(const Ice::LocalException& ex) { - cerr << ex << endl; - test(false); + cerr << ex << endl; + test(false); } cout << "ok" << endl; cout << "testing activation timeout... " << flush; try { - test(admin->getServerState("server-activation-timeout") == IceGrid::Inactive); - const int nThreads = 5; - Ice::ObjectPrx proxy = communicator->stringToProxy("server-activation-timeout"); - vector<PingThreadPtr> threads; - threads.reserve(nThreads); - vector<PingThreadPtr>::const_iterator p; - int i; - for(i = 0; i < nThreads; i++) - { - threads.push_back(new PingThread(proxy, 1)); - } - for(p = threads.begin(); p != threads.end(); ++p) - { - (*p)->start(); - } - for(p = threads.begin(); p != threads.end(); ++p) - { - auto_ptr<Ice::LocalException> ex((*p)->waitUntilFinished()); - test(dynamic_cast<Ice::NoEndpointException*>(ex.get())); - } - admin->stopServer("server-activation-timeout"); + test(admin->getServerState("server-activation-timeout") == IceGrid::Inactive); + const int nThreads = 5; + Ice::ObjectPrx proxy = communicator->stringToProxy("server-activation-timeout"); + vector<PingThreadPtr> threads; + threads.reserve(nThreads); + vector<PingThreadPtr>::const_iterator p; + int i; + for(i = 0; i < nThreads; i++) + { + threads.push_back(new PingThread(proxy, 1)); + } + for(p = threads.begin(); p != threads.end(); ++p) + { + (*p)->start(); + } + for(p = threads.begin(); p != threads.end(); ++p) + { + auto_ptr<Ice::LocalException> ex((*p)->waitUntilFinished()); + test(dynamic_cast<Ice::NoEndpointException*>(ex.get())); + } + admin->stopServer("server-activation-timeout"); } catch(const IceGrid::ServerStopException& ex) { - cerr << ex << ": " << ex.reason << endl; - test(false); + cerr << ex << ": " << ex.reason << endl; + test(false); } catch(const Ice::LocalException& ex) { - cerr << ex << endl; - test(false); + cerr << ex << endl; + test(false); } - cout << "ok" << endl; + cout << "ok" << endl; cout << "testing deactivation timeout... " << flush; try { - test(admin->getServerState("server-deactivation-timeout") == IceGrid::Inactive); - communicator->stringToProxy("server-deactivation-timeout")->ice_ping(); - admin->stopServer("server-deactivation-timeout"); + test(admin->getServerState("server-deactivation-timeout") == IceGrid::Inactive); + communicator->stringToProxy("server-deactivation-timeout")->ice_ping(); + admin->stopServer("server-deactivation-timeout"); } catch(const Ice::LocalException& ex) { - cerr << ex << endl; - test(false); + cerr << ex << endl; + test(false); } - cout << "ok" << endl; + cout << "ok" << endl; cout << "testing permanent disable on failure... " << flush; try { - test(admin->getServerState("server1") == IceGrid::Inactive); - TestIntfPrx obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server1")); - waitForServerState(admin, "server1", IceGrid::Active); - obj->fail(); - waitForServerState(admin, "server1", IceGrid::Inactive); - try - { - obj->ice_ping(); - test(false); - } - catch(const Ice::NoEndpointException&) - { - } - test(!admin->isServerEnabled("server1")); - - test(admin->getServerState("server1-manual") == IceGrid::Inactive); - admin->startServer("server1-manual"); - test(admin->getServerState("server1-manual") == IceGrid::Active); - obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server1-manual")); - test(admin->getServerState("server1-manual") == IceGrid::Active); - obj->fail(); - waitForServerState(admin, "server1-manual", IceGrid::Inactive); - test(!admin->isServerEnabled("server1-manual")); - - test(admin->getServerState("server1-always") == IceGrid::Active); - obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server1-always")); - obj->fail(); - waitForServerState(admin, "server1-always", IceGrid::Inactive); - test(!admin->isServerEnabled("server1-always")); + test(admin->getServerState("server1") == IceGrid::Inactive); + TestIntfPrx obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server1")); + waitForServerState(admin, "server1", IceGrid::Active); + obj->fail(); + waitForServerState(admin, "server1", IceGrid::Inactive); + try + { + obj->ice_ping(); + test(false); + } + catch(const Ice::NoEndpointException&) + { + } + test(!admin->isServerEnabled("server1")); + + test(admin->getServerState("server1-manual") == IceGrid::Inactive); + admin->startServer("server1-manual"); + test(admin->getServerState("server1-manual") == IceGrid::Active); + obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server1-manual")); + test(admin->getServerState("server1-manual") == IceGrid::Active); + obj->fail(); + waitForServerState(admin, "server1-manual", IceGrid::Inactive); + test(!admin->isServerEnabled("server1-manual")); + + test(admin->getServerState("server1-always") == IceGrid::Active); + obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server1-always")); + obj->fail(); + waitForServerState(admin, "server1-always", IceGrid::Inactive); + test(!admin->isServerEnabled("server1-always")); } catch(const Ice::LocalException& ex) { - cerr << ex << endl; - test(false); + cerr << ex << endl; + test(false); } - cout << "ok" << endl; + cout << "ok" << endl; cout << "testing temporary disable on failure... " << flush; try { - test(admin->getServerState("server2") == IceGrid::Inactive); - TestIntfPrx obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server2")); - waitForServerState(admin, "server2", IceGrid::Active); - obj->fail(); - waitForServerState(admin, "server2", IceGrid::Inactive); - try - { - obj->ice_ping(); - test(false); - } - catch(const Ice::NoEndpointException&) - { - } - test(!admin->isServerEnabled("server2")); - nRetry = 0; - while(!admin->isServerEnabled("server2") && nRetry < 15) - { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - ++nRetry; - try - { - obj->ice_ping(); - } - catch(const Ice::NoEndpointException&) - { - } - } - test(admin->isServerEnabled("server2")); - waitForServerState(admin, "server2", IceGrid::Active); - obj->ice_ping(); - admin->stopServer("server2"); - - test(admin->getServerState("server2-manual") == IceGrid::Inactive); - admin->startServer("server2-manual"); - test(admin->getServerState("server2-manual") == IceGrid::Active); - obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server2-manual")); - obj->fail(); - waitForServerState(admin, "server2-manual", IceGrid::Inactive); - test(!admin->isServerEnabled("server2-manual")); - admin->startServer("server2-manual"); - test(admin->isServerEnabled("server2-manual")); - test(admin->getServerState("server2-manual") == IceGrid::Active); - admin->stopServer("server2-manual"); - - test(admin->getServerState("server2-always") == IceGrid::Active); - obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server2-always")); - obj->fail(); - waitForServerState(admin, "server2-always", IceGrid::Inactive); - test(!admin->isServerEnabled("server2-always")); - nRetry = 0; - while((!admin->isServerEnabled("server2-always") || - admin->getServerState("server2-always") != IceGrid::Active) && - nRetry < 15) - { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - ++nRetry; - } - test(admin->isServerEnabled("server2-always") && admin->getServerState("server2-always") == IceGrid::Active); - obj->ice_ping(); + test(admin->getServerState("server2") == IceGrid::Inactive); + TestIntfPrx obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server2")); + waitForServerState(admin, "server2", IceGrid::Active); + obj->fail(); + waitForServerState(admin, "server2", IceGrid::Inactive); + try + { + obj->ice_ping(); + test(false); + } + catch(const Ice::NoEndpointException&) + { + } + test(!admin->isServerEnabled("server2")); + nRetry = 0; + while(!admin->isServerEnabled("server2") && nRetry < 15) + { + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + ++nRetry; + try + { + obj->ice_ping(); + } + catch(const Ice::NoEndpointException&) + { + } + } + test(admin->isServerEnabled("server2")); + waitForServerState(admin, "server2", IceGrid::Active); + obj->ice_ping(); + admin->stopServer("server2"); + + test(admin->getServerState("server2-manual") == IceGrid::Inactive); + admin->startServer("server2-manual"); + test(admin->getServerState("server2-manual") == IceGrid::Active); + obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server2-manual")); + obj->fail(); + waitForServerState(admin, "server2-manual", IceGrid::Inactive); + test(!admin->isServerEnabled("server2-manual")); + admin->startServer("server2-manual"); + test(admin->isServerEnabled("server2-manual")); + test(admin->getServerState("server2-manual") == IceGrid::Active); + admin->stopServer("server2-manual"); + + test(admin->getServerState("server2-always") == IceGrid::Active); + obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server2-always")); + obj->fail(); + waitForServerState(admin, "server2-always", IceGrid::Inactive); + test(!admin->isServerEnabled("server2-always")); + nRetry = 0; + while((!admin->isServerEnabled("server2-always") || + admin->getServerState("server2-always") != IceGrid::Active) && + nRetry < 15) + { + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + ++nRetry; + } + test(admin->isServerEnabled("server2-always") && admin->getServerState("server2-always") == IceGrid::Active); + obj->ice_ping(); } catch(const Ice::LocalException& ex) { - cerr << ex << endl; - test(false); + cerr << ex << endl; + test(false); } cout << "ok" << endl; diff --git a/cpp/test/IceGrid/activation/Client.cpp b/cpp/test/IceGrid/activation/Client.cpp index aaa0e585955..0162051684d 100644 --- a/cpp/test/IceGrid/activation/Client.cpp +++ b/cpp/test/IceGrid/activation/Client.cpp @@ -30,26 +30,26 @@ main(int argc, char* argv[]) try { - communicator = Ice::initialize(argc, argv); - status = run(argc, argv, communicator); + communicator = Ice::initialize(argc, argv); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/IceGrid/activation/Server.cpp b/cpp/test/IceGrid/activation/Server.cpp index d9e5e6e0e4c..721c2132427 100644 --- a/cpp/test/IceGrid/activation/Server.cpp +++ b/cpp/test/IceGrid/activation/Server.cpp @@ -30,7 +30,7 @@ Server::run(int argc, char* argv[]) Ice::stringSeqToArgs(args, argc, argv); if(properties->getPropertyAsInt("FailOnStartup") > 0) { - return EXIT_FAILURE; + return EXIT_FAILURE; } Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("TestAdapter"); @@ -41,13 +41,13 @@ Server::run(int argc, char* argv[]) int delay = properties->getPropertyAsInt("ActivationDelay"); if(delay > 0) { - IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(delay)); + IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(delay)); } shutdownOnInterrupt(); try { - adapter->activate(); + adapter->activate(); } catch(const Ice::ObjectAdapterDeactivatedException&) { @@ -58,7 +58,7 @@ Server::run(int argc, char* argv[]) delay = properties->getPropertyAsInt("DeactivationDelay"); if(delay > 0) { - IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(delay)); + IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(delay)); } return test->isFailed() ? EXIT_FAILURE : EXIT_SUCCESS; diff --git a/cpp/test/IceGrid/allocation/AllTests.cpp b/cpp/test/IceGrid/allocation/AllTests.cpp index 7079f31c4ed..dfc515d904f 100644 --- a/cpp/test/IceGrid/allocation/AllTests.cpp +++ b/cpp/test/IceGrid/allocation/AllTests.cpp @@ -32,47 +32,47 @@ public: void response(const Ice::ObjectPrx& obj) { - Lock sync(*this); - _response = true; - _obj = obj; - notify(); + Lock sync(*this); + _response = true; + _obj = obj; + notify(); } void exception() { - Lock sync(*this); - _exception = true; - notify(); + Lock sync(*this); + _exception = true; + notify(); } void waitResponse(const char* file, int line) { - Lock sync(*this); - while(!_response && !_exception) - { - if(!timedWait(IceUtil::Time::seconds(3))) - { - cerr << "timeout: " << file << ":" << line << endl; - test(false); // Timeout - } - } + Lock sync(*this); + while(!_response && !_exception) + { + if(!timedWait(IceUtil::Time::seconds(3))) + { + cerr << "timeout: " << file << ":" << line << endl; + test(false); // Timeout + } + } } bool hasResponse(Ice::ObjectPrx& obj) { - Lock sync(*this); - obj = _obj; - return _response; + Lock sync(*this); + obj = _obj; + return _response; } bool hasException() { - Lock sync(*this); - return _exception; + Lock sync(*this); + return _exception; } private: @@ -106,171 +106,171 @@ public: StressClient(int id, const RegistryPrx& registry, bool destroySession) : _communicator(registry->ice_getCommunicator()), - _id(id), - _registry(registry), - _notified(false), - _terminated(false), - _destroySession(destroySession) + _id(id), + _registry(registry), + _notified(false), + _terminated(false), + _destroySession(destroySession) { } StressClient(int id, const SessionPrx& session) : _communicator(session->ice_getCommunicator()), - _id(id), - _session(session), - _notified(false), - _terminated(false), - _destroySession(false) + _id(id), + _session(session), + _notified(false), + _terminated(false), + _destroySession(false) { } virtual void run() { - { - Lock sync(*this); - while(!_notified) - { - wait(); - } - } - - SessionPrx session; - while(true) - { - { - Lock sync(*this); - if(_terminated) - { - if(!_session && session) - { - session->destroy(); - } - return; - } - } - - if(!session) - { - ostringstream os; - os << "Client-" << _id; - if(_session) - { - session = _session; - } - else - { - session = _registry->createSession(os.str(), ""); - session->setAllocationTimeout(IceUtil::random(200)); // 200ms timeout - } - } - - assert(session); - session->keepAlive(); - - Ice::ObjectPrx object; - switch(IceUtil::random(_destroySession ? 4 : 2)) - { - case 0: - object = allocate(session); - break; - case 1: - object = allocateByType(session); - break; - case 2: - assert(!_session); - allocateAndDestroy(session); - session = 0; - break; - case 3: - assert(!_session); - allocateByTypeAndDestroy(session); - session = 0; - break; - } - - if(object) - { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(IceUtil::random(20))); - switch(IceUtil::random(_destroySession ? 2 : 1)) - { - case 0: - session->releaseObject(object->ice_getIdentity()); - break; - case 1: - assert(!_session); - session->destroy(); - session = 0; - break; - } - } - } + { + Lock sync(*this); + while(!_notified) + { + wait(); + } + } + + SessionPrx session; + while(true) + { + { + Lock sync(*this); + if(_terminated) + { + if(!_session && session) + { + session->destroy(); + } + return; + } + } + + if(!session) + { + ostringstream os; + os << "Client-" << _id; + if(_session) + { + session = _session; + } + else + { + session = _registry->createSession(os.str(), ""); + session->setAllocationTimeout(IceUtil::random(200)); // 200ms timeout + } + } + + assert(session); + session->keepAlive(); + + Ice::ObjectPrx object; + switch(IceUtil::random(_destroySession ? 4 : 2)) + { + case 0: + object = allocate(session); + break; + case 1: + object = allocateByType(session); + break; + case 2: + assert(!_session); + allocateAndDestroy(session); + session = 0; + break; + case 3: + assert(!_session); + allocateByTypeAndDestroy(session); + session = 0; + break; + } + + if(object) + { + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(IceUtil::random(20))); + switch(IceUtil::random(_destroySession ? 2 : 1)) + { + case 0: + session->releaseObject(object->ice_getIdentity()); + break; + case 1: + assert(!_session); + session->destroy(); + session = 0; + break; + } + } + } } Ice::ObjectPrx allocate(const SessionPrx& session) { - ostringstream os; - os << "stress-" << IceUtil::random(6) + 1; - try - { - return session->allocateObjectById(_communicator->stringToIdentity(os.str())); - } - catch(const AllocationTimeoutException&) - { - } - catch(const AllocationException&) - { - // This can only happen if we are using the common session - // and the object is already allocated. - test(_session); - } - return 0; + ostringstream os; + os << "stress-" << IceUtil::random(6) + 1; + try + { + return session->allocateObjectById(_communicator->stringToIdentity(os.str())); + } + catch(const AllocationTimeoutException&) + { + } + catch(const AllocationException&) + { + // This can only happen if we are using the common session + // and the object is already allocated. + test(_session); + } + return 0; } Ice::ObjectPrx allocateByType(const SessionPrx& session) { - try - { - return session->allocateObjectByType("::StressTest"); - } - catch(const AllocationTimeoutException&) - { - } - return 0; + try + { + return session->allocateObjectByType("::StressTest"); + } + catch(const AllocationTimeoutException&) + { + } + return 0; } void allocateAndDestroy(const SessionPrx& session) { - ostringstream os; - os << "stress-" << IceUtil::random(3); - session->allocateObjectById_async(new AllocateObjectByIdCallback(), _communicator->stringToIdentity(os.str())); - session->destroy(); + ostringstream os; + os << "stress-" << IceUtil::random(3); + session->allocateObjectById_async(new AllocateObjectByIdCallback(), _communicator->stringToIdentity(os.str())); + session->destroy(); } void allocateByTypeAndDestroy(const SessionPrx& session) { - session->allocateObjectByType_async(new AllocateObjectByTypeCallback(), "::StressTest"); - session->destroy(); + session->allocateObjectByType_async(new AllocateObjectByTypeCallback(), "::StressTest"); + session->destroy(); } void notifyThread() { - Lock sync(*this); - _notified = true; - notify(); + Lock sync(*this); + _notified = true; + notify(); } void terminate() { - Lock sync(*this); - _terminated = true; - notify(); + Lock sync(*this); + _terminated = true; + notify(); } protected: @@ -290,72 +290,72 @@ class SessionKeepAliveThread : public IceUtil::Thread, public IceUtil::Monitor<I public: SessionKeepAliveThread(const Ice::LoggerPtr& logger, const IceUtil::Time& timeout) : - _logger(logger), - _timeout(timeout), - _terminated(false) + _logger(logger), + _timeout(timeout), + _terminated(false) { } virtual void run() { - Lock sync(*this); - while(!_terminated) - { - timedWait(_timeout); - if(!_terminated) - { - vector<SessionPrx>::iterator p = _sessions.begin(); - while(p != _sessions.end()) - { - try - { - (*p)->keepAlive(); - ++p; - } - catch(const Ice::Exception&) - { - p = _sessions.erase(p); - } - } - - vector<AdminSessionPrx>::iterator q = _adminSessions.begin(); - while(q != _adminSessions.end()) - { - try - { - (*q)->keepAlive(); - ++q; - } - catch(const Ice::Exception&) - { - q = _adminSessions.erase(q); - } - } - } - } + Lock sync(*this); + while(!_terminated) + { + timedWait(_timeout); + if(!_terminated) + { + vector<SessionPrx>::iterator p = _sessions.begin(); + while(p != _sessions.end()) + { + try + { + (*p)->keepAlive(); + ++p; + } + catch(const Ice::Exception&) + { + p = _sessions.erase(p); + } + } + + vector<AdminSessionPrx>::iterator q = _adminSessions.begin(); + while(q != _adminSessions.end()) + { + try + { + (*q)->keepAlive(); + ++q; + } + catch(const Ice::Exception&) + { + q = _adminSessions.erase(q); + } + } + } + } } void add(const SessionPrx& session) { - Lock sync(*this); - _sessions.push_back(session); + Lock sync(*this); + _sessions.push_back(session); } void add(const AdminSessionPrx& session) { - Lock sync(*this); - _adminSessions.push_back(session); + Lock sync(*this); + _adminSessions.push_back(session); } void terminate() { - Lock sync(*this); - _terminated = true; - notify(); + Lock sync(*this); + _terminated = true; + notify(); } private: @@ -372,7 +372,7 @@ void allTests(const Ice::CommunicatorPtr& communicator) { SessionKeepAliveThreadPtr keepAlive = new SessionKeepAliveThread( - communicator->getLogger(), IceUtil::Time::seconds(5)); + communicator->getLogger(), IceUtil::Time::seconds(5)); keepAlive->start(); RegistryPrx registry = IceGrid::RegistryPrx::checkedCast(communicator->stringToProxy("IceGrid/Registry")); @@ -387,12 +387,12 @@ allTests(const Ice::CommunicatorPtr& communicator) cout << "starting router... " << flush; try { - admin->startServer("Glacier2"); + admin->startServer("Glacier2"); } catch(const ServerStartException& ex) { - cerr << ex.reason << endl; - test(false); + cerr << ex.reason << endl; + test(false); } cout << "ok" << endl; @@ -403,756 +403,756 @@ allTests(const Ice::CommunicatorPtr& communicator) try { - cout << "testing create session... " << flush; - SessionPrx session1 = registry->createSession("Client1", ""); - SessionPrx session2 = registry->createSession("Client2", ""); - - keepAlive->add(session1); - keepAlive->add(session2); + cout << "testing create session... " << flush; + SessionPrx session1 = registry->createSession("Client1", ""); + SessionPrx session2 = registry->createSession("Client2", ""); + + keepAlive->add(session1); + keepAlive->add(session2); - cout << "ok" << endl; - - cout << "testing allocate object by identity... " << flush; - - Ice::Identity allocatable = communicator->stringToIdentity("allocatable"); - Ice::Identity allocatablebis = communicator->stringToIdentity("allocatablebis"); - - try - { - session1->allocateObjectById(communicator->stringToIdentity("dummy")); - } - catch(const ObjectNotRegisteredException&) - { - } - try - { - session1->releaseObject(communicator->stringToIdentity("dummy")); - } - catch(const ObjectNotRegisteredException&) - { - } - - try - { - session1->allocateObjectById(communicator->stringToIdentity("nonallocatable")); - test(false); - } - catch(const AllocationException&) - { - test(false); - } - catch(const ObjectNotRegisteredException&) - { - } - - try - { - session2->allocateObjectById(communicator->stringToIdentity("nonallocatable")); - test(false); - } - catch(const AllocationException&) - { - test(false); - } - catch(const ObjectNotRegisteredException&) - { - } - - try - { - session1->releaseObject(communicator->stringToIdentity("nonallocatable")); - test(false); - } - catch(const AllocationException&) - { - test(false); - } - catch(const ObjectNotRegisteredException&) - { - } - - try - { - session2->releaseObject(communicator->stringToIdentity("nonallocatable")); - test(false); - } - catch(const AllocationException&) - { - test(false); - } - catch(const ObjectNotRegisteredException&) - { - } - - session1->allocateObjectById(allocatable); - try - { - session1->allocateObjectById(allocatable); - test(false); - } - catch(const AllocationException&) - { - } - - session1->setAllocationTimeout(0); - session2->setAllocationTimeout(0); - - try - { - session2->allocateObjectById(allocatable); - test(false); - } - catch(const AllocationTimeoutException&) - { - } - try - { - session2->releaseObject(allocatable); - test(false); - } - catch(const AllocationException&) - { - } - - session1->allocateObjectById(allocatablebis); - try - { - session2->allocateObjectById(allocatablebis); - test(false); - } - catch(const AllocationTimeoutException&) - { - } - session1->releaseObject(allocatablebis); - session2->allocateObjectById(allocatablebis); - try - { - session1->allocateObjectById(allocatablebis); - test(false); - } - catch(const AllocationTimeoutException&) - { - } - session2->releaseObject(allocatablebis); + cout << "ok" << endl; + + cout << "testing allocate object by identity... " << flush; + + Ice::Identity allocatable = communicator->stringToIdentity("allocatable"); + Ice::Identity allocatablebis = communicator->stringToIdentity("allocatablebis"); + + try + { + session1->allocateObjectById(communicator->stringToIdentity("dummy")); + } + catch(const ObjectNotRegisteredException&) + { + } + try + { + session1->releaseObject(communicator->stringToIdentity("dummy")); + } + catch(const ObjectNotRegisteredException&) + { + } + + try + { + session1->allocateObjectById(communicator->stringToIdentity("nonallocatable")); + test(false); + } + catch(const AllocationException&) + { + test(false); + } + catch(const ObjectNotRegisteredException&) + { + } + + try + { + session2->allocateObjectById(communicator->stringToIdentity("nonallocatable")); + test(false); + } + catch(const AllocationException&) + { + test(false); + } + catch(const ObjectNotRegisteredException&) + { + } + + try + { + session1->releaseObject(communicator->stringToIdentity("nonallocatable")); + test(false); + } + catch(const AllocationException&) + { + test(false); + } + catch(const ObjectNotRegisteredException&) + { + } + + try + { + session2->releaseObject(communicator->stringToIdentity("nonallocatable")); + test(false); + } + catch(const AllocationException&) + { + test(false); + } + catch(const ObjectNotRegisteredException&) + { + } + + session1->allocateObjectById(allocatable); + try + { + session1->allocateObjectById(allocatable); + test(false); + } + catch(const AllocationException&) + { + } + + session1->setAllocationTimeout(0); + session2->setAllocationTimeout(0); + + try + { + session2->allocateObjectById(allocatable); + test(false); + } + catch(const AllocationTimeoutException&) + { + } + try + { + session2->releaseObject(allocatable); + test(false); + } + catch(const AllocationException&) + { + } + + session1->allocateObjectById(allocatablebis); + try + { + session2->allocateObjectById(allocatablebis); + test(false); + } + catch(const AllocationTimeoutException&) + { + } + session1->releaseObject(allocatablebis); + session2->allocateObjectById(allocatablebis); + try + { + session1->allocateObjectById(allocatablebis); + test(false); + } + catch(const AllocationTimeoutException&) + { + } + session2->releaseObject(allocatablebis); - session2->setAllocationTimeout(allocationTimeout); - AllocateObjectByIdCallbackPtr cb1 = new AllocateObjectByIdCallback(); - session2->allocateObjectById_async(cb1, allocatable); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - test(!cb1->hasResponse(dummy)); - session1->releaseObject(allocatable); - cb1->waitResponse(__FILE__, __LINE__); - test(cb1->hasResponse(dummy)); - - session1->setAllocationTimeout(0); - try - { - session1->allocateObjectById(allocatable); - test(false); - } - catch(const AllocationTimeoutException&) - { - } - try - { - session1->releaseObject(allocatable); - test(false); - } - catch(const AllocationException&) - { - } - session1->setAllocationTimeout(allocationTimeout); - cb1 = new AllocateObjectByIdCallback(); - session1->allocateObjectById_async(cb1, allocatable); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - test(!cb1->hasResponse(dummy)); - session2->releaseObject(allocatable); - cb1->waitResponse(__FILE__, __LINE__); - test(cb1->hasResponse(dummy)); - - session1->releaseObject(allocatable); - - cout << "ok" << endl; - - cout << "testing allocate object by type... " << flush; + session2->setAllocationTimeout(allocationTimeout); + AllocateObjectByIdCallbackPtr cb1 = new AllocateObjectByIdCallback(); + session2->allocateObjectById_async(cb1, allocatable); + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + test(!cb1->hasResponse(dummy)); + session1->releaseObject(allocatable); + cb1->waitResponse(__FILE__, __LINE__); + test(cb1->hasResponse(dummy)); + + session1->setAllocationTimeout(0); + try + { + session1->allocateObjectById(allocatable); + test(false); + } + catch(const AllocationTimeoutException&) + { + } + try + { + session1->releaseObject(allocatable); + test(false); + } + catch(const AllocationException&) + { + } + session1->setAllocationTimeout(allocationTimeout); + cb1 = new AllocateObjectByIdCallback(); + session1->allocateObjectById_async(cb1, allocatable); + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + test(!cb1->hasResponse(dummy)); + session2->releaseObject(allocatable); + cb1->waitResponse(__FILE__, __LINE__); + test(cb1->hasResponse(dummy)); + + session1->releaseObject(allocatable); + + cout << "ok" << endl; + + cout << "testing allocate object by type... " << flush; - session1->setAllocationTimeout(0); - session2->setAllocationTimeout(0); - - - try - { - obj = session1->allocateObjectByType("::Unknown"); - test(false); - } - catch(const AllocationTimeoutException&) - { - test(false); - } - catch(const AllocationException&) - { - } - - try - { - obj = session1->allocateObjectByType("::NotAllocatable"); - test(false); - } - catch(const AllocationTimeoutException&) - { - test(false); - } - catch(const AllocationException&) - { - } - - obj = session1->allocateObjectByType("::Test"); - test(obj && obj->ice_getIdentity().name == "allocatable"); - try - { - session1->allocateObjectByType("::Test"); - test(false); - } - catch(const AllocationException&) - { - } - try - { - session2->allocateObjectByType("::Test"); - test(false); - } - catch(const AllocationTimeoutException&) - { - } - try - { - session2->releaseObject(obj->ice_getIdentity()); - } - catch(const AllocationException&) - { - } - - session1->releaseObject(obj->ice_getIdentity()); - try - { - session1->releaseObject(obj->ice_getIdentity()); - } - catch(const AllocationException&) - { - } - - obj = session2->allocateObjectByType("::Test"); // Allocate the object - test(obj && obj->ice_getIdentity().name == "allocatable"); - try - { - session2->allocateObjectByType("::Test"); - test(false); - } - catch(const AllocationException&) - { - } - try - { - session1->allocateObjectByType("::Test"); - test(false); - } - catch(const AllocationTimeoutException&) - { - } - session1->allocateObjectByType("::TestBis"); - try - { - session2->allocateObjectByType("::TestBis"); - test(false); - } - catch(const AllocationTimeoutException&) - { - } - session1->releaseObject(allocatablebis); - session2->allocateObjectByType("::TestBis"); - try - { - session1->allocateObjectByType("::TestBis"); - test(false); - } - catch(const AllocationTimeoutException&) - { - } - session2->releaseObject(allocatablebis); - - session1->setAllocationTimeout(allocationTimeout); - AllocateObjectByTypeCallbackPtr cb3 = new AllocateObjectByTypeCallback(); - session1->allocateObjectByType_async(cb3, "::Test"); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - test(!cb3->hasResponse(dummy)); - session2->releaseObject(obj->ice_getIdentity()); - cb3->waitResponse(__FILE__, __LINE__); - test(cb3->hasResponse(obj)); - - session1->releaseObject(obj->ice_getIdentity()); + session1->setAllocationTimeout(0); + session2->setAllocationTimeout(0); + + + try + { + obj = session1->allocateObjectByType("::Unknown"); + test(false); + } + catch(const AllocationTimeoutException&) + { + test(false); + } + catch(const AllocationException&) + { + } + + try + { + obj = session1->allocateObjectByType("::NotAllocatable"); + test(false); + } + catch(const AllocationTimeoutException&) + { + test(false); + } + catch(const AllocationException&) + { + } + + obj = session1->allocateObjectByType("::Test"); + test(obj && obj->ice_getIdentity().name == "allocatable"); + try + { + session1->allocateObjectByType("::Test"); + test(false); + } + catch(const AllocationException&) + { + } + try + { + session2->allocateObjectByType("::Test"); + test(false); + } + catch(const AllocationTimeoutException&) + { + } + try + { + session2->releaseObject(obj->ice_getIdentity()); + } + catch(const AllocationException&) + { + } + + session1->releaseObject(obj->ice_getIdentity()); + try + { + session1->releaseObject(obj->ice_getIdentity()); + } + catch(const AllocationException&) + { + } + + obj = session2->allocateObjectByType("::Test"); // Allocate the object + test(obj && obj->ice_getIdentity().name == "allocatable"); + try + { + session2->allocateObjectByType("::Test"); + test(false); + } + catch(const AllocationException&) + { + } + try + { + session1->allocateObjectByType("::Test"); + test(false); + } + catch(const AllocationTimeoutException&) + { + } + session1->allocateObjectByType("::TestBis"); + try + { + session2->allocateObjectByType("::TestBis"); + test(false); + } + catch(const AllocationTimeoutException&) + { + } + session1->releaseObject(allocatablebis); + session2->allocateObjectByType("::TestBis"); + try + { + session1->allocateObjectByType("::TestBis"); + test(false); + } + catch(const AllocationTimeoutException&) + { + } + session2->releaseObject(allocatablebis); + + session1->setAllocationTimeout(allocationTimeout); + AllocateObjectByTypeCallbackPtr cb3 = new AllocateObjectByTypeCallback(); + session1->allocateObjectByType_async(cb3, "::Test"); + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + test(!cb3->hasResponse(dummy)); + session2->releaseObject(obj->ice_getIdentity()); + cb3->waitResponse(__FILE__, __LINE__); + test(cb3->hasResponse(obj)); + + session1->releaseObject(obj->ice_getIdentity()); - cout << "ok" << endl; - - cout << "testing object allocation timeout... " << flush; - - session1->allocateObjectById(allocatable); - IceUtil::Time time = IceUtil::Time::now(); - session2->setAllocationTimeout(500); - try - { - session2->allocateObjectById(allocatable); - test(false); - } - catch(const AllocationTimeoutException&) - { - test(time + IceUtil::Time::milliSeconds(100) < IceUtil::Time::now()); - } - time = IceUtil::Time::now(); - try - { - session2->allocateObjectById(allocatable); - test(false); - } - catch(const AllocationTimeoutException&) - { - } - test(time + IceUtil::Time::milliSeconds(100) < IceUtil::Time::now()); - time = IceUtil::Time::now(); - try - { - session2->allocateObjectByType("::Test"); - test(false); - } - catch(const AllocationTimeoutException&) - { - } - test(time + IceUtil::Time::milliSeconds(100) < IceUtil::Time::now()); - - session1->releaseObject(allocatable); - session2->setAllocationTimeout(0); - - cout << "ok" << endl; - - cout << "testing server allocation... " << flush; - - session1->setAllocationTimeout(0); - session2->setAllocationTimeout(0); - - Ice::Identity allocatable3 = communicator->stringToIdentity("allocatable3"); - Ice::Identity allocatable4 = communicator->stringToIdentity("allocatable4"); - - session1->allocateObjectById(allocatable3); - try - { - session2->allocateObjectById(allocatable3); - test(false); - } - catch(const AllocationTimeoutException&) - { - } - try - { - session2->allocateObjectById(allocatable4); - test(false); - } - catch(const AllocationTimeoutException&) - { - } - - session1->allocateObjectById(allocatable4); - session1->releaseObject(allocatable3); - try - { - session2->allocateObjectById(allocatable3); - test(false); - } - catch(const AllocationTimeoutException&) - { - } - session1->releaseObject(allocatable4); - session2->allocateObjectById(allocatable3); - try - { - session1->allocateObjectById(allocatable3); - test(false); - } - catch(const AllocationTimeoutException&) - { - } - try - { - session1->allocateObjectById(allocatable4); - test(false); - } - catch(const AllocationTimeoutException&) - { - } - session2->allocateObjectById(allocatable4); - session2->releaseObject(allocatable3); - try - { - session1->allocateObjectById(allocatable3); - test(false); - } - catch(const AllocationTimeoutException&) - { - } - try - { - session1->allocateObjectByType("::TestServer1"); - test(false); - } - catch(AllocationException&) - { - } - try - { - session1->allocateObjectByType("::TestServer2"); - test(false); - } - catch(AllocationException&) - { - } - test(session2->allocateObjectByType("::TestServer1")); - try - { - session2->allocateObjectByType("::TestServer1"); - test(false); - } - catch(AllocationException&) - { - } - try - { - session2->allocateObjectByType("::TestServer2"); - test(false); - } - catch(AllocationException&) - { - } - session2->releaseObject(allocatable3); - session2->releaseObject(allocatable4); - - session1->allocateObjectById(allocatable3); - session1->allocateObjectById(allocatable4); - - session2->setAllocationTimeout(allocationTimeout); - cb1 = new AllocateObjectByIdCallback(); - session2->allocateObjectById_async(cb1, allocatable3); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - test(!cb1->hasResponse(dummy)); - session1->releaseObject(allocatable3); - test(!cb1->hasResponse(dummy)); - session1->releaseObject(allocatable4); - cb1->waitResponse(__FILE__, __LINE__); - test(cb1->hasResponse(dummy)); - session2->releaseObject(allocatable3); - - session1->setAllocationTimeout(allocationTimeout); - test(session2->allocateObjectByType("::TestServer1")); - cb3 = new AllocateObjectByTypeCallback(); - session1->allocateObjectByType_async(cb3, "::TestServer2"); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - test(!cb3->hasResponse(dummy)); - session2->releaseObject(allocatable3); - cb3->waitResponse(__FILE__, __LINE__); - test(cb3->hasResponse(dummy)); - session1->releaseObject(allocatable4); - - session1->setAllocationTimeout(0); - session2->setAllocationTimeout(0); - test(session1->allocateObjectByType("::TestMultipleByServer")); - try - { - session2->allocateObjectByType("::TestMultipleByServer"); - test(false); - } - catch(AllocationException&) - { - } - test(session1->allocateObjectByType("::TestMultipleByServer")); - session1->releaseObject(communicator->stringToIdentity("allocatable31")); - session1->releaseObject(communicator->stringToIdentity("allocatable41")); - test(session2->allocateObjectByType("::TestMultipleByServer")); - try - { - session1->allocateObjectByType("::TestMultipleByServer"); - test(false); - } - catch(AllocationException&) - { - } - test(session2->allocateObjectByType("::TestMultipleByServer")); - session2->releaseObject(communicator->stringToIdentity("allocatable31")); - session2->releaseObject(communicator->stringToIdentity("allocatable41")); - - Ice::ObjectPrx obj1 = session1->allocateObjectByType("::TestMultipleServer"); - test(obj1); - Ice::ObjectPrx obj2 = session2->allocateObjectByType("::TestMultipleServer"); - test(obj2); - try - { - session1->allocateObjectByType("::TestMultipleServer"); - test(false); - } - catch(AllocationTimeoutException&) - { - } - try - { - session2->allocateObjectByType("::TestMultipleServer"); - test(false); - } - catch(AllocationTimeoutException&) - { - } - session1->releaseObject(obj1->ice_getIdentity()); - obj1 = session2->allocateObjectByType("::TestMultipleServer"); - session2->releaseObject(obj1->ice_getIdentity()); - session2->releaseObject(obj2->ice_getIdentity()); - - cout << "ok" << endl; - - cout << "testing concurrent allocations... " << flush; - - session1->setAllocationTimeout(allocationTimeout); - session2->setAllocationTimeout(allocationTimeout); - - session2->allocateObjectById(allocatable); - AllocateObjectByIdCallbackPtr cb11 = new AllocateObjectByIdCallback(); - AllocateObjectByIdCallbackPtr cb12 = new AllocateObjectByIdCallback(); - session1->allocateObjectById_async(cb11, allocatable); - session1->allocateObjectById_async(cb12, allocatable); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - test(!cb11->hasResponse(dummy)); - test(!cb12->hasResponse(dummy)); - session2->releaseObject(allocatable); - cb11->waitResponse(__FILE__, __LINE__); - cb12->waitResponse(__FILE__, __LINE__); - test(cb11->hasResponse(dummy) ? cb12->hasException() : cb12->hasResponse(dummy)); - test(cb12->hasResponse(dummy) ? cb11->hasException() : cb11->hasResponse(dummy)); - session1->releaseObject(allocatable); - - session2->allocateObjectById(allocatable); - AllocateObjectByTypeCallbackPtr cb31 = new AllocateObjectByTypeCallback(); - AllocateObjectByTypeCallbackPtr cb32 = new AllocateObjectByTypeCallback(); - session1->allocateObjectByType_async(cb31, "::Test"); - session1->allocateObjectByType_async(cb32, "::Test"); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - test(!cb31->hasResponse(dummy)); - test(!cb32->hasResponse(dummy)); - session2->releaseObject(allocatable); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(300)); - do - { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(200)); - } - while(!cb31->hasResponse(dummy) && !cb32->hasResponse(dummy)); - test(cb31->hasResponse(dummy) && dummy && !cb32->hasResponse(dummy) || - cb32->hasResponse(dummy) && dummy && !cb31->hasResponse(dummy)); - session1->releaseObject(allocatable); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(300)); - AllocateObjectByTypeCallbackPtr cb33 = cb31->hasResponse(dummy) ? cb32 : cb31; - cb33->waitResponse(__FILE__, __LINE__); - test(cb33->hasResponse(dummy) && dummy); - session1->releaseObject(allocatable); - - session2->allocateObjectById(allocatable3); - cb11 = new AllocateObjectByIdCallback(); - cb12 = new AllocateObjectByIdCallback(); - session1->allocateObjectById_async(cb11, allocatable3); - session1->allocateObjectById_async(cb12, allocatable3); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - test(!cb11->hasResponse(dummy)); - test(!cb12->hasResponse(dummy)); - session2->releaseObject(allocatable3); - cb11->waitResponse(__FILE__, __LINE__); - cb12->waitResponse(__FILE__, __LINE__); - test(cb11->hasResponse(dummy) ? cb12->hasException() : cb12->hasResponse(dummy)); - test(cb12->hasResponse(dummy) ? cb11->hasException() : cb11->hasResponse(dummy)); - session1->releaseObject(allocatable3); - - session2->allocateObjectById(allocatable3); - cb31 = new AllocateObjectByTypeCallback(); - cb32 = new AllocateObjectByTypeCallback(); - session1->allocateObjectByType_async(cb31, "::TestServer1"); - session1->allocateObjectByType_async(cb32, "::TestServer1"); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - test(!cb31->hasResponse(dummy)); - test(!cb32->hasResponse(dummy)); - session2->releaseObject(allocatable3); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(300)); - do - { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(200)); - } - while(!cb31->hasResponse(dummy) && !cb32->hasResponse(dummy)); - test(cb31->hasResponse(dummy) && dummy && !cb32->hasResponse(dummy) || - cb32->hasResponse(dummy) && dummy && !cb31->hasResponse(dummy)); - session1->releaseObject(allocatable3); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(300)); - cb33 = cb31->hasResponse(dummy) ? cb32 : cb31; - cb33->waitResponse(__FILE__, __LINE__); - test(cb33->hasResponse(dummy) && dummy); - session1->releaseObject(allocatable3); - - session1->allocateObjectById(allocatable3); - cb31 = new AllocateObjectByTypeCallback(); - cb32 = new AllocateObjectByTypeCallback(); - session1->allocateObjectByType_async(cb31, "::TestServer1"); - session1->allocateObjectByType_async(cb32, "::TestServer1"); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - test(!cb31->hasResponse(dummy)); - test(!cb32->hasResponse(dummy)); - session1->releaseObject(allocatable3); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(300)); - do - { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(200)); - } - while(!cb31->hasResponse(dummy) && !cb32->hasResponse(dummy)); - test(cb31->hasResponse(dummy) && dummy && !cb32->hasResponse(dummy) || - cb32->hasResponse(dummy) && dummy && !cb31->hasResponse(dummy)); - session1->releaseObject(allocatable3); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(300)); - cb33 = cb31->hasResponse(dummy) ? cb32 : cb31; - cb33->waitResponse(__FILE__, __LINE__); - test(cb33->hasResponse(dummy) && dummy); - session1->releaseObject(allocatable3); - - cout << "ok" << endl; - - cout << "testing session destroy... " << flush; - - obj = session2->allocateObjectByType("::Test"); // Allocate the object - test(obj && obj->ice_getIdentity().name == "allocatable"); - - session1->setAllocationTimeout(allocationTimeout); - cb3 = new AllocateObjectByTypeCallback(); - session1->allocateObjectByType_async(cb3, "::Test"); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - test(!cb3->hasResponse(dummy)); - session2->destroy(); - cb3->waitResponse(__FILE__, __LINE__); - test(cb3->hasResponse(obj)); - session1->destroy(); - - session2 = SessionPrx::uncheckedCast(registry->createSession("Client2", "")); - session2->setAllocationTimeout(0); - session2->allocateObjectById(allocatable); - session2->destroy(); - - cout << "ok" << endl; - - cout << "testing allocation with Glacier2 session... " << flush; - Ice::ObjectPrx routerBase = communicator->stringToProxy("Glacier2/router:default -p 12347"); - Glacier2::RouterPrx router1 = Glacier2::RouterPrx::checkedCast(routerBase->ice_connectionId("client1")); - test(router1); - - Glacier2::SessionPrx sessionBase = router1->createSession("test1", "abc123"); - try - { - session1 = IceGrid::SessionPrx::checkedCast(sessionBase->ice_connectionId("client1")->ice_router(router1)); - test(session1); - session1->ice_ping(); - - Ice::ObjectPrx obj; - obj = session1->allocateObjectById(allocatable)->ice_connectionId("client1")->ice_router(router1); - obj->ice_ping(); - session1->releaseObject(allocatable); - try - { - obj->ice_ping(); - } - catch(const Ice::ObjectNotExistException&) - { - } - - obj = session1->allocateObjectById(allocatable3)->ice_connectionId("client1")->ice_router(router1); - obj->ice_ping(); - obj2 = communicator->stringToProxy("allocatable4")->ice_connectionId("client1")->ice_router(router1); - obj2->ice_ping(); - session1->releaseObject(allocatable3); - try - { - obj->ice_ping(); - } - catch(const Ice::ObjectNotExistException&) - { - } - try - { - obj2->ice_ping(); - } - catch(const Ice::ObjectNotExistException&) - { - } - session1->destroy(); - } - catch(const Ice::LocalException& ex) - { - cerr << ex << endl; - test(false); - } - cout << "ok" << endl; - - cout << "stress test... " << flush; - - SessionPrx stressSession = registry->createSession("StressSession", ""); - keepAlive->add(stressSession); - - const int nClients = 10; - int i; - vector<StressClientPtr> clients; - for(i = 0; i < nClients - 2; ++i) - { - if(IceUtil::random(2) == 1) - { - clients.push_back(new StressClient(i, registry, false)); - } - else - { - clients.push_back(new StressClient(i, stressSession)); - } - clients.back()->start(); - } - clients.push_back(new StressClient(i++, registry, true)); - clients.back()->start(); - clients.push_back(new StressClient(i++, registry, true)); - clients.back()->start(); - - for(vector<StressClientPtr>::const_iterator p = clients.begin(); p != clients.end(); ++p) - { - (*p)->notifyThread(); - } - - // - // Let the stress client run for a bit. - // - IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(8)); - - // - // Terminate the stress clients. - // - for(vector<StressClientPtr>::const_iterator q = clients.begin(); q != clients.end(); ++q) - { - (*q)->terminate(); - (*q)->getThreadControl().join(); - } - - stressSession->destroy(); - - cout << "ok" << endl; + cout << "ok" << endl; + + cout << "testing object allocation timeout... " << flush; + + session1->allocateObjectById(allocatable); + IceUtil::Time time = IceUtil::Time::now(); + session2->setAllocationTimeout(500); + try + { + session2->allocateObjectById(allocatable); + test(false); + } + catch(const AllocationTimeoutException&) + { + test(time + IceUtil::Time::milliSeconds(100) < IceUtil::Time::now()); + } + time = IceUtil::Time::now(); + try + { + session2->allocateObjectById(allocatable); + test(false); + } + catch(const AllocationTimeoutException&) + { + } + test(time + IceUtil::Time::milliSeconds(100) < IceUtil::Time::now()); + time = IceUtil::Time::now(); + try + { + session2->allocateObjectByType("::Test"); + test(false); + } + catch(const AllocationTimeoutException&) + { + } + test(time + IceUtil::Time::milliSeconds(100) < IceUtil::Time::now()); + + session1->releaseObject(allocatable); + session2->setAllocationTimeout(0); + + cout << "ok" << endl; + + cout << "testing server allocation... " << flush; + + session1->setAllocationTimeout(0); + session2->setAllocationTimeout(0); + + Ice::Identity allocatable3 = communicator->stringToIdentity("allocatable3"); + Ice::Identity allocatable4 = communicator->stringToIdentity("allocatable4"); + + session1->allocateObjectById(allocatable3); + try + { + session2->allocateObjectById(allocatable3); + test(false); + } + catch(const AllocationTimeoutException&) + { + } + try + { + session2->allocateObjectById(allocatable4); + test(false); + } + catch(const AllocationTimeoutException&) + { + } + + session1->allocateObjectById(allocatable4); + session1->releaseObject(allocatable3); + try + { + session2->allocateObjectById(allocatable3); + test(false); + } + catch(const AllocationTimeoutException&) + { + } + session1->releaseObject(allocatable4); + session2->allocateObjectById(allocatable3); + try + { + session1->allocateObjectById(allocatable3); + test(false); + } + catch(const AllocationTimeoutException&) + { + } + try + { + session1->allocateObjectById(allocatable4); + test(false); + } + catch(const AllocationTimeoutException&) + { + } + session2->allocateObjectById(allocatable4); + session2->releaseObject(allocatable3); + try + { + session1->allocateObjectById(allocatable3); + test(false); + } + catch(const AllocationTimeoutException&) + { + } + try + { + session1->allocateObjectByType("::TestServer1"); + test(false); + } + catch(AllocationException&) + { + } + try + { + session1->allocateObjectByType("::TestServer2"); + test(false); + } + catch(AllocationException&) + { + } + test(session2->allocateObjectByType("::TestServer1")); + try + { + session2->allocateObjectByType("::TestServer1"); + test(false); + } + catch(AllocationException&) + { + } + try + { + session2->allocateObjectByType("::TestServer2"); + test(false); + } + catch(AllocationException&) + { + } + session2->releaseObject(allocatable3); + session2->releaseObject(allocatable4); + + session1->allocateObjectById(allocatable3); + session1->allocateObjectById(allocatable4); + + session2->setAllocationTimeout(allocationTimeout); + cb1 = new AllocateObjectByIdCallback(); + session2->allocateObjectById_async(cb1, allocatable3); + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + test(!cb1->hasResponse(dummy)); + session1->releaseObject(allocatable3); + test(!cb1->hasResponse(dummy)); + session1->releaseObject(allocatable4); + cb1->waitResponse(__FILE__, __LINE__); + test(cb1->hasResponse(dummy)); + session2->releaseObject(allocatable3); + + session1->setAllocationTimeout(allocationTimeout); + test(session2->allocateObjectByType("::TestServer1")); + cb3 = new AllocateObjectByTypeCallback(); + session1->allocateObjectByType_async(cb3, "::TestServer2"); + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + test(!cb3->hasResponse(dummy)); + session2->releaseObject(allocatable3); + cb3->waitResponse(__FILE__, __LINE__); + test(cb3->hasResponse(dummy)); + session1->releaseObject(allocatable4); + + session1->setAllocationTimeout(0); + session2->setAllocationTimeout(0); + test(session1->allocateObjectByType("::TestMultipleByServer")); + try + { + session2->allocateObjectByType("::TestMultipleByServer"); + test(false); + } + catch(AllocationException&) + { + } + test(session1->allocateObjectByType("::TestMultipleByServer")); + session1->releaseObject(communicator->stringToIdentity("allocatable31")); + session1->releaseObject(communicator->stringToIdentity("allocatable41")); + test(session2->allocateObjectByType("::TestMultipleByServer")); + try + { + session1->allocateObjectByType("::TestMultipleByServer"); + test(false); + } + catch(AllocationException&) + { + } + test(session2->allocateObjectByType("::TestMultipleByServer")); + session2->releaseObject(communicator->stringToIdentity("allocatable31")); + session2->releaseObject(communicator->stringToIdentity("allocatable41")); + + Ice::ObjectPrx obj1 = session1->allocateObjectByType("::TestMultipleServer"); + test(obj1); + Ice::ObjectPrx obj2 = session2->allocateObjectByType("::TestMultipleServer"); + test(obj2); + try + { + session1->allocateObjectByType("::TestMultipleServer"); + test(false); + } + catch(AllocationTimeoutException&) + { + } + try + { + session2->allocateObjectByType("::TestMultipleServer"); + test(false); + } + catch(AllocationTimeoutException&) + { + } + session1->releaseObject(obj1->ice_getIdentity()); + obj1 = session2->allocateObjectByType("::TestMultipleServer"); + session2->releaseObject(obj1->ice_getIdentity()); + session2->releaseObject(obj2->ice_getIdentity()); + + cout << "ok" << endl; + + cout << "testing concurrent allocations... " << flush; + + session1->setAllocationTimeout(allocationTimeout); + session2->setAllocationTimeout(allocationTimeout); + + session2->allocateObjectById(allocatable); + AllocateObjectByIdCallbackPtr cb11 = new AllocateObjectByIdCallback(); + AllocateObjectByIdCallbackPtr cb12 = new AllocateObjectByIdCallback(); + session1->allocateObjectById_async(cb11, allocatable); + session1->allocateObjectById_async(cb12, allocatable); + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + test(!cb11->hasResponse(dummy)); + test(!cb12->hasResponse(dummy)); + session2->releaseObject(allocatable); + cb11->waitResponse(__FILE__, __LINE__); + cb12->waitResponse(__FILE__, __LINE__); + test(cb11->hasResponse(dummy) ? cb12->hasException() : cb12->hasResponse(dummy)); + test(cb12->hasResponse(dummy) ? cb11->hasException() : cb11->hasResponse(dummy)); + session1->releaseObject(allocatable); + + session2->allocateObjectById(allocatable); + AllocateObjectByTypeCallbackPtr cb31 = new AllocateObjectByTypeCallback(); + AllocateObjectByTypeCallbackPtr cb32 = new AllocateObjectByTypeCallback(); + session1->allocateObjectByType_async(cb31, "::Test"); + session1->allocateObjectByType_async(cb32, "::Test"); + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + test(!cb31->hasResponse(dummy)); + test(!cb32->hasResponse(dummy)); + session2->releaseObject(allocatable); + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(300)); + do + { + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(200)); + } + while(!cb31->hasResponse(dummy) && !cb32->hasResponse(dummy)); + test(cb31->hasResponse(dummy) && dummy && !cb32->hasResponse(dummy) || + cb32->hasResponse(dummy) && dummy && !cb31->hasResponse(dummy)); + session1->releaseObject(allocatable); + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(300)); + AllocateObjectByTypeCallbackPtr cb33 = cb31->hasResponse(dummy) ? cb32 : cb31; + cb33->waitResponse(__FILE__, __LINE__); + test(cb33->hasResponse(dummy) && dummy); + session1->releaseObject(allocatable); + + session2->allocateObjectById(allocatable3); + cb11 = new AllocateObjectByIdCallback(); + cb12 = new AllocateObjectByIdCallback(); + session1->allocateObjectById_async(cb11, allocatable3); + session1->allocateObjectById_async(cb12, allocatable3); + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + test(!cb11->hasResponse(dummy)); + test(!cb12->hasResponse(dummy)); + session2->releaseObject(allocatable3); + cb11->waitResponse(__FILE__, __LINE__); + cb12->waitResponse(__FILE__, __LINE__); + test(cb11->hasResponse(dummy) ? cb12->hasException() : cb12->hasResponse(dummy)); + test(cb12->hasResponse(dummy) ? cb11->hasException() : cb11->hasResponse(dummy)); + session1->releaseObject(allocatable3); + + session2->allocateObjectById(allocatable3); + cb31 = new AllocateObjectByTypeCallback(); + cb32 = new AllocateObjectByTypeCallback(); + session1->allocateObjectByType_async(cb31, "::TestServer1"); + session1->allocateObjectByType_async(cb32, "::TestServer1"); + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + test(!cb31->hasResponse(dummy)); + test(!cb32->hasResponse(dummy)); + session2->releaseObject(allocatable3); + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(300)); + do + { + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(200)); + } + while(!cb31->hasResponse(dummy) && !cb32->hasResponse(dummy)); + test(cb31->hasResponse(dummy) && dummy && !cb32->hasResponse(dummy) || + cb32->hasResponse(dummy) && dummy && !cb31->hasResponse(dummy)); + session1->releaseObject(allocatable3); + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(300)); + cb33 = cb31->hasResponse(dummy) ? cb32 : cb31; + cb33->waitResponse(__FILE__, __LINE__); + test(cb33->hasResponse(dummy) && dummy); + session1->releaseObject(allocatable3); + + session1->allocateObjectById(allocatable3); + cb31 = new AllocateObjectByTypeCallback(); + cb32 = new AllocateObjectByTypeCallback(); + session1->allocateObjectByType_async(cb31, "::TestServer1"); + session1->allocateObjectByType_async(cb32, "::TestServer1"); + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + test(!cb31->hasResponse(dummy)); + test(!cb32->hasResponse(dummy)); + session1->releaseObject(allocatable3); + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(300)); + do + { + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(200)); + } + while(!cb31->hasResponse(dummy) && !cb32->hasResponse(dummy)); + test(cb31->hasResponse(dummy) && dummy && !cb32->hasResponse(dummy) || + cb32->hasResponse(dummy) && dummy && !cb31->hasResponse(dummy)); + session1->releaseObject(allocatable3); + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(300)); + cb33 = cb31->hasResponse(dummy) ? cb32 : cb31; + cb33->waitResponse(__FILE__, __LINE__); + test(cb33->hasResponse(dummy) && dummy); + session1->releaseObject(allocatable3); + + cout << "ok" << endl; + + cout << "testing session destroy... " << flush; + + obj = session2->allocateObjectByType("::Test"); // Allocate the object + test(obj && obj->ice_getIdentity().name == "allocatable"); + + session1->setAllocationTimeout(allocationTimeout); + cb3 = new AllocateObjectByTypeCallback(); + session1->allocateObjectByType_async(cb3, "::Test"); + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + test(!cb3->hasResponse(dummy)); + session2->destroy(); + cb3->waitResponse(__FILE__, __LINE__); + test(cb3->hasResponse(obj)); + session1->destroy(); + + session2 = SessionPrx::uncheckedCast(registry->createSession("Client2", "")); + session2->setAllocationTimeout(0); + session2->allocateObjectById(allocatable); + session2->destroy(); + + cout << "ok" << endl; + + cout << "testing allocation with Glacier2 session... " << flush; + Ice::ObjectPrx routerBase = communicator->stringToProxy("Glacier2/router:default -p 12347"); + Glacier2::RouterPrx router1 = Glacier2::RouterPrx::checkedCast(routerBase->ice_connectionId("client1")); + test(router1); + + Glacier2::SessionPrx sessionBase = router1->createSession("test1", "abc123"); + try + { + session1 = IceGrid::SessionPrx::checkedCast(sessionBase->ice_connectionId("client1")->ice_router(router1)); + test(session1); + session1->ice_ping(); + + Ice::ObjectPrx obj; + obj = session1->allocateObjectById(allocatable)->ice_connectionId("client1")->ice_router(router1); + obj->ice_ping(); + session1->releaseObject(allocatable); + try + { + obj->ice_ping(); + } + catch(const Ice::ObjectNotExistException&) + { + } + + obj = session1->allocateObjectById(allocatable3)->ice_connectionId("client1")->ice_router(router1); + obj->ice_ping(); + obj2 = communicator->stringToProxy("allocatable4")->ice_connectionId("client1")->ice_router(router1); + obj2->ice_ping(); + session1->releaseObject(allocatable3); + try + { + obj->ice_ping(); + } + catch(const Ice::ObjectNotExistException&) + { + } + try + { + obj2->ice_ping(); + } + catch(const Ice::ObjectNotExistException&) + { + } + session1->destroy(); + } + catch(const Ice::LocalException& ex) + { + cerr << ex << endl; + test(false); + } + cout << "ok" << endl; + + cout << "stress test... " << flush; + + SessionPrx stressSession = registry->createSession("StressSession", ""); + keepAlive->add(stressSession); + + const int nClients = 10; + int i; + vector<StressClientPtr> clients; + for(i = 0; i < nClients - 2; ++i) + { + if(IceUtil::random(2) == 1) + { + clients.push_back(new StressClient(i, registry, false)); + } + else + { + clients.push_back(new StressClient(i, stressSession)); + } + clients.back()->start(); + } + clients.push_back(new StressClient(i++, registry, true)); + clients.back()->start(); + clients.push_back(new StressClient(i++, registry, true)); + clients.back()->start(); + + for(vector<StressClientPtr>::const_iterator p = clients.begin(); p != clients.end(); ++p) + { + (*p)->notifyThread(); + } + + // + // Let the stress client run for a bit. + // + IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(8)); + + // + // Terminate the stress clients. + // + for(vector<StressClientPtr>::const_iterator q = clients.begin(); q != clients.end(); ++q) + { + (*q)->terminate(); + (*q)->getThreadControl().join(); + } + + stressSession->destroy(); + + cout << "ok" << endl; } catch(const AllocationTimeoutException& ex) { - cerr << ex << endl; - test(false); + cerr << ex << endl; + test(false); } catch(const AllocationException& ex) { - cerr << ex.reason << endl; - test(false); + cerr << ex.reason << endl; + test(false); } cout << "shutting down router... " << flush; diff --git a/cpp/test/IceGrid/allocation/Client.cpp b/cpp/test/IceGrid/allocation/Client.cpp index 47f910e24da..940ae6bec73 100644 --- a/cpp/test/IceGrid/allocation/Client.cpp +++ b/cpp/test/IceGrid/allocation/Client.cpp @@ -27,28 +27,28 @@ main(int argc, char* argv[]) int status; Ice::CommunicatorPtr communicator; try - { - communicator = Ice::initialize(argc, argv); - communicator->getProperties()->parseCommandLineOptions("", Ice::argsToStringSeq(argc, argv)); - status = run(argc, argv, communicator); + { + communicator = Ice::initialize(argc, argv); + communicator->getProperties()->parseCommandLineOptions("", Ice::argsToStringSeq(argc, argv)); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/IceGrid/allocation/PermissionsVerifier.cpp b/cpp/test/IceGrid/allocation/PermissionsVerifier.cpp index d5d8bbd5d0b..37e46baa4e9 100644 --- a/cpp/test/IceGrid/allocation/PermissionsVerifier.cpp +++ b/cpp/test/IceGrid/allocation/PermissionsVerifier.cpp @@ -19,7 +19,7 @@ public: virtual bool checkPermissions(const string& userId, const string& passwd, string&, const Ice::Current& c) const { - return true; + return true; } }; @@ -29,11 +29,11 @@ public: virtual int run(int, char*[]) { - Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("PermissionsVerifier"); - adapter->add(new PermissionsVerifierI, communicator()->stringToIdentity("PermissionsVerifier")); - adapter->activate(); - communicator()->waitForShutdown(); - return EXIT_SUCCESS; + Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("PermissionsVerifier"); + adapter->add(new PermissionsVerifierI, communicator()->stringToIdentity("PermissionsVerifier")); + adapter->activate(); + communicator()->waitForShutdown(); + return EXIT_SUCCESS; } }; diff --git a/cpp/test/IceGrid/deployer/AllTests.cpp b/cpp/test/IceGrid/deployer/AllTests.cpp index ca0c77d6e78..5a87f264d18 100644 --- a/cpp/test/IceGrid/deployer/AllTests.cpp +++ b/cpp/test/IceGrid/deployer/AllTests.cpp @@ -71,7 +71,7 @@ public: bool operator()(const Ice::ObjectPrx& p1, const string& id) const { - return p1->ice_getIdentity() == _communicator->stringToIdentity(id); + return p1->ice_getIdentity() == _communicator->stringToIdentity(id); } private: @@ -84,7 +84,7 @@ class SessionKeepAliveThread : public IceUtil::Thread, public IceUtil::Monitor<I public: SessionKeepAliveThread(const IceGrid::AdminSessionPrx& session, long timeout) : - _session(session), + _session(session), _timeout(IceUtil::Time::seconds(timeout)), _destroy(false) { @@ -99,15 +99,15 @@ public: timedWait(_timeout); if(_destroy) { - break; - } + break; + } try { _session->keepAlive(); } catch(const Ice::Exception&) { - break; + break; } } } @@ -180,37 +180,37 @@ allTests(const Ice::CommunicatorPtr& comm) test(find_if(objs.begin(), objs.end(), bind2nd(ProxyIdentityEqual(comm),"ReplicatedObject")) != objs.end()); { - test(comm->identityToString(query->findObjectByType("::TestId1")->ice_getIdentity()) == "cat/name1"); - test(comm->identityToString(query->findObjectByType("::TestId2")->ice_getIdentity()) == "cat1/name1"); - test(comm->identityToString(query->findObjectByType("::TestId3")->ice_getIdentity()) == "cat1/name1-bis"); - test(comm->identityToString(query->findObjectByType("::TestId4")->ice_getIdentity()) == "c2\\/c2/n2\\/n2"); - test(comm->identityToString(query->findObjectByType("::TestId5")->ice_getIdentity()) == "n2\\/n2"); + test(comm->identityToString(query->findObjectByType("::TestId1")->ice_getIdentity()) == "cat/name1"); + test(comm->identityToString(query->findObjectByType("::TestId2")->ice_getIdentity()) == "cat1/name1"); + test(comm->identityToString(query->findObjectByType("::TestId3")->ice_getIdentity()) == "cat1/name1-bis"); + test(comm->identityToString(query->findObjectByType("::TestId4")->ice_getIdentity()) == "c2\\/c2/n2\\/n2"); + test(comm->identityToString(query->findObjectByType("::TestId5")->ice_getIdentity()) == "n2\\/n2"); } { - Ice::ObjectPrx obj = query->findObjectByType("::Test"); - string id = comm->identityToString(obj->ice_getIdentity()); - test(id == "Server1" || id == "Server2" || id == "SimpleServer" || - id == "IceBox1-Service1" || id == "IceBox1-Service2" || - id == "IceBox2-Service1" || id == "IceBox2-Service2" || - id == "SimpleIceBox-SimpleService" || "ReplicatedObject"); + Ice::ObjectPrx obj = query->findObjectByType("::Test"); + string id = comm->identityToString(obj->ice_getIdentity()); + test(id == "Server1" || id == "Server2" || id == "SimpleServer" || + id == "IceBox1-Service1" || id == "IceBox1-Service2" || + id == "IceBox2-Service1" || id == "IceBox2-Service2" || + id == "SimpleIceBox-SimpleService" || "ReplicatedObject"); } { - Ice::ObjectPrx obj = query->findObjectByTypeOnLeastLoadedNode("::Test", LoadSample5); - string id = comm->identityToString(obj->ice_getIdentity()); - test(id == "Server1" || id == "Server2" || id == "SimpleServer" || - id == "IceBox1-Service1" || id == "IceBox1-Service2" || - id == "IceBox2-Service1" || id == "IceBox2-Service2" || - id == "SimpleIceBox-SimpleService" || "ReplicatedObject"); + Ice::ObjectPrx obj = query->findObjectByTypeOnLeastLoadedNode("::Test", LoadSample5); + string id = comm->identityToString(obj->ice_getIdentity()); + test(id == "Server1" || id == "Server2" || id == "SimpleServer" || + id == "IceBox1-Service1" || id == "IceBox1-Service2" || + id == "IceBox2-Service1" || id == "IceBox2-Service2" || + id == "SimpleIceBox-SimpleService" || "ReplicatedObject"); } { - Ice::ObjectPrx obj = query->findObjectByType("::Foo"); - test(!obj); + Ice::ObjectPrx obj = query->findObjectByType("::Foo"); + test(!obj); - obj = query->findObjectByTypeOnLeastLoadedNode("::Foo", LoadSample15); - test(!obj); + obj = query->findObjectByTypeOnLeastLoadedNode("::Foo", LoadSample15); + test(!obj); } cout << "ok" << endl; @@ -233,7 +233,7 @@ allTests(const Ice::CommunicatorPtr& comm) obj = TestIntfPrx::checkedCast(comm->stringToProxy("IceBox2-Service1@IceBox2.Service1.Service1")); obj = TestIntfPrx::checkedCast(comm->stringToProxy("IceBox2-Service2@IceBox2Service2Adapter")); obj = TestIntfPrx::checkedCast( - comm->stringToProxy("SimpleIceBox-SimpleService@SimpleIceBox.SimpleService.SimpleService")); + comm->stringToProxy("SimpleIceBox-SimpleService@SimpleIceBox.SimpleService.SimpleService")); cout << "ok" << endl; cout << "testing server configuration... " << flush; @@ -280,21 +280,21 @@ allTests(const Ice::CommunicatorPtr& comm) obj = TestIntfPrx::checkedCast(comm->stringToProxy("SimpleServer@SimpleServer.Server")); proxies.push_back(obj); obj = TestIntfPrx::checkedCast( - comm->stringToProxy("SimpleIceBox-SimpleService@SimpleIceBox.SimpleService.SimpleService")); + comm->stringToProxy("SimpleIceBox-SimpleService@SimpleIceBox.SimpleService.SimpleService")); proxies.push_back(obj); for(vector<TestIntfPrx>::const_iterator p = proxies.begin(); p != proxies.end(); ++p) { - test((*p)->getProperty("AppVarProp") == "AppVar"); - test((*p)->getProperty("NodeVarProp") == "NodeVar"); - test((*p)->getProperty("RecursiveAppVarProp") == "Test"); - test((*p)->getProperty("AppVarOverridedProp") == "OverridedInNode"); - test((*p)->getProperty("AppVarDefinedInNodeProp") == "localnode"); - test((*p)->getProperty("EscapedAppVarProp") == "${escaped}"); - test((*p)->getProperty("RecursiveEscapedAppVarProp") == "${escaped}"); - test((*p)->getProperty("Recursive2EscapedAppVarProp") == "${escaped}"); - test((*p)->getProperty("RecursiveNodeVarProp") == "localnode"); - test((*p)->getProperty("TestDirProp") != "NotThisValue"); + test((*p)->getProperty("AppVarProp") == "AppVar"); + test((*p)->getProperty("NodeVarProp") == "NodeVar"); + test((*p)->getProperty("RecursiveAppVarProp") == "Test"); + test((*p)->getProperty("AppVarOverridedProp") == "OverridedInNode"); + test((*p)->getProperty("AppVarDefinedInNodeProp") == "localnode"); + test((*p)->getProperty("EscapedAppVarProp") == "${escaped}"); + test((*p)->getProperty("RecursiveEscapedAppVarProp") == "${escaped}"); + test((*p)->getProperty("Recursive2EscapedAppVarProp") == "${escaped}"); + test((*p)->getProperty("RecursiveNodeVarProp") == "localnode"); + test((*p)->getProperty("TestDirProp") != "NotThisValue"); } cout << "ok" << endl; @@ -416,17 +416,17 @@ allTests(const Ice::CommunicatorPtr& comm) desc.serverTemplates["ServerTemplate"] = templ; try { - admin->addApplication(desc); - test(false); + admin->addApplication(desc); + test(false); } catch(const DeploymentException& ex) { - test(ex.reason.find("duplicate parameters") != string::npos); + test(ex.reason.find("duplicate parameters") != string::npos); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - test(false); + cerr << ex << endl; + test(false); } cout << "ok" << endl; @@ -731,7 +731,7 @@ void allTestsWithTarget(const Ice::CommunicatorPtr& comm) { RegistryPrx registry = IceGrid::RegistryPrx::checkedCast( - comm->stringToProxy("IceGrid/Registry")); + comm->stringToProxy("IceGrid/Registry")); test(registry); AdminSessionPrx session = registry->createAdminSession("foo", "bar"); diff --git a/cpp/test/IceGrid/deployer/Client.cpp b/cpp/test/IceGrid/deployer/Client.cpp index 1288409798d..50ee597c317 100644 --- a/cpp/test/IceGrid/deployer/Client.cpp +++ b/cpp/test/IceGrid/deployer/Client.cpp @@ -20,21 +20,21 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) bool withTemplates = false; if(argc > 1) { - int i = 1; - while(i < argc) - { - if(strcmp(argv[i], "-t") == 0) - { - withTarget = true; - break; - } - else if(strcmp(argv[i], "-e") == 0) - { - withTemplates = true; - break; - } - i++; - } + int i = 1; + while(i < argc) + { + if(strcmp(argv[i], "-t") == 0) + { + withTarget = true; + break; + } + else if(strcmp(argv[i], "-e") == 0) + { + withTemplates = true; + break; + } + i++; + } } Ice::StringSeq args = Ice::argsToStringSeq(argc, argv); @@ -43,13 +43,13 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) if(!withTarget) { - void allTests(const Ice::CommunicatorPtr&); - allTests(communicator); + void allTests(const Ice::CommunicatorPtr&); + allTests(communicator); } else { - void allTestsWithTarget(const Ice::CommunicatorPtr&); - allTestsWithTarget(communicator); + void allTestsWithTarget(const Ice::CommunicatorPtr&); + allTestsWithTarget(communicator); } return EXIT_SUCCESS; @@ -63,26 +63,26 @@ main(int argc, char* argv[]) try { - communicator = Ice::initialize(argc, argv); - status = run(argc, argv, communicator); + communicator = Ice::initialize(argc, argv); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/IceGrid/deployer/Service.cpp b/cpp/test/IceGrid/deployer/Service.cpp index 4e1b5d66e26..0bb30aff9bd 100644 --- a/cpp/test/IceGrid/deployer/Service.cpp +++ b/cpp/test/IceGrid/deployer/Service.cpp @@ -28,8 +28,8 @@ public: virtual ~ServiceI(); virtual void start(const string&, - const CommunicatorPtr&, - const StringSeq&); + const CommunicatorPtr&, + const StringSeq&); virtual void stop(); }; @@ -58,17 +58,17 @@ ServiceI::~ServiceI() void ServiceI::start(const string& name, - const CommunicatorPtr& communicator, - const StringSeq& args) + const CommunicatorPtr& communicator, + const StringSeq& args) { Ice::PropertiesPtr properties = communicator->getProperties(); Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter(name); if(properties->getPropertyAsInt(name + ".Freeze") > 0) { - // - // We do this to ensure the dbenv directory exists. - // - Freeze::createConnection(communicator, name); + // + // We do this to ensure the dbenv directory exists. + // + Freeze::createConnection(communicator, name); } Ice::ObjectPtr object = new TestI(adapter, properties); adapter->add(object, communicator->stringToIdentity(properties->getProperty(name + ".Identity"))); diff --git a/cpp/test/IceGrid/distribution/AllTests.cpp b/cpp/test/IceGrid/distribution/AllTests.cpp index d47a3a9263c..c8e0dfc169f 100644 --- a/cpp/test/IceGrid/distribution/AllTests.cpp +++ b/cpp/test/IceGrid/distribution/AllTests.cpp @@ -26,7 +26,7 @@ class SessionKeepAliveThread : public IceUtil::Thread, public IceUtil::Monitor<I public: SessionKeepAliveThread(const IceGrid::AdminSessionPrx& session, long timeout) : - _session(session), + _session(session), _timeout(IceUtil::Time::seconds(timeout)), _destroy(false) { @@ -41,15 +41,15 @@ public: timedWait(_timeout); if(_destroy) { - break; - } + break; + } try { _session->keepAlive(); } catch(const Ice::Exception&) { - break; + break; } } } @@ -88,9 +88,9 @@ allTests(const Ice::CommunicatorPtr& communicator) cout << "testing distributions... " << flush; { - TestIntfPrx test; - test = TestIntfPrx::uncheckedCast(communicator->stringToProxy("server-all")); - test(test->getServerFile("rootfile") == ""); + TestIntfPrx test; + test = TestIntfPrx::uncheckedCast(communicator->stringToProxy("server-all")); + test(test->getServerFile("rootfile") == ""); try { @@ -102,15 +102,15 @@ allTests(const Ice::CommunicatorPtr& communicator) test(false); } - test(test->getServerFile("rootfile") == "rootfile"); - test(test->getServerFile("dir1/file1") == "dummy-file1"); - test(test->getServerFile("dir1/file2") == "dummy-file2"); - test(test->getServerFile("dir2/file3") == "dummy-file3"); + test(test->getServerFile("rootfile") == "rootfile"); + test(test->getServerFile("dir1/file1") == "dummy-file1"); + test(test->getServerFile("dir1/file2") == "dummy-file2"); + test(test->getServerFile("dir2/file3") == "dummy-file3"); - test(test->getApplicationFile("rootfile") == ""); - test(test->getApplicationFile("dir1/file1") == ""); - test(test->getApplicationFile("dir1/file2") == ""); - test(test->getApplicationFile("dir2/file3") == "dummy-file3"); + test(test->getApplicationFile("rootfile") == ""); + test(test->getApplicationFile("dir1/file1") == ""); + test(test->getApplicationFile("dir1/file2") == ""); + test(test->getApplicationFile("dir2/file3") == "dummy-file3"); try { @@ -121,17 +121,17 @@ allTests(const Ice::CommunicatorPtr& communicator) copy(ex.reasons.begin(), ex.reasons.end(), ostream_iterator<string>(cerr, "\n")); test(false); } - test = TestIntfPrx::uncheckedCast(communicator->stringToProxy("server-all-direct")); + test = TestIntfPrx::uncheckedCast(communicator->stringToProxy("server-all-direct")); - test(test->getServerFile("rootfile") == "rootfile"); - test(test->getServerFile("dir1/file1") == "dummy-file1"); - test(test->getServerFile("dir1/file2") == "dummy-file2"); - test(test->getServerFile("dir2/file3") == "dummy-file3"); + test(test->getServerFile("rootfile") == "rootfile"); + test(test->getServerFile("dir1/file1") == "dummy-file1"); + test(test->getServerFile("dir1/file2") == "dummy-file2"); + test(test->getServerFile("dir2/file3") == "dummy-file3"); - test(test->getApplicationFile("rootfile") == ""); - test(test->getApplicationFile("dir1/file1") == ""); - test(test->getApplicationFile("dir1/file2") == ""); - test(test->getApplicationFile("dir2/file3") == "dummy-file3"); + test(test->getApplicationFile("rootfile") == ""); + test(test->getApplicationFile("dir1/file1") == ""); + test(test->getApplicationFile("dir1/file2") == ""); + test(test->getApplicationFile("dir2/file3") == "dummy-file3"); try { @@ -142,17 +142,17 @@ allTests(const Ice::CommunicatorPtr& communicator) copy(ex.reasons.begin(), ex.reasons.end(), ostream_iterator<string>(cerr, "\n")); test(false); } - test = TestIntfPrx::uncheckedCast(communicator->stringToProxy("server-dir1")); + test = TestIntfPrx::uncheckedCast(communicator->stringToProxy("server-dir1")); - test(test->getServerFile("rootfile") == ""); - test(test->getServerFile("dir1/file1") == "dummy-file1"); - test(test->getServerFile("dir1/file2") == "dummy-file2"); - test(test->getServerFile("dir2/file3") == ""); + test(test->getServerFile("rootfile") == ""); + test(test->getServerFile("dir1/file1") == "dummy-file1"); + test(test->getServerFile("dir1/file2") == "dummy-file2"); + test(test->getServerFile("dir2/file3") == ""); - test(test->getApplicationFile("rootfile") == ""); - test(test->getApplicationFile("dir1/file1") == ""); - test(test->getApplicationFile("dir1/file2") == ""); - test(test->getApplicationFile("dir2/file3") == "dummy-file3"); + test(test->getApplicationFile("rootfile") == ""); + test(test->getApplicationFile("dir1/file1") == ""); + test(test->getApplicationFile("dir1/file2") == ""); + test(test->getApplicationFile("dir2/file3") == "dummy-file3"); } cout << "ok" << endl; @@ -169,9 +169,9 @@ allTests(const Ice::CommunicatorPtr& communicator) cout << "testing distributions after update... " << flush; { - TestIntfPrx test; - test = TestIntfPrx::uncheckedCast(communicator->stringToProxy("server-all")); - test(test->getServerFile("rootfile") == "rootfile"); + TestIntfPrx test; + test = TestIntfPrx::uncheckedCast(communicator->stringToProxy("server-all")); + test(test->getServerFile("rootfile") == "rootfile"); try { @@ -183,17 +183,17 @@ allTests(const Ice::CommunicatorPtr& communicator) test(false); } - test(test->getServerFile("rootfile") == "rootfile-updated!"); - test(test->getServerFile("dir1/file1") == ""); - test(test->getServerFile("dir1/file2") == "dummy-file2-updated!"); - test(test->getServerFile("dir2/file3") == "dummy-file3"); - test(test->getServerFile("dir2/file4") == "dummy-file4"); - - test(test->getApplicationFile("rootfile") == ""); - test(test->getApplicationFile("dir1/file1") == ""); - test(test->getApplicationFile("dir1/file2") == ""); - test(test->getApplicationFile("dir2/file3") == "dummy-file3"); - test(test->getApplicationFile("dir2/file4") == "dummy-file4"); + test(test->getServerFile("rootfile") == "rootfile-updated!"); + test(test->getServerFile("dir1/file1") == ""); + test(test->getServerFile("dir1/file2") == "dummy-file2-updated!"); + test(test->getServerFile("dir2/file3") == "dummy-file3"); + test(test->getServerFile("dir2/file4") == "dummy-file4"); + + test(test->getApplicationFile("rootfile") == ""); + test(test->getApplicationFile("dir1/file1") == ""); + test(test->getApplicationFile("dir1/file2") == ""); + test(test->getApplicationFile("dir2/file3") == "dummy-file3"); + test(test->getApplicationFile("dir2/file4") == "dummy-file4"); try { @@ -204,19 +204,19 @@ allTests(const Ice::CommunicatorPtr& communicator) copy(ex.reasons.begin(), ex.reasons.end(), ostream_iterator<string>(cerr, "\n")); test(false); } - test = TestIntfPrx::uncheckedCast(communicator->stringToProxy("server-all-direct")); + test = TestIntfPrx::uncheckedCast(communicator->stringToProxy("server-all-direct")); - test(test->getServerFile("rootfile") == "rootfile-updated!"); - test(test->getServerFile("dir1/file1") == ""); - test(test->getServerFile("dir1/file2") == "dummy-file2-updated!"); - test(test->getServerFile("dir2/file3") == "dummy-file3"); - test(test->getServerFile("dir2/file4") == "dummy-file4"); + test(test->getServerFile("rootfile") == "rootfile-updated!"); + test(test->getServerFile("dir1/file1") == ""); + test(test->getServerFile("dir1/file2") == "dummy-file2-updated!"); + test(test->getServerFile("dir2/file3") == "dummy-file3"); + test(test->getServerFile("dir2/file4") == "dummy-file4"); - test(test->getApplicationFile("rootfile") == ""); - test(test->getApplicationFile("dir1/file1") == ""); - test(test->getApplicationFile("dir1/file2") == ""); - test(test->getApplicationFile("dir2/file3") == "dummy-file3"); - test(test->getApplicationFile("dir2/file4") == "dummy-file4"); + test(test->getApplicationFile("rootfile") == ""); + test(test->getApplicationFile("dir1/file1") == ""); + test(test->getApplicationFile("dir1/file2") == ""); + test(test->getApplicationFile("dir2/file3") == "dummy-file3"); + test(test->getApplicationFile("dir2/file4") == "dummy-file4"); try { @@ -227,19 +227,19 @@ allTests(const Ice::CommunicatorPtr& communicator) copy(ex.reasons.begin(), ex.reasons.end(), ostream_iterator<string>(cerr, "\n")); test(false); } - test = TestIntfPrx::uncheckedCast(communicator->stringToProxy("server-dir1")); - - test(test->getServerFile("rootfile") == ""); - test(test->getServerFile("dir1/file1") == ""); - test(test->getServerFile("dir1/file2") == "dummy-file2-updated!"); - test(test->getServerFile("dir2/file3") == ""); - test(test->getServerFile("dir2/file4") == ""); - - test(test->getApplicationFile("rootfile") == ""); - test(test->getApplicationFile("dir1/file1") == ""); - test(test->getApplicationFile("dir1/file2") == ""); - test(test->getApplicationFile("dir2/file3") == "dummy-file3"); - test(test->getApplicationFile("dir2/file4") == "dummy-file4"); + test = TestIntfPrx::uncheckedCast(communicator->stringToProxy("server-dir1")); + + test(test->getServerFile("rootfile") == ""); + test(test->getServerFile("dir1/file1") == ""); + test(test->getServerFile("dir1/file2") == "dummy-file2-updated!"); + test(test->getServerFile("dir2/file3") == ""); + test(test->getServerFile("dir2/file4") == ""); + + test(test->getApplicationFile("rootfile") == ""); + test(test->getApplicationFile("dir1/file1") == ""); + test(test->getApplicationFile("dir1/file2") == ""); + test(test->getApplicationFile("dir2/file3") == "dummy-file3"); + test(test->getApplicationFile("dir2/file4") == "dummy-file4"); } cout << "ok" << endl; diff --git a/cpp/test/IceGrid/distribution/Client.cpp b/cpp/test/IceGrid/distribution/Client.cpp index 47f910e24da..940ae6bec73 100644 --- a/cpp/test/IceGrid/distribution/Client.cpp +++ b/cpp/test/IceGrid/distribution/Client.cpp @@ -27,28 +27,28 @@ main(int argc, char* argv[]) int status; Ice::CommunicatorPtr communicator; try - { - communicator = Ice::initialize(argc, argv); - communicator->getProperties()->parseCommandLineOptions("", Ice::argsToStringSeq(argc, argv)); - status = run(argc, argv, communicator); + { + communicator = Ice::initialize(argc, argv); + communicator->getProperties()->parseCommandLineOptions("", Ice::argsToStringSeq(argc, argv)); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/IceGrid/distribution/TestI.cpp b/cpp/test/IceGrid/distribution/TestI.cpp index d762e5a3ed0..903c51caeb9 100644 --- a/cpp/test/IceGrid/distribution/TestI.cpp +++ b/cpp/test/IceGrid/distribution/TestI.cpp @@ -28,7 +28,7 @@ TestI::getServerFile(const string& path, const Ice::Current&) string content; if(is.good()) { - is >> content; + is >> content; } return content; } @@ -41,7 +41,7 @@ TestI::getApplicationFile(const string& path, const Ice::Current&) string content; if(is.good()) { - is >> content; + is >> content; } return content; } diff --git a/cpp/test/IceGrid/distribution/run.py b/cpp/test/IceGrid/distribution/run.py index 81ca0f497d7..1e27b744862 100755 --- a/cpp/test/IceGrid/distribution/run.py +++ b/cpp/test/IceGrid/distribution/run.py @@ -57,7 +57,7 @@ else: for [file, content] in files: file = os.path.join(datadir, file) if not os.path.exists(os.path.dirname(file)): - os.makedirs(os.path.dirname(file)) + os.makedirs(os.path.dirname(file)) f = open(file, 'w') f.write(content) f.close() diff --git a/cpp/test/IceGrid/replicaGroup/AllTests.cpp b/cpp/test/IceGrid/replicaGroup/AllTests.cpp index 9ae9ce21c3c..d07d69a1c17 100644 --- a/cpp/test/IceGrid/replicaGroup/AllTests.cpp +++ b/cpp/test/IceGrid/replicaGroup/AllTests.cpp @@ -27,7 +27,7 @@ class SessionKeepAliveThread : public IceUtil::Thread, public IceUtil::Monitor<I public: SessionKeepAliveThread(const IceGrid::AdminSessionPrx& session, long timeout) : - _session(session), + _session(session), _timeout(IceUtil::Time::seconds(timeout)), _destroy(false) { @@ -42,15 +42,15 @@ public: timedWait(_timeout); if(_destroy) { - break; - } + break; + } try { _session->keepAlive(); } catch(const Ice::Exception&) { - break; + break; } } } @@ -86,12 +86,12 @@ instantiateServer(const AdminPrx& admin, const string& templ, const string& node update.nodes.push_back(nodeUpdate); try { - admin->updateApplication(update); + admin->updateApplication(update); } catch(DeploymentException& ex) { - cerr << ex.reason << endl; - test(false); + cerr << ex.reason << endl; + test(false); } } @@ -100,7 +100,7 @@ removeServer(const AdminPrx& admin, const string& id) { try { - admin->stopServer(id); + admin->stopServer(id); } catch(const ServerStopException&) { @@ -110,8 +110,8 @@ removeServer(const AdminPrx& admin, const string& id) } catch(const Ice::UserException& ex) { - cerr << ex << endl; - test(false); + cerr << ex << endl; + test(false); } NodeUpdateDescriptor nodeUpdate; @@ -122,12 +122,12 @@ removeServer(const AdminPrx& admin, const string& id) update.nodes.push_back(nodeUpdate); try { - admin->updateApplication(update); + admin->updateApplication(update); } catch(DeploymentException& ex) { - cerr << ex.reason << endl; - test(false); + cerr << ex.reason << endl; + test(false); } } @@ -155,434 +155,434 @@ allTests(const Ice::CommunicatorPtr& comm) cout << "testing Query::findAllReplicas... " << flush; { - map<string, string> params; - params["replicaGroup"] = "RoundRobin"; - params["id"] = "Server1"; - instantiateServer(admin, "Server", "localnode", params); - params["id"] = "Server2"; - instantiateServer(admin, "Server", "localnode", params); - params["id"] = "Server3"; - instantiateServer(admin, "Server", "localnode", params); - - QueryPrx query = IceGrid::QueryPrx::checkedCast(comm->stringToProxy("IceGrid/Query")); - test(query); - - TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("dummy@RoundRobin")); - Ice::ObjectProxySeq objs = query->findAllReplicas(obj); - test(objs.size() == 3); - test(serverReplicaIds.find(objs[0]->ice_getAdapterId()) != serverReplicaIds.end()); - test(serverReplicaIds.find(objs[1]->ice_getAdapterId()) != serverReplicaIds.end()); - test(serverReplicaIds.find(objs[2]->ice_getAdapterId()) != serverReplicaIds.end()); - - obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("dummy@dummy")); - objs = query->findAllReplicas(obj); - test(objs.empty()); - - obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("dummy@Server1.ReplicatedAdapter")); - objs = query->findAllReplicas(obj); - test(objs.empty()); - - obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("dummy:tcp")); - objs = query->findAllReplicas(obj); - test(objs.empty()); - - removeServer(admin, "Server1"); - removeServer(admin, "Server2"); - removeServer(admin, "Server3"); + map<string, string> params; + params["replicaGroup"] = "RoundRobin"; + params["id"] = "Server1"; + instantiateServer(admin, "Server", "localnode", params); + params["id"] = "Server2"; + instantiateServer(admin, "Server", "localnode", params); + params["id"] = "Server3"; + instantiateServer(admin, "Server", "localnode", params); + + QueryPrx query = IceGrid::QueryPrx::checkedCast(comm->stringToProxy("IceGrid/Query")); + test(query); + + TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("dummy@RoundRobin")); + Ice::ObjectProxySeq objs = query->findAllReplicas(obj); + test(objs.size() == 3); + test(serverReplicaIds.find(objs[0]->ice_getAdapterId()) != serverReplicaIds.end()); + test(serverReplicaIds.find(objs[1]->ice_getAdapterId()) != serverReplicaIds.end()); + test(serverReplicaIds.find(objs[2]->ice_getAdapterId()) != serverReplicaIds.end()); + + obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("dummy@dummy")); + objs = query->findAllReplicas(obj); + test(objs.empty()); + + obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("dummy@Server1.ReplicatedAdapter")); + objs = query->findAllReplicas(obj); + test(objs.empty()); + + obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("dummy:tcp")); + objs = query->findAllReplicas(obj); + test(objs.empty()); + + removeServer(admin, "Server1"); + removeServer(admin, "Server2"); + removeServer(admin, "Server3"); } cout << "ok" << endl; cout << "testing replication with round-robin load balancing... " << flush; { - map<string, string> params; - params["replicaGroup"] = "RoundRobin"; - params["id"] = "Server1"; - instantiateServer(admin, "Server", "localnode", params); - params["id"] = "Server2"; - instantiateServer(admin, "Server", "localnode", params); - params["id"] = "Server3"; - instantiateServer(admin, "Server", "localnode", params); - TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("RoundRobin")); - try - { - test(obj->getReplicaIdAndShutdown() == "Server1.ReplicatedAdapter"); - test(obj->getReplicaIdAndShutdown() == "Server2.ReplicatedAdapter"); - test(obj->getReplicaIdAndShutdown() == "Server3.ReplicatedAdapter"); - } - catch(const Ice::LocalException& ex) - { - cerr << ex << endl; - test(false); - } - removeServer(admin, "Server1"); - removeServer(admin, "Server2"); - removeServer(admin, "Server3"); + map<string, string> params; + params["replicaGroup"] = "RoundRobin"; + params["id"] = "Server1"; + instantiateServer(admin, "Server", "localnode", params); + params["id"] = "Server2"; + instantiateServer(admin, "Server", "localnode", params); + params["id"] = "Server3"; + instantiateServer(admin, "Server", "localnode", params); + TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("RoundRobin")); + try + { + test(obj->getReplicaIdAndShutdown() == "Server1.ReplicatedAdapter"); + test(obj->getReplicaIdAndShutdown() == "Server2.ReplicatedAdapter"); + test(obj->getReplicaIdAndShutdown() == "Server3.ReplicatedAdapter"); + } + catch(const Ice::LocalException& ex) + { + cerr << ex << endl; + test(false); + } + removeServer(admin, "Server1"); + removeServer(admin, "Server2"); + removeServer(admin, "Server3"); } { - map<string, string> params; - params["replicaGroup"] = "RoundRobin"; - params["id"] = "IceBox1"; - instantiateServer(admin, "IceBox", "localnode", params); - TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("RoundRobin")); - try - { - test(obj->getReplicaIdAndShutdown() == "IceBox1.Service1.Service1"); - test(obj->getReplicaIdAndShutdown() == "IceBox1.Service2.Service2"); - test(obj->getReplicaIdAndShutdown() == "IceBox1.Service3.Service3"); - } - catch(const Ice::LocalException& ex) - { - cerr << ex << endl; - test(false); - } - removeServer(admin, "IceBox1"); + map<string, string> params; + params["replicaGroup"] = "RoundRobin"; + params["id"] = "IceBox1"; + instantiateServer(admin, "IceBox", "localnode", params); + TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("RoundRobin")); + try + { + test(obj->getReplicaIdAndShutdown() == "IceBox1.Service1.Service1"); + test(obj->getReplicaIdAndShutdown() == "IceBox1.Service2.Service2"); + test(obj->getReplicaIdAndShutdown() == "IceBox1.Service3.Service3"); + } + catch(const Ice::LocalException& ex) + { + cerr << ex << endl; + test(false); + } + removeServer(admin, "IceBox1"); } cout << "ok" << endl; cout << "testing replication with ordered load balancing... " << flush; { - map<string, string> params; - params["replicaGroup"] = "Ordered"; - params["id"] = "Server1"; - params["priority"] = "3"; - instantiateServer(admin, "Server", "localnode", params); - params["id"] = "Server2"; - params["priority"] = "1"; - instantiateServer(admin, "Server", "localnode", params); - params["id"] = "Server3"; - params["priority"] = "2"; - instantiateServer(admin, "Server", "localnode", params); - TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("Ordered")); - try - { - test(obj->getReplicaIdAndShutdown() == "Server2.ReplicatedAdapter"); - admin->enableServer("Server2", false); - test(obj->getReplicaIdAndShutdown() == "Server3.ReplicatedAdapter"); - admin->enableServer("Server3", false); - test(obj->getReplicaIdAndShutdown() == "Server1.ReplicatedAdapter"); - } - catch(const Ice::LocalException& ex) - { - cerr << ex << endl; - test(false); - } - removeServer(admin, "Server1"); - removeServer(admin, "Server2"); - removeServer(admin, "Server3"); + map<string, string> params; + params["replicaGroup"] = "Ordered"; + params["id"] = "Server1"; + params["priority"] = "3"; + instantiateServer(admin, "Server", "localnode", params); + params["id"] = "Server2"; + params["priority"] = "1"; + instantiateServer(admin, "Server", "localnode", params); + params["id"] = "Server3"; + params["priority"] = "2"; + instantiateServer(admin, "Server", "localnode", params); + TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("Ordered")); + try + { + test(obj->getReplicaIdAndShutdown() == "Server2.ReplicatedAdapter"); + admin->enableServer("Server2", false); + test(obj->getReplicaIdAndShutdown() == "Server3.ReplicatedAdapter"); + admin->enableServer("Server3", false); + test(obj->getReplicaIdAndShutdown() == "Server1.ReplicatedAdapter"); + } + catch(const Ice::LocalException& ex) + { + cerr << ex << endl; + test(false); + } + removeServer(admin, "Server1"); + removeServer(admin, "Server2"); + removeServer(admin, "Server3"); } { - map<string, string> params; - params["replicaGroup"] = "Ordered"; - params["id"] = "IceBox1"; - instantiateServer(admin, "IceBox", "localnode", params); - TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("Ordered")); - try - { - test(obj->getReplicaIdAndShutdown() == "IceBox1.Service3.Service3"); - test(obj->getReplicaIdAndShutdown() == "IceBox1.Service2.Service2"); - test(obj->getReplicaIdAndShutdown() == "IceBox1.Service1.Service1"); - } - catch(const Ice::LocalException& ex) - { - cerr << ex << endl; - test(false); - } - removeServer(admin, "IceBox1"); + map<string, string> params; + params["replicaGroup"] = "Ordered"; + params["id"] = "IceBox1"; + instantiateServer(admin, "IceBox", "localnode", params); + TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("Ordered")); + try + { + test(obj->getReplicaIdAndShutdown() == "IceBox1.Service3.Service3"); + test(obj->getReplicaIdAndShutdown() == "IceBox1.Service2.Service2"); + test(obj->getReplicaIdAndShutdown() == "IceBox1.Service1.Service1"); + } + catch(const Ice::LocalException& ex) + { + cerr << ex << endl; + test(false); + } + removeServer(admin, "IceBox1"); } cout << "ok" << endl; cout << "testing replication with random load balancing... " << flush; { - map<string, string> params; - params["replicaGroup"] = "Random"; - params["id"] = "Server1"; - instantiateServer(admin, "Server", "localnode", params); - params["id"] = "Server2"; - instantiateServer(admin, "Server", "localnode", params); - params["id"] = "Server3"; - instantiateServer(admin, "Server", "localnode", params); - TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("Random")); - obj = TestIntfPrx::uncheckedCast(obj->ice_locatorCacheTimeout(0)); - obj = TestIntfPrx::uncheckedCast(obj->ice_connectionCached(false)); - set<string> replicaIds = serverReplicaIds; - while(!replicaIds.empty()) - { - try - { - replicaIds.erase(obj->getReplicaId()); - } - catch(const Ice::LocalException& ex) - { - cerr << ex << endl; - test(false); - } - } - removeServer(admin, "Server1"); - removeServer(admin, "Server2"); - removeServer(admin, "Server3"); + map<string, string> params; + params["replicaGroup"] = "Random"; + params["id"] = "Server1"; + instantiateServer(admin, "Server", "localnode", params); + params["id"] = "Server2"; + instantiateServer(admin, "Server", "localnode", params); + params["id"] = "Server3"; + instantiateServer(admin, "Server", "localnode", params); + TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("Random")); + obj = TestIntfPrx::uncheckedCast(obj->ice_locatorCacheTimeout(0)); + obj = TestIntfPrx::uncheckedCast(obj->ice_connectionCached(false)); + set<string> replicaIds = serverReplicaIds; + while(!replicaIds.empty()) + { + try + { + replicaIds.erase(obj->getReplicaId()); + } + catch(const Ice::LocalException& ex) + { + cerr << ex << endl; + test(false); + } + } + removeServer(admin, "Server1"); + removeServer(admin, "Server2"); + removeServer(admin, "Server3"); } { - map<string, string> params; - params["replicaGroup"] = "Random"; - params["id"] = "IceBox1"; - instantiateServer(admin, "IceBox", "localnode", params); - TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("Random")); - obj = TestIntfPrx::uncheckedCast(obj->ice_locatorCacheTimeout(0)); - obj = TestIntfPrx::uncheckedCast(obj->ice_connectionCached(false)); - set<string> replicaIds = svcReplicaIds; - while(!replicaIds.empty()) - { - try - { - replicaIds.erase(obj->getReplicaId()); - } - catch(const Ice::ConnectionRefusedException&) - { - } - catch(const Ice::LocalException& ex) - { - cerr << ex << endl; - test(false); - } - } - removeServer(admin, "IceBox1"); + map<string, string> params; + params["replicaGroup"] = "Random"; + params["id"] = "IceBox1"; + instantiateServer(admin, "IceBox", "localnode", params); + TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("Random")); + obj = TestIntfPrx::uncheckedCast(obj->ice_locatorCacheTimeout(0)); + obj = TestIntfPrx::uncheckedCast(obj->ice_connectionCached(false)); + set<string> replicaIds = svcReplicaIds; + while(!replicaIds.empty()) + { + try + { + replicaIds.erase(obj->getReplicaId()); + } + catch(const Ice::ConnectionRefusedException&) + { + } + catch(const Ice::LocalException& ex) + { + cerr << ex << endl; + test(false); + } + } + removeServer(admin, "IceBox1"); } cout << "ok" << endl; cout << "testing replication with adaptive load balancing... " << flush; { - map<string, string> params; - params["replicaGroup"] = "Adaptive"; - params["id"] = "Server1"; - instantiateServer(admin, "Server", "localnode", params); - params["id"] = "Server2"; - instantiateServer(admin, "Server", "localnode", params); - params["id"] = "Server3"; - instantiateServer(admin, "Server", "localnode", params); - TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("Adaptive")); - obj = TestIntfPrx::uncheckedCast(obj->ice_locatorCacheTimeout(0)); - obj = TestIntfPrx::uncheckedCast(obj->ice_connectionCached(false)); - set<string> replicaIds = serverReplicaIds; - while(!replicaIds.empty()) - { - try - { - replicaIds.erase(obj->getReplicaId()); - } - catch(const Ice::LocalException& ex) - { - cerr << ex << endl; - test(false); - } - } - removeServer(admin, "Server1"); - removeServer(admin, "Server2"); - removeServer(admin, "Server3"); + map<string, string> params; + params["replicaGroup"] = "Adaptive"; + params["id"] = "Server1"; + instantiateServer(admin, "Server", "localnode", params); + params["id"] = "Server2"; + instantiateServer(admin, "Server", "localnode", params); + params["id"] = "Server3"; + instantiateServer(admin, "Server", "localnode", params); + TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("Adaptive")); + obj = TestIntfPrx::uncheckedCast(obj->ice_locatorCacheTimeout(0)); + obj = TestIntfPrx::uncheckedCast(obj->ice_connectionCached(false)); + set<string> replicaIds = serverReplicaIds; + while(!replicaIds.empty()) + { + try + { + replicaIds.erase(obj->getReplicaId()); + } + catch(const Ice::LocalException& ex) + { + cerr << ex << endl; + test(false); + } + } + removeServer(admin, "Server1"); + removeServer(admin, "Server2"); + removeServer(admin, "Server3"); } { - map<string, string> params; - params["replicaGroup"] = "Adaptive"; - params["id"] = "IceBox1"; - instantiateServer(admin, "IceBox", "localnode", params); - TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("Adaptive")); - obj = TestIntfPrx::uncheckedCast(obj->ice_locatorCacheTimeout(0)); - obj = TestIntfPrx::uncheckedCast(obj->ice_connectionCached(false)); - set<string> replicaIds = svcReplicaIds; - while(!replicaIds.empty()) - { - try - { - replicaIds.erase(obj->getReplicaId()); - } - catch(const Ice::ConnectionRefusedException&) - { - } - catch(const Ice::LocalException& ex) - { - cerr << ex << endl; - test(false); - } - } - removeServer(admin, "IceBox1"); + map<string, string> params; + params["replicaGroup"] = "Adaptive"; + params["id"] = "IceBox1"; + instantiateServer(admin, "IceBox", "localnode", params); + TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("Adaptive")); + obj = TestIntfPrx::uncheckedCast(obj->ice_locatorCacheTimeout(0)); + obj = TestIntfPrx::uncheckedCast(obj->ice_connectionCached(false)); + set<string> replicaIds = svcReplicaIds; + while(!replicaIds.empty()) + { + try + { + replicaIds.erase(obj->getReplicaId()); + } + catch(const Ice::ConnectionRefusedException&) + { + } + catch(const Ice::LocalException& ex) + { + cerr << ex << endl; + test(false); + } + } + removeServer(admin, "IceBox1"); } cout << "ok" << endl; cout << "testing load balancing n-replicas..." << flush; { - TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("RoundRobin-2")); - obj = TestIntfPrx::uncheckedCast(obj->ice_locatorCacheTimeout(-1)); - obj = TestIntfPrx::uncheckedCast(obj->ice_connectionCached(false)); - try - { - obj->ice_ping(); - test(false); - } - catch(const Ice::NoEndpointException&) - { - } - - map<string, string> params; - params["replicaGroup"] = "RoundRobin-2"; - params["id"] = "Server1"; - instantiateServer(admin, "Server", "localnode", params); - params["id"] = "Server2"; - instantiateServer(admin, "Server", "localnode", params); - params["id"] = "Server3"; - instantiateServer(admin, "Server", "localnode", params); - try - { - set<string> replicaIds; - set<string> expected; - replicaIds.insert("Server1.ReplicatedAdapter"); - replicaIds.insert("Server2.ReplicatedAdapter"); - expected = replicaIds; - while(!replicaIds.empty()) - { - string replicaId = obj->getReplicaId(); - test(expected.find(replicaId) != expected.end()); - replicaIds.erase(replicaId); - } - obj->ice_locatorCacheTimeout(0)->ice_ping(); - replicaIds.insert("Server2.ReplicatedAdapter"); - replicaIds.insert("Server3.ReplicatedAdapter"); - expected = replicaIds; - while(!replicaIds.empty()) - { - string replicaId = obj->getReplicaId(); - test(expected.find(replicaId) != expected.end()); - replicaIds.erase(replicaId); - } - obj->ice_locatorCacheTimeout(0)->ice_ping(); - replicaIds.insert("Server3.ReplicatedAdapter"); - replicaIds.insert("Server1.ReplicatedAdapter"); - expected = replicaIds; - while(!replicaIds.empty()) - { - string replicaId = obj->getReplicaId(); - test(expected.find(replicaId) != expected.end()); - replicaIds.erase(replicaId); - } - } - catch(const Ice::LocalException& ex) - { - cerr << ex << endl; - test(false); - } - removeServer(admin, "Server1"); - removeServer(admin, "Server2"); - removeServer(admin, "Server3"); + TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("RoundRobin-2")); + obj = TestIntfPrx::uncheckedCast(obj->ice_locatorCacheTimeout(-1)); + obj = TestIntfPrx::uncheckedCast(obj->ice_connectionCached(false)); + try + { + obj->ice_ping(); + test(false); + } + catch(const Ice::NoEndpointException&) + { + } + + map<string, string> params; + params["replicaGroup"] = "RoundRobin-2"; + params["id"] = "Server1"; + instantiateServer(admin, "Server", "localnode", params); + params["id"] = "Server2"; + instantiateServer(admin, "Server", "localnode", params); + params["id"] = "Server3"; + instantiateServer(admin, "Server", "localnode", params); + try + { + set<string> replicaIds; + set<string> expected; + replicaIds.insert("Server1.ReplicatedAdapter"); + replicaIds.insert("Server2.ReplicatedAdapter"); + expected = replicaIds; + while(!replicaIds.empty()) + { + string replicaId = obj->getReplicaId(); + test(expected.find(replicaId) != expected.end()); + replicaIds.erase(replicaId); + } + obj->ice_locatorCacheTimeout(0)->ice_ping(); + replicaIds.insert("Server2.ReplicatedAdapter"); + replicaIds.insert("Server3.ReplicatedAdapter"); + expected = replicaIds; + while(!replicaIds.empty()) + { + string replicaId = obj->getReplicaId(); + test(expected.find(replicaId) != expected.end()); + replicaIds.erase(replicaId); + } + obj->ice_locatorCacheTimeout(0)->ice_ping(); + replicaIds.insert("Server3.ReplicatedAdapter"); + replicaIds.insert("Server1.ReplicatedAdapter"); + expected = replicaIds; + while(!replicaIds.empty()) + { + string replicaId = obj->getReplicaId(); + test(expected.find(replicaId) != expected.end()); + replicaIds.erase(replicaId); + } + } + catch(const Ice::LocalException& ex) + { + cerr << ex << endl; + test(false); + } + removeServer(admin, "Server1"); + removeServer(admin, "Server2"); + removeServer(admin, "Server3"); } { - TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("RoundRobin-All")); - obj = TestIntfPrx::uncheckedCast(obj->ice_locatorCacheTimeout(-1)); - obj = TestIntfPrx::uncheckedCast(obj->ice_connectionCached(false)); - try - { - obj->ice_ping(); - test(false); - } - catch(const Ice::NoEndpointException&) - { - } - - map<string, string> params; - params["replicaGroup"] = "RoundRobin-All"; - params["id"] = "Server1"; - instantiateServer(admin, "Server", "localnode", params); - params["id"] = "Server2"; - instantiateServer(admin, "Server", "localnode", params); - params["id"] = "Server3"; - instantiateServer(admin, "Server", "localnode", params); - try - { - set<string> replicaIds; - set<string> expected; - replicaIds.insert("Server1.ReplicatedAdapter"); - replicaIds.insert("Server2.ReplicatedAdapter"); - replicaIds.insert("Server3.ReplicatedAdapter"); - expected = replicaIds; - while(!replicaIds.empty()) - { - string replicaId = obj->getReplicaId(); - test(expected.find(replicaId) != expected.end()); - replicaIds.erase(replicaId); - } - obj->ice_locatorCacheTimeout(0)->ice_ping(); - replicaIds.insert("Server1.ReplicatedAdapter"); - replicaIds.insert("Server2.ReplicatedAdapter"); - replicaIds.insert("Server3.ReplicatedAdapter"); - expected = replicaIds; - while(!replicaIds.empty()) - { - string replicaId = obj->getReplicaId(); - test(expected.find(replicaId) != expected.end()); - replicaIds.erase(replicaId); - } - } - catch(const Ice::LocalException& ex) - { - cerr << ex << endl; - test(false); - } - removeServer(admin, "Server1"); - removeServer(admin, "Server2"); - removeServer(admin, "Server3"); + TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("RoundRobin-All")); + obj = TestIntfPrx::uncheckedCast(obj->ice_locatorCacheTimeout(-1)); + obj = TestIntfPrx::uncheckedCast(obj->ice_connectionCached(false)); + try + { + obj->ice_ping(); + test(false); + } + catch(const Ice::NoEndpointException&) + { + } + + map<string, string> params; + params["replicaGroup"] = "RoundRobin-All"; + params["id"] = "Server1"; + instantiateServer(admin, "Server", "localnode", params); + params["id"] = "Server2"; + instantiateServer(admin, "Server", "localnode", params); + params["id"] = "Server3"; + instantiateServer(admin, "Server", "localnode", params); + try + { + set<string> replicaIds; + set<string> expected; + replicaIds.insert("Server1.ReplicatedAdapter"); + replicaIds.insert("Server2.ReplicatedAdapter"); + replicaIds.insert("Server3.ReplicatedAdapter"); + expected = replicaIds; + while(!replicaIds.empty()) + { + string replicaId = obj->getReplicaId(); + test(expected.find(replicaId) != expected.end()); + replicaIds.erase(replicaId); + } + obj->ice_locatorCacheTimeout(0)->ice_ping(); + replicaIds.insert("Server1.ReplicatedAdapter"); + replicaIds.insert("Server2.ReplicatedAdapter"); + replicaIds.insert("Server3.ReplicatedAdapter"); + expected = replicaIds; + while(!replicaIds.empty()) + { + string replicaId = obj->getReplicaId(); + test(expected.find(replicaId) != expected.end()); + replicaIds.erase(replicaId); + } + } + catch(const Ice::LocalException& ex) + { + cerr << ex << endl; + test(false); + } + removeServer(admin, "Server1"); + removeServer(admin, "Server2"); + removeServer(admin, "Server3"); } cout << "ok" << endl; cout << "testing replication with inactive nodes... " << flush; { - map<string, string> params; - - params["replicaGroup"] = "Random"; - params["id"] = "Server1"; - instantiateServer(admin, "Server", "inactivenode", params); - params["id"] = "Server2"; - instantiateServer(admin, "Server", "localnode", params); - TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("Random")); - test(obj->getReplicaId() == "Server2.ReplicatedAdapter"); - - // - // Also make sure that findObjectByTypeOnLeastLoadedNode still work. - // - QueryPrx query = IceGrid::QueryPrx::checkedCast(comm->stringToProxy("IceGrid/Query")); - obj = TestIntfPrx::uncheckedCast(query->findObjectByTypeOnLeastLoadedNode("::Test::TestIntf", LoadSample1)); - test(obj->getReplicaId() == "Server2.ReplicatedAdapter"); - - removeServer(admin, "Server1"); - removeServer(admin, "Server2"); - - params["replicaGroup"] = "RoundRobin"; - params["id"] = "Server1"; - instantiateServer(admin, "Server", "inactivenode", params); - params["id"] = "Server2"; - instantiateServer(admin, "Server", "localnode", params); - obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("RoundRobin")); - test(obj->getReplicaId() == "Server2.ReplicatedAdapter"); - removeServer(admin, "Server1"); - removeServer(admin, "Server2"); - - params["replicaGroup"] = "Adaptive"; - params["id"] = "Server1"; - instantiateServer(admin, "Server", "inactivenode", params); - params["id"] = "Server2"; - instantiateServer(admin, "Server", "localnode", params); - obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("Adaptive")); - test(obj->getReplicaId() == "Server2.ReplicatedAdapter"); - removeServer(admin, "Server1"); - removeServer(admin, "Server2"); - - params["replicaGroup"] = "Random"; - params["id"] = "IceBox1"; - instantiateServer(admin, "IceBox", "localnode", params); - params["id"] = "Server1"; - instantiateServer(admin, "Server", "inactivenode", params); - obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("Random")); - test(svcReplicaIds.find(obj->getReplicaId()) != svcReplicaIds.end()); - removeServer(admin, "IceBox1"); - removeServer(admin, "Server1"); + map<string, string> params; + + params["replicaGroup"] = "Random"; + params["id"] = "Server1"; + instantiateServer(admin, "Server", "inactivenode", params); + params["id"] = "Server2"; + instantiateServer(admin, "Server", "localnode", params); + TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("Random")); + test(obj->getReplicaId() == "Server2.ReplicatedAdapter"); + + // + // Also make sure that findObjectByTypeOnLeastLoadedNode still work. + // + QueryPrx query = IceGrid::QueryPrx::checkedCast(comm->stringToProxy("IceGrid/Query")); + obj = TestIntfPrx::uncheckedCast(query->findObjectByTypeOnLeastLoadedNode("::Test::TestIntf", LoadSample1)); + test(obj->getReplicaId() == "Server2.ReplicatedAdapter"); + + removeServer(admin, "Server1"); + removeServer(admin, "Server2"); + + params["replicaGroup"] = "RoundRobin"; + params["id"] = "Server1"; + instantiateServer(admin, "Server", "inactivenode", params); + params["id"] = "Server2"; + instantiateServer(admin, "Server", "localnode", params); + obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("RoundRobin")); + test(obj->getReplicaId() == "Server2.ReplicatedAdapter"); + removeServer(admin, "Server1"); + removeServer(admin, "Server2"); + + params["replicaGroup"] = "Adaptive"; + params["id"] = "Server1"; + instantiateServer(admin, "Server", "inactivenode", params); + params["id"] = "Server2"; + instantiateServer(admin, "Server", "localnode", params); + obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("Adaptive")); + test(obj->getReplicaId() == "Server2.ReplicatedAdapter"); + removeServer(admin, "Server1"); + removeServer(admin, "Server2"); + + params["replicaGroup"] = "Random"; + params["id"] = "IceBox1"; + instantiateServer(admin, "IceBox", "localnode", params); + params["id"] = "Server1"; + instantiateServer(admin, "Server", "inactivenode", params); + obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("Random")); + test(svcReplicaIds.find(obj->getReplicaId()) != svcReplicaIds.end()); + removeServer(admin, "IceBox1"); + removeServer(admin, "Server1"); }; cout << "ok" << endl; diff --git a/cpp/test/IceGrid/replicaGroup/Client.cpp b/cpp/test/IceGrid/replicaGroup/Client.cpp index 0527d790712..a0f1ccc1976 100644 --- a/cpp/test/IceGrid/replicaGroup/Client.cpp +++ b/cpp/test/IceGrid/replicaGroup/Client.cpp @@ -29,26 +29,26 @@ main(int argc, char* argv[]) try { - communicator = Ice::initialize(argc, argv); - status = run(argc, argv, communicator); + communicator = Ice::initialize(argc, argv); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/IceGrid/replicaGroup/Service.cpp b/cpp/test/IceGrid/replicaGroup/Service.cpp index 4948e4914a0..f90125bd4b8 100644 --- a/cpp/test/IceGrid/replicaGroup/Service.cpp +++ b/cpp/test/IceGrid/replicaGroup/Service.cpp @@ -27,8 +27,8 @@ public: virtual ~ServiceI(); virtual void start(const string&, - const CommunicatorPtr&, - const StringSeq&); + const CommunicatorPtr&, + const StringSeq&); virtual void stop(); }; @@ -57,8 +57,8 @@ ServiceI::~ServiceI() void ServiceI::start(const string& name, - const CommunicatorPtr& communicator, - const StringSeq& args) + const CommunicatorPtr& communicator, + const StringSeq& args) { Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter(name); Ice::ObjectPtr object = new TestI(adapter, communicator->getProperties()); diff --git a/cpp/test/IceGrid/replication/AllTests.cpp b/cpp/test/IceGrid/replication/AllTests.cpp index 6ea8a923372..2ebf0731d48 100644 --- a/cpp/test/IceGrid/replication/AllTests.cpp +++ b/cpp/test/IceGrid/replication/AllTests.cpp @@ -28,7 +28,7 @@ class SessionKeepAliveThread : public IceUtil::Thread, public IceUtil::Monitor<I public: SessionKeepAliveThread(const IceGrid::AdminSessionPrx& session, long timeout) : - _session(session), + _session(session), _timeout(IceUtil::Time::seconds(timeout)), _destroy(false) { @@ -43,15 +43,15 @@ public: timedWait(_timeout); if(_destroy) { - break; - } + break; + } try { _session->keepAlive(); } catch(const Ice::Exception&) { - break; + break; } } } @@ -78,13 +78,13 @@ waitForServerState(const IceGrid::AdminPrx& admin, const std::string& server, bo int nRetry = 0; while(nRetry < 30) { - if(admin->getServerState(server) == (up ? Active : Inactive)) - { - return; - } + if(admin->getServerState(server) == (up ? Active : Inactive)) + { + return; + } - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - ++nRetry; + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + ++nRetry; } test(false); } @@ -95,41 +95,41 @@ waitForNodeState(const IceGrid::AdminPrx& admin, const std::string& node, bool u int nRetry = 0; while(nRetry < 30) { - try - { - if(admin->pingNode(node) == up) // Wait for the node to be removed. - { - return; - } - } - catch(const NodeNotExistException&) - { - if(!up) - { - return; - } - } - - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - ++nRetry; + try + { + if(admin->pingNode(node) == up) // Wait for the node to be removed. + { + return; + } + } + catch(const NodeNotExistException&) + { + if(!up) + { + return; + } + } + + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + ++nRetry; } try { - if(admin->pingNode(node) != up) - { - cerr << "node state change timed out:" << endl; - cerr << "node: " << node << endl; - cerr << "state: " << up << endl; - } + if(admin->pingNode(node) != up) + { + cerr << "node state change timed out:" << endl; + cerr << "node: " << node << endl; + cerr << "state: " << up << endl; + } } catch(NodeNotExistException&) { - if(up) - { - cerr << "node state change timed out:" << endl; - cerr << "node: " << node << endl; - cerr << "state: " << up << endl; - } + if(up) + { + cerr << "node state change timed out:" << endl; + cerr << "node: " << node << endl; + cerr << "state: " << up << endl; + } } } @@ -147,17 +147,17 @@ instantiateServer(const AdminPrx& admin, const string& templ, const map<string, update.nodes.push_back(nodeUpdate); try { - admin->updateApplication(update); + admin->updateApplication(update); } catch(DeploymentException& ex) { - cerr << ex.reason << endl; - test(false); + cerr << ex.reason << endl; + test(false); } catch(const Ice::LocalException& ex) { - cerr << ex << endl; - test(false); + cerr << ex << endl; + test(false); } } @@ -166,7 +166,7 @@ removeServer(const AdminPrx& admin, const string& id) { try { - admin->stopServer(id); + admin->stopServer(id); } catch(const ServerStopException&) { @@ -176,8 +176,8 @@ removeServer(const AdminPrx& admin, const string& id) } catch(const Ice::UserException& ex) { - cerr << ex << endl; - test(false); + cerr << ex << endl; + test(false); } NodeUpdateDescriptor nodeUpdate; @@ -188,12 +188,12 @@ removeServer(const AdminPrx& admin, const string& id) update.nodes.push_back(nodeUpdate); try { - admin->updateApplication(update); + admin->updateApplication(update); } catch(DeploymentException& ex) { - cerr << ex.reason << endl; - test(false); + cerr << ex.reason << endl; + test(false); } } @@ -203,16 +203,16 @@ waitAndPing(const Ice::ObjectPrx& obj) int nRetry = 0; while(nRetry < 30) { - try - { - obj->ice_ping(); - return true; - } - catch(const Ice::LocalException&) - { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - ++nRetry; - } + try + { + obj->ice_ping(); + return true; + } + catch(const Ice::LocalException&) + { + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + ++nRetry; + } } return false; } @@ -225,7 +225,7 @@ createAdminSession(const Ice::LocatorPrx& locator, const string& replica) string registryStr("TestIceGrid/Registry"); if(!replica.empty() && replica != "Master") { - registryStr += "-" + replica; + registryStr += "-" + replica; } Ice::ObjectPrx obj = locator->ice_getCommunicator()->stringToProxy(registryStr)->ice_locator(locator); RegistryPrx registry = RegistryPrx::checkedCast(obj); @@ -270,14 +270,14 @@ allTests(const Ice::CommunicatorPtr& comm) instantiateServer(admin, "IceGridRegistry", params); Ice::LocatorPrx masterLocator = - Ice::LocatorPrx::uncheckedCast(comm->stringToProxy("TestIceGrid/Locator-Master:default -p 12050")); + Ice::LocatorPrx::uncheckedCast(comm->stringToProxy("TestIceGrid/Locator-Master:default -p 12050")); Ice::LocatorPrx slave1Locator = - Ice::LocatorPrx::uncheckedCast(comm->stringToProxy("TestIceGrid/Locator-Slave1:default -p 12051")); + Ice::LocatorPrx::uncheckedCast(comm->stringToProxy("TestIceGrid/Locator-Slave1:default -p 12051")); Ice::LocatorPrx slave2Locator = - Ice::LocatorPrx::uncheckedCast(comm->stringToProxy("TestIceGrid/Locator-Slave2:default -p 12052")); + Ice::LocatorPrx::uncheckedCast(comm->stringToProxy("TestIceGrid/Locator-Slave2:default -p 12052")); Ice::LocatorPrx replicatedLocator = - Ice::LocatorPrx::uncheckedCast(comm->stringToProxy("TestIceGrid/Locator:default -p 12050:default -p 12051")); + Ice::LocatorPrx::uncheckedCast(comm->stringToProxy("TestIceGrid/Locator:default -p 12050:default -p 12051")); AdminPrx masterAdmin, slave1Admin, slave2Admin; @@ -300,203 +300,203 @@ allTests(const Ice::CommunicatorPtr& comm) // cout << "testing replicated locator and query interface... " << flush; { - Ice::EndpointSeq endpoints; - ObjectInfo info; - - info = masterAdmin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Locator")); - ObjectInfo info1 = slave1Admin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Locator")); - test(slave1Admin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Locator")) == info); - test(info.type == Ice::Locator::ice_staticId()); - endpoints = info.proxy->ice_getEndpoints(); - test(endpoints.size() == 2); - test(endpoints[0]->toString().find("-p 12050") != string::npos); - test(endpoints[1]->toString().find("-p 12051") != string::npos); - - info = masterAdmin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Query")); - test(slave1Admin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Query")) == info); - test(info.type == IceGrid::Query::ice_staticId()); - endpoints = info.proxy->ice_getEndpoints(); - test(endpoints.size() == 2); - test(endpoints[0]->toString().find("-p 12050") != string::npos); - test(endpoints[1]->toString().find("-p 12051") != string::npos); - - admin->startServer("Slave2"); - slave2Admin = createAdminSession(slave2Locator, "Slave2"); - - info = masterAdmin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Locator")); - // We eventually need to wait here for the update of the replicated objects to propagate to the replica. - int nRetry = 0; - while(slave1Admin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Locator")) != info && nRetry < 30) - { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - ++nRetry; - } - test(slave2Admin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Locator")) == info); - test(info.type == Ice::Locator::ice_staticId()); - endpoints = info.proxy->ice_getEndpoints(); - test(endpoints.size() == 3); - test(endpoints[0]->toString().find("-p 12050") != string::npos); - test(endpoints[1]->toString().find("-p 12051") != string::npos); - test(endpoints[2]->toString().find("-p 12052") != string::npos); - - info = masterAdmin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Query")); - // We eventually need to wait here for the update of the replicated objects to propagate to the replica. - nRetry = 0; - while(slave1Admin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Query")) != info && nRetry < 30) - { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - ++nRetry; - } - test(slave2Admin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Query")) == info); - test(info.type == IceGrid::Query::ice_staticId()); - endpoints = info.proxy->ice_getEndpoints(); - test(endpoints.size() == 3); - test(endpoints[0]->toString().find("-p 12050") != string::npos); - test(endpoints[1]->toString().find("-p 12051") != string::npos); - test(endpoints[2]->toString().find("-p 12052") != string::npos); - - slave2Admin->shutdown(); - waitForServerState(admin, "Slave2", false); - - info = masterAdmin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Locator")); - // We eventually need to wait here for the update of the replicated objects to propagate to the replica. - nRetry = 0; - while(slave1Admin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Locator")) != info && nRetry < 30) - { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - ++nRetry; - } - test(slave1Admin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Locator")) == info); - test(info.type == Ice::Locator::ice_staticId()); - endpoints = info.proxy->ice_getEndpoints(); - test(endpoints.size() == 2); - test(endpoints[0]->toString().find("-p 12050") != string::npos); - test(endpoints[1]->toString().find("-p 12051") != string::npos); - - info = masterAdmin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Query")); - nRetry = 0; - while(slave1Admin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Query")) != info && nRetry < 30) - { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - ++nRetry; - } - test(slave1Admin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Query")) == info); - test(info.type == IceGrid::Query::ice_staticId()); - endpoints = info.proxy->ice_getEndpoints(); - test(endpoints.size() == 2); - test(endpoints[0]->toString().find("-p 12050") != string::npos); - test(endpoints[1]->toString().find("-p 12051") != string::npos); - - QueryPrx query; - query = QueryPrx::uncheckedCast(comm->stringToProxy("TestIceGrid/Query:" + endpoints[0]->toString())); - Ice::ObjectProxySeq objs = query->findAllObjectsByType("::IceGrid::Registry"); - test(objs.size() == 2); - query = QueryPrx::uncheckedCast(comm->stringToProxy("TestIceGrid/Query:" + endpoints[1]->toString())); - test(objs == query->findAllObjectsByType("::IceGrid::Registry")); + Ice::EndpointSeq endpoints; + ObjectInfo info; + + info = masterAdmin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Locator")); + ObjectInfo info1 = slave1Admin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Locator")); + test(slave1Admin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Locator")) == info); + test(info.type == Ice::Locator::ice_staticId()); + endpoints = info.proxy->ice_getEndpoints(); + test(endpoints.size() == 2); + test(endpoints[0]->toString().find("-p 12050") != string::npos); + test(endpoints[1]->toString().find("-p 12051") != string::npos); + + info = masterAdmin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Query")); + test(slave1Admin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Query")) == info); + test(info.type == IceGrid::Query::ice_staticId()); + endpoints = info.proxy->ice_getEndpoints(); + test(endpoints.size() == 2); + test(endpoints[0]->toString().find("-p 12050") != string::npos); + test(endpoints[1]->toString().find("-p 12051") != string::npos); + + admin->startServer("Slave2"); + slave2Admin = createAdminSession(slave2Locator, "Slave2"); + + info = masterAdmin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Locator")); + // We eventually need to wait here for the update of the replicated objects to propagate to the replica. + int nRetry = 0; + while(slave1Admin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Locator")) != info && nRetry < 30) + { + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + ++nRetry; + } + test(slave2Admin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Locator")) == info); + test(info.type == Ice::Locator::ice_staticId()); + endpoints = info.proxy->ice_getEndpoints(); + test(endpoints.size() == 3); + test(endpoints[0]->toString().find("-p 12050") != string::npos); + test(endpoints[1]->toString().find("-p 12051") != string::npos); + test(endpoints[2]->toString().find("-p 12052") != string::npos); + + info = masterAdmin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Query")); + // We eventually need to wait here for the update of the replicated objects to propagate to the replica. + nRetry = 0; + while(slave1Admin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Query")) != info && nRetry < 30) + { + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + ++nRetry; + } + test(slave2Admin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Query")) == info); + test(info.type == IceGrid::Query::ice_staticId()); + endpoints = info.proxy->ice_getEndpoints(); + test(endpoints.size() == 3); + test(endpoints[0]->toString().find("-p 12050") != string::npos); + test(endpoints[1]->toString().find("-p 12051") != string::npos); + test(endpoints[2]->toString().find("-p 12052") != string::npos); + + slave2Admin->shutdown(); + waitForServerState(admin, "Slave2", false); + + info = masterAdmin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Locator")); + // We eventually need to wait here for the update of the replicated objects to propagate to the replica. + nRetry = 0; + while(slave1Admin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Locator")) != info && nRetry < 30) + { + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + ++nRetry; + } + test(slave1Admin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Locator")) == info); + test(info.type == Ice::Locator::ice_staticId()); + endpoints = info.proxy->ice_getEndpoints(); + test(endpoints.size() == 2); + test(endpoints[0]->toString().find("-p 12050") != string::npos); + test(endpoints[1]->toString().find("-p 12051") != string::npos); + + info = masterAdmin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Query")); + nRetry = 0; + while(slave1Admin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Query")) != info && nRetry < 30) + { + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + ++nRetry; + } + test(slave1Admin->getObjectInfo(comm->stringToIdentity("TestIceGrid/Query")) == info); + test(info.type == IceGrid::Query::ice_staticId()); + endpoints = info.proxy->ice_getEndpoints(); + test(endpoints.size() == 2); + test(endpoints[0]->toString().find("-p 12050") != string::npos); + test(endpoints[1]->toString().find("-p 12051") != string::npos); + + QueryPrx query; + query = QueryPrx::uncheckedCast(comm->stringToProxy("TestIceGrid/Query:" + endpoints[0]->toString())); + Ice::ObjectProxySeq objs = query->findAllObjectsByType("::IceGrid::Registry"); + test(objs.size() == 2); + query = QueryPrx::uncheckedCast(comm->stringToProxy("TestIceGrid/Query:" + endpoints[1]->toString())); + test(objs == query->findAllObjectsByType("::IceGrid::Registry")); } cout << "ok" << endl; cout << "testing well-known IceGrid objects... " << flush; { - // - // Test Registry well-known object (we have already tested - // admin session creation for the creation of the admin - // session above!) - // - RegistryPrx masterRegistry = RegistryPrx::checkedCast( - comm->stringToProxy("TestIceGrid/Registry")->ice_locator(replicatedLocator)); - RegistryPrx slave1Registry = RegistryPrx::checkedCast( - comm->stringToProxy("TestIceGrid/Registry-Slave1")->ice_locator(replicatedLocator)); - - SessionPrx session = masterRegistry->createSession("dummy", "dummy"); - session->destroy(); - if(comm->getProperties()->getProperty("Ice.Default.Protocol") == "ssl") - { - session = masterRegistry->createSessionFromSecureConnection(); - session->destroy(); - } - else - { - try - { - masterRegistry->createSessionFromSecureConnection(); - } - catch(const PermissionDeniedException&) - { - } - } - - try - { - slave1Registry->createSession("dummy", ""); - } - catch(const PermissionDeniedException&) - { - } - try - { - slave1Registry->createSessionFromSecureConnection(); - } - catch(const PermissionDeniedException&) - { - } - - // - // Test registry user-account mapper. - // - UserAccountMapperPrx masterMapper = UserAccountMapperPrx::checkedCast( - comm->stringToProxy("TestIceGrid/RegistryUserAccountMapper")->ice_locator(replicatedLocator)); - UserAccountMapperPrx slave1Mapper = UserAccountMapperPrx::checkedCast( - comm->stringToProxy("TestIceGrid/RegistryUserAccountMapper-Slave1")->ice_locator(replicatedLocator)); - - test(masterMapper->getUserAccount("Dummy User Account1") == "dummy1"); - test(masterMapper->getUserAccount("Dummy User Account2") == "dummy2"); - test(slave1Mapper->getUserAccount("Dummy User Account1") == "dummy1"); - test(slave1Mapper->getUserAccount("Dummy User Account2") == "dummy2"); - try - { - masterMapper->getUserAccount("unknown"); - test(false); - } - catch(UserAccountNotFoundException&) - { - } - try - { - slave1Mapper->getUserAccount("unknown"); - test(false); - } - catch(UserAccountNotFoundException&) - { - } - - // - // Test SessionManager, SSLSessionManager, - // AdminSessionManager, AdminSSLSessionManager - // - comm->stringToProxy("TestIceGrid/SessionManager")->ice_locator(replicatedLocator)->ice_ping(); - comm->stringToProxy("TestIceGrid/SSLSessionManager")->ice_locator(replicatedLocator)->ice_ping(); - try - { - comm->stringToProxy("TestIceGrid/SessionManager-Slave1")->ice_locator(replicatedLocator)->ice_ping(); - test(false); - } - catch(const Ice::NotRegisteredException&) - { - } - try - { - comm->stringToProxy("TestIceGrid/SSLSessionManager-Slave1")->ice_locator(replicatedLocator)->ice_ping(); - test(false); - } - catch(const Ice::NotRegisteredException&) - { - } - - comm->stringToProxy("TestIceGrid/AdminSessionManager")->ice_locator(replicatedLocator)->ice_ping(); - comm->stringToProxy("TestIceGrid/AdminSSLSessionManager")->ice_locator(replicatedLocator)->ice_ping(); - comm->stringToProxy("TestIceGrid/AdminSessionManager-Slave1")->ice_locator(replicatedLocator)->ice_ping(); - comm->stringToProxy("TestIceGrid/AdminSSLSessionManager-Slave1")->ice_locator(replicatedLocator)->ice_ping(); + // + // Test Registry well-known object (we have already tested + // admin session creation for the creation of the admin + // session above!) + // + RegistryPrx masterRegistry = RegistryPrx::checkedCast( + comm->stringToProxy("TestIceGrid/Registry")->ice_locator(replicatedLocator)); + RegistryPrx slave1Registry = RegistryPrx::checkedCast( + comm->stringToProxy("TestIceGrid/Registry-Slave1")->ice_locator(replicatedLocator)); + + SessionPrx session = masterRegistry->createSession("dummy", "dummy"); + session->destroy(); + if(comm->getProperties()->getProperty("Ice.Default.Protocol") == "ssl") + { + session = masterRegistry->createSessionFromSecureConnection(); + session->destroy(); + } + else + { + try + { + masterRegistry->createSessionFromSecureConnection(); + } + catch(const PermissionDeniedException&) + { + } + } + + try + { + slave1Registry->createSession("dummy", ""); + } + catch(const PermissionDeniedException&) + { + } + try + { + slave1Registry->createSessionFromSecureConnection(); + } + catch(const PermissionDeniedException&) + { + } + + // + // Test registry user-account mapper. + // + UserAccountMapperPrx masterMapper = UserAccountMapperPrx::checkedCast( + comm->stringToProxy("TestIceGrid/RegistryUserAccountMapper")->ice_locator(replicatedLocator)); + UserAccountMapperPrx slave1Mapper = UserAccountMapperPrx::checkedCast( + comm->stringToProxy("TestIceGrid/RegistryUserAccountMapper-Slave1")->ice_locator(replicatedLocator)); + + test(masterMapper->getUserAccount("Dummy User Account1") == "dummy1"); + test(masterMapper->getUserAccount("Dummy User Account2") == "dummy2"); + test(slave1Mapper->getUserAccount("Dummy User Account1") == "dummy1"); + test(slave1Mapper->getUserAccount("Dummy User Account2") == "dummy2"); + try + { + masterMapper->getUserAccount("unknown"); + test(false); + } + catch(UserAccountNotFoundException&) + { + } + try + { + slave1Mapper->getUserAccount("unknown"); + test(false); + } + catch(UserAccountNotFoundException&) + { + } + + // + // Test SessionManager, SSLSessionManager, + // AdminSessionManager, AdminSSLSessionManager + // + comm->stringToProxy("TestIceGrid/SessionManager")->ice_locator(replicatedLocator)->ice_ping(); + comm->stringToProxy("TestIceGrid/SSLSessionManager")->ice_locator(replicatedLocator)->ice_ping(); + try + { + comm->stringToProxy("TestIceGrid/SessionManager-Slave1")->ice_locator(replicatedLocator)->ice_ping(); + test(false); + } + catch(const Ice::NotRegisteredException&) + { + } + try + { + comm->stringToProxy("TestIceGrid/SSLSessionManager-Slave1")->ice_locator(replicatedLocator)->ice_ping(); + test(false); + } + catch(const Ice::NotRegisteredException&) + { + } + + comm->stringToProxy("TestIceGrid/AdminSessionManager")->ice_locator(replicatedLocator)->ice_ping(); + comm->stringToProxy("TestIceGrid/AdminSSLSessionManager")->ice_locator(replicatedLocator)->ice_ping(); + comm->stringToProxy("TestIceGrid/AdminSessionManager-Slave1")->ice_locator(replicatedLocator)->ice_ping(); + comm->stringToProxy("TestIceGrid/AdminSSLSessionManager-Slave1")->ice_locator(replicatedLocator)->ice_ping(); } cout << "ok" << endl; @@ -511,257 +511,257 @@ allTests(const Ice::CommunicatorPtr& comm) // cout << "testing registry updates... " << flush; { - ApplicationDescriptor app; - app.name = "TestApp"; - app.description = "added application"; - - AdapterInfo adpt; - adpt.id = "TestAdpt"; - adpt.proxy = comm->stringToProxy("dummy:tcp -p 12345 -h 127.0.0.1"); - - ObjectInfo obj; - obj.proxy = comm->stringToProxy("dummy:tcp -p 12345 -h 127.0.0.1"); - obj.type = "::Hello"; - - // - // We use the locator registry from Slave1 to ensure that the - // forwarding to the master work (the slave locator registry - // forwards everything to the master). - // - Ice::LocatorRegistryPrx locatorRegistry = slave1Locator->getRegistry(); - - // - // Test addition of application, adapter, object. - // - - try - { - slave1Admin->addApplication(app); - test(false); - } - catch(const DeploymentException&) - { - // Slave can't modify the database. - } - masterAdmin->addApplication(app); - - locatorRegistry->setAdapterDirectProxy(adpt.id, adpt.proxy); - - try - { - slave1Admin->addObjectWithType(obj.proxy, obj.type); - test(false); - } - catch(const DeploymentException&) - { - // Slave can't modify the database - } - masterAdmin->addObjectWithType(obj.proxy, obj.type); - - admin->startServer("Slave2"); - slave2Admin = createAdminSession(slave2Locator, "Slave2"); - - test(masterAdmin->getApplicationInfo("TestApp").descriptor.description == "added application"); - test(slave1Admin->getApplicationInfo("TestApp").descriptor.description == "added application"); - test(slave2Admin->getApplicationInfo("TestApp").descriptor.description == "added application"); - - test(masterAdmin->getAdapterInfo("TestAdpt")[0] == adpt); - test(slave1Admin->getAdapterInfo("TestAdpt")[0] == adpt); - test(slave2Admin->getAdapterInfo("TestAdpt")[0] == adpt); - - test(masterAdmin->getObjectInfo(obj.proxy->ice_getIdentity()) == obj); - test(slave1Admin->getObjectInfo(obj.proxy->ice_getIdentity()) == obj); - test(slave2Admin->getObjectInfo(obj.proxy->ice_getIdentity()) == obj); - - slave2Admin->shutdown(); - waitForServerState(admin, "Slave2", false); - - // - // Test sync of application. - // - - app.description = "updated1 application"; - try - { - slave1Admin->syncApplication(app); - test(false); - } - catch(const DeploymentException&) - { - // Slave can't modify the database. - } - masterAdmin->syncApplication(app); - - admin->startServer("Slave2"); - slave2Admin = createAdminSession(slave2Locator, "Slave2"); - test(masterAdmin->getApplicationInfo("TestApp").descriptor.description == "updated1 application"); - test(slave1Admin->getApplicationInfo("TestApp").descriptor.description == "updated1 application"); - test(slave2Admin->getApplicationInfo("TestApp").descriptor.description == "updated1 application"); - slave2Admin->shutdown(); - waitForServerState(admin, "Slave2", false); - - // - // Test update of application, adapter, object. - // - - ApplicationUpdateDescriptor appUpdate; - appUpdate.name = "TestApp"; - appUpdate.description = new BoxedString("updated2 application"); - try - { - slave1Admin->updateApplication(appUpdate); - test(false); - } - catch(const DeploymentException&) - { - // Slave can't modify the database. - } - masterAdmin->updateApplication(appUpdate); - - adpt.replicaGroupId = "TestReplicaGroup"; - locatorRegistry->setReplicatedAdapterDirectProxy(adpt.id, adpt.replicaGroupId, adpt.proxy); - - obj.proxy = comm->stringToProxy("dummy:tcp -p 12346 -h 127.0.0.1"); - try - { - slave1Admin->updateObject(obj.proxy); - test(false); - } - catch(const DeploymentException&) - { - // Slave can't modify the database - } - masterAdmin->updateObject(obj.proxy); - - admin->startServer("Slave2"); - slave2Admin = createAdminSession(slave2Locator, "Slave2"); - - test(masterAdmin->getApplicationInfo("TestApp").descriptor.description == "updated2 application"); - test(slave1Admin->getApplicationInfo("TestApp").descriptor.description == "updated2 application"); - test(slave2Admin->getApplicationInfo("TestApp").descriptor.description == "updated2 application"); - - test(masterAdmin->getAdapterInfo("TestAdpt")[0] == adpt); - test(slave1Admin->getAdapterInfo("TestAdpt")[0] == adpt); - test(slave2Admin->getAdapterInfo("TestAdpt")[0] == adpt); - - test(masterAdmin->getObjectInfo(obj.proxy->ice_getIdentity()) == obj); - test(slave1Admin->getObjectInfo(obj.proxy->ice_getIdentity()) == obj); - test(slave2Admin->getObjectInfo(obj.proxy->ice_getIdentity()) == obj); - - slave2Admin->shutdown(); - waitForServerState(admin, "Slave2", false); - - // - // Test removal of application, adapter and object. - - try - { - slave1Admin->removeApplication("TestApp"); - test(false); - } - catch(const DeploymentException&) - { - // Slave can't modify the database. - } - masterAdmin->removeApplication("TestApp"); - - try - { - slave1Admin->removeAdapter("TestAdpt"); - test(false); - } - catch(const DeploymentException&) - { - // Slave can't modify the database. - } - masterAdmin->removeAdapter("TestAdpt"); - try - { - slave1Admin->removeObject(obj.proxy->ice_getIdentity()); - } - catch(const DeploymentException&) - { - // Slave can't modify the database. - } - masterAdmin->removeObject(obj.proxy->ice_getIdentity()); - - admin->startServer("Slave2"); - slave2Admin = createAdminSession(slave2Locator, "Slave2"); - try - { - masterAdmin->getApplicationInfo("TestApp"); - test(false); - } - catch(const ApplicationNotExistException&) - { - } - try - { - slave1Admin->getApplicationInfo("TestApp"); - test(false); - } - catch(const ApplicationNotExistException&) - { - } - try - { - slave2Admin->getApplicationInfo("TestApp"); - test(false); - } - catch(const ApplicationNotExistException&) - { - } - try - { - masterAdmin->getAdapterInfo("TestAdpt"); - test(false); - } - catch(const AdapterNotExistException&) - { - } - try - { - slave1Admin->getAdapterInfo("TestAdpt"); - test(false); - } - catch(const AdapterNotExistException&) - { - } - try - { - slave2Admin->getAdapterInfo("TestAdpt"); - test(false); - } - catch(const AdapterNotExistException&) - { - } - try - { - masterAdmin->getObjectInfo(obj.proxy->ice_getIdentity()); - test(false); - } - catch(const ObjectNotRegisteredException&) - { - } - try - { - slave1Admin->getObjectInfo(obj.proxy->ice_getIdentity()); - test(false); - } - catch(const ObjectNotRegisteredException&) - { - } - try - { - slave2Admin->getObjectInfo(obj.proxy->ice_getIdentity()); - test(false); - } - catch(const ObjectNotRegisteredException&) - { - } - - slave2Admin->shutdown(); - waitForServerState(admin, "Slave2", false); + ApplicationDescriptor app; + app.name = "TestApp"; + app.description = "added application"; + + AdapterInfo adpt; + adpt.id = "TestAdpt"; + adpt.proxy = comm->stringToProxy("dummy:tcp -p 12345 -h 127.0.0.1"); + + ObjectInfo obj; + obj.proxy = comm->stringToProxy("dummy:tcp -p 12345 -h 127.0.0.1"); + obj.type = "::Hello"; + + // + // We use the locator registry from Slave1 to ensure that the + // forwarding to the master work (the slave locator registry + // forwards everything to the master). + // + Ice::LocatorRegistryPrx locatorRegistry = slave1Locator->getRegistry(); + + // + // Test addition of application, adapter, object. + // + + try + { + slave1Admin->addApplication(app); + test(false); + } + catch(const DeploymentException&) + { + // Slave can't modify the database. + } + masterAdmin->addApplication(app); + + locatorRegistry->setAdapterDirectProxy(adpt.id, adpt.proxy); + + try + { + slave1Admin->addObjectWithType(obj.proxy, obj.type); + test(false); + } + catch(const DeploymentException&) + { + // Slave can't modify the database + } + masterAdmin->addObjectWithType(obj.proxy, obj.type); + + admin->startServer("Slave2"); + slave2Admin = createAdminSession(slave2Locator, "Slave2"); + + test(masterAdmin->getApplicationInfo("TestApp").descriptor.description == "added application"); + test(slave1Admin->getApplicationInfo("TestApp").descriptor.description == "added application"); + test(slave2Admin->getApplicationInfo("TestApp").descriptor.description == "added application"); + + test(masterAdmin->getAdapterInfo("TestAdpt")[0] == adpt); + test(slave1Admin->getAdapterInfo("TestAdpt")[0] == adpt); + test(slave2Admin->getAdapterInfo("TestAdpt")[0] == adpt); + + test(masterAdmin->getObjectInfo(obj.proxy->ice_getIdentity()) == obj); + test(slave1Admin->getObjectInfo(obj.proxy->ice_getIdentity()) == obj); + test(slave2Admin->getObjectInfo(obj.proxy->ice_getIdentity()) == obj); + + slave2Admin->shutdown(); + waitForServerState(admin, "Slave2", false); + + // + // Test sync of application. + // + + app.description = "updated1 application"; + try + { + slave1Admin->syncApplication(app); + test(false); + } + catch(const DeploymentException&) + { + // Slave can't modify the database. + } + masterAdmin->syncApplication(app); + + admin->startServer("Slave2"); + slave2Admin = createAdminSession(slave2Locator, "Slave2"); + test(masterAdmin->getApplicationInfo("TestApp").descriptor.description == "updated1 application"); + test(slave1Admin->getApplicationInfo("TestApp").descriptor.description == "updated1 application"); + test(slave2Admin->getApplicationInfo("TestApp").descriptor.description == "updated1 application"); + slave2Admin->shutdown(); + waitForServerState(admin, "Slave2", false); + + // + // Test update of application, adapter, object. + // + + ApplicationUpdateDescriptor appUpdate; + appUpdate.name = "TestApp"; + appUpdate.description = new BoxedString("updated2 application"); + try + { + slave1Admin->updateApplication(appUpdate); + test(false); + } + catch(const DeploymentException&) + { + // Slave can't modify the database. + } + masterAdmin->updateApplication(appUpdate); + + adpt.replicaGroupId = "TestReplicaGroup"; + locatorRegistry->setReplicatedAdapterDirectProxy(adpt.id, adpt.replicaGroupId, adpt.proxy); + + obj.proxy = comm->stringToProxy("dummy:tcp -p 12346 -h 127.0.0.1"); + try + { + slave1Admin->updateObject(obj.proxy); + test(false); + } + catch(const DeploymentException&) + { + // Slave can't modify the database + } + masterAdmin->updateObject(obj.proxy); + + admin->startServer("Slave2"); + slave2Admin = createAdminSession(slave2Locator, "Slave2"); + + test(masterAdmin->getApplicationInfo("TestApp").descriptor.description == "updated2 application"); + test(slave1Admin->getApplicationInfo("TestApp").descriptor.description == "updated2 application"); + test(slave2Admin->getApplicationInfo("TestApp").descriptor.description == "updated2 application"); + + test(masterAdmin->getAdapterInfo("TestAdpt")[0] == adpt); + test(slave1Admin->getAdapterInfo("TestAdpt")[0] == adpt); + test(slave2Admin->getAdapterInfo("TestAdpt")[0] == adpt); + + test(masterAdmin->getObjectInfo(obj.proxy->ice_getIdentity()) == obj); + test(slave1Admin->getObjectInfo(obj.proxy->ice_getIdentity()) == obj); + test(slave2Admin->getObjectInfo(obj.proxy->ice_getIdentity()) == obj); + + slave2Admin->shutdown(); + waitForServerState(admin, "Slave2", false); + + // + // Test removal of application, adapter and object. + + try + { + slave1Admin->removeApplication("TestApp"); + test(false); + } + catch(const DeploymentException&) + { + // Slave can't modify the database. + } + masterAdmin->removeApplication("TestApp"); + + try + { + slave1Admin->removeAdapter("TestAdpt"); + test(false); + } + catch(const DeploymentException&) + { + // Slave can't modify the database. + } + masterAdmin->removeAdapter("TestAdpt"); + try + { + slave1Admin->removeObject(obj.proxy->ice_getIdentity()); + } + catch(const DeploymentException&) + { + // Slave can't modify the database. + } + masterAdmin->removeObject(obj.proxy->ice_getIdentity()); + + admin->startServer("Slave2"); + slave2Admin = createAdminSession(slave2Locator, "Slave2"); + try + { + masterAdmin->getApplicationInfo("TestApp"); + test(false); + } + catch(const ApplicationNotExistException&) + { + } + try + { + slave1Admin->getApplicationInfo("TestApp"); + test(false); + } + catch(const ApplicationNotExistException&) + { + } + try + { + slave2Admin->getApplicationInfo("TestApp"); + test(false); + } + catch(const ApplicationNotExistException&) + { + } + try + { + masterAdmin->getAdapterInfo("TestAdpt"); + test(false); + } + catch(const AdapterNotExistException&) + { + } + try + { + slave1Admin->getAdapterInfo("TestAdpt"); + test(false); + } + catch(const AdapterNotExistException&) + { + } + try + { + slave2Admin->getAdapterInfo("TestAdpt"); + test(false); + } + catch(const AdapterNotExistException&) + { + } + try + { + masterAdmin->getObjectInfo(obj.proxy->ice_getIdentity()); + test(false); + } + catch(const ObjectNotRegisteredException&) + { + } + try + { + slave1Admin->getObjectInfo(obj.proxy->ice_getIdentity()); + test(false); + } + catch(const ObjectNotRegisteredException&) + { + } + try + { + slave2Admin->getObjectInfo(obj.proxy->ice_getIdentity()); + test(false); + } + catch(const ObjectNotRegisteredException&) + { + } + + slave2Admin->shutdown(); + waitForServerState(admin, "Slave2", false); } cout << "ok" << endl; @@ -779,12 +779,12 @@ allTests(const Ice::CommunicatorPtr& comm) app.nodes["Node1"].description = "dummy node"; try { - masterAdmin->addApplication(app); + masterAdmin->addApplication(app); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - test(false); + cerr << ex << endl; + test(false); } // @@ -800,104 +800,104 @@ allTests(const Ice::CommunicatorPtr& comm) // cout << "testing node session establishment... " << flush; { - admin->startServer("Node1"); - - waitForNodeState(masterAdmin, "Node1", true); - waitForNodeState(slave1Admin, "Node1", true); - - admin->startServer("Slave2"); - slave2Admin = createAdminSession(slave2Locator, "Slave2"); - - waitForNodeState(slave2Admin, "Node1", true); // Node should connect. - - slave1Admin->shutdown(); - waitForServerState(admin, "Slave1", false); - admin->startServer("Slave1"); - slave1Admin = createAdminSession(slave1Locator, "Slave1"); - - try - { - test(slave1Admin->pingNode("Node1")); // Node should be re-connected. - } - catch(const NodeNotExistException&) - { - test(false); - } - - masterAdmin->shutdown(); - waitForServerState(admin, "Master", false); - - slave2Admin->shutdown(); - waitForServerState(admin, "Slave2", false); - admin->startServer("Slave2"); - slave2Admin = createAdminSession(slave2Locator, "Slave2"); - - try - { - test(slave2Admin->pingNode("Node1")); // Node should be re-connected even if the master is down. - } - catch(const NodeNotExistException&) - { - test(false); - } - - slave1Admin->shutdown(); - waitForServerState(admin, "Slave1", false); - - admin->startServer("Master"); - masterAdmin = createAdminSession(masterLocator, ""); - - try - { - test(masterAdmin->pingNode("Node1")); // Node should be re-connected. - } - catch(const NodeNotExistException&) - { - test(false); - } - - admin->startServer("Slave1"); - slave1Admin = createAdminSession(slave1Locator, "Slave1"); - - try - { - test(slave1Admin->pingNode("Node1")); // Node should be re-connected. - } - catch(const NodeNotExistException&) - { - test(false); - } - - try - { - test(masterAdmin->pingNode("Node1")); - } - catch(const NodeNotExistException&) - { - test(false); - } - - try - { - test(slave2Admin->pingNode("Node1")); - } - catch(const NodeNotExistException&) - { - test(false); - } - - slave2Admin->shutdown(); - waitForServerState(admin, "Slave2", false); - admin->startServer("Slave2"); - slave2Admin = createAdminSession(slave2Locator, "Slave2"); - try - { - test(slave2Admin->pingNode("Node1")); - } - catch(const NodeNotExistException&) - { - test(false); - } + admin->startServer("Node1"); + + waitForNodeState(masterAdmin, "Node1", true); + waitForNodeState(slave1Admin, "Node1", true); + + admin->startServer("Slave2"); + slave2Admin = createAdminSession(slave2Locator, "Slave2"); + + waitForNodeState(slave2Admin, "Node1", true); // Node should connect. + + slave1Admin->shutdown(); + waitForServerState(admin, "Slave1", false); + admin->startServer("Slave1"); + slave1Admin = createAdminSession(slave1Locator, "Slave1"); + + try + { + test(slave1Admin->pingNode("Node1")); // Node should be re-connected. + } + catch(const NodeNotExistException&) + { + test(false); + } + + masterAdmin->shutdown(); + waitForServerState(admin, "Master", false); + + slave2Admin->shutdown(); + waitForServerState(admin, "Slave2", false); + admin->startServer("Slave2"); + slave2Admin = createAdminSession(slave2Locator, "Slave2"); + + try + { + test(slave2Admin->pingNode("Node1")); // Node should be re-connected even if the master is down. + } + catch(const NodeNotExistException&) + { + test(false); + } + + slave1Admin->shutdown(); + waitForServerState(admin, "Slave1", false); + + admin->startServer("Master"); + masterAdmin = createAdminSession(masterLocator, ""); + + try + { + test(masterAdmin->pingNode("Node1")); // Node should be re-connected. + } + catch(const NodeNotExistException&) + { + test(false); + } + + admin->startServer("Slave1"); + slave1Admin = createAdminSession(slave1Locator, "Slave1"); + + try + { + test(slave1Admin->pingNode("Node1")); // Node should be re-connected. + } + catch(const NodeNotExistException&) + { + test(false); + } + + try + { + test(masterAdmin->pingNode("Node1")); + } + catch(const NodeNotExistException&) + { + test(false); + } + + try + { + test(slave2Admin->pingNode("Node1")); + } + catch(const NodeNotExistException&) + { + test(false); + } + + slave2Admin->shutdown(); + waitForServerState(admin, "Slave2", false); + admin->startServer("Slave2"); + slave2Admin = createAdminSession(slave2Locator, "Slave2"); + try + { + test(slave2Admin->pingNode("Node1")); + } + catch(const NodeNotExistException&) + { + test(false); + } } cout << "ok" << endl; @@ -906,267 +906,267 @@ allTests(const Ice::CommunicatorPtr& comm) // cout << "testing out-of-date replicas... " << flush; { - ApplicationDescriptor app; - app.name = "TestApp"; - app.description = "added application"; - - ServerDescriptorPtr server = new ServerDescriptor(); - server->id = "Server"; - server->exe = comm->getProperties()->getProperty("TestDir") + "/server"; - server->pwd = "."; - server->activation = "on-demand"; - AdapterDescriptor adapter; - adapter.name = "TestAdapter"; - adapter.id = "TestAdapter.Server"; - adapter.registerProcess = true; - PropertyDescriptor property; - property.name = "Ice.OA.TestAdapter.Endpoints"; - property.value = "default"; - server->propertySet.properties.push_back(property); - property.name = "Identity"; - property.value = "test"; - server->propertySet.properties.push_back(property); - ObjectDescriptor object; - object.id = comm->stringToIdentity("test"); - object.type = "::Test::TestIntf"; - adapter.objects.push_back(object); - server->adapters.push_back(adapter); - app.nodes["Node1"].servers.push_back(server); - - masterAdmin->addApplication(app); - - comm->stringToProxy("test")->ice_locator(masterLocator)->ice_locatorCacheTimeout(0)->ice_ping(); - comm->stringToProxy("test")->ice_locator(slave1Locator)->ice_locatorCacheTimeout(0)->ice_ping(); - comm->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); - masterAdmin->stopServer("Server"); - - // - // Shutdown Slave2 and update application. - // - slave2Admin->shutdown(); - waitForServerState(admin, "Slave2", false); - - ApplicationUpdateDescriptor update; - update.name = "TestApp"; - NodeUpdateDescriptor node; - node.name = "Node1"; - node.servers.push_back(server); - update.nodes.push_back(node); - property.name = "Dummy"; - property.value = "val"; - server->propertySet.properties.push_back(property); - masterAdmin->updateApplication(update); - - comm->stringToProxy("test")->ice_locator(masterLocator)->ice_locatorCacheTimeout(0)->ice_ping(); - comm->stringToProxy("test")->ice_locator(slave1Locator)->ice_locatorCacheTimeout(0)->ice_ping(); - - masterAdmin->shutdown(); - waitForServerState(admin, "Master", false); - - admin->startServer("Slave2"); - slave2Admin = createAdminSession(slave2Locator, "Slave2"); - try - { - slave2Admin->startServer("Server"); - test(false); - } - catch(const DeploymentException&) - { - } - try - { - comm->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); - test(false); - } - catch(const Ice::NoEndpointException&) - { - } - - admin->startServer("Master"); - masterAdmin = createAdminSession(masterLocator, ""); - - slave2Admin->shutdown(); - waitForServerState(admin, "Slave2", false); - admin->startServer("Slave2"); - slave2Admin = createAdminSession(slave2Locator, "Slave2"); - - comm->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); - - // - // Shutdown Node1 and update the application, then, shutdown - // the master. - // - slave1Admin->shutdownNode("Node1"); - waitForServerState(admin, "Node1", false); - - slave2Admin->shutdown(); - waitForServerState(admin, "Slave2", false); - - property.name = "Dummy2"; - property.value = "val"; - server->propertySet.properties.push_back(property); - masterAdmin->updateApplication(update); - - masterAdmin->shutdown(); - waitForServerState(admin, "Master", false); - - // - // Restart Node1 and Slave2, Slave2 still has the old version - // of the server so it should be able to load it. Slave1 has - // a more recent version, so it can't load it. - // - admin->startServer("Slave2"); - slave2Admin = createAdminSession(slave2Locator, "Slave2"); - - admin->startServer("Node1"); - - waitForNodeState(slave2Admin, "Node1", true); - - slave1Admin->shutdown(); - waitForServerState(admin, "Slave1", false); - - comm->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); - - admin->startServer("Slave1"); - slave1Admin = createAdminSession(slave1Locator, "Slave1"); - - try - { - comm->stringToProxy("test")->ice_locator(slave1Locator)->ice_locatorCacheTimeout(0)->ice_ping(); - } - catch(const Ice::NoEndpointException&) - { - } - - comm->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); - slave2Admin->stopServer("Server"); - - // - // Start the master. This will re-load the server on the node - // and update the out-of-date replicas. - // - admin->startServer("Master"); - masterAdmin = createAdminSession(masterLocator, ""); - - slave1Admin->shutdown(); - waitForServerState(admin, "Slave1", false); - admin->startServer("Slave1"); - slave1Admin = createAdminSession(slave1Locator, "Slave1"); - - slave2Admin->shutdownNode("Node1"); - waitForServerState(admin, "Node1", false); - admin->startServer("Node1"); - - slave2Admin->shutdown(); - waitForServerState(admin, "Slave2", false); - admin->startServer("Slave2"); - slave2Admin = createAdminSession(slave2Locator, "Slave2"); - - waitForNodeState(masterAdmin, "Node1", true); - waitForNodeState(slave1Admin, "Node1", true); - waitForNodeState(slave2Admin, "Node1", true); - - comm->stringToProxy("test")->ice_locator(masterLocator)->ice_locatorCacheTimeout(0)->ice_ping(); - comm->stringToProxy("test")->ice_locator(slave1Locator)->ice_locatorCacheTimeout(0)->ice_ping(); - comm->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); - - slave2Admin->stopServer("Server"); - - masterAdmin->removeApplication("TestApp"); + ApplicationDescriptor app; + app.name = "TestApp"; + app.description = "added application"; + + ServerDescriptorPtr server = new ServerDescriptor(); + server->id = "Server"; + server->exe = comm->getProperties()->getProperty("TestDir") + "/server"; + server->pwd = "."; + server->activation = "on-demand"; + AdapterDescriptor adapter; + adapter.name = "TestAdapter"; + adapter.id = "TestAdapter.Server"; + adapter.registerProcess = true; + PropertyDescriptor property; + property.name = "Ice.OA.TestAdapter.Endpoints"; + property.value = "default"; + server->propertySet.properties.push_back(property); + property.name = "Identity"; + property.value = "test"; + server->propertySet.properties.push_back(property); + ObjectDescriptor object; + object.id = comm->stringToIdentity("test"); + object.type = "::Test::TestIntf"; + adapter.objects.push_back(object); + server->adapters.push_back(adapter); + app.nodes["Node1"].servers.push_back(server); + + masterAdmin->addApplication(app); + + comm->stringToProxy("test")->ice_locator(masterLocator)->ice_locatorCacheTimeout(0)->ice_ping(); + comm->stringToProxy("test")->ice_locator(slave1Locator)->ice_locatorCacheTimeout(0)->ice_ping(); + comm->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); + masterAdmin->stopServer("Server"); + + // + // Shutdown Slave2 and update application. + // + slave2Admin->shutdown(); + waitForServerState(admin, "Slave2", false); + + ApplicationUpdateDescriptor update; + update.name = "TestApp"; + NodeUpdateDescriptor node; + node.name = "Node1"; + node.servers.push_back(server); + update.nodes.push_back(node); + property.name = "Dummy"; + property.value = "val"; + server->propertySet.properties.push_back(property); + masterAdmin->updateApplication(update); + + comm->stringToProxy("test")->ice_locator(masterLocator)->ice_locatorCacheTimeout(0)->ice_ping(); + comm->stringToProxy("test")->ice_locator(slave1Locator)->ice_locatorCacheTimeout(0)->ice_ping(); + + masterAdmin->shutdown(); + waitForServerState(admin, "Master", false); + + admin->startServer("Slave2"); + slave2Admin = createAdminSession(slave2Locator, "Slave2"); + try + { + slave2Admin->startServer("Server"); + test(false); + } + catch(const DeploymentException&) + { + } + try + { + comm->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); + test(false); + } + catch(const Ice::NoEndpointException&) + { + } + + admin->startServer("Master"); + masterAdmin = createAdminSession(masterLocator, ""); + + slave2Admin->shutdown(); + waitForServerState(admin, "Slave2", false); + admin->startServer("Slave2"); + slave2Admin = createAdminSession(slave2Locator, "Slave2"); + + comm->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); + + // + // Shutdown Node1 and update the application, then, shutdown + // the master. + // + slave1Admin->shutdownNode("Node1"); + waitForServerState(admin, "Node1", false); + + slave2Admin->shutdown(); + waitForServerState(admin, "Slave2", false); + + property.name = "Dummy2"; + property.value = "val"; + server->propertySet.properties.push_back(property); + masterAdmin->updateApplication(update); + + masterAdmin->shutdown(); + waitForServerState(admin, "Master", false); + + // + // Restart Node1 and Slave2, Slave2 still has the old version + // of the server so it should be able to load it. Slave1 has + // a more recent version, so it can't load it. + // + admin->startServer("Slave2"); + slave2Admin = createAdminSession(slave2Locator, "Slave2"); + + admin->startServer("Node1"); + + waitForNodeState(slave2Admin, "Node1", true); + + slave1Admin->shutdown(); + waitForServerState(admin, "Slave1", false); + + comm->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); + + admin->startServer("Slave1"); + slave1Admin = createAdminSession(slave1Locator, "Slave1"); + + try + { + comm->stringToProxy("test")->ice_locator(slave1Locator)->ice_locatorCacheTimeout(0)->ice_ping(); + } + catch(const Ice::NoEndpointException&) + { + } + + comm->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); + slave2Admin->stopServer("Server"); + + // + // Start the master. This will re-load the server on the node + // and update the out-of-date replicas. + // + admin->startServer("Master"); + masterAdmin = createAdminSession(masterLocator, ""); + + slave1Admin->shutdown(); + waitForServerState(admin, "Slave1", false); + admin->startServer("Slave1"); + slave1Admin = createAdminSession(slave1Locator, "Slave1"); + + slave2Admin->shutdownNode("Node1"); + waitForServerState(admin, "Node1", false); + admin->startServer("Node1"); + + slave2Admin->shutdown(); + waitForServerState(admin, "Slave2", false); + admin->startServer("Slave2"); + slave2Admin = createAdminSession(slave2Locator, "Slave2"); + + waitForNodeState(masterAdmin, "Node1", true); + waitForNodeState(slave1Admin, "Node1", true); + waitForNodeState(slave2Admin, "Node1", true); + + comm->stringToProxy("test")->ice_locator(masterLocator)->ice_locatorCacheTimeout(0)->ice_ping(); + comm->stringToProxy("test")->ice_locator(slave1Locator)->ice_locatorCacheTimeout(0)->ice_ping(); + comm->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); + + slave2Admin->stopServer("Server"); + + masterAdmin->removeApplication("TestApp"); } cout << "ok" << endl; cout << "testing master upgrade... " << flush; { - ApplicationDescriptor app; - app.name = "TestApp"; - app.description = "added application"; - - ServerDescriptorPtr server = new ServerDescriptor(); - server->id = "Server"; - server->exe = comm->getProperties()->getProperty("TestDir") + "/server"; - server->pwd = "."; - server->activation = "on-demand"; - AdapterDescriptor adapter; - adapter.name = "TestAdapter"; - adapter.id = "TestAdapter.Server"; - adapter.registerProcess = true; - PropertyDescriptor property; - property.name = "Ice.OA.TestAdapter.Endpoints"; - property.value = "default"; - server->propertySet.properties.push_back(property); - property.name = "Identity"; - property.value = "test"; - server->propertySet.properties.push_back(property); - ObjectDescriptor object; - object.id = comm->stringToIdentity("test"); - object.type = "::Test::TestIntf"; - adapter.objects.push_back(object); - server->adapters.push_back(adapter); - app.nodes["Node1"].servers.push_back(server); - - masterAdmin->addApplication(app); - - comm->stringToProxy("test")->ice_locator(masterLocator)->ice_locatorCacheTimeout(0)->ice_ping(); - comm->stringToProxy("test")->ice_locator(slave1Locator)->ice_locatorCacheTimeout(0)->ice_ping(); - comm->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); - masterAdmin->stopServer("Server"); - - // - // Shutdown the Master, update Slave1 to be the Master. - // - masterAdmin->shutdown(); - waitForServerState(admin, "Master", false); - slave1Admin->shutdown(); - waitForServerState(admin, "Slave1", false); - - params["id"] = "Slave1"; - params["port"] = "12051"; - params["replicaName"] = "Master"; - instantiateServer(admin, "IceGridRegistry", params); - - admin->startServer("Slave1"); - slave1Locator = - Ice::LocatorPrx::uncheckedCast(comm->stringToProxy("TestIceGrid/Locator-Master:default -p 12051")); - slave1Admin = createAdminSession(slave1Locator, ""); - - ApplicationUpdateDescriptor update; - update.name = "TestApp"; - NodeUpdateDescriptor node; - node.name = "Node1"; - node.servers.push_back(server); - update.nodes.push_back(node); - property.name = "Dummy"; - property.value = "val"; - server->propertySet.properties.push_back(property); - slave1Admin->updateApplication(update); - - comm->stringToProxy("test")->ice_locator(slave1Locator)->ice_locatorCacheTimeout(0)->ice_ping(); - comm->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); - - slave1Admin->shutdown(); - waitForServerState(admin, "Slave1", false); - - params["id"] = "Slave1"; - params["replicaName"] = "Slave1"; - params["port"] = "12051"; - instantiateServer(admin, "IceGridRegistry", params); - - admin->startServer("Master"); - masterAdmin = createAdminSession(masterLocator, ""); - - admin->startServer("Slave1"); - slave1Locator = - Ice::LocatorPrx::uncheckedCast(comm->stringToProxy("TestIceGrid/Locator-Slave1:default -p 12051")); - slave1Admin = createAdminSession(slave1Locator, "Slave1"); - - comm->stringToProxy("test")->ice_locator(masterLocator)->ice_locatorCacheTimeout(0)->ice_ping(); - comm->stringToProxy("test")->ice_locator(slave1Locator)->ice_locatorCacheTimeout(0)->ice_ping(); - comm->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); - - masterAdmin->stopServer("Server"); - - masterAdmin->removeApplication("TestApp"); + ApplicationDescriptor app; + app.name = "TestApp"; + app.description = "added application"; + + ServerDescriptorPtr server = new ServerDescriptor(); + server->id = "Server"; + server->exe = comm->getProperties()->getProperty("TestDir") + "/server"; + server->pwd = "."; + server->activation = "on-demand"; + AdapterDescriptor adapter; + adapter.name = "TestAdapter"; + adapter.id = "TestAdapter.Server"; + adapter.registerProcess = true; + PropertyDescriptor property; + property.name = "Ice.OA.TestAdapter.Endpoints"; + property.value = "default"; + server->propertySet.properties.push_back(property); + property.name = "Identity"; + property.value = "test"; + server->propertySet.properties.push_back(property); + ObjectDescriptor object; + object.id = comm->stringToIdentity("test"); + object.type = "::Test::TestIntf"; + adapter.objects.push_back(object); + server->adapters.push_back(adapter); + app.nodes["Node1"].servers.push_back(server); + + masterAdmin->addApplication(app); + + comm->stringToProxy("test")->ice_locator(masterLocator)->ice_locatorCacheTimeout(0)->ice_ping(); + comm->stringToProxy("test")->ice_locator(slave1Locator)->ice_locatorCacheTimeout(0)->ice_ping(); + comm->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); + masterAdmin->stopServer("Server"); + + // + // Shutdown the Master, update Slave1 to be the Master. + // + masterAdmin->shutdown(); + waitForServerState(admin, "Master", false); + slave1Admin->shutdown(); + waitForServerState(admin, "Slave1", false); + + params["id"] = "Slave1"; + params["port"] = "12051"; + params["replicaName"] = "Master"; + instantiateServer(admin, "IceGridRegistry", params); + + admin->startServer("Slave1"); + slave1Locator = + Ice::LocatorPrx::uncheckedCast(comm->stringToProxy("TestIceGrid/Locator-Master:default -p 12051")); + slave1Admin = createAdminSession(slave1Locator, ""); + + ApplicationUpdateDescriptor update; + update.name = "TestApp"; + NodeUpdateDescriptor node; + node.name = "Node1"; + node.servers.push_back(server); + update.nodes.push_back(node); + property.name = "Dummy"; + property.value = "val"; + server->propertySet.properties.push_back(property); + slave1Admin->updateApplication(update); + + comm->stringToProxy("test")->ice_locator(slave1Locator)->ice_locatorCacheTimeout(0)->ice_ping(); + comm->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); + + slave1Admin->shutdown(); + waitForServerState(admin, "Slave1", false); + + params["id"] = "Slave1"; + params["replicaName"] = "Slave1"; + params["port"] = "12051"; + instantiateServer(admin, "IceGridRegistry", params); + + admin->startServer("Master"); + masterAdmin = createAdminSession(masterLocator, ""); + + admin->startServer("Slave1"); + slave1Locator = + Ice::LocatorPrx::uncheckedCast(comm->stringToProxy("TestIceGrid/Locator-Slave1:default -p 12051")); + slave1Admin = createAdminSession(slave1Locator, "Slave1"); + + comm->stringToProxy("test")->ice_locator(masterLocator)->ice_locatorCacheTimeout(0)->ice_ping(); + comm->stringToProxy("test")->ice_locator(slave1Locator)->ice_locatorCacheTimeout(0)->ice_ping(); + comm->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); + + masterAdmin->stopServer("Server"); + + masterAdmin->removeApplication("TestApp"); } cout << "ok" << endl; diff --git a/cpp/test/IceGrid/replication/Client.cpp b/cpp/test/IceGrid/replication/Client.cpp index cf34f395e60..0d5fbf4b5bd 100644 --- a/cpp/test/IceGrid/replication/Client.cpp +++ b/cpp/test/IceGrid/replication/Client.cpp @@ -29,27 +29,27 @@ main(int argc, char* argv[]) try { - communicator = Ice::initialize(argc, argv); - communicator->getProperties()->parseCommandLineOptions("", Ice::argsToStringSeq(argc, argv)); - status = run(argc, argv, communicator); + communicator = Ice::initialize(argc, argv); + communicator->getProperties()->parseCommandLineOptions("", Ice::argsToStringSeq(argc, argv)); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/IceGrid/session/AllTests.cpp b/cpp/test/IceGrid/session/AllTests.cpp index 73cb564752f..75b2e6b6031 100644 --- a/cpp/test/IceGrid/session/AllTests.cpp +++ b/cpp/test/IceGrid/session/AllTests.cpp @@ -34,51 +34,51 @@ class SessionKeepAliveThread : public IceUtil::Thread, public IceUtil::Monitor<I public: SessionKeepAliveThread(const Ice::LoggerPtr& logger, const IceUtil::Time& timeout) : - _logger(logger), - _timeout(timeout), - _terminated(false) + _logger(logger), + _timeout(timeout), + _terminated(false) { } virtual void run() { - Lock sync(*this); - while(!_terminated) - { - timedWait(_timeout); - if(!_terminated) - { - vector<AdminSessionPrx>::iterator p = _sessions.begin(); - while(p != _sessions.end()) - { - try - { - (*p)->keepAlive(); - ++p; - } - catch(const Ice::Exception&) - { - p = _sessions.erase(p); - } - } - } - } + Lock sync(*this); + while(!_terminated) + { + timedWait(_timeout); + if(!_terminated) + { + vector<AdminSessionPrx>::iterator p = _sessions.begin(); + while(p != _sessions.end()) + { + try + { + (*p)->keepAlive(); + ++p; + } + catch(const Ice::Exception&) + { + p = _sessions.erase(p); + } + } + } + } } void add(const AdminSessionPrx& session) { - Lock sync(*this); - _sessions.push_back(session); + Lock sync(*this); + _sessions.push_back(session); } void terminate() { - Lock sync(*this); - _terminated = true; - notify(); + Lock sync(*this); + _terminated = true; + notify(); } private: @@ -96,59 +96,59 @@ public: ObserverBase(const string& name) : _name(name), _updated(0) { - _observers.insert(make_pair(name, this)); + _observers.insert(make_pair(name, this)); } virtual ~ObserverBase() { - _observers.erase(_name); + _observers.erase(_name); } static void printStack() { - map<string, ObserverBase*>::const_iterator p; - for(p = _observers.begin(); p != _observers.end(); ++p) - { - vector<string>::const_iterator q = p->second->_stack.begin(); - if(p->second->_stack.size() > 10) - { - q = p->second->_stack.begin() + p->second->_stack.size() - 10; - } - cerr << "Last 10 updates of observer `" << p->second->_name << "':" << endl; - for(; q != p->second->_stack.end(); ++q) - { - cerr << " " << *q << endl; - } - p->second->_stack.clear(); - } + map<string, ObserverBase*>::const_iterator p; + for(p = _observers.begin(); p != _observers.end(); ++p) + { + vector<string>::const_iterator q = p->second->_stack.begin(); + if(p->second->_stack.size() > 10) + { + q = p->second->_stack.begin() + p->second->_stack.size() - 10; + } + cerr << "Last 10 updates of observer `" << p->second->_name << "':" << endl; + for(; q != p->second->_stack.end(); ++q) + { + cerr << " " << *q << endl; + } + p->second->_stack.clear(); + } } void trace(const string& msg) { - _stack.push_back(msg); + _stack.push_back(msg); } void waitForUpdate(const char* file, int line) { - Lock sync(*this); - - ostringstream os; - os << "wait for update from line " << line; - trace(os.str()); - - while(!_updated) - { - if(!timedWait(IceUtil::Time::seconds(10))) - { - cerr << "timeout: " << file << ":" << line << endl; - ObserverBase::printStack(); - test(false); // Timeout - } - } - --_updated; + Lock sync(*this); + + ostringstream os; + os << "wait for update from line " << line; + trace(os.str()); + + while(!_updated) + { + if(!timedWait(IceUtil::Time::seconds(10))) + { + cerr << "timeout: " << file << ":" << line << endl; + ObserverBase::printStack(); + test(false); // Timeout + } + } + --_updated; } protected: @@ -156,9 +156,9 @@ protected: void updated(const string& update) { - trace(update); - ++_updated; - notifyAll(); + trace(update); + ++_updated; + notifyAll(); } string _name; @@ -172,54 +172,54 @@ class ApplicationObserverI : public ApplicationObserver, public ObserverBase { public: - ApplicationObserverI(const string& name) : ObserverBase(name) + ApplicationObserverI(const string& name) : ObserverBase(name) { } virtual void applicationInit(int serial, const ApplicationInfoSeq& apps, const Ice::Current&) { - Lock sync(*this); - for(ApplicationInfoSeq::const_iterator p = apps.begin(); p != apps.end(); ++p) - { - if(p->descriptor.name != "Test") // Ignore the test application from application.xml! - { - this->applications.insert(make_pair(p->descriptor.name, *p)); - } - } - updated(updateSerial(serial, "init update")); + Lock sync(*this); + for(ApplicationInfoSeq::const_iterator p = apps.begin(); p != apps.end(); ++p) + { + if(p->descriptor.name != "Test") // Ignore the test application from application.xml! + { + this->applications.insert(make_pair(p->descriptor.name, *p)); + } + } + updated(updateSerial(serial, "init update")); } virtual void applicationAdded(int serial, const ApplicationInfo& app, const Ice::Current&) { - Lock sync(*this); - this->applications.insert(make_pair(app.descriptor.name, app)); - updated(updateSerial(serial, "application added `" + app.descriptor.name + "'")); + Lock sync(*this); + this->applications.insert(make_pair(app.descriptor.name, app)); + updated(updateSerial(serial, "application added `" + app.descriptor.name + "'")); } virtual void applicationRemoved(int serial, const std::string& name, const Ice::Current&) { - Lock sync(*this); - this->applications.erase(name); - updated(updateSerial(serial, "application removed `" + name + "'")); + Lock sync(*this); + this->applications.erase(name); + updated(updateSerial(serial, "application removed `" + name + "'")); } virtual void applicationUpdated(int serial, const ApplicationUpdateInfo& info, const Ice::Current&) { - Lock sync(*this); - const ApplicationUpdateDescriptor& desc = info.descriptor; - for(Ice::StringSeq::const_iterator q = desc.removeVariables.begin(); q != desc.removeVariables.end(); ++q) - { - this->applications[desc.name].descriptor.variables.erase(*q); - } - for(map<string, string>::const_iterator p = desc.variables.begin(); p != desc.variables.end(); ++p) - { - this->applications[desc.name].descriptor.variables[p->first] = p->second; - } - updated(updateSerial(serial, "application updated `" + desc.name + "'")); + Lock sync(*this); + const ApplicationUpdateDescriptor& desc = info.descriptor; + for(Ice::StringSeq::const_iterator q = desc.removeVariables.begin(); q != desc.removeVariables.end(); ++q) + { + this->applications[desc.name].descriptor.variables.erase(*q); + } + for(map<string, string>::const_iterator p = desc.variables.begin(); p != desc.variables.end(); ++p) + { + this->applications[desc.name].descriptor.variables[p->first] = p->second; + } + updated(updateSerial(serial, "application updated `" + desc.name + "'")); } int serial; @@ -230,10 +230,10 @@ private: string updateSerial(int serial, const string& update) { - this->serial = serial; - ostringstream os; - os << update << " (serial = " << serial << ")"; - return os.str(); + this->serial = serial; + ostringstream os; + os << update << " (serial = " << serial << ")"; + return os.str(); } }; typedef IceUtil::Handle<ApplicationObserverI> ApplicationObserverIPtr; @@ -249,36 +249,36 @@ public: virtual void adapterInit(const AdapterInfoSeq& adapters, const Ice::Current&) { - Lock sync(*this); - for(AdapterInfoSeq::const_iterator q = adapters.begin(); q != adapters.end(); ++q) - { - this->adapters.insert(make_pair(q->id, *q)); - } - updated(updateSerial(0, "init update")); + Lock sync(*this); + for(AdapterInfoSeq::const_iterator q = adapters.begin(); q != adapters.end(); ++q) + { + this->adapters.insert(make_pair(q->id, *q)); + } + updated(updateSerial(0, "init update")); } void adapterAdded(const AdapterInfo& info, const Ice::Current&) { - Lock sync(*this); - this->adapters.insert(make_pair(info.id, info)); - updated(updateSerial(0, "adapter added `" + info.id + "'")); + Lock sync(*this); + this->adapters.insert(make_pair(info.id, info)); + updated(updateSerial(0, "adapter added `" + info.id + "'")); } void adapterUpdated(const AdapterInfo& info, const Ice::Current&) { - Lock sync(*this); - this->adapters[info.id] = info; - updated(updateSerial(0, "adapter updated `" + info.id + "'")); + Lock sync(*this); + this->adapters[info.id] = info; + updated(updateSerial(0, "adapter updated `" + info.id + "'")); } void adapterRemoved(const string& id, const Ice::Current&) { - Lock sync(*this); - this->adapters.erase(id); - updated(updateSerial(0, "adapter removed `" + id + "'")); + Lock sync(*this); + this->adapters.erase(id); + updated(updateSerial(0, "adapter removed `" + id + "'")); } int serial; @@ -289,10 +289,10 @@ private: string updateSerial(int serial, const string& update) { - this->serial = serial; - ostringstream os; - os << update << " (serial = " << serial << ")"; - return os.str(); + this->serial = serial; + ostringstream os; + os << update << " (serial = " << serial << ")"; + return os.str(); } }; typedef IceUtil::Handle<AdapterObserverI> AdapterObserverIPtr; @@ -308,37 +308,37 @@ public: virtual void objectInit(const ObjectInfoSeq& objects, const Ice::Current&) { - Lock sync(*this); - for(ObjectInfoSeq::const_iterator r = objects.begin(); r != objects.end(); ++r) - { - this->objects.insert(make_pair(r->proxy->ice_getIdentity(), *r)); - } - updated(updateSerial(0, "init update")); + Lock sync(*this); + for(ObjectInfoSeq::const_iterator r = objects.begin(); r != objects.end(); ++r) + { + this->objects.insert(make_pair(r->proxy->ice_getIdentity(), *r)); + } + updated(updateSerial(0, "init update")); } void objectAdded(const ObjectInfo& info, const Ice::Current&) { - Lock sync(*this); - this->objects.insert(make_pair(info.proxy->ice_getIdentity(), info)); - updated(updateSerial(0, "object added `" + info.proxy->ice_toString() + "'")); + Lock sync(*this); + this->objects.insert(make_pair(info.proxy->ice_getIdentity(), info)); + updated(updateSerial(0, "object added `" + info.proxy->ice_toString() + "'")); } void objectUpdated(const ObjectInfo& info, const Ice::Current&) { - Lock sync(*this); - this->objects[info.proxy->ice_getIdentity()] = info; - updated(updateSerial(0, "object updated `" + info.proxy->ice_toString() + "'")); + Lock sync(*this); + this->objects[info.proxy->ice_getIdentity()] = info; + updated(updateSerial(0, "object updated `" + info.proxy->ice_toString() + "'")); } void objectRemoved(const Ice::Identity& id, const Ice::Current& current) { - Lock sync(*this); - this->objects.erase(id); - updated(updateSerial(0, "object removed `" + - current.adapter->getCommunicator()->identityToString(id) + "'")); + Lock sync(*this); + this->objects.erase(id); + updated(updateSerial(0, "object removed `" + + current.adapter->getCommunicator()->identityToString(id) + "'")); } int serial; @@ -349,10 +349,10 @@ private: string updateSerial(int serial, const string& update) { - this->serial = serial; - ostringstream os; - os << update << " (serial = " << serial << ")"; - return os.str(); + this->serial = serial; + ostringstream os; + os << update << " (serial = " << serial << ")"; + return os.str(); } }; typedef IceUtil::Handle<ObjectObserverI> ObjectObserverIPtr; @@ -368,136 +368,136 @@ public: virtual void nodeInit(const NodeDynamicInfoSeq& info, const Ice::Current& current) { - Lock sync(*this); - for(NodeDynamicInfoSeq::const_iterator p = info.begin(); p != info.end(); ++p) - { - this->nodes[p->info.name] = filter(*p); - } - updated("init"); + Lock sync(*this); + for(NodeDynamicInfoSeq::const_iterator p = info.begin(); p != info.end(); ++p) + { + this->nodes[p->info.name] = filter(*p); + } + updated("init"); } virtual void nodeUp(const NodeDynamicInfo& info, const Ice::Current& current) { - Lock sync(*this); - this->nodes[info.info.name] = filter(info); - updated("node `" + info.info.name + "' up"); + Lock sync(*this); + this->nodes[info.info.name] = filter(info); + updated("node `" + info.info.name + "' up"); } virtual void nodeDown(const string& name, const Ice::Current& current) { - Lock sync(*this); - this->nodes.erase(name); - updated("node `" + name + "' down"); + Lock sync(*this); + this->nodes.erase(name); + updated("node `" + name + "' down"); } virtual void updateServer(const string& node, const ServerDynamicInfo& info, const Ice::Current& current) { - if(info.id == "Glacier2" || info.id == "Glacier2Admin" || info.id == "PermissionsVerifierServer") - { - return; - } - - Lock sync(*this); - //cerr << node << " " << info.id << " " << info.state << " " << info.pid << endl; - ServerDynamicInfoSeq& servers = this->nodes[node].servers; - ServerDynamicInfoSeq::iterator p; - for(p = servers.begin(); p != servers.end(); ++p) - { - if(p->id == info.id) - { - if(info.state == Destroyed) - { - servers.erase(p); - } - else - { - *p = info; - } - break; - } - } - if(info.state != Destroyed && p == servers.end()) - { - servers.push_back(info); - } - - ostringstream os; - os << "server `" << info.id << "' on node `" << node << "' state updated: " << info.state - << " (pid = " << info.pid << ")"; - updated(os.str()); + if(info.id == "Glacier2" || info.id == "Glacier2Admin" || info.id == "PermissionsVerifierServer") + { + return; + } + + Lock sync(*this); + //cerr << node << " " << info.id << " " << info.state << " " << info.pid << endl; + ServerDynamicInfoSeq& servers = this->nodes[node].servers; + ServerDynamicInfoSeq::iterator p; + for(p = servers.begin(); p != servers.end(); ++p) + { + if(p->id == info.id) + { + if(info.state == Destroyed) + { + servers.erase(p); + } + else + { + *p = info; + } + break; + } + } + if(info.state != Destroyed && p == servers.end()) + { + servers.push_back(info); + } + + ostringstream os; + os << "server `" << info.id << "' on node `" << node << "' state updated: " << info.state + << " (pid = " << info.pid << ")"; + updated(os.str()); } virtual void updateAdapter(const string& node, const AdapterDynamicInfo& info, const Ice::Current& current) { - if(info.id == "PermissionsVerifierServer.Server") - { - return; - } - - Lock sync(*this); - //cerr << "update adapter: " << info.id << " " << (info.proxy ? "active" : "inactive") << endl; - AdapterDynamicInfoSeq& adapters = this->nodes[node].adapters; - AdapterDynamicInfoSeq::iterator p; - for(p = adapters.begin(); p != adapters.end(); ++p) - { - if(p->id == info.id) - { - if(info.proxy) - { - *p = info; - } - else - { - adapters.erase(p); - } - break; - } - } - if(info.proxy && p == adapters.end()) - { - adapters.push_back(info); - } - - ostringstream os; - os << "adapter `" << info.id << " on node `" << node << "' state updated: " - << (info.proxy ? "active" : "inactive"); - updated(os.str()); + if(info.id == "PermissionsVerifierServer.Server") + { + return; + } + + Lock sync(*this); + //cerr << "update adapter: " << info.id << " " << (info.proxy ? "active" : "inactive") << endl; + AdapterDynamicInfoSeq& adapters = this->nodes[node].adapters; + AdapterDynamicInfoSeq::iterator p; + for(p = adapters.begin(); p != adapters.end(); ++p) + { + if(p->id == info.id) + { + if(info.proxy) + { + *p = info; + } + else + { + adapters.erase(p); + } + break; + } + } + if(info.proxy && p == adapters.end()) + { + adapters.push_back(info); + } + + ostringstream os; + os << "adapter `" << info.id << " on node `" << node << "' state updated: " + << (info.proxy ? "active" : "inactive"); + updated(os.str()); } NodeDynamicInfo filter(const NodeDynamicInfo& info) { - if(info.info.name != "localnode") - { - return info; - } - - NodeDynamicInfo filtered; - filtered.info = info.info; - - for(ServerDynamicInfoSeq::const_iterator p = info.servers.begin(); p != info.servers.end(); ++p) - { - if(p->id == "Glacier2" || p->id == "Glacier2Admin" || p->id == "PermissionsVerifierServer") - { - continue; - } - filtered.servers.push_back(*p); - } - - for(AdapterDynamicInfoSeq::const_iterator a = info.adapters.begin(); a != info.adapters.end(); ++a) - { - if(a->id == "PermissionsVerifierServer.Server") - { - continue; - } - filtered.adapters.push_back(*a); - } - - return filtered; + if(info.info.name != "localnode") + { + return info; + } + + NodeDynamicInfo filtered; + filtered.info = info.info; + + for(ServerDynamicInfoSeq::const_iterator p = info.servers.begin(); p != info.servers.end(); ++p) + { + if(p->id == "Glacier2" || p->id == "Glacier2Admin" || p->id == "PermissionsVerifierServer") + { + continue; + } + filtered.servers.push_back(*p); + } + + for(AdapterDynamicInfoSeq::const_iterator a = info.adapters.begin(); a != info.adapters.end(); ++a) + { + if(a->id == "PermissionsVerifierServer.Server") + { + continue; + } + filtered.adapters.push_back(*a); + } + + return filtered; } map<string, NodeDynamicInfo> nodes; @@ -515,29 +515,29 @@ public: virtual void registryInit(const RegistryInfoSeq& info, const Ice::Current& current) { - Lock sync(*this); - for(RegistryInfoSeq::const_iterator p = info.begin(); p != info.end(); ++p) - { - this->registries[p->name] = *p; - } - updated("init"); + Lock sync(*this); + for(RegistryInfoSeq::const_iterator p = info.begin(); p != info.end(); ++p) + { + this->registries[p->name] = *p; + } + updated("init"); } virtual void registryUp(const RegistryInfo& info, const Ice::Current& current) { - Lock sync(*this); - this->registries[info.name] = info; - updated("registry `" + info.name + "' up"); + Lock sync(*this); + this->registries[info.name] = info; + updated("registry `" + info.name + "' up"); } virtual void registryDown(const string& name, const Ice::Current& current) - { - Lock sync(*this); - this->registries.erase(name); - updated("registry `" + name + "' down"); - } + { + Lock sync(*this); + this->registries.erase(name); + updated("registry `" + name + "' down"); + } map<string, RegistryInfo> registries; }; @@ -557,7 +557,7 @@ void allTests(const Ice::CommunicatorPtr& communicator) { SessionKeepAliveThreadPtr keepAlive = new SessionKeepAliveThread( - communicator->getLogger(), IceUtil::Time::seconds(5)); + communicator->getLogger(), IceUtil::Time::seconds(5)); keepAlive->start(); RegistryPrx registry = RegistryPrx::checkedCast(communicator->stringToProxy("IceGrid/Registry")); @@ -572,24 +572,24 @@ allTests(const Ice::CommunicatorPtr& communicator) cout << "starting router... " << flush; try { - admin->startServer("Glacier2"); + admin->startServer("Glacier2"); } catch(const ServerStartException& ex) { - cerr << ex.reason << endl; - test(false); + cerr << ex.reason << endl; + test(false); } cout << "ok" << endl; cout << "starting admin router... " << flush; try { - admin->startServer("Glacier2Admin"); + admin->startServer("Glacier2Admin"); } catch(const ServerStartException& ex) { - cerr << ex.reason << endl; - test(false); + cerr << ex.reason << endl; + test(false); } cout << "ok" << endl; @@ -613,1321 +613,1321 @@ allTests(const Ice::CommunicatorPtr& communicator) // while(true) { - try - { - router1->ice_ping(); - adminRouter1->ice_ping(); - break; - } - catch(const Ice::LocalException&) - { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(100)); - } + try + { + router1->ice_ping(); + adminRouter1->ice_ping(); + break; + } + catch(const Ice::LocalException&) + { + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(100)); + } } { - cout << "testing username/password sessions... " << flush; - - SessionPrx session1, session2; - - session1 = SessionPrx::uncheckedCast(registry1->createSession("client1", "test1")->ice_connectionId("reg1")); - session2 = SessionPrx::uncheckedCast(registry2->createSession("client2", "test2")->ice_connectionId("reg2")); - try - { - registry1->createSession("client3", "test1"); - test(false); - } - catch(const IceGrid::PermissionDeniedException&) - { - } - - session1->ice_ping(); - session2->ice_ping(); - - try - { - session1->ice_connectionId("")->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - try - { - session2->ice_connectionId("")->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - - try - { - session1->ice_connectionId("reg2")->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - try - { - session2->ice_connectionId("reg1")->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - - - session1->destroy(); - session2->destroy(); - - AdminSessionPrx adminSession1, adminSession2; - - adminSession1 = AdminSessionPrx::uncheckedCast( - registry1->createAdminSession("admin1", "test1")->ice_connectionId("reg1")); - adminSession2 = AdminSessionPrx::uncheckedCast( - registry2->createAdminSession("admin2", "test2")->ice_connectionId("reg2")); - try - { - registry1->createAdminSession("admin3", "test1"); - test(false); - } - catch(const IceGrid::PermissionDeniedException&) - { - } - - adminSession1->ice_ping(); - adminSession2->ice_ping(); - - try - { - adminSession1->ice_connectionId("")->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - try - { - adminSession2->ice_connectionId("")->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - - adminSession1->getAdmin()->ice_connectionId("reg1")->ice_ping(); - adminSession2->getAdmin()->ice_connectionId("reg2")->ice_ping(); - - try - { - adminSession1->getAdmin()->ice_connectionId("reg2")->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - try - { - adminSession2->getAdmin()->ice_connectionId("reg1")->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - - adminSession1->destroy(); - adminSession2->destroy(); - - cout << "ok" << endl; + cout << "testing username/password sessions... " << flush; + + SessionPrx session1, session2; + + session1 = SessionPrx::uncheckedCast(registry1->createSession("client1", "test1")->ice_connectionId("reg1")); + session2 = SessionPrx::uncheckedCast(registry2->createSession("client2", "test2")->ice_connectionId("reg2")); + try + { + registry1->createSession("client3", "test1"); + test(false); + } + catch(const IceGrid::PermissionDeniedException&) + { + } + + session1->ice_ping(); + session2->ice_ping(); + + try + { + session1->ice_connectionId("")->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + try + { + session2->ice_connectionId("")->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + + try + { + session1->ice_connectionId("reg2")->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + try + { + session2->ice_connectionId("reg1")->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + + + session1->destroy(); + session2->destroy(); + + AdminSessionPrx adminSession1, adminSession2; + + adminSession1 = AdminSessionPrx::uncheckedCast( + registry1->createAdminSession("admin1", "test1")->ice_connectionId("reg1")); + adminSession2 = AdminSessionPrx::uncheckedCast( + registry2->createAdminSession("admin2", "test2")->ice_connectionId("reg2")); + try + { + registry1->createAdminSession("admin3", "test1"); + test(false); + } + catch(const IceGrid::PermissionDeniedException&) + { + } + + adminSession1->ice_ping(); + adminSession2->ice_ping(); + + try + { + adminSession1->ice_connectionId("")->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + try + { + adminSession2->ice_connectionId("")->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + + adminSession1->getAdmin()->ice_connectionId("reg1")->ice_ping(); + adminSession2->getAdmin()->ice_connectionId("reg2")->ice_ping(); + + try + { + adminSession1->getAdmin()->ice_connectionId("reg2")->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + try + { + adminSession2->getAdmin()->ice_connectionId("reg1")->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + + adminSession1->destroy(); + adminSession2->destroy(); + + cout << "ok" << endl; } if(properties->getProperty("Ice.Default.Protocol") == "ssl") { - cout << "testing sessions from secure connection... " << flush; - - SessionPrx session1, session2; - - session1 = SessionPrx::uncheckedCast(registry1->createSessionFromSecureConnection()->ice_connectionId("reg1")); - session2 = SessionPrx::uncheckedCast(registry2->createSessionFromSecureConnection()->ice_connectionId("reg2")); - - session1->ice_ping(); - session2->ice_ping(); - - try - { - session1->ice_connectionId("")->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - try - { - session2->ice_connectionId("")->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - - session1->destroy(); - session2->destroy(); - - AdminSessionPrx adminSession1, adminSession2; - - adminSession1 = AdminSessionPrx::uncheckedCast( - registry1->createAdminSessionFromSecureConnection()->ice_connectionId("reg1")); - adminSession2 = AdminSessionPrx::uncheckedCast( - registry2->createAdminSessionFromSecureConnection()->ice_connectionId("reg2")); - - adminSession1->ice_ping(); - adminSession2->ice_ping(); - - try - { - adminSession1->ice_connectionId("")->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - try - { - adminSession2->ice_connectionId("")->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - - adminSession1->destroy(); - adminSession2->destroy(); - - cout << "ok" << endl; + cout << "testing sessions from secure connection... " << flush; + + SessionPrx session1, session2; + + session1 = SessionPrx::uncheckedCast(registry1->createSessionFromSecureConnection()->ice_connectionId("reg1")); + session2 = SessionPrx::uncheckedCast(registry2->createSessionFromSecureConnection()->ice_connectionId("reg2")); + + session1->ice_ping(); + session2->ice_ping(); + + try + { + session1->ice_connectionId("")->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + try + { + session2->ice_connectionId("")->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + + session1->destroy(); + session2->destroy(); + + AdminSessionPrx adminSession1, adminSession2; + + adminSession1 = AdminSessionPrx::uncheckedCast( + registry1->createAdminSessionFromSecureConnection()->ice_connectionId("reg1")); + adminSession2 = AdminSessionPrx::uncheckedCast( + registry2->createAdminSessionFromSecureConnection()->ice_connectionId("reg2")); + + adminSession1->ice_ping(); + adminSession2->ice_ping(); + + try + { + adminSession1->ice_connectionId("")->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + try + { + adminSession2->ice_connectionId("")->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + + adminSession1->destroy(); + adminSession2->destroy(); + + cout << "ok" << endl; } else { - cout << "testing sessions from secure connection... " << flush; - try - { - registry1->createSessionFromSecureConnection(); - test(false); - } - catch(const IceGrid::PermissionDeniedException&) - { - } - try - { - registry1->createAdminSessionFromSecureConnection(); - test(false); - } - catch(const IceGrid::PermissionDeniedException&) - { - } - cout << "ok" << endl; + cout << "testing sessions from secure connection... " << flush; + try + { + registry1->createSessionFromSecureConnection(); + test(false); + } + catch(const IceGrid::PermissionDeniedException&) + { + } + try + { + registry1->createAdminSessionFromSecureConnection(); + test(false); + } + catch(const IceGrid::PermissionDeniedException&) + { + } + cout << "ok" << endl; } { - cout << "testing Glacier2 username/password sessions... " << flush; - - SessionPrx session1, session2; - - Glacier2::SessionPrx base; - - base = router1->createSession("client1", "test1"); - test(base); - session1 = SessionPrx::uncheckedCast(base->ice_connectionId("router1")->ice_router(router1)); - - base = router2->createSession("client2", "test2"); - test(base); - session2 = SessionPrx::uncheckedCast(base->ice_connectionId("router2")->ice_router(router2)); - - try - { - router1->createSession("client3", "test1"); - test(false); - } - catch(const Glacier2::CannotCreateSessionException&) - { - } - - session1->ice_ping(); - session2->ice_ping(); - - try - { - session1->ice_connectionId("router2")->ice_router(router2)->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - try - { - session2->ice_connectionId("router1")->ice_router(router1)->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - - Ice::ObjectPrx obj = communicator->stringToProxy("IceGrid/Query"); - obj->ice_connectionId("router1")->ice_router(router1)->ice_ping(); - obj->ice_connectionId("router2")->ice_router(router2)->ice_ping(); - - obj = communicator->stringToProxy("IceGrid/Registry"); - try - { - obj->ice_connectionId("router1")->ice_router(router1)->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - try - { - obj->ice_connectionId("router2")->ice_router(router2)->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - - try - { - router1->destroySession(); - test(false); - } - catch(const Ice::ConnectionLostException&) - { - } - try - { - router2->destroySession(); - test(false); - } - catch(const Ice::ConnectionLostException&) - { - } - - AdminSessionPrx admSession1, admSession2; - - base = adminRouter1->createSession("admin1", "test1"); - admSession1 = AdminSessionPrx::uncheckedCast(base->ice_connectionId("admRouter1")->ice_router(adminRouter1)); - - base = adminRouter2->createSession("admin2", "test2"); - admSession2 = AdminSessionPrx::uncheckedCast(base->ice_connectionId("admRouter2")->ice_router(adminRouter2)); - - try - { - adminRouter1->createSession("client3", "test1"); - test(false); - } - catch(const Glacier2::CannotCreateSessionException&) - { - } - - admSession1->ice_ping(); - admSession2->ice_ping(); - - Ice::ObjectPrx admin1 = admSession1->getAdmin()->ice_router(adminRouter1)->ice_connectionId("admRouter1"); - Ice::ObjectPrx admin2 = admSession2->getAdmin()->ice_router(adminRouter2)->ice_connectionId("admRouter2"); - - admin1->ice_ping(); - admin2->ice_ping(); - - obj = communicator->stringToProxy("IceGrid/Query"); - obj->ice_connectionId("admRouter1")->ice_router(adminRouter1)->ice_ping(); - obj->ice_connectionId("admRouter2")->ice_router(adminRouter2)->ice_ping(); - - try - { - admSession1->ice_connectionId("admRouter2")->ice_router(adminRouter2)->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - try - { - admSession2->ice_connectionId("admRouter1")->ice_router(adminRouter1)->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - - try - { - admin1->ice_connectionId("admRouter2")->ice_router(adminRouter2)->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - try - { - admin2->ice_connectionId("admRouter1")->ice_router(adminRouter1)->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - - try - { - adminRouter1->destroySession(); - } - catch(const Ice::ConnectionLostException&) - { - } - try - { - adminRouter2->destroySession(); - } - catch(const Ice::ConnectionLostException&) - { - } - - cout << "ok" << endl; + cout << "testing Glacier2 username/password sessions... " << flush; + + SessionPrx session1, session2; + + Glacier2::SessionPrx base; + + base = router1->createSession("client1", "test1"); + test(base); + session1 = SessionPrx::uncheckedCast(base->ice_connectionId("router1")->ice_router(router1)); + + base = router2->createSession("client2", "test2"); + test(base); + session2 = SessionPrx::uncheckedCast(base->ice_connectionId("router2")->ice_router(router2)); + + try + { + router1->createSession("client3", "test1"); + test(false); + } + catch(const Glacier2::CannotCreateSessionException&) + { + } + + session1->ice_ping(); + session2->ice_ping(); + + try + { + session1->ice_connectionId("router2")->ice_router(router2)->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + try + { + session2->ice_connectionId("router1")->ice_router(router1)->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + + Ice::ObjectPrx obj = communicator->stringToProxy("IceGrid/Query"); + obj->ice_connectionId("router1")->ice_router(router1)->ice_ping(); + obj->ice_connectionId("router2")->ice_router(router2)->ice_ping(); + + obj = communicator->stringToProxy("IceGrid/Registry"); + try + { + obj->ice_connectionId("router1")->ice_router(router1)->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + try + { + obj->ice_connectionId("router2")->ice_router(router2)->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + + try + { + router1->destroySession(); + test(false); + } + catch(const Ice::ConnectionLostException&) + { + } + try + { + router2->destroySession(); + test(false); + } + catch(const Ice::ConnectionLostException&) + { + } + + AdminSessionPrx admSession1, admSession2; + + base = adminRouter1->createSession("admin1", "test1"); + admSession1 = AdminSessionPrx::uncheckedCast(base->ice_connectionId("admRouter1")->ice_router(adminRouter1)); + + base = adminRouter2->createSession("admin2", "test2"); + admSession2 = AdminSessionPrx::uncheckedCast(base->ice_connectionId("admRouter2")->ice_router(adminRouter2)); + + try + { + adminRouter1->createSession("client3", "test1"); + test(false); + } + catch(const Glacier2::CannotCreateSessionException&) + { + } + + admSession1->ice_ping(); + admSession2->ice_ping(); + + Ice::ObjectPrx admin1 = admSession1->getAdmin()->ice_router(adminRouter1)->ice_connectionId("admRouter1"); + Ice::ObjectPrx admin2 = admSession2->getAdmin()->ice_router(adminRouter2)->ice_connectionId("admRouter2"); + + admin1->ice_ping(); + admin2->ice_ping(); + + obj = communicator->stringToProxy("IceGrid/Query"); + obj->ice_connectionId("admRouter1")->ice_router(adminRouter1)->ice_ping(); + obj->ice_connectionId("admRouter2")->ice_router(adminRouter2)->ice_ping(); + + try + { + admSession1->ice_connectionId("admRouter2")->ice_router(adminRouter2)->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + try + { + admSession2->ice_connectionId("admRouter1")->ice_router(adminRouter1)->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + + try + { + admin1->ice_connectionId("admRouter2")->ice_router(adminRouter2)->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + try + { + admin2->ice_connectionId("admRouter1")->ice_router(adminRouter1)->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + + try + { + adminRouter1->destroySession(); + } + catch(const Ice::ConnectionLostException&) + { + } + try + { + adminRouter2->destroySession(); + } + catch(const Ice::ConnectionLostException&) + { + } + + cout << "ok" << endl; } if(properties->getProperty("Ice.Default.Protocol") == "ssl") { - cout << "testing Glacier2 sessions from secure connection... " << flush; - - SessionPrx session1, session2; - - Glacier2::SessionPrx base; - - // - // BUGFIX: We can't re-use the same router proxies because of bug 1034. - // - router1 = Glacier2::RouterPrx::uncheckedCast(router1->ice_connectionId("router11")); - router2 = Glacier2::RouterPrx::uncheckedCast(router2->ice_connectionId("router21")); - - base = router1->createSessionFromSecureConnection(); - session1 = SessionPrx::uncheckedCast(base->ice_connectionId("router11")->ice_router(router1)); - - base = router2->createSessionFromSecureConnection(); - session2 = SessionPrx::uncheckedCast(base->ice_connectionId("router21")->ice_router(router2)); - - session1->ice_ping(); - session2->ice_ping(); - - try - { - session1->ice_connectionId("router21")->ice_router(router2)->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - try - { - session2->ice_connectionId("router11")->ice_router(router1)->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - - Ice::ObjectPrx obj = communicator->stringToProxy("IceGrid/Query"); - obj->ice_connectionId("router11")->ice_router(router1)->ice_ping(); - obj->ice_connectionId("router21")->ice_router(router2)->ice_ping(); - - obj = communicator->stringToProxy("IceGrid/Registry"); - try - { - obj->ice_connectionId("router11")->ice_router(router1)->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - try - { - obj->ice_connectionId("router21")->ice_router(router2)->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - - try - { - router1->destroySession(); - } - catch(const Ice::ConnectionLostException&) - { - } - try - { - router2->destroySession(); - } - catch(const Ice::ConnectionLostException&) - { - } - - AdminSessionPrx admSession1, admSession2; - - // - // BUGFIX: We can't re-use the same router proxies because of bug 1034. - // - adminRouter1 = Glacier2::RouterPrx::uncheckedCast(adminRouter->ice_connectionId("admRouter11")); - adminRouter2 = Glacier2::RouterPrx::uncheckedCast(adminRouter->ice_connectionId("admRouter21")); - - base = adminRouter1->createSessionFromSecureConnection(); - admSession1 = AdminSessionPrx::uncheckedCast(base->ice_connectionId("admRouter11")->ice_router(adminRouter1)); - - base = adminRouter2->createSessionFromSecureConnection(); - admSession2 = AdminSessionPrx::uncheckedCast(base->ice_connectionId("admRouter21")->ice_router(adminRouter2)); - - admSession1->ice_ping(); - admSession2->ice_ping(); - - Ice::ObjectPrx admin1 = admSession1->getAdmin()->ice_router(adminRouter1)->ice_connectionId("admRouter11"); - Ice::ObjectPrx admin2 = admSession2->getAdmin()->ice_router(adminRouter2)->ice_connectionId("admRouter21"); - - admin1->ice_ping(); - admin2->ice_ping(); - - obj = communicator->stringToProxy("IceGrid/Query"); - obj->ice_connectionId("admRouter11")->ice_router(adminRouter1)->ice_ping(); - obj->ice_connectionId("admRouter21")->ice_router(adminRouter2)->ice_ping(); - - try - { - admSession1->ice_connectionId("admRouter21")->ice_router(adminRouter2)->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - try - { - admSession2->ice_connectionId("admRouter11")->ice_router(adminRouter1)->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - - try - { - admin1->ice_connectionId("admRouter21")->ice_router(adminRouter2)->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - try - { - admin2->ice_connectionId("admRouter11")->ice_router(adminRouter1)->ice_ping(); - test(false); - } - catch(const Ice::ObjectNotExistException&) - { - } - - try - { - adminRouter1->destroySession(); - } - catch(const Ice::ConnectionLostException&) - { - } - try - { - adminRouter2->destroySession(); - } - catch(const Ice::ConnectionLostException&) - { - } - - cout << "ok" << endl; + cout << "testing Glacier2 sessions from secure connection... " << flush; + + SessionPrx session1, session2; + + Glacier2::SessionPrx base; + + // + // BUGFIX: We can't re-use the same router proxies because of bug 1034. + // + router1 = Glacier2::RouterPrx::uncheckedCast(router1->ice_connectionId("router11")); + router2 = Glacier2::RouterPrx::uncheckedCast(router2->ice_connectionId("router21")); + + base = router1->createSessionFromSecureConnection(); + session1 = SessionPrx::uncheckedCast(base->ice_connectionId("router11")->ice_router(router1)); + + base = router2->createSessionFromSecureConnection(); + session2 = SessionPrx::uncheckedCast(base->ice_connectionId("router21")->ice_router(router2)); + + session1->ice_ping(); + session2->ice_ping(); + + try + { + session1->ice_connectionId("router21")->ice_router(router2)->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + try + { + session2->ice_connectionId("router11")->ice_router(router1)->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + + Ice::ObjectPrx obj = communicator->stringToProxy("IceGrid/Query"); + obj->ice_connectionId("router11")->ice_router(router1)->ice_ping(); + obj->ice_connectionId("router21")->ice_router(router2)->ice_ping(); + + obj = communicator->stringToProxy("IceGrid/Registry"); + try + { + obj->ice_connectionId("router11")->ice_router(router1)->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + try + { + obj->ice_connectionId("router21")->ice_router(router2)->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + + try + { + router1->destroySession(); + } + catch(const Ice::ConnectionLostException&) + { + } + try + { + router2->destroySession(); + } + catch(const Ice::ConnectionLostException&) + { + } + + AdminSessionPrx admSession1, admSession2; + + // + // BUGFIX: We can't re-use the same router proxies because of bug 1034. + // + adminRouter1 = Glacier2::RouterPrx::uncheckedCast(adminRouter->ice_connectionId("admRouter11")); + adminRouter2 = Glacier2::RouterPrx::uncheckedCast(adminRouter->ice_connectionId("admRouter21")); + + base = adminRouter1->createSessionFromSecureConnection(); + admSession1 = AdminSessionPrx::uncheckedCast(base->ice_connectionId("admRouter11")->ice_router(adminRouter1)); + + base = adminRouter2->createSessionFromSecureConnection(); + admSession2 = AdminSessionPrx::uncheckedCast(base->ice_connectionId("admRouter21")->ice_router(adminRouter2)); + + admSession1->ice_ping(); + admSession2->ice_ping(); + + Ice::ObjectPrx admin1 = admSession1->getAdmin()->ice_router(adminRouter1)->ice_connectionId("admRouter11"); + Ice::ObjectPrx admin2 = admSession2->getAdmin()->ice_router(adminRouter2)->ice_connectionId("admRouter21"); + + admin1->ice_ping(); + admin2->ice_ping(); + + obj = communicator->stringToProxy("IceGrid/Query"); + obj->ice_connectionId("admRouter11")->ice_router(adminRouter1)->ice_ping(); + obj->ice_connectionId("admRouter21")->ice_router(adminRouter2)->ice_ping(); + + try + { + admSession1->ice_connectionId("admRouter21")->ice_router(adminRouter2)->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + try + { + admSession2->ice_connectionId("admRouter11")->ice_router(adminRouter1)->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + + try + { + admin1->ice_connectionId("admRouter21")->ice_router(adminRouter2)->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + try + { + admin2->ice_connectionId("admRouter11")->ice_router(adminRouter1)->ice_ping(); + test(false); + } + catch(const Ice::ObjectNotExistException&) + { + } + + try + { + adminRouter1->destroySession(); + } + catch(const Ice::ConnectionLostException&) + { + } + try + { + adminRouter2->destroySession(); + } + catch(const Ice::ConnectionLostException&) + { + } + + cout << "ok" << endl; } else { - cout << "testing Glacier2 sessions from secure connection... " << flush; - try - { - router1->createSessionFromSecureConnection(); - test(false); - } - catch(const Glacier2::PermissionDeniedException&) - { - } - try - { - adminRouter1->createSessionFromSecureConnection(); - test(false); - } - catch(const Glacier2::PermissionDeniedException&) - { - } - cout << "ok" << endl; + cout << "testing Glacier2 sessions from secure connection... " << flush; + try + { + router1->createSessionFromSecureConnection(); + test(false); + } + catch(const Glacier2::PermissionDeniedException&) + { + } + try + { + adminRouter1->createSessionFromSecureConnection(); + test(false); + } + catch(const Glacier2::PermissionDeniedException&) + { + } + cout << "ok" << endl; } { - cout << "testing updates with admin sessions... " << flush; - AdminSessionPrx session1 = registry->createAdminSession("admin1", "test1"); - AdminSessionPrx session2 = registry->createAdminSession("admin2", "test2"); - - keepAlive->add(session1); - keepAlive->add(session2); - - AdminPrx admin1 = session1->getAdmin(); - AdminPrx admin2 = session2->getAdmin(); - - Ice::ObjectAdapterPtr adpt1 = communicator->createObjectAdapter(""); - ApplicationObserverIPtr appObs1 = new ApplicationObserverI("appObs1.1"); - Ice::ObjectPrx app1 = adpt1->addWithUUID(appObs1); - NodeObserverIPtr nodeObs1 = new NodeObserverI("nodeObs1"); - Ice::ObjectPrx no1 = adpt1->addWithUUID(nodeObs1); - adpt1->activate(); - registry->ice_getConnection()->setAdapter(adpt1); - session1->setObserversByIdentity(Ice::Identity(), - no1->ice_getIdentity(), - app1->ice_getIdentity(), - Ice::Identity(), - Ice::Identity()); - - Ice::ObjectAdapterPtr adpt2 = communicator->createObjectAdapterWithEndpoints("Observer2", "default"); - ApplicationObserverIPtr appObs2 = new ApplicationObserverI("appObs2"); - Ice::ObjectPrx app2 = adpt2->addWithUUID(appObs2); - NodeObserverIPtr nodeObs2 = new NodeObserverI("nodeObs1"); - Ice::ObjectPrx no2 = adpt2->addWithUUID(nodeObs2); - adpt2->activate(); - session2->setObservers(0, - NodeObserverPrx::uncheckedCast(no2), - ApplicationObserverPrx::uncheckedCast(app2), - 0, - 0); - - appObs1->waitForUpdate(__FILE__, __LINE__); - appObs2->waitForUpdate(__FILE__, __LINE__); - - int serial = appObs1->serial; - test(serial == appObs2->serial); - - try - { - session1->getAdmin()->ice_ping(); - } - catch(const Ice::LocalException&) - { - test(false); - } - - try - { - int s = session1->startUpdate(); - test(s != serial + 1); - } - catch(const AccessDeniedException&) - { - test(false); - } - - try - { - int s = session1->startUpdate(); - test(s == serial); - } - catch(const Ice::UserException&) - { - test(false); - } - - try - { - session2->startUpdate(); - test(false); - } - catch(const AccessDeniedException& ex) - { - test(ex.lockUserId == "admin1"); - } - - try - { - session1->finishUpdate(); - } - catch(const Ice::UserException&) - { - test(false); - } - - try - { - int s = session2->startUpdate(); - test(s == appObs2->serial); - } - catch(const Ice::UserException&) - { - test(false); - } - - try - { - ApplicationDescriptor app; - app.name = "Application"; - admin2->addApplication(app); - } - catch(const Ice::UserException&) - { - test(false); - } - - try - { - admin1->addApplication(ApplicationDescriptor()); - test(false); - } - catch(const AccessDeniedException&) - { - } - - try - { - session2->finishUpdate(); - } - catch(const Ice::UserException&) - { - test(false); - } - - appObs1->waitForUpdate(__FILE__, __LINE__); - appObs2->waitForUpdate(__FILE__, __LINE__); - - test(serial + 1 == appObs1->serial); - test(serial + 1 == appObs2->serial); - ++serial; - - try - { - int s = session1->startUpdate(); - test(s == serial); - ApplicationUpdateDescriptor update; - update.name = "Application"; - update.variables.insert(make_pair(string("test"), string("test"))); - admin1->updateApplication(update); - session1->finishUpdate(); - } - catch(const Ice::UserException& ex) - { - cerr << ex << endl; - test(false); - } - - appObs1->waitForUpdate(__FILE__, __LINE__); - appObs2->waitForUpdate(__FILE__, __LINE__); - - test(serial + 1 == appObs1->serial); - test(serial + 1 == appObs2->serial); - ++serial; - - // - // We now allow modifying the database without holding the - // exclusive lock. - // -// try -// { -// ApplicationUpdateDescriptor update; -// update.name = "Application"; -// admin1->updateApplication(update); -// test(false); -// } -// catch(const AccessDeniedException&) -// { -// } - - try - { - int s = session2->startUpdate(); - test(s == serial); - admin2->removeApplication("Application"); - session2->finishUpdate(); - } - catch(const Ice::UserException&) - { - test(false); - } - - appObs1->waitForUpdate(__FILE__, __LINE__); - appObs2->waitForUpdate(__FILE__, __LINE__); - - test(serial + 1 == appObs1->serial); - test(serial + 1 == appObs2->serial); - ++serial; - - try - { - int s = session1->startUpdate(); - test(s == serial); - } - catch(const Ice::UserException&) - { - test(false); - } - session1->destroy(); - - try - { - int s = session2->startUpdate(); - test(s == serial); - session2->finishUpdate(); - } - catch(const Ice::UserException&) - { - test(false); - } - session2->destroy(); - - adpt1->destroy(); - adpt2->destroy(); - - // - // TODO: test session reaping? - // - - cout << "ok" << endl; + cout << "testing updates with admin sessions... " << flush; + AdminSessionPrx session1 = registry->createAdminSession("admin1", "test1"); + AdminSessionPrx session2 = registry->createAdminSession("admin2", "test2"); + + keepAlive->add(session1); + keepAlive->add(session2); + + AdminPrx admin1 = session1->getAdmin(); + AdminPrx admin2 = session2->getAdmin(); + + Ice::ObjectAdapterPtr adpt1 = communicator->createObjectAdapter(""); + ApplicationObserverIPtr appObs1 = new ApplicationObserverI("appObs1.1"); + Ice::ObjectPrx app1 = adpt1->addWithUUID(appObs1); + NodeObserverIPtr nodeObs1 = new NodeObserverI("nodeObs1"); + Ice::ObjectPrx no1 = adpt1->addWithUUID(nodeObs1); + adpt1->activate(); + registry->ice_getConnection()->setAdapter(adpt1); + session1->setObserversByIdentity(Ice::Identity(), + no1->ice_getIdentity(), + app1->ice_getIdentity(), + Ice::Identity(), + Ice::Identity()); + + Ice::ObjectAdapterPtr adpt2 = communicator->createObjectAdapterWithEndpoints("Observer2", "default"); + ApplicationObserverIPtr appObs2 = new ApplicationObserverI("appObs2"); + Ice::ObjectPrx app2 = adpt2->addWithUUID(appObs2); + NodeObserverIPtr nodeObs2 = new NodeObserverI("nodeObs1"); + Ice::ObjectPrx no2 = adpt2->addWithUUID(nodeObs2); + adpt2->activate(); + session2->setObservers(0, + NodeObserverPrx::uncheckedCast(no2), + ApplicationObserverPrx::uncheckedCast(app2), + 0, + 0); + + appObs1->waitForUpdate(__FILE__, __LINE__); + appObs2->waitForUpdate(__FILE__, __LINE__); + + int serial = appObs1->serial; + test(serial == appObs2->serial); + + try + { + session1->getAdmin()->ice_ping(); + } + catch(const Ice::LocalException&) + { + test(false); + } + + try + { + int s = session1->startUpdate(); + test(s != serial + 1); + } + catch(const AccessDeniedException&) + { + test(false); + } + + try + { + int s = session1->startUpdate(); + test(s == serial); + } + catch(const Ice::UserException&) + { + test(false); + } + + try + { + session2->startUpdate(); + test(false); + } + catch(const AccessDeniedException& ex) + { + test(ex.lockUserId == "admin1"); + } + + try + { + session1->finishUpdate(); + } + catch(const Ice::UserException&) + { + test(false); + } + + try + { + int s = session2->startUpdate(); + test(s == appObs2->serial); + } + catch(const Ice::UserException&) + { + test(false); + } + + try + { + ApplicationDescriptor app; + app.name = "Application"; + admin2->addApplication(app); + } + catch(const Ice::UserException&) + { + test(false); + } + + try + { + admin1->addApplication(ApplicationDescriptor()); + test(false); + } + catch(const AccessDeniedException&) + { + } + + try + { + session2->finishUpdate(); + } + catch(const Ice::UserException&) + { + test(false); + } + + appObs1->waitForUpdate(__FILE__, __LINE__); + appObs2->waitForUpdate(__FILE__, __LINE__); + + test(serial + 1 == appObs1->serial); + test(serial + 1 == appObs2->serial); + ++serial; + + try + { + int s = session1->startUpdate(); + test(s == serial); + ApplicationUpdateDescriptor update; + update.name = "Application"; + update.variables.insert(make_pair(string("test"), string("test"))); + admin1->updateApplication(update); + session1->finishUpdate(); + } + catch(const Ice::UserException& ex) + { + cerr << ex << endl; + test(false); + } + + appObs1->waitForUpdate(__FILE__, __LINE__); + appObs2->waitForUpdate(__FILE__, __LINE__); + + test(serial + 1 == appObs1->serial); + test(serial + 1 == appObs2->serial); + ++serial; + + // + // We now allow modifying the database without holding the + // exclusive lock. + // +// try +// { +// ApplicationUpdateDescriptor update; +// update.name = "Application"; +// admin1->updateApplication(update); +// test(false); +// } +// catch(const AccessDeniedException&) +// { +// } + + try + { + int s = session2->startUpdate(); + test(s == serial); + admin2->removeApplication("Application"); + session2->finishUpdate(); + } + catch(const Ice::UserException&) + { + test(false); + } + + appObs1->waitForUpdate(__FILE__, __LINE__); + appObs2->waitForUpdate(__FILE__, __LINE__); + + test(serial + 1 == appObs1->serial); + test(serial + 1 == appObs2->serial); + ++serial; + + try + { + int s = session1->startUpdate(); + test(s == serial); + } + catch(const Ice::UserException&) + { + test(false); + } + session1->destroy(); + + try + { + int s = session2->startUpdate(); + test(s == serial); + session2->finishUpdate(); + } + catch(const Ice::UserException&) + { + test(false); + } + session2->destroy(); + + adpt1->destroy(); + adpt2->destroy(); + + // + // TODO: test session reaping? + // + + cout << "ok" << endl; } { - cout << "testing application observer... " << flush; - AdminSessionPrx session1 = registry->createAdminSession("admin1", "test1"); - AdminPrx admin1 = session1->getAdmin(); - - keepAlive->add(session1); - - Ice::ObjectAdapterPtr adpt1 = communicator->createObjectAdapter(""); - ApplicationObserverIPtr appObs1 = new ApplicationObserverI("appObs1.2"); - Ice::ObjectPrx app1 = adpt1->addWithUUID(appObs1); - adpt1->activate(); - registry->ice_getConnection()->setAdapter(adpt1); - session1->setObserversByIdentity(Ice::Identity(), - Ice::Identity(), - app1->ice_getIdentity(), - Ice::Identity(), - Ice::Identity()); - - appObs1->waitForUpdate(__FILE__, __LINE__); - - int serial = appObs1->serial; - test(appObs1->applications.empty()); - - try - { - ApplicationDescriptor app; - app.name = "Application"; - int s = session1->startUpdate(); - test(s == serial); - admin1->addApplication(app); - appObs1->waitForUpdate(__FILE__, __LINE__); - test(appObs1->applications.find("Application") != appObs1->applications.end()); - test(++serial == appObs1->serial); - } - catch(const Ice::UserException& ex) - { - cerr << ex << endl; - test(false); - } - - try - { - ApplicationUpdateDescriptor update; - update.name = "Application"; - update.variables.insert(make_pair(string("test"), string("test"))); - admin1->updateApplication(update); - appObs1->waitForUpdate(__FILE__, __LINE__); - test(appObs1->applications.find("Application") != appObs1->applications.end()); - test(appObs1->applications["Application"].descriptor.variables["test"] == "test"); - test(++serial == appObs1->serial); - } - catch(const Ice::UserException& ex) - { - cerr << ex << endl; - test(false); - } - - try - { - ApplicationDescriptor app; - app = appObs1->applications["Application"].descriptor; - app.variables.clear(); - app.variables["test1"] = "test"; - admin1->syncApplication(app); - appObs1->waitForUpdate(__FILE__, __LINE__); - test(appObs1->applications.find("Application") != appObs1->applications.end()); - test(appObs1->applications["Application"].descriptor.variables.size() == 1); - test(appObs1->applications["Application"].descriptor.variables["test1"] == "test"); - test(++serial == appObs1->serial); - } - catch(const Ice::UserException& ex) - { - cerr << ex << endl; - test(false); - } - - try - { - admin1->removeApplication("Application"); - appObs1->waitForUpdate(__FILE__, __LINE__); - test(appObs1->applications.empty()); - test(++serial == appObs1->serial); - } - catch(const Ice::UserException& ex) - { - cerr << ex << endl; - test(false); - } - - session1->destroy(); - adpt1->destroy(); - - cout << "ok" << endl; + cout << "testing application observer... " << flush; + AdminSessionPrx session1 = registry->createAdminSession("admin1", "test1"); + AdminPrx admin1 = session1->getAdmin(); + + keepAlive->add(session1); + + Ice::ObjectAdapterPtr adpt1 = communicator->createObjectAdapter(""); + ApplicationObserverIPtr appObs1 = new ApplicationObserverI("appObs1.2"); + Ice::ObjectPrx app1 = adpt1->addWithUUID(appObs1); + adpt1->activate(); + registry->ice_getConnection()->setAdapter(adpt1); + session1->setObserversByIdentity(Ice::Identity(), + Ice::Identity(), + app1->ice_getIdentity(), + Ice::Identity(), + Ice::Identity()); + + appObs1->waitForUpdate(__FILE__, __LINE__); + + int serial = appObs1->serial; + test(appObs1->applications.empty()); + + try + { + ApplicationDescriptor app; + app.name = "Application"; + int s = session1->startUpdate(); + test(s == serial); + admin1->addApplication(app); + appObs1->waitForUpdate(__FILE__, __LINE__); + test(appObs1->applications.find("Application") != appObs1->applications.end()); + test(++serial == appObs1->serial); + } + catch(const Ice::UserException& ex) + { + cerr << ex << endl; + test(false); + } + + try + { + ApplicationUpdateDescriptor update; + update.name = "Application"; + update.variables.insert(make_pair(string("test"), string("test"))); + admin1->updateApplication(update); + appObs1->waitForUpdate(__FILE__, __LINE__); + test(appObs1->applications.find("Application") != appObs1->applications.end()); + test(appObs1->applications["Application"].descriptor.variables["test"] == "test"); + test(++serial == appObs1->serial); + } + catch(const Ice::UserException& ex) + { + cerr << ex << endl; + test(false); + } + + try + { + ApplicationDescriptor app; + app = appObs1->applications["Application"].descriptor; + app.variables.clear(); + app.variables["test1"] = "test"; + admin1->syncApplication(app); + appObs1->waitForUpdate(__FILE__, __LINE__); + test(appObs1->applications.find("Application") != appObs1->applications.end()); + test(appObs1->applications["Application"].descriptor.variables.size() == 1); + test(appObs1->applications["Application"].descriptor.variables["test1"] == "test"); + test(++serial == appObs1->serial); + } + catch(const Ice::UserException& ex) + { + cerr << ex << endl; + test(false); + } + + try + { + admin1->removeApplication("Application"); + appObs1->waitForUpdate(__FILE__, __LINE__); + test(appObs1->applications.empty()); + test(++serial == appObs1->serial); + } + catch(const Ice::UserException& ex) + { + cerr << ex << endl; + test(false); + } + + session1->destroy(); + adpt1->destroy(); + + cout << "ok" << endl; } { - cout << "testing adapter observer... " << flush; - - AdminSessionPrx session1 = AdminSessionPrx::uncheckedCast(registry->createAdminSession("admin1", "test1")); - AdminPrx admin1 = session1->getAdmin(); - - keepAlive->add(session1); - - Ice::ObjectAdapterPtr adpt1 = communicator->createObjectAdapter(""); - AdapterObserverIPtr adptObs1 = new AdapterObserverI("adptObs1"); - Ice::ObjectPrx adapter1 = adpt1->addWithUUID(adptObs1); - adpt1->activate(); - registry->ice_getConnection()->setAdapter(adpt1); - session1->setObserversByIdentity(Ice::Identity(), - Ice::Identity(), - Ice::Identity(), - adapter1->ice_getIdentity(), - Ice::Identity()); - - adptObs1->waitForUpdate(__FILE__, __LINE__); // init - - try - { - Ice::ObjectPrx obj = communicator->stringToProxy("dummy:tcp -p 10000"); - - Ice::LocatorRegistryPrx locatorRegistry = communicator->getDefaultLocator()->getRegistry(); - locatorRegistry->setAdapterDirectProxy("DummyAdapter", obj); - adptObs1->waitForUpdate(__FILE__, __LINE__); - test(adptObs1->adapters.find("DummyAdapter") != adptObs1->adapters.end()); - test(adptObs1->adapters["DummyAdapter"].proxy == obj); - - obj = communicator->stringToProxy("dummy:tcp -p 10000 -h host"); - locatorRegistry->setAdapterDirectProxy("DummyAdapter", obj); - adptObs1->waitForUpdate(__FILE__, __LINE__); - test(adptObs1->adapters.find("DummyAdapter") != adptObs1->adapters.end()); - test(adptObs1->adapters["DummyAdapter"].proxy == obj); - - obj = communicator->stringToProxy("dummy:tcp -p 10000 -h host"); - locatorRegistry->setReplicatedAdapterDirectProxy("DummyAdapter", "DummyReplicaGroup", obj); - adptObs1->waitForUpdate(__FILE__, __LINE__); - test(adptObs1->adapters.find("DummyAdapter") != adptObs1->adapters.end()); - test(adptObs1->adapters["DummyAdapter"].proxy == obj); - test(adptObs1->adapters["DummyAdapter"].replicaGroupId == "DummyReplicaGroup"); - - obj = communicator->stringToProxy("dummy:tcp -p 10000 -h host"); - locatorRegistry->setReplicatedAdapterDirectProxy("DummyAdapter1", "DummyReplicaGroup", obj); - adptObs1->waitForUpdate(__FILE__, __LINE__); - test(adptObs1->adapters.find("DummyAdapter1") != adptObs1->adapters.end()); - test(adptObs1->adapters["DummyAdapter1"].proxy == obj); - test(adptObs1->adapters["DummyAdapter1"].replicaGroupId == "DummyReplicaGroup"); - - obj = communicator->stringToProxy("dummy:tcp -p 10000 -h host"); - locatorRegistry->setReplicatedAdapterDirectProxy("DummyAdapter2", "DummyReplicaGroup", obj); - adptObs1->waitForUpdate(__FILE__, __LINE__); - test(adptObs1->adapters.find("DummyAdapter2") != adptObs1->adapters.end()); - test(adptObs1->adapters["DummyAdapter2"].proxy == obj); - test(adptObs1->adapters["DummyAdapter2"].replicaGroupId == "DummyReplicaGroup"); - - admin->removeAdapter("DummyAdapter2"); - adptObs1->waitForUpdate(__FILE__, __LINE__); - test(adptObs1->adapters.find("DummyAdapter2") == adptObs1->adapters.end()); - - admin->removeAdapter("DummyReplicaGroup"); - adptObs1->waitForUpdate(__FILE__, __LINE__); - adptObs1->waitForUpdate(__FILE__, __LINE__); - test(adptObs1->adapters["DummyAdapter"].replicaGroupId == ""); - test(adptObs1->adapters["DummyAdapter1"].replicaGroupId == ""); - - locatorRegistry->setAdapterDirectProxy("DummyAdapter", 0); - adptObs1->waitForUpdate(__FILE__, __LINE__); - test(adptObs1->adapters.find("DummyAdapter") == adptObs1->adapters.end()); - } - catch(const Ice::UserException& ex) - { - cerr << ex << endl; - test(false); - } - - session1->destroy(); - adpt1->destroy(); - - cout << "ok" << endl; + cout << "testing adapter observer... " << flush; + + AdminSessionPrx session1 = AdminSessionPrx::uncheckedCast(registry->createAdminSession("admin1", "test1")); + AdminPrx admin1 = session1->getAdmin(); + + keepAlive->add(session1); + + Ice::ObjectAdapterPtr adpt1 = communicator->createObjectAdapter(""); + AdapterObserverIPtr adptObs1 = new AdapterObserverI("adptObs1"); + Ice::ObjectPrx adapter1 = adpt1->addWithUUID(adptObs1); + adpt1->activate(); + registry->ice_getConnection()->setAdapter(adpt1); + session1->setObserversByIdentity(Ice::Identity(), + Ice::Identity(), + Ice::Identity(), + adapter1->ice_getIdentity(), + Ice::Identity()); + + adptObs1->waitForUpdate(__FILE__, __LINE__); // init + + try + { + Ice::ObjectPrx obj = communicator->stringToProxy("dummy:tcp -p 10000"); + + Ice::LocatorRegistryPrx locatorRegistry = communicator->getDefaultLocator()->getRegistry(); + locatorRegistry->setAdapterDirectProxy("DummyAdapter", obj); + adptObs1->waitForUpdate(__FILE__, __LINE__); + test(adptObs1->adapters.find("DummyAdapter") != adptObs1->adapters.end()); + test(adptObs1->adapters["DummyAdapter"].proxy == obj); + + obj = communicator->stringToProxy("dummy:tcp -p 10000 -h host"); + locatorRegistry->setAdapterDirectProxy("DummyAdapter", obj); + adptObs1->waitForUpdate(__FILE__, __LINE__); + test(adptObs1->adapters.find("DummyAdapter") != adptObs1->adapters.end()); + test(adptObs1->adapters["DummyAdapter"].proxy == obj); + + obj = communicator->stringToProxy("dummy:tcp -p 10000 -h host"); + locatorRegistry->setReplicatedAdapterDirectProxy("DummyAdapter", "DummyReplicaGroup", obj); + adptObs1->waitForUpdate(__FILE__, __LINE__); + test(adptObs1->adapters.find("DummyAdapter") != adptObs1->adapters.end()); + test(adptObs1->adapters["DummyAdapter"].proxy == obj); + test(adptObs1->adapters["DummyAdapter"].replicaGroupId == "DummyReplicaGroup"); + + obj = communicator->stringToProxy("dummy:tcp -p 10000 -h host"); + locatorRegistry->setReplicatedAdapterDirectProxy("DummyAdapter1", "DummyReplicaGroup", obj); + adptObs1->waitForUpdate(__FILE__, __LINE__); + test(adptObs1->adapters.find("DummyAdapter1") != adptObs1->adapters.end()); + test(adptObs1->adapters["DummyAdapter1"].proxy == obj); + test(adptObs1->adapters["DummyAdapter1"].replicaGroupId == "DummyReplicaGroup"); + + obj = communicator->stringToProxy("dummy:tcp -p 10000 -h host"); + locatorRegistry->setReplicatedAdapterDirectProxy("DummyAdapter2", "DummyReplicaGroup", obj); + adptObs1->waitForUpdate(__FILE__, __LINE__); + test(adptObs1->adapters.find("DummyAdapter2") != adptObs1->adapters.end()); + test(adptObs1->adapters["DummyAdapter2"].proxy == obj); + test(adptObs1->adapters["DummyAdapter2"].replicaGroupId == "DummyReplicaGroup"); + + admin->removeAdapter("DummyAdapter2"); + adptObs1->waitForUpdate(__FILE__, __LINE__); + test(adptObs1->adapters.find("DummyAdapter2") == adptObs1->adapters.end()); + + admin->removeAdapter("DummyReplicaGroup"); + adptObs1->waitForUpdate(__FILE__, __LINE__); + adptObs1->waitForUpdate(__FILE__, __LINE__); + test(adptObs1->adapters["DummyAdapter"].replicaGroupId == ""); + test(adptObs1->adapters["DummyAdapter1"].replicaGroupId == ""); + + locatorRegistry->setAdapterDirectProxy("DummyAdapter", 0); + adptObs1->waitForUpdate(__FILE__, __LINE__); + test(adptObs1->adapters.find("DummyAdapter") == adptObs1->adapters.end()); + } + catch(const Ice::UserException& ex) + { + cerr << ex << endl; + test(false); + } + + session1->destroy(); + adpt1->destroy(); + + cout << "ok" << endl; } { - cout << "testing object observer... " << flush; - - AdminSessionPrx session1 = AdminSessionPrx::uncheckedCast(registry->createAdminSession("admin1", "test1")); - AdminPrx admin1 = session1->getAdmin(); - - keepAlive->add(session1); - - Ice::ObjectAdapterPtr adpt1 = communicator->createObjectAdapter(""); - ObjectObserverIPtr objectObs1 = new ObjectObserverI("objectObs1"); - Ice::ObjectPrx object1 = adpt1->addWithUUID(objectObs1); - adpt1->activate(); - registry->ice_getConnection()->setAdapter(adpt1); - session1->setObserversByIdentity(Ice::Identity(), - Ice::Identity(), - Ice::Identity(), - Ice::Identity(), - object1->ice_getIdentity()); - - objectObs1->waitForUpdate(__FILE__, __LINE__); // init - - try - { - Ice::ObjectPrx obj = communicator->stringToProxy("dummy:tcp -p 10000"); - - admin->addObjectWithType(obj, "::Dummy"); - objectObs1->waitForUpdate(__FILE__, __LINE__); - test(objectObs1->objects.find(communicator->stringToIdentity("dummy")) != objectObs1->objects.end()); - test(objectObs1->objects[communicator->stringToIdentity("dummy")].type == "::Dummy"); - test(objectObs1->objects[communicator->stringToIdentity("dummy")].proxy == obj); - - obj = communicator->stringToProxy("dummy:tcp -p 10000 -h host"); - admin->updateObject(obj); - objectObs1->waitForUpdate(__FILE__, __LINE__); - test(objectObs1->objects.find(communicator->stringToIdentity("dummy")) != objectObs1->objects.end()); - test(objectObs1->objects[communicator->stringToIdentity("dummy")].type == "::Dummy"); - test(objectObs1->objects[communicator->stringToIdentity("dummy")].proxy == obj); - - admin->removeObject(obj->ice_getIdentity()); - objectObs1->waitForUpdate(__FILE__, __LINE__); - test(objectObs1->objects.find(communicator->stringToIdentity("dummy")) == objectObs1->objects.end()); - } - catch(const Ice::UserException& ex) - { - cerr << ex << endl; - test(false); - } - - session1->destroy(); - adpt1->destroy(); - - cout << "ok" << endl; + cout << "testing object observer... " << flush; + + AdminSessionPrx session1 = AdminSessionPrx::uncheckedCast(registry->createAdminSession("admin1", "test1")); + AdminPrx admin1 = session1->getAdmin(); + + keepAlive->add(session1); + + Ice::ObjectAdapterPtr adpt1 = communicator->createObjectAdapter(""); + ObjectObserverIPtr objectObs1 = new ObjectObserverI("objectObs1"); + Ice::ObjectPrx object1 = adpt1->addWithUUID(objectObs1); + adpt1->activate(); + registry->ice_getConnection()->setAdapter(adpt1); + session1->setObserversByIdentity(Ice::Identity(), + Ice::Identity(), + Ice::Identity(), + Ice::Identity(), + object1->ice_getIdentity()); + + objectObs1->waitForUpdate(__FILE__, __LINE__); // init + + try + { + Ice::ObjectPrx obj = communicator->stringToProxy("dummy:tcp -p 10000"); + + admin->addObjectWithType(obj, "::Dummy"); + objectObs1->waitForUpdate(__FILE__, __LINE__); + test(objectObs1->objects.find(communicator->stringToIdentity("dummy")) != objectObs1->objects.end()); + test(objectObs1->objects[communicator->stringToIdentity("dummy")].type == "::Dummy"); + test(objectObs1->objects[communicator->stringToIdentity("dummy")].proxy == obj); + + obj = communicator->stringToProxy("dummy:tcp -p 10000 -h host"); + admin->updateObject(obj); + objectObs1->waitForUpdate(__FILE__, __LINE__); + test(objectObs1->objects.find(communicator->stringToIdentity("dummy")) != objectObs1->objects.end()); + test(objectObs1->objects[communicator->stringToIdentity("dummy")].type == "::Dummy"); + test(objectObs1->objects[communicator->stringToIdentity("dummy")].proxy == obj); + + admin->removeObject(obj->ice_getIdentity()); + objectObs1->waitForUpdate(__FILE__, __LINE__); + test(objectObs1->objects.find(communicator->stringToIdentity("dummy")) == objectObs1->objects.end()); + } + catch(const Ice::UserException& ex) + { + cerr << ex << endl; + test(false); + } + + session1->destroy(); + adpt1->destroy(); + + cout << "ok" << endl; } { -// cout << "???" << endl; - -// // -// // Setup a descriptor to deploy a node on the node. -// // -// ApplicationDescriptor nodeApp; -// nodeApp.name = "NodeApp"; -// ServerDescriptorPtr server = new ServerDescriptor(); -// server->id = "node-1"; -// server->exe = properties->getProperty("IceDir") + "/bin/icegridnode"; -// server->options.push_back("--nowarn"); -// server->pwd = "."; -// AdapterDescriptor adapter; -// adapter.name = "IceGrid.Node"; -// adapter.id = "IceGrid.Node.node-1"; -// adapter.registerProcess = true; -// adapter.waitForActivation = false; -// server->adapters.push_back(adapter); -// addProperty(server, "IceGrid.Node.Name", "node-1"); -// addProperty(server, "IceGrid.Node.Data", properties->getProperty("TestDir") + "/db/node-1"); -// addProperty(server, "Ice.OA.IceGrid.Node.Endpoints", "default"); -// NodeDescriptor node; -// node.servers.push_back(server); -// nodeApp.nodes["localnode"] = node; - -// try -// { -// int s = session1->startUpdate(); -// test(s == serial); -// admin1->addApplication(nodeApp); -// appObs1->waitForUpdate(__FILE__, __LINE__); // application added -// test(appObs1->applications.find("NodeApp") != appObs1->applications.end()); -// test(++serial == appObs1->serial); -// } -// catch(const DeploymentException& ex) -// { -// cerr << ex.reason << endl; -// test(false); -// } -// catch(const Ice::UserException& ex) -// { -// cerr << ex << endl; -// test(false); -// } - -// try -// { -// admin->startServer("node-1"); -// } -// catch(const NodeUnreachableException& ex) -// { -// cerr << ex << ":\n"; -// cerr << "node = " << ex.name << endl; -// cerr << "reason = " << ex.reason << endl; -// } -// appObs1->waitForUpdate(__FILE__, __LINE__); // object added (for node well-known proxy) -// test(++serial == appObs1->serial); - -// nodeObs1->waitForUpdate(__FILE__, __LINE__); // updateServer -// nodeObs1->waitForUpdate(__FILE__, __LINE__); // updateServer -// do -// { -// nodeObs1->waitForUpdate(__FILE__, __LINE__); // nodeUp -// } -// while(nodeObs1->nodes.find("node-1") == nodeObs1->nodes.end()); - -// try -// { -// admin->stopServer("node-1"); -// } -// catch(const NodeUnreachableException& ex) -// { -// cerr << ex << ":\n"; -// cerr << "node = " << ex.name << endl; -// cerr << "reason = " << ex.reason << endl; -// } -// appObs1->waitForUpdate(__FILE__, __LINE__); // object removed (for node well-known proxy) -// test(++serial == appObs1->serial); - -// nodeObs1->waitForUpdate(__FILE__, __LINE__); // updateServer -// nodeObs1->waitForUpdate(__FILE__, __LINE__); // updateServer -// nodeObs1->waitForUpdate(__FILE__, __LINE__); // nodeDown -// test(nodeObs1->nodes.find("node-1") == nodeObs1->nodes.end()); - -// try -// { -// admin1->removeApplication("NodeApp"); -// appObs1->waitForUpdate(__FILE__, __LINE__); // application removed -// test(appObs1->applications.empty()); -// test(++serial == appObs1->serial); -// } -// catch(const DeploymentException& ex) -// { -// cerr << ex.reason << endl; -// test(false); -// } -// catch(const Ice::UserException& ex) -// { -// cerr << ex << endl; -// test(false); -// } - -// nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate(Destroying) -// nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate(Destroyed) - -// session1->destroy(); -// adpt1->destroy(); - -// cout << "ok" << endl; +// cout << "???" << endl; + +// // +// // Setup a descriptor to deploy a node on the node. +// // +// ApplicationDescriptor nodeApp; +// nodeApp.name = "NodeApp"; +// ServerDescriptorPtr server = new ServerDescriptor(); +// server->id = "node-1"; +// server->exe = properties->getProperty("IceDir") + "/bin/icegridnode"; +// server->options.push_back("--nowarn"); +// server->pwd = "."; +// AdapterDescriptor adapter; +// adapter.name = "IceGrid.Node"; +// adapter.id = "IceGrid.Node.node-1"; +// adapter.registerProcess = true; +// adapter.waitForActivation = false; +// server->adapters.push_back(adapter); +// addProperty(server, "IceGrid.Node.Name", "node-1"); +// addProperty(server, "IceGrid.Node.Data", properties->getProperty("TestDir") + "/db/node-1"); +// addProperty(server, "Ice.OA.IceGrid.Node.Endpoints", "default"); +// NodeDescriptor node; +// node.servers.push_back(server); +// nodeApp.nodes["localnode"] = node; + +// try +// { +// int s = session1->startUpdate(); +// test(s == serial); +// admin1->addApplication(nodeApp); +// appObs1->waitForUpdate(__FILE__, __LINE__); // application added +// test(appObs1->applications.find("NodeApp") != appObs1->applications.end()); +// test(++serial == appObs1->serial); +// } +// catch(const DeploymentException& ex) +// { +// cerr << ex.reason << endl; +// test(false); +// } +// catch(const Ice::UserException& ex) +// { +// cerr << ex << endl; +// test(false); +// } + +// try +// { +// admin->startServer("node-1"); +// } +// catch(const NodeUnreachableException& ex) +// { +// cerr << ex << ":\n"; +// cerr << "node = " << ex.name << endl; +// cerr << "reason = " << ex.reason << endl; +// } +// appObs1->waitForUpdate(__FILE__, __LINE__); // object added (for node well-known proxy) +// test(++serial == appObs1->serial); + +// nodeObs1->waitForUpdate(__FILE__, __LINE__); // updateServer +// nodeObs1->waitForUpdate(__FILE__, __LINE__); // updateServer +// do +// { +// nodeObs1->waitForUpdate(__FILE__, __LINE__); // nodeUp +// } +// while(nodeObs1->nodes.find("node-1") == nodeObs1->nodes.end()); + +// try +// { +// admin->stopServer("node-1"); +// } +// catch(const NodeUnreachableException& ex) +// { +// cerr << ex << ":\n"; +// cerr << "node = " << ex.name << endl; +// cerr << "reason = " << ex.reason << endl; +// } +// appObs1->waitForUpdate(__FILE__, __LINE__); // object removed (for node well-known proxy) +// test(++serial == appObs1->serial); + +// nodeObs1->waitForUpdate(__FILE__, __LINE__); // updateServer +// nodeObs1->waitForUpdate(__FILE__, __LINE__); // updateServer +// nodeObs1->waitForUpdate(__FILE__, __LINE__); // nodeDown +// test(nodeObs1->nodes.find("node-1") == nodeObs1->nodes.end()); + +// try +// { +// admin1->removeApplication("NodeApp"); +// appObs1->waitForUpdate(__FILE__, __LINE__); // application removed +// test(appObs1->applications.empty()); +// test(++serial == appObs1->serial); +// } +// catch(const DeploymentException& ex) +// { +// cerr << ex.reason << endl; +// test(false); +// } +// catch(const Ice::UserException& ex) +// { +// cerr << ex << endl; +// test(false); +// } + +// nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate(Destroying) +// nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate(Destroyed) + +// session1->destroy(); +// adpt1->destroy(); + +// cout << "ok" << endl; } { - cout << "testing node observer... " << flush; - AdminSessionPrx session1 = registry->createAdminSession("admin1", "test1"); - - keepAlive->add(session1); - - Ice::ObjectAdapterPtr adpt1 = communicator->createObjectAdapter(""); - ApplicationObserverIPtr appObs1 = new ApplicationObserverI("appObs1.3"); - Ice::ObjectPrx app1 = adpt1->addWithUUID(appObs1); - NodeObserverIPtr nodeObs1 = new NodeObserverI("nodeObs1"); - Ice::ObjectPrx no1 = adpt1->addWithUUID(nodeObs1); - adpt1->activate(); - registry->ice_getConnection()->setAdapter(adpt1); - session1->setObserversByIdentity(Ice::Identity(), - no1->ice_getIdentity(), - app1->ice_getIdentity(), - Ice::Identity(), - Ice::Identity()); - - appObs1->waitForUpdate(__FILE__, __LINE__); - nodeObs1->waitForUpdate(__FILE__, __LINE__); // init - - test(nodeObs1->nodes.find("localnode") != nodeObs1->nodes.end()); - test(appObs1->applications.empty()); - - ApplicationDescriptor nodeApp; - nodeApp.name = "NodeApp"; - ServerDescriptorPtr server = new ServerDescriptor(); - server->id = "node-1"; - server->exe = properties->getProperty("IceDir") + "/bin/icegridnode"; - server->options.push_back("--nowarn"); - server->pwd = "."; - AdapterDescriptor adapter; - adapter.name = "IceGrid.Node"; - adapter.id = "IceGrid.Node.node-1"; - adapter.registerProcess = true; - adapter.serverLifetime = false; - server->adapters.push_back(adapter); - addProperty(server, "IceGrid.Node.Name", "node-1"); - addProperty(server, "IceGrid.Node.Data", properties->getProperty("TestDir") + "/db/node-1"); - addProperty(server, "Ice.OA.IceGrid.Node.Endpoints", "default"); - NodeDescriptor node; - node.servers.push_back(server); - nodeApp.nodes["localnode"] = node; - - session->startUpdate(); - admin->addApplication(nodeApp); - session->finishUpdate(); - appObs1->waitForUpdate(__FILE__, __LINE__); - - admin->startServer("node-1"); - - nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate - nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate - do - { - nodeObs1->waitForUpdate(__FILE__, __LINE__); // nodeUp - } - while(nodeObs1->nodes.find("node-1") == nodeObs1->nodes.end()); - - test(nodeObs1->nodes["localnode"].servers.size() == 1); - test(nodeObs1->nodes["localnode"].servers[0].state == Active); - admin->stopServer("node-1"); - - nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate(Deactivating) - nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate(Inactive) - nodeObs1->waitForUpdate(__FILE__, __LINE__); // nodeDown - test(nodeObs1->nodes["localnode"].servers[0].state == Inactive); - - session->startUpdate(); - admin->removeApplication("NodeApp"); - session->finishUpdate(); - nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate(Destroying) - nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate(Destroyed) - - appObs1->waitForUpdate(__FILE__, __LINE__); - test(nodeObs1->nodes.find("node-1") == nodeObs1->nodes.end()); - - ApplicationDescriptor testApp; - testApp.name = "TestApp"; - - server = new ServerDescriptor(); - server->id = "Server"; - server->exe = properties->getProperty("TestDir") + "/server"; - server->pwd = "."; - adapter.name = "Server"; - adapter.id = "ServerAdapter"; - adapter.registerProcess = true; - adapter.serverLifetime = true; - server->adapters.push_back(adapter); - addProperty(server, "Ice.OA.Server.Endpoints", "default"); - node = NodeDescriptor(); - node.servers.push_back(server); - testApp.nodes["localnode"] = node; - - session->startUpdate(); - admin->addApplication(testApp); - session->finishUpdate(); - appObs1->waitForUpdate(__FILE__, __LINE__); - - - session->startUpdate(); - admin->startServer("Server"); - session->finishUpdate(); - - nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate - nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate - nodeObs1->waitForUpdate(__FILE__, __LINE__); // adapterUpdate - - test(nodeObs1->nodes.find("localnode") != nodeObs1->nodes.end()); - test(nodeObs1->nodes["localnode"].servers.size() == 1); - test(nodeObs1->nodes["localnode"].servers[0].state == Active); - test(nodeObs1->nodes["localnode"].adapters.size() == 1); - test(nodeObs1->nodes["localnode"].adapters[0].proxy); - - test(nodeObs1->nodes["localnode"].servers[0].enabled); - admin->enableServer("Server", false); - nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate - test(!nodeObs1->nodes["localnode"].servers[0].enabled); - admin->enableServer("Server", true); - nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate - test(nodeObs1->nodes["localnode"].servers[0].enabled); - - admin->stopServer("Server"); - - nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate - nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate - nodeObs1->waitForUpdate(__FILE__, __LINE__); // adapterUpdate - - test(nodeObs1->nodes.find("localnode") != nodeObs1->nodes.end()); - test(nodeObs1->nodes["localnode"].servers.size() == 1); - test(nodeObs1->nodes["localnode"].servers[0].state == Inactive); - test(nodeObs1->nodes["localnode"].adapters.empty()); - - session->startUpdate(); - admin->removeApplication("TestApp"); - session->finishUpdate(); - - nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate(Destroying) - nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate(Destroyed) - test(nodeObs1->nodes["localnode"].servers.empty()); - - appObs1->waitForUpdate(__FILE__, __LINE__); - - cout << "ok" << endl; + cout << "testing node observer... " << flush; + AdminSessionPrx session1 = registry->createAdminSession("admin1", "test1"); + + keepAlive->add(session1); + + Ice::ObjectAdapterPtr adpt1 = communicator->createObjectAdapter(""); + ApplicationObserverIPtr appObs1 = new ApplicationObserverI("appObs1.3"); + Ice::ObjectPrx app1 = adpt1->addWithUUID(appObs1); + NodeObserverIPtr nodeObs1 = new NodeObserverI("nodeObs1"); + Ice::ObjectPrx no1 = adpt1->addWithUUID(nodeObs1); + adpt1->activate(); + registry->ice_getConnection()->setAdapter(adpt1); + session1->setObserversByIdentity(Ice::Identity(), + no1->ice_getIdentity(), + app1->ice_getIdentity(), + Ice::Identity(), + Ice::Identity()); + + appObs1->waitForUpdate(__FILE__, __LINE__); + nodeObs1->waitForUpdate(__FILE__, __LINE__); // init + + test(nodeObs1->nodes.find("localnode") != nodeObs1->nodes.end()); + test(appObs1->applications.empty()); + + ApplicationDescriptor nodeApp; + nodeApp.name = "NodeApp"; + ServerDescriptorPtr server = new ServerDescriptor(); + server->id = "node-1"; + server->exe = properties->getProperty("IceDir") + "/bin/icegridnode"; + server->options.push_back("--nowarn"); + server->pwd = "."; + AdapterDescriptor adapter; + adapter.name = "IceGrid.Node"; + adapter.id = "IceGrid.Node.node-1"; + adapter.registerProcess = true; + adapter.serverLifetime = false; + server->adapters.push_back(adapter); + addProperty(server, "IceGrid.Node.Name", "node-1"); + addProperty(server, "IceGrid.Node.Data", properties->getProperty("TestDir") + "/db/node-1"); + addProperty(server, "Ice.OA.IceGrid.Node.Endpoints", "default"); + NodeDescriptor node; + node.servers.push_back(server); + nodeApp.nodes["localnode"] = node; + + session->startUpdate(); + admin->addApplication(nodeApp); + session->finishUpdate(); + appObs1->waitForUpdate(__FILE__, __LINE__); + + admin->startServer("node-1"); + + nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate + nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate + do + { + nodeObs1->waitForUpdate(__FILE__, __LINE__); // nodeUp + } + while(nodeObs1->nodes.find("node-1") == nodeObs1->nodes.end()); + + test(nodeObs1->nodes["localnode"].servers.size() == 1); + test(nodeObs1->nodes["localnode"].servers[0].state == Active); + admin->stopServer("node-1"); + + nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate(Deactivating) + nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate(Inactive) + nodeObs1->waitForUpdate(__FILE__, __LINE__); // nodeDown + test(nodeObs1->nodes["localnode"].servers[0].state == Inactive); + + session->startUpdate(); + admin->removeApplication("NodeApp"); + session->finishUpdate(); + nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate(Destroying) + nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate(Destroyed) + + appObs1->waitForUpdate(__FILE__, __LINE__); + test(nodeObs1->nodes.find("node-1") == nodeObs1->nodes.end()); + + ApplicationDescriptor testApp; + testApp.name = "TestApp"; + + server = new ServerDescriptor(); + server->id = "Server"; + server->exe = properties->getProperty("TestDir") + "/server"; + server->pwd = "."; + adapter.name = "Server"; + adapter.id = "ServerAdapter"; + adapter.registerProcess = true; + adapter.serverLifetime = true; + server->adapters.push_back(adapter); + addProperty(server, "Ice.OA.Server.Endpoints", "default"); + node = NodeDescriptor(); + node.servers.push_back(server); + testApp.nodes["localnode"] = node; + + session->startUpdate(); + admin->addApplication(testApp); + session->finishUpdate(); + appObs1->waitForUpdate(__FILE__, __LINE__); + + + session->startUpdate(); + admin->startServer("Server"); + session->finishUpdate(); + + nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate + nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate + nodeObs1->waitForUpdate(__FILE__, __LINE__); // adapterUpdate + + test(nodeObs1->nodes.find("localnode") != nodeObs1->nodes.end()); + test(nodeObs1->nodes["localnode"].servers.size() == 1); + test(nodeObs1->nodes["localnode"].servers[0].state == Active); + test(nodeObs1->nodes["localnode"].adapters.size() == 1); + test(nodeObs1->nodes["localnode"].adapters[0].proxy); + + test(nodeObs1->nodes["localnode"].servers[0].enabled); + admin->enableServer("Server", false); + nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate + test(!nodeObs1->nodes["localnode"].servers[0].enabled); + admin->enableServer("Server", true); + nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate + test(nodeObs1->nodes["localnode"].servers[0].enabled); + + admin->stopServer("Server"); + + nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate + nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate + nodeObs1->waitForUpdate(__FILE__, __LINE__); // adapterUpdate + + test(nodeObs1->nodes.find("localnode") != nodeObs1->nodes.end()); + test(nodeObs1->nodes["localnode"].servers.size() == 1); + test(nodeObs1->nodes["localnode"].servers[0].state == Inactive); + test(nodeObs1->nodes["localnode"].adapters.empty()); + + session->startUpdate(); + admin->removeApplication("TestApp"); + session->finishUpdate(); + + nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate(Destroying) + nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate(Destroyed) + test(nodeObs1->nodes["localnode"].servers.empty()); + + appObs1->waitForUpdate(__FILE__, __LINE__); + + cout << "ok" << endl; } { - cout << "testing registry observer... " << flush; - AdminSessionPrx session1 = registry->createAdminSession("admin1", "test1"); - - keepAlive->add(session1); - - Ice::ObjectAdapterPtr adpt1 = communicator->createObjectAdapter(""); - ApplicationObserverIPtr appObs1 = new ApplicationObserverI("appObs1.4"); - Ice::ObjectPrx app1 = adpt1->addWithUUID(appObs1); - RegistryObserverIPtr registryObs1 = new RegistryObserverI("registryObs1"); - Ice::ObjectPrx ro1 = adpt1->addWithUUID(registryObs1); - adpt1->activate(); - registry->ice_getConnection()->setAdapter(adpt1); - session1->setObserversByIdentity(ro1->ice_getIdentity(), - Ice::Identity(), - app1->ice_getIdentity(), - Ice::Identity(), - Ice::Identity()); - - appObs1->waitForUpdate(__FILE__, __LINE__); - registryObs1->waitForUpdate(__FILE__, __LINE__); // init - - test(registryObs1->registries.find("Master") != registryObs1->registries.end()); - test(appObs1->applications.empty()); - - QueryPrx query = QueryPrx::uncheckedCast(communicator->stringToProxy("IceGrid/Query")); - Ice::ObjectProxySeq registries = query->findAllObjectsByType("::IceGrid::Registry"); - const string prefix("Registry-"); - for(Ice::ObjectProxySeq::const_iterator p = registries.begin(); p != registries.end(); ++p) - { - string name = (*p)->ice_getIdentity().name; - string::size_type pos = name.find(prefix); - if(pos != string::npos) - { - name = name.substr(prefix.size()); - test(registryObs1->registries.find(name) != registryObs1->registries.end()); - } - } - cout << "ok" << endl; + cout << "testing registry observer... " << flush; + AdminSessionPrx session1 = registry->createAdminSession("admin1", "test1"); + + keepAlive->add(session1); + + Ice::ObjectAdapterPtr adpt1 = communicator->createObjectAdapter(""); + ApplicationObserverIPtr appObs1 = new ApplicationObserverI("appObs1.4"); + Ice::ObjectPrx app1 = adpt1->addWithUUID(appObs1); + RegistryObserverIPtr registryObs1 = new RegistryObserverI("registryObs1"); + Ice::ObjectPrx ro1 = adpt1->addWithUUID(registryObs1); + adpt1->activate(); + registry->ice_getConnection()->setAdapter(adpt1); + session1->setObserversByIdentity(ro1->ice_getIdentity(), + Ice::Identity(), + app1->ice_getIdentity(), + Ice::Identity(), + Ice::Identity()); + + appObs1->waitForUpdate(__FILE__, __LINE__); + registryObs1->waitForUpdate(__FILE__, __LINE__); // init + + test(registryObs1->registries.find("Master") != registryObs1->registries.end()); + test(appObs1->applications.empty()); + + QueryPrx query = QueryPrx::uncheckedCast(communicator->stringToProxy("IceGrid/Query")); + Ice::ObjectProxySeq registries = query->findAllObjectsByType("::IceGrid::Registry"); + const string prefix("Registry-"); + for(Ice::ObjectProxySeq::const_iterator p = registries.begin(); p != registries.end(); ++p) + { + string name = (*p)->ice_getIdentity().name; + string::size_type pos = name.find(prefix); + if(pos != string::npos) + { + name = name.substr(prefix.size()); + test(registryObs1->registries.find(name) != registryObs1->registries.end()); + } + } + cout << "ok" << endl; } diff --git a/cpp/test/IceGrid/session/Client.cpp b/cpp/test/IceGrid/session/Client.cpp index 3074006cc71..a2b38017c27 100644 --- a/cpp/test/IceGrid/session/Client.cpp +++ b/cpp/test/IceGrid/session/Client.cpp @@ -27,30 +27,30 @@ main(int argc, char* argv[]) Ice::CommunicatorPtr communicator; try { - Ice::InitializationData initData; - initData.properties = Ice::createProperties(argc, argv); - initData.properties->setProperty("Ice.Warn.Connections", "0"); - communicator = Ice::initialize(argc, argv, initData); - communicator->getProperties()->parseCommandLineOptions("", Ice::argsToStringSeq(argc, argv)); - status = run(argc, argv, communicator); + Ice::InitializationData initData; + initData.properties = Ice::createProperties(argc, argv); + initData.properties->setProperty("Ice.Warn.Connections", "0"); + communicator = Ice::initialize(argc, argv, initData); + communicator->getProperties()->parseCommandLineOptions("", Ice::argsToStringSeq(argc, argv)); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/IceGrid/session/PermissionsVerifier.cpp b/cpp/test/IceGrid/session/PermissionsVerifier.cpp index 11ce11e3e98..726464c29d4 100644 --- a/cpp/test/IceGrid/session/PermissionsVerifier.cpp +++ b/cpp/test/IceGrid/session/PermissionsVerifier.cpp @@ -20,13 +20,13 @@ public: virtual bool checkPermissions(const string& userId, const string& passwd, string&, const Ice::Current& c) const { - if(userId == "shutdown") - { - c.adapter->getCommunicator()->shutdown(); - return true; - } - return userId == "admin1" && passwd == "test1" || userId == "admin2" && passwd == "test2" || - userId == "admin3" && passwd == "test3"; + if(userId == "shutdown") + { + c.adapter->getCommunicator()->shutdown(); + return true; + } + return userId == "admin1" && passwd == "test1" || userId == "admin2" && passwd == "test2" || + userId == "admin3" && passwd == "test3"; } }; @@ -36,12 +36,12 @@ public: virtual int run(int, char*[]) { - Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapterWithEndpoints( - "PermissionsVerifier", "tcp -p 12002"); - adapter->add(new AdminPermissionsVerifierI, communicator()->stringToIdentity("AdminPermissionsVerifier")); - adapter->activate(); - communicator()->waitForShutdown(); - return EXIT_SUCCESS; + Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapterWithEndpoints( + "PermissionsVerifier", "tcp -p 12002"); + adapter->add(new AdminPermissionsVerifierI, communicator()->stringToIdentity("AdminPermissionsVerifier")); + adapter->activate(); + communicator()->waitForShutdown(); + return EXIT_SUCCESS; } }; diff --git a/cpp/test/IceGrid/session/Server.cpp b/cpp/test/IceGrid/session/Server.cpp index a52ac4fa42e..c22cebc53ec 100644 --- a/cpp/test/IceGrid/session/Server.cpp +++ b/cpp/test/IceGrid/session/Server.cpp @@ -21,7 +21,7 @@ public: virtual bool checkPermissions(const string& userId, const string& passwd, string&, const Ice::Current&) const { - return userId == "client1" && passwd == "test1" || userId == "client2" && passwd == "test2"; + return userId == "client1" && passwd == "test1" || userId == "client2" && passwd == "test2"; } }; @@ -32,15 +32,15 @@ public: virtual bool authorize(const Glacier2::SSLInfo& info, string&, const Ice::Current& current) const { - IceSSL::CertificatePtr cert = IceSSL::Certificate::decode(info.certs[0]); - test(cert->getIssuerDN() == IceSSL::DistinguishedName( - "emailAddress=info@zeroc.com,CN=ZeroC Test CA,OU=Ice,O=ZeroC\\, Inc.,L=Palm Beach Gardens," - "ST=Florida,C=US")); - test(cert->getSubjectDN() == IceSSL::DistinguishedName( - "CN=Client,emailAddress=info@zeroc.com,OU=Ice,O=ZeroC\\, Inc.,ST=Florida,C=US")); - test(cert->checkValidity()); + IceSSL::CertificatePtr cert = IceSSL::Certificate::decode(info.certs[0]); + test(cert->getIssuerDN() == IceSSL::DistinguishedName( + "emailAddress=info@zeroc.com,CN=ZeroC Test CA,OU=Ice,O=ZeroC\\, Inc.,L=Palm Beach Gardens," + "ST=Florida,C=US")); + test(cert->getSubjectDN() == IceSSL::DistinguishedName( + "CN=Client,emailAddress=info@zeroc.com,OU=Ice,O=ZeroC\\, Inc.,ST=Florida,C=US")); + test(cert->checkValidity()); - return true; + return true; } }; @@ -57,8 +57,8 @@ Server::run(int argc, char* argv[]) Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Server"); if(communicator()->getProperties()->getPropertyAsInt("AddPermissionsVerifiers") > 0) { - adapter->add(new ClientPermissionsVerifierI(), communicator()->stringToIdentity("ClientPermissionsVerifier")); - adapter->add(new SSLPermissionsVerifierI(), communicator()->stringToIdentity("SSLPermissionsVerifier")); + adapter->add(new ClientPermissionsVerifierI(), communicator()->stringToIdentity("ClientPermissionsVerifier")); + adapter->add(new SSLPermissionsVerifierI(), communicator()->stringToIdentity("SSLPermissionsVerifier")); } adapter->activate(); diff --git a/cpp/test/IceGrid/simple/AllTests.cpp b/cpp/test/IceGrid/simple/AllTests.cpp index cf759e6d78f..a2e502ae1fc 100644 --- a/cpp/test/IceGrid/simple/AllTests.cpp +++ b/cpp/test/IceGrid/simple/AllTests.cpp @@ -22,7 +22,7 @@ class SessionKeepAliveThread : public IceUtil::Thread, public IceUtil::Monitor<I public: SessionKeepAliveThread(const IceGrid::AdminSessionPrx& session, long timeout) : - _session(session), + _session(session), _timeout(IceUtil::Time::seconds(timeout)), _destroy(false) { @@ -37,15 +37,15 @@ public: timedWait(_timeout); if(_destroy) { - break; - } + break; + } try { _session->keepAlive(); } catch(const Ice::Exception&) { - break; + break; } } } @@ -116,31 +116,31 @@ allTestsWithDeploy(const Ice::CommunicatorPtr& communicator) cout << "testing reference with unknown identity... " << flush; try { - communicator->stringToProxy("unknown/unknown")->ice_ping(); - test(false); + communicator->stringToProxy("unknown/unknown")->ice_ping(); + test(false); } catch (const Ice::NotRegisteredException& ex) { - test(ex.kindOfObject == "object"); - test(ex.id == "unknown/unknown"); + test(ex.kindOfObject == "object"); + test(ex.id == "unknown/unknown"); } cout << "ok" << endl; cout << "testing reference with unknown adapter... " << flush; try { - communicator->stringToProxy("test @ TestAdapterUnknown")->ice_ping(); - test(false); + communicator->stringToProxy("test @ TestAdapterUnknown")->ice_ping(); + test(false); } catch (const Ice::NotRegisteredException& ex) { - test(ex.kindOfObject == "object adapter"); - test(ex.id == "TestAdapterUnknown"); + test(ex.kindOfObject == "object adapter"); + test(ex.id == "TestAdapterUnknown"); } cout << "ok" << endl; IceGrid::RegistryPrx registry = IceGrid::RegistryPrx::checkedCast( - communicator->stringToProxy("IceGrid/Registry")); + communicator->stringToProxy("IceGrid/Registry")); test(registry); IceGrid::AdminSessionPrx session = registry->createAdminSession("foo", "bar"); @@ -156,16 +156,16 @@ allTestsWithDeploy(const Ice::CommunicatorPtr& communicator) cout << "testing whether server is still reachable... " << flush; try { - obj = TestIntfPrx::checkedCast(base); - test(false); + obj = TestIntfPrx::checkedCast(base); + test(false); } catch(const Ice::NoEndpointException&) { } try { - obj2 = TestIntfPrx::checkedCast(base2); - test(false); + obj2 = TestIntfPrx::checkedCast(base2); + test(false); } catch(const Ice::NoEndpointException&) { @@ -175,19 +175,19 @@ allTestsWithDeploy(const Ice::CommunicatorPtr& communicator) try { - obj = TestIntfPrx::checkedCast(base); + obj = TestIntfPrx::checkedCast(base); } catch(const Ice::NoEndpointException&) { - test(false); + test(false); } try { - obj2 = TestIntfPrx::checkedCast(base2); + obj2 = TestIntfPrx::checkedCast(base2); } catch(const Ice::NoEndpointException&) { - test(false); + test(false); } cout << "ok" << endl; diff --git a/cpp/test/IceGrid/simple/Client.cpp b/cpp/test/IceGrid/simple/Client.cpp index 57499a1d856..57c7ae95e38 100644 --- a/cpp/test/IceGrid/simple/Client.cpp +++ b/cpp/test/IceGrid/simple/Client.cpp @@ -22,22 +22,22 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) for(int i = 1; i < argc; ++i) { - if(strcmp(argv[i], "--with-deploy") == 0) - { - withDeploy = true; - break; - } + if(strcmp(argv[i], "--with-deploy") == 0) + { + withDeploy = true; + break; + } } if(!withDeploy) { - void allTests(const Ice::CommunicatorPtr&); - allTests(communicator); + void allTests(const Ice::CommunicatorPtr&); + allTests(communicator); } else { - void allTestsWithDeploy(const Ice::CommunicatorPtr&); - allTestsWithDeploy(communicator); + void allTestsWithDeploy(const Ice::CommunicatorPtr&); + allTestsWithDeploy(communicator); } return EXIT_SUCCESS; @@ -52,26 +52,26 @@ main(int argc, char* argv[]) try { - communicator = Ice::initialize(argc, argv); - status = run(argc, argv, communicator); + communicator = Ice::initialize(argc, argv); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/IceGrid/simple/Server.cpp b/cpp/test/IceGrid/simple/Server.cpp index 17146db154f..0a54b1a3a77 100644 --- a/cpp/test/IceGrid/simple/Server.cpp +++ b/cpp/test/IceGrid/simple/Server.cpp @@ -34,7 +34,7 @@ Server::run(int argc, char* argv[]) shutdownOnInterrupt(); try { - adapter->activate(); + adapter->activate(); } catch(const Ice::ObjectAdapterDeactivatedException&) { diff --git a/cpp/test/IceGrid/simple/run.py b/cpp/test/IceGrid/simple/run.py index e6a9b24de2d..adda46062b3 100755 --- a/cpp/test/IceGrid/simple/run.py +++ b/cpp/test/IceGrid/simple/run.py @@ -27,7 +27,7 @@ name = os.path.join("IceGrid", "simple") # Test client/server without on demand activation. # IceGridAdmin.iceGridClientServerTest(name, "", "--Ice.OA.TestAdapter.Endpoints=default" + \ - " --Ice.OA.TestAdapter.AdapterId=TestAdapter") + " --Ice.OA.TestAdapter.AdapterId=TestAdapter") # # Test client/server with on demand activation. diff --git a/cpp/test/IceGrid/update/AllTests.cpp b/cpp/test/IceGrid/update/AllTests.cpp index 4ab8362766c..37ceba2b818 100644 --- a/cpp/test/IceGrid/update/AllTests.cpp +++ b/cpp/test/IceGrid/update/AllTests.cpp @@ -24,7 +24,7 @@ class SessionKeepAliveThread : public IceUtil::Thread, public IceUtil::Monitor<I public: SessionKeepAliveThread(const IceGrid::AdminSessionPrx& session, long timeout) : - _session(session), + _session(session), _timeout(IceUtil::Time::seconds(timeout)), _destroy(false) { @@ -39,15 +39,15 @@ public: timedWait(_timeout); if(_destroy) { - break; - } + break; + } try { _session->keepAlive(); } catch(const Ice::Exception&) { - break; + break; } } } @@ -82,10 +82,10 @@ getProperty(const PropertyDescriptorSeq& properties, const string& name) { for(PropertyDescriptorSeq::const_iterator q = properties.begin(); q != properties.end(); ++q) { - if(q->name == name) - { - return q->value; - } + if(q->name == name) + { + return q->value; + } } return ""; } @@ -103,12 +103,12 @@ bool hasProperty(const CommunicatorDescriptorPtr& desc, const string& name, const string& value) { for(PropertyDescriptorSeq::const_iterator p = desc->propertySet.properties.begin(); - p != desc->propertySet.properties.end(); ++p) + p != desc->propertySet.properties.end(); ++p) { - if(p->name == name) - { - return p->value == value; - } + if(p->name == name) + { + return p->value == value; + } } return false; } @@ -117,7 +117,7 @@ void allTests(const Ice::CommunicatorPtr& communicator) { RegistryPrx registry = IceGrid::RegistryPrx::checkedCast( - communicator->stringToProxy("IceGrid/Registry")); + communicator->stringToProxy("IceGrid/Registry")); test(registry); AdminSessionPrx session = registry->createAdminSession("foo", "bar"); @@ -130,1085 +130,1085 @@ allTests(const Ice::CommunicatorPtr& communicator) Ice::PropertiesPtr properties = communicator->getProperties(); { - ApplicationDescriptor testApp; - testApp.name = "TestApp"; - admin->addApplication(testApp); - - ApplicationUpdateDescriptor empty; - empty.name = "TestApp"; - NodeUpdateDescriptor node; - node.name = "localnode"; - empty.nodes.push_back(node); - - ApplicationUpdateDescriptor update = empty; - - cout << "testing server add... " << flush; - - ServerDescriptorPtr server = new ServerDescriptor(); - server->id = "Server"; - server->exe = properties->getProperty("TestDir") + "/server"; - server->pwd = "."; - AdapterDescriptor adapter; - adapter.name = "Server"; - adapter.id = "ServerAdapter"; - adapter.registerProcess = true; - addProperty(server, "Ice.OA.Server.Endpoints", "default"); - ObjectDescriptor object; - object.id = communicator->stringToIdentity("test"); - object.type = "::Test::TestIntf"; - adapter.objects.push_back(object); - server->adapters.push_back(adapter); - update.nodes[0].servers.push_back(server); - admin->updateApplication(update); - - update.nodes[0].servers[0]->id = "Server2"; - try - { - admin->updateApplication(update); - test(false); - } - catch(const DeploymentException&) - { - // Adapter already exists - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - update.nodes[0].servers[0]->adapters[0].id = "ServerAdapter2"; - try - { - admin->updateApplication(update); - test(false); - } - catch(const DeploymentException&) - { - // Object already exists - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - update.nodes[0].servers[0]->adapters[0].objects[0].id = communicator->stringToIdentity("test2"); - try - { - admin->updateApplication(update); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - TemplateDescriptor templ; - templ.parameters.push_back("name"); - templ.descriptor = new ServerDescriptor(); - server = ServerDescriptorPtr::dynamicCast(templ.descriptor); - server->id = "${name}"; - server->exe = "${test.dir}/server"; - server->pwd = "."; - adapter = AdapterDescriptor(); - adapter.name = "Server"; - adapter.id = "${server}"; - adapter.registerProcess = true; - addProperty(server, "Ice.OA.Server.Endpoints", "default"); - object = ObjectDescriptor(); - object.id = communicator->stringToIdentity("${server}"); - object.type = "::Test::TestIntf"; - adapter.objects.push_back(object); - server->adapters.push_back(adapter); - update = empty; - update.serverTemplates["ServerTemplate"] = templ; - try - { - admin->updateApplication(update); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - update = empty; - ServerInstanceDescriptor instance; - instance._cpp_template = "ServerTemplate"; - update.nodes[0].serverInstances.push_back(instance); - try - { - admin->updateApplication(update); - test(false); - } - catch(const DeploymentException&) - { - // Missing parameter - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - update = empty; - update.variables["test.dir"] = properties->getProperty("TestDir"); - update.variables["variable"] = ""; - instance = ServerInstanceDescriptor(); - instance._cpp_template = "ServerTemplate"; - instance.parameterValues["name"] = "Server1"; - update.nodes[0].serverInstances.push_back(instance); - try - { - admin->updateApplication(update); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - cout << "ok" << endl; - - cout << "testing server remove... " << flush; - update = empty; - update.nodes[0].removeServers.push_back("Server2"); - try - { - admin->updateApplication(update); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - try - { - admin->getServerInfo("Server2"); - test(false); - } - catch(const ServerNotExistException&) - { - } - - try - { - admin->updateApplication(update); - } - catch(const DeploymentException& ex) - { - cerr << ex.reason << endl; - test(false); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - update = empty; - update.removeServerTemplates.push_back("ServerTemplate"); - try - { - admin->updateApplication(update); - test(false); - } - catch(const DeploymentException&) - { - // Server without template! - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - update = empty; - update.nodes[0].removeServers.push_back("Server1"); - try - { - admin->updateApplication(update); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - try - { - admin->getServerInfo("Server1"); - test(false); - } - catch(const ServerNotExistException&) - { - } - - update = empty; - update.removeServerTemplates.push_back("ServerTemplate"); - try - { - admin->updateApplication(update); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - cout << "ok" << endl; - - cout << "testing server update... " << flush; - - ServerInfo info = admin->getServerInfo("Server"); - test(info.descriptor); - addProperty(info.descriptor, "test", "test"); - update = empty; - update.nodes[0].servers.push_back(info.descriptor); - try - { - admin->updateApplication(update); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - info = admin->getServerInfo("Server"); - test(info.descriptor); - test(getProperty(info.descriptor->propertySet.properties, "test") == "test"); - - update = empty; - update.serverTemplates["ServerTemplate"] = templ; - instance = ServerInstanceDescriptor(); - instance._cpp_template = "ServerTemplate"; - instance.parameterValues["name"] = "Server1"; - update.nodes[0].serverInstances.push_back(instance); - try - { - admin->updateApplication(update); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - update = empty; - addProperty(server, "test", "test"); - assert(templ.descriptor == server); - update.serverTemplates["ServerTemplate"] = templ; - try - { - admin->updateApplication(update); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - info = admin->getServerInfo("Server1"); - test(info.descriptor); - test(getProperty(info.descriptor->propertySet.properties, "test") == "test"); - - info = admin->getServerInfo("Server"); - test(info.descriptor); - adapter = AdapterDescriptor(); - adapter.id = "Server1"; - info.descriptor->adapters.push_back(adapter); - update = empty; - update.nodes[0].servers.push_back(info.descriptor); - try - { - admin->updateApplication(update); - test(false); - } - catch(const DeploymentException&) - { - // Adapter already exists - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - info = admin->getServerInfo("Server"); - test(info.descriptor); - adapter = AdapterDescriptor(); - adapter.id = "ServerX"; - object = ObjectDescriptor(); - object.id = communicator->stringToIdentity("test"); - adapter.objects.push_back(object); - info.descriptor->adapters.push_back(adapter); - update = empty; - update.nodes[0].servers.push_back(info.descriptor); - try - { - admin->updateApplication(update); - test(false); - } - catch(const DeploymentException&) - { - // Object already exists - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - cout << "ok" << endl; - - admin->removeApplication("TestApp"); + ApplicationDescriptor testApp; + testApp.name = "TestApp"; + admin->addApplication(testApp); + + ApplicationUpdateDescriptor empty; + empty.name = "TestApp"; + NodeUpdateDescriptor node; + node.name = "localnode"; + empty.nodes.push_back(node); + + ApplicationUpdateDescriptor update = empty; + + cout << "testing server add... " << flush; + + ServerDescriptorPtr server = new ServerDescriptor(); + server->id = "Server"; + server->exe = properties->getProperty("TestDir") + "/server"; + server->pwd = "."; + AdapterDescriptor adapter; + adapter.name = "Server"; + adapter.id = "ServerAdapter"; + adapter.registerProcess = true; + addProperty(server, "Ice.OA.Server.Endpoints", "default"); + ObjectDescriptor object; + object.id = communicator->stringToIdentity("test"); + object.type = "::Test::TestIntf"; + adapter.objects.push_back(object); + server->adapters.push_back(adapter); + update.nodes[0].servers.push_back(server); + admin->updateApplication(update); + + update.nodes[0].servers[0]->id = "Server2"; + try + { + admin->updateApplication(update); + test(false); + } + catch(const DeploymentException&) + { + // Adapter already exists + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + update.nodes[0].servers[0]->adapters[0].id = "ServerAdapter2"; + try + { + admin->updateApplication(update); + test(false); + } + catch(const DeploymentException&) + { + // Object already exists + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + update.nodes[0].servers[0]->adapters[0].objects[0].id = communicator->stringToIdentity("test2"); + try + { + admin->updateApplication(update); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + TemplateDescriptor templ; + templ.parameters.push_back("name"); + templ.descriptor = new ServerDescriptor(); + server = ServerDescriptorPtr::dynamicCast(templ.descriptor); + server->id = "${name}"; + server->exe = "${test.dir}/server"; + server->pwd = "."; + adapter = AdapterDescriptor(); + adapter.name = "Server"; + adapter.id = "${server}"; + adapter.registerProcess = true; + addProperty(server, "Ice.OA.Server.Endpoints", "default"); + object = ObjectDescriptor(); + object.id = communicator->stringToIdentity("${server}"); + object.type = "::Test::TestIntf"; + adapter.objects.push_back(object); + server->adapters.push_back(adapter); + update = empty; + update.serverTemplates["ServerTemplate"] = templ; + try + { + admin->updateApplication(update); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + update = empty; + ServerInstanceDescriptor instance; + instance._cpp_template = "ServerTemplate"; + update.nodes[0].serverInstances.push_back(instance); + try + { + admin->updateApplication(update); + test(false); + } + catch(const DeploymentException&) + { + // Missing parameter + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + update = empty; + update.variables["test.dir"] = properties->getProperty("TestDir"); + update.variables["variable"] = ""; + instance = ServerInstanceDescriptor(); + instance._cpp_template = "ServerTemplate"; + instance.parameterValues["name"] = "Server1"; + update.nodes[0].serverInstances.push_back(instance); + try + { + admin->updateApplication(update); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + cout << "ok" << endl; + + cout << "testing server remove... " << flush; + update = empty; + update.nodes[0].removeServers.push_back("Server2"); + try + { + admin->updateApplication(update); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + try + { + admin->getServerInfo("Server2"); + test(false); + } + catch(const ServerNotExistException&) + { + } + + try + { + admin->updateApplication(update); + } + catch(const DeploymentException& ex) + { + cerr << ex.reason << endl; + test(false); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + update = empty; + update.removeServerTemplates.push_back("ServerTemplate"); + try + { + admin->updateApplication(update); + test(false); + } + catch(const DeploymentException&) + { + // Server without template! + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + update = empty; + update.nodes[0].removeServers.push_back("Server1"); + try + { + admin->updateApplication(update); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + try + { + admin->getServerInfo("Server1"); + test(false); + } + catch(const ServerNotExistException&) + { + } + + update = empty; + update.removeServerTemplates.push_back("ServerTemplate"); + try + { + admin->updateApplication(update); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + cout << "ok" << endl; + + cout << "testing server update... " << flush; + + ServerInfo info = admin->getServerInfo("Server"); + test(info.descriptor); + addProperty(info.descriptor, "test", "test"); + update = empty; + update.nodes[0].servers.push_back(info.descriptor); + try + { + admin->updateApplication(update); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + info = admin->getServerInfo("Server"); + test(info.descriptor); + test(getProperty(info.descriptor->propertySet.properties, "test") == "test"); + + update = empty; + update.serverTemplates["ServerTemplate"] = templ; + instance = ServerInstanceDescriptor(); + instance._cpp_template = "ServerTemplate"; + instance.parameterValues["name"] = "Server1"; + update.nodes[0].serverInstances.push_back(instance); + try + { + admin->updateApplication(update); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + update = empty; + addProperty(server, "test", "test"); + assert(templ.descriptor == server); + update.serverTemplates["ServerTemplate"] = templ; + try + { + admin->updateApplication(update); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + info = admin->getServerInfo("Server1"); + test(info.descriptor); + test(getProperty(info.descriptor->propertySet.properties, "test") == "test"); + + info = admin->getServerInfo("Server"); + test(info.descriptor); + adapter = AdapterDescriptor(); + adapter.id = "Server1"; + info.descriptor->adapters.push_back(adapter); + update = empty; + update.nodes[0].servers.push_back(info.descriptor); + try + { + admin->updateApplication(update); + test(false); + } + catch(const DeploymentException&) + { + // Adapter already exists + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + info = admin->getServerInfo("Server"); + test(info.descriptor); + adapter = AdapterDescriptor(); + adapter.id = "ServerX"; + object = ObjectDescriptor(); + object.id = communicator->stringToIdentity("test"); + adapter.objects.push_back(object); + info.descriptor->adapters.push_back(adapter); + update = empty; + update.nodes[0].servers.push_back(info.descriptor); + try + { + admin->updateApplication(update); + test(false); + } + catch(const DeploymentException&) + { + // Object already exists + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + cout << "ok" << endl; + + admin->removeApplication("TestApp"); } { - ApplicationDescriptor testApp; - testApp.name = "TestApp"; - admin->addApplication(testApp); - - ApplicationUpdateDescriptor empty; - empty.name = "TestApp"; - NodeUpdateDescriptor node; - node.name = "localnode"; - empty.nodes.push_back(node); - - ApplicationUpdateDescriptor update = empty; - - cout << "testing icebox server add... " << flush; - - ServiceDescriptorPtr service = new ServiceDescriptor(); - service->name = "Service1"; - service->entry = "TestService:create"; - AdapterDescriptor adapter; - adapter.name = "${service}"; - adapter.id = "${server}.${service}"; - adapter.registerProcess = true; - addProperty(service, "Ice.OA.${service}.Endpoints", "default"); - service->adapters.push_back(adapter); - - IceBoxDescriptorPtr server = new IceBoxDescriptor(); - server->id = "IceBox"; - server->exe = properties->getProperty("IceDir") + "/bin/icebox"; - server->services.resize(3); - server->services[0].descriptor = ServiceDescriptorPtr::dynamicCast(service->ice_clone()); - service->name = "Service2"; - server->services[1].descriptor = ServiceDescriptorPtr::dynamicCast(service->ice_clone()); - service->name = "Service3"; - server->services[2].descriptor = ServiceDescriptorPtr::dynamicCast(service->ice_clone()); - - update.nodes[0].servers.push_back(server); - try - { - admin->updateApplication(update); - } - catch(const DeploymentException& ex) - { - cerr << ex.reason << endl; - test(false); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - cout << "ok" << endl; - - cout << "testing service add... " << flush; - service->name = "First"; - server->services.resize(4); - server->services[3].descriptor = service; - try - { - admin->updateApplication(update); - } - catch(const DeploymentException& ex) - { - cerr << ex.reason << endl; - test(false); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - cout << "ok" << endl; - - cout << "testing service remove... " << flush; - server->services.resize(3); - try - { - admin->updateApplication(update); - } - catch(const DeploymentException& ex) - { - cerr << ex.reason << endl; - test(false); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - cout << "ok" << endl; - - admin->removeApplication("TestApp"); + ApplicationDescriptor testApp; + testApp.name = "TestApp"; + admin->addApplication(testApp); + + ApplicationUpdateDescriptor empty; + empty.name = "TestApp"; + NodeUpdateDescriptor node; + node.name = "localnode"; + empty.nodes.push_back(node); + + ApplicationUpdateDescriptor update = empty; + + cout << "testing icebox server add... " << flush; + + ServiceDescriptorPtr service = new ServiceDescriptor(); + service->name = "Service1"; + service->entry = "TestService:create"; + AdapterDescriptor adapter; + adapter.name = "${service}"; + adapter.id = "${server}.${service}"; + adapter.registerProcess = true; + addProperty(service, "Ice.OA.${service}.Endpoints", "default"); + service->adapters.push_back(adapter); + + IceBoxDescriptorPtr server = new IceBoxDescriptor(); + server->id = "IceBox"; + server->exe = properties->getProperty("IceDir") + "/bin/icebox"; + server->services.resize(3); + server->services[0].descriptor = ServiceDescriptorPtr::dynamicCast(service->ice_clone()); + service->name = "Service2"; + server->services[1].descriptor = ServiceDescriptorPtr::dynamicCast(service->ice_clone()); + service->name = "Service3"; + server->services[2].descriptor = ServiceDescriptorPtr::dynamicCast(service->ice_clone()); + + update.nodes[0].servers.push_back(server); + try + { + admin->updateApplication(update); + } + catch(const DeploymentException& ex) + { + cerr << ex.reason << endl; + test(false); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + cout << "ok" << endl; + + cout << "testing service add... " << flush; + service->name = "First"; + server->services.resize(4); + server->services[3].descriptor = service; + try + { + admin->updateApplication(update); + } + catch(const DeploymentException& ex) + { + cerr << ex.reason << endl; + test(false); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + cout << "ok" << endl; + + cout << "testing service remove... " << flush; + server->services.resize(3); + try + { + admin->updateApplication(update); + } + catch(const DeploymentException& ex) + { + cerr << ex.reason << endl; + test(false); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + cout << "ok" << endl; + + admin->removeApplication("TestApp"); } { - cout << "testing node add... " << flush; - - ApplicationDescriptor testApp; - testApp.name = "TestApp"; - NodeDescriptor node; - node.variables["nodename"] = "node1"; - testApp.nodes["node1"] = node; - - try - { - admin->addApplication(testApp); - } - catch(const DeploymentException& ex) - { - cerr << ex.reason << endl; - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - ApplicationUpdateDescriptor update; - update.name = "TestApp"; - NodeUpdateDescriptor nodeUpdate; - nodeUpdate.name = "node2"; - nodeUpdate.variables["nodename"] = "node2"; - update.nodes.push_back(nodeUpdate); - - try - { - admin->updateApplication(update); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - testApp = admin->getApplicationInfo("TestApp").descriptor; - test(testApp.nodes.size() == 2); - test(testApp.nodes["node1"].variables["nodename"] == "node1"); - test(testApp.nodes["node2"].variables["nodename"] == "node2"); - cout << "ok" << endl; - - cout << "testing node update... " << flush; - - nodeUpdate.name = "node2"; - nodeUpdate.variables["nodename"] = "node2updated"; - update.nodes.back() = nodeUpdate; - try - { - admin->updateApplication(update); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - testApp = admin->getApplicationInfo("TestApp").descriptor; - test(testApp.nodes.size() == 2); - test(testApp.nodes["node1"].variables["nodename"] == "node1"); - test(testApp.nodes["node2"].variables["nodename"] == "node2updated"); - - cout << "ok" << endl; - - cout << "testing node remove... " << flush; - - update.nodes.clear(); - update.removeNodes.push_back("node1"); - try - { - admin->updateApplication(update); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - testApp = admin->getApplicationInfo("TestApp").descriptor; - test(testApp.nodes.size() == 1); - test(testApp.nodes["node2"].variables["nodename"] == "node2updated"); - - admin->removeApplication("TestApp"); - - cout << "ok" << endl; - } + cout << "testing node add... " << flush; + + ApplicationDescriptor testApp; + testApp.name = "TestApp"; + NodeDescriptor node; + node.variables["nodename"] = "node1"; + testApp.nodes["node1"] = node; + + try + { + admin->addApplication(testApp); + } + catch(const DeploymentException& ex) + { + cerr << ex.reason << endl; + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + ApplicationUpdateDescriptor update; + update.name = "TestApp"; + NodeUpdateDescriptor nodeUpdate; + nodeUpdate.name = "node2"; + nodeUpdate.variables["nodename"] = "node2"; + update.nodes.push_back(nodeUpdate); + + try + { + admin->updateApplication(update); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + testApp = admin->getApplicationInfo("TestApp").descriptor; + test(testApp.nodes.size() == 2); + test(testApp.nodes["node1"].variables["nodename"] == "node1"); + test(testApp.nodes["node2"].variables["nodename"] == "node2"); + cout << "ok" << endl; + + cout << "testing node update... " << flush; + + nodeUpdate.name = "node2"; + nodeUpdate.variables["nodename"] = "node2updated"; + update.nodes.back() = nodeUpdate; + try + { + admin->updateApplication(update); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + testApp = admin->getApplicationInfo("TestApp").descriptor; + test(testApp.nodes.size() == 2); + test(testApp.nodes["node1"].variables["nodename"] == "node1"); + test(testApp.nodes["node2"].variables["nodename"] == "node2updated"); + + cout << "ok" << endl; + + cout << "testing node remove... " << flush; + + update.nodes.clear(); + update.removeNodes.push_back("node1"); + try + { + admin->updateApplication(update); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + testApp = admin->getApplicationInfo("TestApp").descriptor; + test(testApp.nodes.size() == 1); + test(testApp.nodes["node2"].variables["nodename"] == "node2updated"); + + admin->removeApplication("TestApp"); + + cout << "ok" << endl; + } { - cout << "testing variable update... " << flush; - - ServerDescriptorPtr server = new ServerDescriptor(); - server->id = "${name}"; - server->exe = "server"; - server->pwd = "."; - - addProperty(server, "ApplicationVar", "${appvar}"); - addProperty(server, "NodeVar", "${nodevar}"); - addProperty(server, "ServerParamVar", "${serverparamvar}"); - - TemplateDescriptor templ; - templ.parameters.push_back("name"); - templ.parameters.push_back("serverparamvar"); - templ.descriptor = server; - - ApplicationDescriptor testApp; - testApp.name = "TestApp"; - testApp.variables["appvar"] = "AppValue"; - testApp.serverTemplates["ServerTemplate"] = templ; - - NodeDescriptor node; - node.variables["nodevar"] = "NodeValue"; - - ServerInstanceDescriptor serverInstance; - serverInstance._cpp_template = "ServerTemplate"; - serverInstance.parameterValues["name"] = "Server"; - serverInstance.parameterValues["serverparamvar"] = "ServerParamValue"; - node.serverInstances.push_back(serverInstance); - - testApp.nodes["node1"] = node; - - try - { - admin->addApplication(testApp); - } - catch(const DeploymentException& ex) - { - cerr << ex.reason << endl; - test(false); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - ApplicationUpdateDescriptor empty; - empty.name = "TestApp"; - ApplicationUpdateDescriptor update = empty; - update.removeVariables.push_back("appvar"); - try - { - admin->updateApplication(update); - test(false); - } - catch(const DeploymentException&) - { - // Missing app variable - //cerr << ex.reason << endl; - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - update = empty; - NodeUpdateDescriptor nodeUpdate; - nodeUpdate.name = "node1"; - nodeUpdate.removeVariables.push_back("nodevar"); - update.nodes.push_back(nodeUpdate); - try - { - admin->updateApplication(update); - test(false); - } - catch(const DeploymentException&) - { - // Missing node variable - //cerr << ex.reason << endl; - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - update = empty; - serverInstance = ServerInstanceDescriptor(); - serverInstance._cpp_template = "ServerTemplate"; - serverInstance.parameterValues["name"] = "Server"; - nodeUpdate = NodeUpdateDescriptor(); - nodeUpdate.name = "node1"; - nodeUpdate.serverInstances.push_back(serverInstance); - update.nodes.push_back(nodeUpdate); - try - { - admin->updateApplication(update); - test(false); - } - catch(const DeploymentException&) - { - // Missing parameter - //cerr << ex.reason << endl; - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - ServerInfo serverBefore = admin->getServerInfo("Server"); - ApplicationDescriptor origApp = admin->getApplicationInfo("TestApp").descriptor; - - update = empty; - update.variables["nodevar"] = "appoverride"; - nodeUpdate = NodeUpdateDescriptor(); - nodeUpdate.name = "node1"; - nodeUpdate.variables["serverparamvar"] = "nodeoverride"; - update.nodes.push_back(nodeUpdate); - try - { - admin->updateApplication(update); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - ServerInfo serverAfter = admin->getServerInfo("Server"); - test(serverBefore.descriptor->propertySet == serverAfter.descriptor->propertySet); - - update = empty; - nodeUpdate = NodeUpdateDescriptor(); - nodeUpdate.name = "node1"; - nodeUpdate.variables["appvar"] = "nodeoverride"; - update.nodes.push_back(nodeUpdate); - try - { - admin->updateApplication(update); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - serverAfter = admin->getServerInfo("Server"); - PropertyDescriptorSeq newProps = serverAfter.descriptor->propertySet.properties; - test(getProperty(serverAfter.descriptor->propertySet.properties, "ApplicationVar") == "nodeoverride"); - test(getProperty(serverAfter.descriptor->propertySet.properties, "NodeVar") == "NodeValue"); - test(getProperty(serverAfter.descriptor->propertySet.properties, "ServerParamVar") == "ServerParamValue"); - admin->removeApplication("TestApp"); - cout << "ok" << endl; + cout << "testing variable update... " << flush; + + ServerDescriptorPtr server = new ServerDescriptor(); + server->id = "${name}"; + server->exe = "server"; + server->pwd = "."; + + addProperty(server, "ApplicationVar", "${appvar}"); + addProperty(server, "NodeVar", "${nodevar}"); + addProperty(server, "ServerParamVar", "${serverparamvar}"); + + TemplateDescriptor templ; + templ.parameters.push_back("name"); + templ.parameters.push_back("serverparamvar"); + templ.descriptor = server; + + ApplicationDescriptor testApp; + testApp.name = "TestApp"; + testApp.variables["appvar"] = "AppValue"; + testApp.serverTemplates["ServerTemplate"] = templ; + + NodeDescriptor node; + node.variables["nodevar"] = "NodeValue"; + + ServerInstanceDescriptor serverInstance; + serverInstance._cpp_template = "ServerTemplate"; + serverInstance.parameterValues["name"] = "Server"; + serverInstance.parameterValues["serverparamvar"] = "ServerParamValue"; + node.serverInstances.push_back(serverInstance); + + testApp.nodes["node1"] = node; + + try + { + admin->addApplication(testApp); + } + catch(const DeploymentException& ex) + { + cerr << ex.reason << endl; + test(false); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + ApplicationUpdateDescriptor empty; + empty.name = "TestApp"; + ApplicationUpdateDescriptor update = empty; + update.removeVariables.push_back("appvar"); + try + { + admin->updateApplication(update); + test(false); + } + catch(const DeploymentException&) + { + // Missing app variable + //cerr << ex.reason << endl; + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + update = empty; + NodeUpdateDescriptor nodeUpdate; + nodeUpdate.name = "node1"; + nodeUpdate.removeVariables.push_back("nodevar"); + update.nodes.push_back(nodeUpdate); + try + { + admin->updateApplication(update); + test(false); + } + catch(const DeploymentException&) + { + // Missing node variable + //cerr << ex.reason << endl; + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + update = empty; + serverInstance = ServerInstanceDescriptor(); + serverInstance._cpp_template = "ServerTemplate"; + serverInstance.parameterValues["name"] = "Server"; + nodeUpdate = NodeUpdateDescriptor(); + nodeUpdate.name = "node1"; + nodeUpdate.serverInstances.push_back(serverInstance); + update.nodes.push_back(nodeUpdate); + try + { + admin->updateApplication(update); + test(false); + } + catch(const DeploymentException&) + { + // Missing parameter + //cerr << ex.reason << endl; + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + ServerInfo serverBefore = admin->getServerInfo("Server"); + ApplicationDescriptor origApp = admin->getApplicationInfo("TestApp").descriptor; + + update = empty; + update.variables["nodevar"] = "appoverride"; + nodeUpdate = NodeUpdateDescriptor(); + nodeUpdate.name = "node1"; + nodeUpdate.variables["serverparamvar"] = "nodeoverride"; + update.nodes.push_back(nodeUpdate); + try + { + admin->updateApplication(update); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + ServerInfo serverAfter = admin->getServerInfo("Server"); + test(serverBefore.descriptor->propertySet == serverAfter.descriptor->propertySet); + + update = empty; + nodeUpdate = NodeUpdateDescriptor(); + nodeUpdate.name = "node1"; + nodeUpdate.variables["appvar"] = "nodeoverride"; + update.nodes.push_back(nodeUpdate); + try + { + admin->updateApplication(update); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + serverAfter = admin->getServerInfo("Server"); + PropertyDescriptorSeq newProps = serverAfter.descriptor->propertySet.properties; + test(getProperty(serverAfter.descriptor->propertySet.properties, "ApplicationVar") == "nodeoverride"); + test(getProperty(serverAfter.descriptor->propertySet.properties, "NodeVar") == "NodeValue"); + test(getProperty(serverAfter.descriptor->propertySet.properties, "ServerParamVar") == "ServerParamValue"); + admin->removeApplication("TestApp"); + cout << "ok" << endl; } { - cout << "testing property set update... " << flush; - - ServiceDescriptorPtr service = new ServiceDescriptor(); - service->name = "${name}"; - service->entry = "dummy"; - addProperty(service, "ServiceProp", "test"); - - TemplateDescriptor svcTempl; - svcTempl.parameters.push_back("name"); - svcTempl.descriptor = service; - - ServiceInstanceDescriptor serviceInstance; - serviceInstance._cpp_template = "ServiceTemplate"; - serviceInstance.parameterValues["name"] = "Service"; - serviceInstance.propertySet.properties.push_back(createProperty("ServiceInstanceProp", "test")); - - IceBoxDescriptorPtr server = new IceBoxDescriptor(); - server->id = "${name}"; - server->exe = "server"; - server->pwd = "."; - server->propertySet.references.push_back("ApplicationPropertySet"); - server->propertySet.references.push_back("NodePropertySet"); - addProperty(server, "ServerProp", "test"); - server->services.push_back(serviceInstance); - - TemplateDescriptor templ; - templ.parameters.push_back("name"); - templ.descriptor = server; - - ApplicationDescriptor testApp; - testApp.name = "TestApp"; - testApp.variables["appvar"] = "AppValue"; - testApp.serverTemplates["ServerTemplate"] = templ; - testApp.serviceTemplates["ServiceTemplate"] = svcTempl; - testApp.propertySets["ApplicationPropertySet"].properties.push_back(createProperty("ApplicationProp","test")); - testApp.propertySets["ApplicationPropertySet1"].properties.push_back(createProperty("ApplicationProp", "d")); - - NodeDescriptor node; - node.variables["nodevar"] = "NodeValue"; - node.propertySets["NodePropertySet"].properties.push_back(createProperty("NodeProp", "test")); - node.propertySets["NodePropertySet1"].properties.push_back(createProperty("NodeProp", "test")); - - ServerInstanceDescriptor serverInstance; - serverInstance._cpp_template = "ServerTemplate"; - serverInstance.parameterValues["name"] = "Server"; - serverInstance.propertySet.properties.push_back(createProperty("ServerInstanceProp", "test")); - node.serverInstances.push_back(serverInstance); - - testApp.nodes["node1"] = node; - - try - { - admin->addApplication(testApp); - } - catch(const DeploymentException& ex) - { - cerr << ex.reason << endl; - test(false); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - ServerInfo info = admin->getServerInfo("Server"); - test(hasProperty(info.descriptor, "ServerProp", "test")); - test(hasProperty(info.descriptor, "NodeProp", "test")); - test(hasProperty(info.descriptor, "ApplicationProp", "test")); - test(hasProperty(info.descriptor, "ServerInstanceProp", "test")); - - ServiceDescriptorPtr svc = IceBoxDescriptorPtr::dynamicCast(info.descriptor)->services[0].descriptor; - test(hasProperty(svc, "ServiceProp", "test")); - - ApplicationUpdateDescriptor empty; - empty.name = "TestApp"; - ApplicationUpdateDescriptor update; - - update = empty; - service->propertySet.properties.clear(); - addProperty(service, "ServiceProp", "updated"); - svcTempl.descriptor = service; - update.serviceTemplates["ServiceTemplate"] = svcTempl; - admin->updateApplication(update); - info = admin->getServerInfo("Server"); - svc = IceBoxDescriptorPtr::dynamicCast(info.descriptor)->services[0].descriptor; - test(hasProperty(svc, "ServiceProp", "updated")); - - update = empty; - serviceInstance.propertySet.properties.clear(); - serviceInstance.propertySet.properties.push_back(createProperty("ServiceInstanceProp", "updated")); - server->services.clear(); - server->services.push_back(serviceInstance); - templ.descriptor = server; - update.serverTemplates["ServerTemplate"] = templ; - admin->updateApplication(update); - info = admin->getServerInfo("Server"); - svc = IceBoxDescriptorPtr::dynamicCast(info.descriptor)->services[0].descriptor; - test(hasProperty(svc, "ServiceInstanceProp", "updated")); - - update = empty; - server->propertySet.properties.clear(); - addProperty(server, "ServerProp", "updated"); - templ.descriptor = server; - update.serverTemplates["ServerTemplate"] = templ; - admin->updateApplication(update); - info = admin->getServerInfo("Server"); - test(hasProperty(info.descriptor, "ServerProp", "updated")); - - update = empty; - serverInstance.propertySet.properties.clear(); - serverInstance.propertySet.properties.push_back(createProperty("ServerInstanceProp", "updated")); - NodeUpdateDescriptor nodeUpdate; - nodeUpdate.name = "node1"; - nodeUpdate.serverInstances.push_back(serverInstance); - update.nodes.push_back(nodeUpdate); - admin->updateApplication(update); - info = admin->getServerInfo("Server"); - test(hasProperty(info.descriptor, "ServerInstanceProp", "updated")); - - update = empty; - nodeUpdate.name = "node1"; - nodeUpdate.serverInstances.clear(); - nodeUpdate.propertySets["NodePropertySet"].properties.clear(); - nodeUpdate.propertySets["NodePropertySet"].properties.push_back( - createProperty("NodeProp", "updated")); - nodeUpdate.removePropertySets.push_back("NodePropertySet1"); - update.nodes.push_back(nodeUpdate); - admin->updateApplication(update); - info = admin->getServerInfo("Server"); - test(hasProperty(info.descriptor, "NodeProp", "updated")); - ApplicationDescriptor updatedApplication = admin->getApplicationInfo("TestApp").descriptor; - test(updatedApplication.nodes["node1"].propertySets.find("NodePropertySet1") == - updatedApplication.nodes["node1"].propertySets.end()); - - update = empty; - update.propertySets["ApplicationPropertySet"].properties.clear(); - update.propertySets["ApplicationPropertySet"].properties.push_back( - createProperty("ApplicationProp", "updated")); - update.removePropertySets.push_back("ApplicationPropertySet1"); - admin->updateApplication(update); - info = admin->getServerInfo("Server"); - test(hasProperty(info.descriptor, "ApplicationProp", "updated")); - updatedApplication = admin->getApplicationInfo("TestApp").descriptor; - test(updatedApplication.propertySets.find("ApplicationPropertySet1") == - updatedApplication.propertySets.end()); - - admin->removeApplication("TestApp"); - cout << "ok" << endl; + cout << "testing property set update... " << flush; + + ServiceDescriptorPtr service = new ServiceDescriptor(); + service->name = "${name}"; + service->entry = "dummy"; + addProperty(service, "ServiceProp", "test"); + + TemplateDescriptor svcTempl; + svcTempl.parameters.push_back("name"); + svcTempl.descriptor = service; + + ServiceInstanceDescriptor serviceInstance; + serviceInstance._cpp_template = "ServiceTemplate"; + serviceInstance.parameterValues["name"] = "Service"; + serviceInstance.propertySet.properties.push_back(createProperty("ServiceInstanceProp", "test")); + + IceBoxDescriptorPtr server = new IceBoxDescriptor(); + server->id = "${name}"; + server->exe = "server"; + server->pwd = "."; + server->propertySet.references.push_back("ApplicationPropertySet"); + server->propertySet.references.push_back("NodePropertySet"); + addProperty(server, "ServerProp", "test"); + server->services.push_back(serviceInstance); + + TemplateDescriptor templ; + templ.parameters.push_back("name"); + templ.descriptor = server; + + ApplicationDescriptor testApp; + testApp.name = "TestApp"; + testApp.variables["appvar"] = "AppValue"; + testApp.serverTemplates["ServerTemplate"] = templ; + testApp.serviceTemplates["ServiceTemplate"] = svcTempl; + testApp.propertySets["ApplicationPropertySet"].properties.push_back(createProperty("ApplicationProp","test")); + testApp.propertySets["ApplicationPropertySet1"].properties.push_back(createProperty("ApplicationProp", "d")); + + NodeDescriptor node; + node.variables["nodevar"] = "NodeValue"; + node.propertySets["NodePropertySet"].properties.push_back(createProperty("NodeProp", "test")); + node.propertySets["NodePropertySet1"].properties.push_back(createProperty("NodeProp", "test")); + + ServerInstanceDescriptor serverInstance; + serverInstance._cpp_template = "ServerTemplate"; + serverInstance.parameterValues["name"] = "Server"; + serverInstance.propertySet.properties.push_back(createProperty("ServerInstanceProp", "test")); + node.serverInstances.push_back(serverInstance); + + testApp.nodes["node1"] = node; + + try + { + admin->addApplication(testApp); + } + catch(const DeploymentException& ex) + { + cerr << ex.reason << endl; + test(false); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + ServerInfo info = admin->getServerInfo("Server"); + test(hasProperty(info.descriptor, "ServerProp", "test")); + test(hasProperty(info.descriptor, "NodeProp", "test")); + test(hasProperty(info.descriptor, "ApplicationProp", "test")); + test(hasProperty(info.descriptor, "ServerInstanceProp", "test")); + + ServiceDescriptorPtr svc = IceBoxDescriptorPtr::dynamicCast(info.descriptor)->services[0].descriptor; + test(hasProperty(svc, "ServiceProp", "test")); + + ApplicationUpdateDescriptor empty; + empty.name = "TestApp"; + ApplicationUpdateDescriptor update; + + update = empty; + service->propertySet.properties.clear(); + addProperty(service, "ServiceProp", "updated"); + svcTempl.descriptor = service; + update.serviceTemplates["ServiceTemplate"] = svcTempl; + admin->updateApplication(update); + info = admin->getServerInfo("Server"); + svc = IceBoxDescriptorPtr::dynamicCast(info.descriptor)->services[0].descriptor; + test(hasProperty(svc, "ServiceProp", "updated")); + + update = empty; + serviceInstance.propertySet.properties.clear(); + serviceInstance.propertySet.properties.push_back(createProperty("ServiceInstanceProp", "updated")); + server->services.clear(); + server->services.push_back(serviceInstance); + templ.descriptor = server; + update.serverTemplates["ServerTemplate"] = templ; + admin->updateApplication(update); + info = admin->getServerInfo("Server"); + svc = IceBoxDescriptorPtr::dynamicCast(info.descriptor)->services[0].descriptor; + test(hasProperty(svc, "ServiceInstanceProp", "updated")); + + update = empty; + server->propertySet.properties.clear(); + addProperty(server, "ServerProp", "updated"); + templ.descriptor = server; + update.serverTemplates["ServerTemplate"] = templ; + admin->updateApplication(update); + info = admin->getServerInfo("Server"); + test(hasProperty(info.descriptor, "ServerProp", "updated")); + + update = empty; + serverInstance.propertySet.properties.clear(); + serverInstance.propertySet.properties.push_back(createProperty("ServerInstanceProp", "updated")); + NodeUpdateDescriptor nodeUpdate; + nodeUpdate.name = "node1"; + nodeUpdate.serverInstances.push_back(serverInstance); + update.nodes.push_back(nodeUpdate); + admin->updateApplication(update); + info = admin->getServerInfo("Server"); + test(hasProperty(info.descriptor, "ServerInstanceProp", "updated")); + + update = empty; + nodeUpdate.name = "node1"; + nodeUpdate.serverInstances.clear(); + nodeUpdate.propertySets["NodePropertySet"].properties.clear(); + nodeUpdate.propertySets["NodePropertySet"].properties.push_back( + createProperty("NodeProp", "updated")); + nodeUpdate.removePropertySets.push_back("NodePropertySet1"); + update.nodes.push_back(nodeUpdate); + admin->updateApplication(update); + info = admin->getServerInfo("Server"); + test(hasProperty(info.descriptor, "NodeProp", "updated")); + ApplicationDescriptor updatedApplication = admin->getApplicationInfo("TestApp").descriptor; + test(updatedApplication.nodes["node1"].propertySets.find("NodePropertySet1") == + updatedApplication.nodes["node1"].propertySets.end()); + + update = empty; + update.propertySets["ApplicationPropertySet"].properties.clear(); + update.propertySets["ApplicationPropertySet"].properties.push_back( + createProperty("ApplicationProp", "updated")); + update.removePropertySets.push_back("ApplicationPropertySet1"); + admin->updateApplication(update); + info = admin->getServerInfo("Server"); + test(hasProperty(info.descriptor, "ApplicationProp", "updated")); + updatedApplication = admin->getApplicationInfo("TestApp").descriptor; + test(updatedApplication.propertySets.find("ApplicationPropertySet1") == + updatedApplication.propertySets.end()); + + admin->removeApplication("TestApp"); + cout << "ok" << endl; } { - cout << "testing description update... " << flush; - - ApplicationDescriptor testApp; - testApp.name = "TestApp"; - testApp.description = "Description"; - try - { - admin->addApplication(testApp); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - testApp = admin->getApplicationInfo("TestApp").descriptor; - test(testApp.description == "Description"); - - ApplicationUpdateDescriptor update; - update.name = "TestApp"; - try - { - admin->updateApplication(update); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - testApp = admin->getApplicationInfo("TestApp").descriptor; - test(testApp.description == "Description"); - - update.description = new BoxedString("updatedDescription"); - try - { - admin->updateApplication(update); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - testApp = admin->getApplicationInfo("TestApp").descriptor; - test(testApp.description == "updatedDescription"); - - update.description = new BoxedString(""); - try - { - admin->updateApplication(update); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - testApp = admin->getApplicationInfo("TestApp").descriptor; - test(testApp.description == ""); - - admin->removeApplication("TestApp"); - - cout << "ok" << endl; + cout << "testing description update... " << flush; + + ApplicationDescriptor testApp; + testApp.name = "TestApp"; + testApp.description = "Description"; + try + { + admin->addApplication(testApp); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + testApp = admin->getApplicationInfo("TestApp").descriptor; + test(testApp.description == "Description"); + + ApplicationUpdateDescriptor update; + update.name = "TestApp"; + try + { + admin->updateApplication(update); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + testApp = admin->getApplicationInfo("TestApp").descriptor; + test(testApp.description == "Description"); + + update.description = new BoxedString("updatedDescription"); + try + { + admin->updateApplication(update); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + testApp = admin->getApplicationInfo("TestApp").descriptor; + test(testApp.description == "updatedDescription"); + + update.description = new BoxedString(""); + try + { + admin->updateApplication(update); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + testApp = admin->getApplicationInfo("TestApp").descriptor; + test(testApp.description == ""); + + admin->removeApplication("TestApp"); + + cout << "ok" << endl; } { - cout << "testing server node move... " << flush; - - ApplicationDescriptor nodeApp; - nodeApp.name = "NodeApp"; - - ServerDescriptorPtr server = new ServerDescriptor(); - server->id = "node-${index}"; - server->exe = properties->getProperty("IceDir") + "/bin/icegridnode"; - server->pwd = "."; - server->options.push_back("--nowarn"); - AdapterDescriptor adapter; - adapter.name = "IceGrid.Node"; - adapter.id = "IceGrid.Node.node-${index}"; - adapter.registerProcess = true; - adapter.serverLifetime = false; - server->adapters.push_back(adapter); - - addProperty(server, "IceGrid.Node.Name", "node-${index}"); - addProperty(server, "IceGrid.Node.Data", properties->getProperty("TestDir") + "/db/node-${index}"); - addProperty(server, "Ice.OA.IceGrid.Node.Endpoints", "default"); - addProperty(server, "IceGrid.Node.PropertiesOverride", properties->getProperty("NodePropertiesOverride")); - - nodeApp.serverTemplates["nodeTemplate"].descriptor = server; - nodeApp.serverTemplates["nodeTemplate"].parameters.push_back("index"); - - ServerInstanceDescriptor instance; - instance._cpp_template = "nodeTemplate"; - instance.parameterValues["index"] = "1"; - nodeApp.nodes["localnode"].serverInstances.push_back(instance); - instance.parameterValues["index"] = "2"; - nodeApp.nodes["localnode"].serverInstances.push_back(instance); - - try - { - admin->addApplication(nodeApp); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - admin->startServer("node-1"); - admin->startServer("node-2"); - - // - // We need to wait because the node might not be fully started - // here (the node adapter isn't indirect, so we can't use the - // wait-for-activation feature here.) - // - int retry = 0; - while(retry < 20) - { - try - { - if(admin->pingNode("node-1") && admin->pingNode("node-2")) - { - break; - } - } - catch(const NodeNotExistException&) - { - } - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - ++retry; - } - test(admin->pingNode("node-1")); - test(admin->pingNode("node-2")); - - ApplicationDescriptor testApp; - testApp.name = "TestApp"; - server = new ServerDescriptor(); - server->id = "Server"; - server->exe = properties->getProperty("TestDir") + "/server"; - server->pwd = "."; - adapter.name = "Server"; - adapter.id = "ServerAdapter"; - adapter.registerProcess = true; - adapter.serverLifetime = true; - server->adapters.push_back(adapter); - addProperty(server, "Ice.OA.Server.Endpoints", "default"); - testApp.nodes["node-1"].servers.push_back(server); - - try - { - admin->addApplication(testApp); - } - catch(const DeploymentException& ex) - { - cerr << ex.reason << endl; - test(false); - } - - try - { - admin->startServer("Server"); - test(admin->getServerState("Server") == Active); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - ApplicationUpdateDescriptor update; - update.name = "TestApp"; - - NodeUpdateDescriptor nodeUpdate; - nodeUpdate.name = "node-1"; - nodeUpdate.removeServers.push_back("Server"); - update.nodes.push_back(nodeUpdate); - nodeUpdate.name = "node-2"; - nodeUpdate.servers.push_back(server); - nodeUpdate.removeServers.clear(); - update.nodes.push_back(nodeUpdate); - - try - { - admin->updateApplication(update); - } - catch(const DeploymentException& ex) - { - cerr << ex.reason << endl; - test(false); - } - test(admin->getServerInfo("Server").node == "node-2" && admin->getServerState("Server") == Inactive); - - admin->startServer("Server"); - test(admin->getServerState("Server") == Active); - - IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(1)); - - update = ApplicationUpdateDescriptor(); - update.name = "TestApp"; - nodeUpdate = NodeUpdateDescriptor(); - nodeUpdate.name = "node-2"; - nodeUpdate.removeServers.push_back("Server"); - update.nodes.push_back(nodeUpdate); - nodeUpdate = NodeUpdateDescriptor(); - nodeUpdate.name = "unknownNode"; - nodeUpdate.servers.push_back(server); - update.nodes.push_back(nodeUpdate); - - try - { - admin->updateApplication(update); - } - catch(const DeploymentException& ex) - { - cerr << ex.reason << endl; - test(false); - } - - try - { - admin->getServerState("Server"); - test(false); - } - catch(const NodeUnreachableException&) - { - } - - try - { - admin->removeApplication("TestApp"); - } - catch(const DeploymentException& ex) - { - cerr << ex.reason << endl; - test(false); - } - - admin->stopServer("node-1"); - admin->stopServer("node-2"); - - try - { - admin->removeApplication("NodeApp"); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - - cout << "ok" << endl; + cout << "testing server node move... " << flush; + + ApplicationDescriptor nodeApp; + nodeApp.name = "NodeApp"; + + ServerDescriptorPtr server = new ServerDescriptor(); + server->id = "node-${index}"; + server->exe = properties->getProperty("IceDir") + "/bin/icegridnode"; + server->pwd = "."; + server->options.push_back("--nowarn"); + AdapterDescriptor adapter; + adapter.name = "IceGrid.Node"; + adapter.id = "IceGrid.Node.node-${index}"; + adapter.registerProcess = true; + adapter.serverLifetime = false; + server->adapters.push_back(adapter); + + addProperty(server, "IceGrid.Node.Name", "node-${index}"); + addProperty(server, "IceGrid.Node.Data", properties->getProperty("TestDir") + "/db/node-${index}"); + addProperty(server, "Ice.OA.IceGrid.Node.Endpoints", "default"); + addProperty(server, "IceGrid.Node.PropertiesOverride", properties->getProperty("NodePropertiesOverride")); + + nodeApp.serverTemplates["nodeTemplate"].descriptor = server; + nodeApp.serverTemplates["nodeTemplate"].parameters.push_back("index"); + + ServerInstanceDescriptor instance; + instance._cpp_template = "nodeTemplate"; + instance.parameterValues["index"] = "1"; + nodeApp.nodes["localnode"].serverInstances.push_back(instance); + instance.parameterValues["index"] = "2"; + nodeApp.nodes["localnode"].serverInstances.push_back(instance); + + try + { + admin->addApplication(nodeApp); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + admin->startServer("node-1"); + admin->startServer("node-2"); + + // + // We need to wait because the node might not be fully started + // here (the node adapter isn't indirect, so we can't use the + // wait-for-activation feature here.) + // + int retry = 0; + while(retry < 20) + { + try + { + if(admin->pingNode("node-1") && admin->pingNode("node-2")) + { + break; + } + } + catch(const NodeNotExistException&) + { + } + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + ++retry; + } + test(admin->pingNode("node-1")); + test(admin->pingNode("node-2")); + + ApplicationDescriptor testApp; + testApp.name = "TestApp"; + server = new ServerDescriptor(); + server->id = "Server"; + server->exe = properties->getProperty("TestDir") + "/server"; + server->pwd = "."; + adapter.name = "Server"; + adapter.id = "ServerAdapter"; + adapter.registerProcess = true; + adapter.serverLifetime = true; + server->adapters.push_back(adapter); + addProperty(server, "Ice.OA.Server.Endpoints", "default"); + testApp.nodes["node-1"].servers.push_back(server); + + try + { + admin->addApplication(testApp); + } + catch(const DeploymentException& ex) + { + cerr << ex.reason << endl; + test(false); + } + + try + { + admin->startServer("Server"); + test(admin->getServerState("Server") == Active); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + ApplicationUpdateDescriptor update; + update.name = "TestApp"; + + NodeUpdateDescriptor nodeUpdate; + nodeUpdate.name = "node-1"; + nodeUpdate.removeServers.push_back("Server"); + update.nodes.push_back(nodeUpdate); + nodeUpdate.name = "node-2"; + nodeUpdate.servers.push_back(server); + nodeUpdate.removeServers.clear(); + update.nodes.push_back(nodeUpdate); + + try + { + admin->updateApplication(update); + } + catch(const DeploymentException& ex) + { + cerr << ex.reason << endl; + test(false); + } + test(admin->getServerInfo("Server").node == "node-2" && admin->getServerState("Server") == Inactive); + + admin->startServer("Server"); + test(admin->getServerState("Server") == Active); + + IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(1)); + + update = ApplicationUpdateDescriptor(); + update.name = "TestApp"; + nodeUpdate = NodeUpdateDescriptor(); + nodeUpdate.name = "node-2"; + nodeUpdate.removeServers.push_back("Server"); + update.nodes.push_back(nodeUpdate); + nodeUpdate = NodeUpdateDescriptor(); + nodeUpdate.name = "unknownNode"; + nodeUpdate.servers.push_back(server); + update.nodes.push_back(nodeUpdate); + + try + { + admin->updateApplication(update); + } + catch(const DeploymentException& ex) + { + cerr << ex.reason << endl; + test(false); + } + + try + { + admin->getServerState("Server"); + test(false); + } + catch(const NodeUnreachableException&) + { + } + + try + { + admin->removeApplication("TestApp"); + } + catch(const DeploymentException& ex) + { + cerr << ex.reason << endl; + test(false); + } + + admin->stopServer("node-1"); + admin->stopServer("node-2"); + + try + { + admin->removeApplication("NodeApp"); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + cout << "ok" << endl; } keepAlive->destroy(); diff --git a/cpp/test/IceGrid/update/Client.cpp b/cpp/test/IceGrid/update/Client.cpp index 47f910e24da..940ae6bec73 100644 --- a/cpp/test/IceGrid/update/Client.cpp +++ b/cpp/test/IceGrid/update/Client.cpp @@ -27,28 +27,28 @@ main(int argc, char* argv[]) int status; Ice::CommunicatorPtr communicator; try - { - communicator = Ice::initialize(argc, argv); - communicator->getProperties()->parseCommandLineOptions("", Ice::argsToStringSeq(argc, argv)); - status = run(argc, argv, communicator); + { + communicator = Ice::initialize(argc, argv); + communicator->getProperties()->parseCommandLineOptions("", Ice::argsToStringSeq(argc, argv)); + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; diff --git a/cpp/test/IceGrid/update/run.py b/cpp/test/IceGrid/update/run.py index 1d4fee7324c..ffc218efb4b 100755 --- a/cpp/test/IceGrid/update/run.py +++ b/cpp/test/IceGrid/update/run.py @@ -39,7 +39,7 @@ else: nodeOverrideOptions = "--IceDir=\"" + toplevel + "\" --TestDir=\"" + testdir + "\"" + \ ' --NodePropertiesOverride="' + \ TestUtil.clientServerOptions.replace("--", "") + \ - ' Ice.ServerIdleTime=0 Ice.PrintProcessId=0 Ice.PrintAdapterReady=0' + '"' + ' Ice.ServerIdleTime=0 Ice.PrintProcessId=0 Ice.PrintAdapterReady=0' + '"' IceGridAdmin.iceGridTest(name, "", nodeOverrideOptions) sys.exit(0) |