summaryrefslogtreecommitdiff
path: root/cpp/test
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2005-06-21 12:40:26 +0000
committerBenoit Foucher <benoit@zeroc.com>2005-06-21 12:40:26 +0000
commit91b10476449de133a15743272be8c5fab8010c7f (patch)
tree5c721ee19d9d3a8aa228cc9466412a1edd978446 /cpp/test
parentFix (diff)
downloadice-91b10476449de133a15743272be8c5fab8010c7f.tar.bz2
ice-91b10476449de133a15743272be8c5fab8010c7f.tar.xz
ice-91b10476449de133a15743272be8c5fab8010c7f.zip
Fixes
Diffstat (limited to 'cpp/test')
-rw-r--r--cpp/test/IceGrid/Makefile2
-rw-r--r--cpp/test/IceGrid/simple/Makefile2
-rw-r--r--cpp/test/IceGrid/update/AllTests.cpp107
-rw-r--r--cpp/test/IceGrid/update/Client.cpp3
-rwxr-xr-xcpp/test/IceGrid/update/run.py7
5 files changed, 108 insertions, 13 deletions
diff --git a/cpp/test/IceGrid/Makefile b/cpp/test/IceGrid/Makefile
index ee81f12fc54..78a043ff5d7 100644
--- a/cpp/test/IceGrid/Makefile
+++ b/cpp/test/IceGrid/Makefile
@@ -11,7 +11,7 @@ top_srcdir = ../..
include $(top_srcdir)/config/Make.rules
-SUBDIRS = perf simple deployer
+SUBDIRS = perf simple deployer update
$(EVERYTHING)::
@for subdir in $(SUBDIRS); \
diff --git a/cpp/test/IceGrid/simple/Makefile b/cpp/test/IceGrid/simple/Makefile
index 523f458bbba..b17534becb4 100644
--- a/cpp/test/IceGrid/simple/Makefile
+++ b/cpp/test/IceGrid/simple/Makefile
@@ -34,7 +34,7 @@ CPPFLAGS := -I. -I../../include $(CPPFLAGS)
$(CLIENT): $(OBJS) $(COBJS)
rm -f $@
- $(CXX) $(LDFLAGS) -o $@ $(OBJS) $(COBJS) $(LIBS) -lIceGrid -lGlacier2
+ $(CXX) $(LDFLAGS) -o $@ $(OBJS) $(COBJS) $(LIBS) -lIceGrid
$(SERVER): $(OBJS) $(SOBJS)
rm -f $@
diff --git a/cpp/test/IceGrid/update/AllTests.cpp b/cpp/test/IceGrid/update/AllTests.cpp
index ef29323fd87..f2ad4bca864 100644
--- a/cpp/test/IceGrid/update/AllTests.cpp
+++ b/cpp/test/IceGrid/update/AllTests.cpp
@@ -10,6 +10,7 @@
#include <IceUtil/Thread.h>
#include <Ice/Ice.h>
#include <IceGrid/Observer.h>
+#include <IceGrid/Admin.h>
#include <TestCommon.h>
#include <Test.h>
@@ -94,7 +95,7 @@ public:
{
this->applications.insert(make_pair((*p)->name, *p));
}
- this->nodes = nodes;
+ this->nodes = set<string>(nodes.begin(), nodes.end());
updated(serial);
}
@@ -136,11 +137,17 @@ public:
virtual void
nodeUp(const string& name, const Ice::Current& current)
{
+ Lock sync(*this);
+ this->nodes.insert(name);
+ updated();
}
virtual void
nodeDown(const string& name, const Ice::Current& current)
{
+ Lock sync(*this);
+ this->nodes.erase(name);
+ updated();
}
void
@@ -160,14 +167,17 @@ public:
int serial;
map<string, ApplicationDescriptorPtr> applications;
- Ice::StringSeq nodes;
+ set<string> nodes;
private:
void
- updated(int serial)
+ updated(int serial = -1)
{
- this->serial = serial;
+ if(serial != -1)
+ {
+ this->serial = serial;
+ }
_updated = true;
notifyAll();
}
@@ -206,6 +216,11 @@ allTests(const Ice::CommunicatorPtr& communicator)
SessionManagerPrx manager = SessionManagerPrx::checkedCast(communicator->stringToProxy("IceGrid/SessionManager"));
test(manager);
+ AdminPrx admin = AdminPrx::checkedCast(communicator->stringToProxy("IceGrid/Admin"));
+ test(admin);
+
+ Ice::PropertiesPtr properties = communicator->getProperties();
+
SessionKeepAliveThreadPtr keepAlive;
keepAlive = new SessionKeepAliveThread(communicator->getLogger(), IceUtil::Time::seconds(5));
keepAlive->start();
@@ -413,7 +428,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
}
{
- cout << "testing observers... " << flush;
+ cout << "testing registry observer... " << flush;
SessionPrx session1 = manager->createLocalSession("Observer1");
keepAlive->add(session1);
@@ -443,8 +458,9 @@ allTests(const Ice::CommunicatorPtr& communicator)
test(regObs1->applications["Application"]);
test(++serial == regObs1->serial);
}
- catch(const Ice::UserException&)
+ catch(const Ice::UserException& ex)
{
+ cerr << ex << endl;
test(false);
}
@@ -459,8 +475,9 @@ allTests(const Ice::CommunicatorPtr& communicator)
test(regObs1->applications["Application"]->variables["test"] == "test");
test(++serial == regObs1->serial);
}
- catch(const Ice::UserException&)
+ catch(const Ice::UserException& ex)
{
+ cerr << ex << endl;
test(false);
}
@@ -477,8 +494,9 @@ allTests(const Ice::CommunicatorPtr& communicator)
test(regObs1->applications["Application"]->variables["test1"] == "test");
test(++serial == regObs1->serial);
}
- catch(const Ice::UserException&)
+ catch(const Ice::UserException& ex)
{
+ cerr << ex << endl;
test(false);
}
@@ -489,8 +507,79 @@ allTests(const Ice::CommunicatorPtr& communicator)
test(regObs1->applications.empty());
test(++serial == regObs1->serial);
}
- catch(const Ice::UserException&)
+ catch(const Ice::UserException& ex)
+ {
+ cerr << ex << endl;
+ test(false);
+ }
+
+ //
+ // Setup a descriptor to deploy a node on the node.
+ //
+ ApplicationDescriptorPtr nodeApp = new ApplicationDescriptor();
+ nodeApp->name = "NodeApp";
+ ServerDescriptorPtr server = new ServerDescriptor();
+ server->name = "node-1";
+ server->exe = properties->getProperty("IceDir") + "/bin/icegridnode";
+ AdapterDescriptor adapter;
+ adapter.name = "IceGrid.Node";
+ adapter.endpoints = "default";
+ adapter.id = "IceGrid.Node.node-1";
+ adapter.registerProcess = true;
+ server->adapters.push_back(adapter);
+ PropertyDescriptor prop;
+ prop.name = "IceGrid.Node.Name";
+ prop.value = "node-1";
+ server->properties.push_back(prop);
+ prop.name = "IceGrid.Node.Data";
+ prop.value = properties->getProperty("TestDir") + "/db/node-1";
+ server->properties.push_back(prop);
+ ServerInstanceDescriptor instance;
+ instance.descriptor = server;
+ instance.node = "localnode";
+ nodeApp->servers.push_back(instance);
+
+ try
+ {
+ session1->startUpdate(serial);
+ session1->addApplication(nodeApp);
+ regObs1->waitForUpdate(__FILE__, __LINE__);
+ test(regObs1->applications["NodeApp"]);
+ test(++serial == regObs1->serial);
+ }
+ catch(const DeploymentException& ex)
+ {
+ cerr << ex.reason << endl;
+ test(false);
+ }
+ catch(const Ice::UserException& ex)
{
+ cerr << ex << endl;
+ test(false);
+ }
+
+ admin->startServer("node-1");
+ regObs1->waitForUpdate(__FILE__, __LINE__);
+ test(regObs1->nodes.find("node-1") != regObs1->nodes.end());
+ admin->stopServer("node-1");
+ regObs1->waitForUpdate(__FILE__, __LINE__);
+ test(regObs1->nodes.find("node-1") == regObs1->nodes.end());
+
+ try
+ {
+ session1->removeApplication("NodeApp");
+ regObs1->waitForUpdate(__FILE__, __LINE__);
+ test(regObs1->applications.empty());
+ test(++serial == regObs1->serial);
+ }
+ catch(const DeploymentException& ex)
+ {
+ cerr << ex.reason << endl;
+ test(false);
+ }
+ catch(const Ice::UserException& ex)
+ {
+ cerr << ex << endl;
test(false);
}
diff --git a/cpp/test/IceGrid/update/Client.cpp b/cpp/test/IceGrid/update/Client.cpp
index 4e4c921ec05..c2dc6eac0b1 100644
--- a/cpp/test/IceGrid/update/Client.cpp
+++ b/cpp/test/IceGrid/update/Client.cpp
@@ -26,10 +26,11 @@ 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);
}
catch(const Ice::Exception& ex)
diff --git a/cpp/test/IceGrid/update/run.py b/cpp/test/IceGrid/update/run.py
index 6f94ef3559b..1319b654aeb 100755
--- a/cpp/test/IceGrid/update/run.py
+++ b/cpp/test/IceGrid/update/run.py
@@ -30,12 +30,17 @@ client = os.path.join(testdir, "client")
# invokes on the locator it's also considered to be a client.
#
additionalOptions = " --Ice.Default.Locator=\"IceGrid/Locator:default -p 12345\" " + \
- "--Ice.PrintAdapterReady=0 --Ice.PrintProcessId=0"
+ "--Ice.PrintAdapterReady=0 --Ice.PrintProcessId=0 --IceDir=\"" + toplevel + "\" --TestDir=\"" + testdir + "\""
IceGridAdmin.cleanDbDir(os.path.join(testdir, "db"))
iceGridRegistryThread = IceGridAdmin.startIceGridRegistry("12345", testdir)
iceGridNodeThread = IceGridAdmin.startIceGridNode(testdir)
+node1Dir = os.path.join(testdir, "db", "node-1")
+if not os.path.exists(node1Dir):
+ os.mkdir(node1Dir)
+IceGridAdmin.cleanServerDir(node1Dir);
+
print "starting client...",
clientPipe = os.popen(client + TestUtil.clientServerOptions + additionalOptions + " 2>&1")
print "ok"