diff options
author | Matthew Newhook <matthew@zeroc.com> | 2006-09-05 10:07:34 +0000 |
---|---|---|
committer | Matthew Newhook <matthew@zeroc.com> | 2006-09-05 10:07:34 +0000 |
commit | 1e377cefaae392f6e8be2857990541a6728be7c1 (patch) | |
tree | ce6a9a375eca626c31b9cc31ef208949325b3e5a | |
parent | fix bug with Glacier2 router test. (diff) | |
download | ice-1e377cefaae392f6e8be2857990541a6728be7c1.tar.bz2 ice-1e377cefaae392f6e8be2857990541a6728be7c1.tar.xz ice-1e377cefaae392f6e8be2857990541a6728be7c1.zip |
http://bugzilla.zeroc.com/bugzilla/show_bug.cgi?id=1356
-rw-r--r-- | cpp/config/IceGridAdmin.py | 50 | ||||
-rw-r--r-- | cpp/config/TestUtil.py | 2 | ||||
-rw-r--r-- | cpp/test/Glacier2/router/Client.cpp | 2 | ||||
-rwxr-xr-x | cpp/test/Glacier2/router/run.py | 1 | ||||
-rw-r--r-- | cs/config/IceGridAdmin.py | 47 | ||||
-rw-r--r-- | cs/test/IceGrid/simple/AllTests.cs | 70 | ||||
-rw-r--r-- | java/config/IceGridAdmin.py | 53 | ||||
-rw-r--r-- | java/test/IceGrid/simple/AllTests.java | 75 |
8 files changed, 245 insertions, 55 deletions
diff --git a/cpp/config/IceGridAdmin.py b/cpp/config/IceGridAdmin.py index 4853aade3ea..e4c168be3de 100644 --- a/cpp/config/IceGridAdmin.py +++ b/cpp/config/IceGridAdmin.py @@ -11,9 +11,6 @@ import sys, os, TestUtil from threading import Thread -debug = 0 -#debug = 1 - for toplevel in [".", "..", "../..", "../../..", "../../../.."]: toplevel = os.path.normpath(toplevel) if os.path.exists(os.path.join(toplevel, "config", "TestUtil.py")): @@ -70,11 +67,11 @@ def startIceGridRegistry(testdir, dynamicRegistration = False): if dynamicRegistration: command += ' --IceGrid.Registry.DynamicRegistration' - if debug: - print command + if TestUtil.debug: + print "(" + command + ")", - (stdin, iceGridPipe) = os.popen4(command) + iceGridPipe = os.popen(command + " 2>&1") TestUtil.getServerPid(iceGridPipe) TestUtil.getAdapterReady(iceGridPipe, True, 4) print "ok" @@ -100,11 +97,11 @@ def startIceGridNode(testdir): r' --IceGrid.Node.Data=' + dataDir + \ r' --IceGrid.Node.Name=localnode' + \ r' --IceGrid.Node.PropertiesOverride=' + overrideOptions - if debug: - print command + if TestUtil.debug: + print "(" + command + ")", - (stdin, iceGridPipe) = os.popen4(command) + iceGridPipe = os.popen(command + " 2>&1") TestUtil.getServerPid(iceGridPipe) TestUtil.getAdapterReady(iceGridPipe, False) TestUtil.waitServiceReady(iceGridPipe, 'node') @@ -124,11 +121,12 @@ def iceGridAdmin(cmd, ignoreFailure = False): command = iceGridAdmin + TestUtil.clientOptions + \ r' --Ice.Default.Locator="IceGrid/Locator:default -p ' + iceGridPort + '" ' + \ r" --IceGridAdmin.Username=" + user + " --IceGridAdmin.Password=test1 " + \ - r' -e "' + cmd + '" 2>&1' - if debug: - print command + r' -e "' + cmd + '"' + + if TestUtil.debug: + print "(" + command +")", - iceGridAdminPipe = os.popen(command) + iceGridAdminPipe = os.popen(command + " 2>&1") output = iceGridAdminPipe.readlines() @@ -169,11 +167,12 @@ def iceGridTest(name, application, additionalOptions = "", applicationOptions = print "starting client...", - command = client + TestUtil.clientOptions + " " + clientOptions + " 2>&1" - if debug: - print command + command = client + TestUtil.clientOptions + " " + clientOptions - clientPipe = os.popen(command) + if TestUtil.debug: + print "(" + command +")", + + clientPipe = os.popen(command + " 2>&1") print "ok" TestUtil.printOutputFromPipe(clientPipe) @@ -220,17 +219,24 @@ def iceGridClientServerTest(name, additionalClientOptions, additionalServerOptio iceGridRegistryPipe = startIceGridRegistry(testdir, True) print "starting sever...", - serverPipe = os.popen(server + TestUtil.clientServerOptions + " " + serverOptions + " 2>&1") + + command = server + TestUtil.clientServerOptions + " " + serverOptions + + if TestUtil.debug: + print "(" + command +")", + + serverPipe = os.popen(command + " 2>&1") TestUtil.getServerPid(serverPipe) TestUtil.getAdapterReady(serverPipe) print "ok" print "starting client...", - command = client + TestUtil.clientOptions + " " + clientOptions + " 2>&1" - if debug: - print command + command = client + TestUtil.clientOptions + " " + clientOptions + + if TestUtil.debug: + print "(" + command +")", - clientPipe = os.popen(command) + clientPipe = os.popen(command + " 2>&1") print "ok" TestUtil.printOutputFromPipe(clientPipe) diff --git a/cpp/config/TestUtil.py b/cpp/config/TestUtil.py index 5cc36d8efd8..1c101f392cd 100644 --- a/cpp/config/TestUtil.py +++ b/cpp/config/TestUtil.py @@ -395,7 +395,7 @@ else: commonClientOptions = " --Ice.NullHandleAbort --Ice.Warn.Connections" commonServerOptions = " --Ice.PrintProcessId --Ice.PrintAdapterReady --Ice.NullHandleAbort" + \ - " --Ice.Warn.Connections --Ice.ServerIdleTime=30"; + " --Ice.Warn.Connections --Ice.ServerIdleTime=30" if threadPerConnection > 0: commonClientOptions += " --Ice.ThreadPerConnection=" + str(threadPerConnection) diff --git a/cpp/test/Glacier2/router/Client.cpp b/cpp/test/Glacier2/router/Client.cpp index 14f41a8ef97..163bb8965e1 100644 --- a/cpp/test/Glacier2/router/Client.cpp +++ b/cpp/test/Glacier2/router/Client.cpp @@ -455,6 +455,7 @@ CallbackClient::run(int argc, char* argv[]) communicator()->setDefaultRouter(router); cout << "ok" << endl; } + { cout << "getting the session timeout... " << flush; Ice::Long timeout = router->getSessionTimeout(); @@ -462,7 +463,6 @@ CallbackClient::run(int argc, char* argv[]) cout << "ok" << endl; } - ObjectPrx base; { diff --git a/cpp/test/Glacier2/router/run.py b/cpp/test/Glacier2/router/run.py index 99f01dd0ca9..34f7039b947 100755 --- a/cpp/test/Glacier2/router/run.py +++ b/cpp/test/Glacier2/router/run.py @@ -45,6 +45,7 @@ TestUtil.getServerPid(starterPipe) # TestUtil.getAdapterReady(starterPipe, False) print "ok" + starterThread = TestUtil.ReaderThread(starterPipe); starterThread.start() diff --git a/cs/config/IceGridAdmin.py b/cs/config/IceGridAdmin.py index e83e598859d..0e6fa9e3313 100644 --- a/cs/config/IceGridAdmin.py +++ b/cs/config/IceGridAdmin.py @@ -30,12 +30,12 @@ nodeOptions = r' --Ice.Warn.Connections=0' + \ r' --IceGrid.Node.Endpoints=default' + \ r' --IceGrid.Node.WaitTime=30' + \ r' --Ice.ProgramName=icegridnode' + \ + r' --IceGrid.Node.Trace.Replica=0' + \ r' --IceGrid.Node.Trace.Activator=0' + \ r' --IceGrid.Node.Trace.Adapter=0' + \ r' --IceGrid.Node.Trace.Server=0' + \ r' --IceGrid.Node.PrintServersReady=node' + \ r' --Ice.NullHandleAbort' + \ - r' --Ice.PrintProcessId' \ r' --Ice.ThreadPool.Server.Size=0'; registryOptions = r' --Ice.Warn.Connections=0' + \ @@ -43,17 +43,14 @@ registryOptions = r' --Ice.Warn.Connections=0' + \ r' --IceGrid.Registry.AdminPermissionsVerifier=IceGrid/NullPermissionsVerifier' + \ r' --IceGrid.Registry.Server.Endpoints=default' + \ r' --IceGrid.Registry.Internal.Endpoints=default' + \ - r' --IceGrid.Registry.Admin.Endpoints=default' + \ - r' --IceGrid.Registry.Server.Endpoints=default' + \ - r' --IceGrid.Registry.Internal.Endpoints=default' + \ - r' --IceGrid.Registry.Admin.Endpoints=default' + \ + r' --IceGrid.Registry.SessionManager.Endpoints=default' + \ r' --IceGrid.Registry.Trace.Session=0' + \ r' --IceGrid.Registry.Trace.Application=0' + \ + r' --IceGrid.Registry.Trace.Node=0' + \ r' --IceGrid.Registry.Trace.Adapter=0' + \ r' --IceGrid.Registry.Trace.Object=0' + \ r' --IceGrid.Registry.Trace.Server=0' + \ r' --IceGrid.Registry.Trace.Locator=0' + \ - r' --Ice.PrintProcessId' \ r' --Ice.ThreadPool.Server.Size=0'; def startIceGridRegistry(testdir, dynamicRegistration = False): @@ -77,7 +74,9 @@ def startIceGridRegistry(testdir, dynamicRegistration = False): if dynamicRegistration: command += ' --IceGrid.Registry.DynamicRegistration' - (stdin, iceGridPipe) = os.popen4(command) + if TestUtil.debug: + print "(" + command +")", + iceGridPipe = os.popen(command + " 2>&1") TestUtil.getServerPid(iceGridPipe) TestUtil.getAdapterReady(iceGridPipe, True, 4) print "ok" @@ -104,7 +103,9 @@ def startIceGridNode(testdir): r' --IceGrid.Node.Name=localnode' + \ r' --IceGrid.Node.PropertiesOverride=' + overrideOptions - (stdin, iceGridPipe) = os.popen4(command) + if TestUtil.debug: + print "(" + command +")", + iceGridPipe = os.popen(command + " 2>&1") TestUtil.getServerPid(iceGridPipe) TestUtil.getAdapterReady(iceGridPipe, False) TestUtil.waitServiceReady(iceGridPipe, 'node') @@ -118,17 +119,26 @@ def iceGridAdmin(cmd, ignoreFailure = False): global iceGridPort iceGridAdmin = os.path.join(ice_home, "bin", "icegridadmin") + user = r"admin1" + if cmd == "shutdown": + user = r"shutdown" command = iceGridAdmin + TestUtil.cppClientOptions + \ r' --Ice.Default.Locator="IceGrid/Locator:default -p ' + iceGridPort + '" ' + \ - r' -e "' + cmd + '" 2>&1' + r" --IceGridAdmin.Username=" + user + " --IceGridAdmin.Password=test1 " + \ + r' -e "' + cmd + '"' + + if TestUtil.debug: + print "(" + command + ")", - iceGridAdminPipe = os.popen(command) + iceGridAdminPipe = os.popen(command + " 2>&1") output = iceGridAdminPipe.readlines() - iceGridAdminStatus = iceGridAdminPipe.close() + iceGridAdminStatus = TestUtil.closePipe(iceGridAdminPipe) if not ignoreFailure and iceGridAdminStatus: print "icegridadmin command failed: " + cmd + for line in output: + print line TestUtil.killServers() sys.exit(1) @@ -160,7 +170,10 @@ def iceGridTest(name, application, additionalOptions = "", applicationOptions = print "ok" print TestUtil.createMsg("client"), - clientPipe = os.popen(TestUtil.createCmd(client) + TestUtil.clientOptions + " " + clientOptions + " 2>&1") + command = TestUtil.createCmd(client) + TestUtil.clientOptions + " " + clientOptions + if TestUtil.debug: + print "(" + command +")", + clientPipe = os.popen(command + " 2>&1") print "ok" TestUtil.printOutputFromPipe(clientPipe) @@ -203,12 +216,18 @@ def iceGridClientServerTest(name, additionalClientOptions, additionalServerOptio iceGridRegistryPipe = startIceGridRegistry(testdir, True) print TestUtil.createMsg("server"), - serverPipe = os.popen(TestUtil.createCmd(server) + TestUtil.clientServerOptions + " " + serverOptions + " 2>&1") + command = TestUtil.createCmd(server) + TestUtil.clientServerOptions + " " + serverOptions + if TestUtil.debug: + print "(" + command +")", + serverPipe = os.popen(command + " 2>&1") TestUtil.getAdapterReady(serverPipe) print "ok" print TestUtil.createMsg("client"), - clientPipe = os.popen(TestUtil.createCmd(client) + TestUtil.clientOptions + " " + clientOptions + " 2>&1") + command = TestUtil.createCmd(client) + TestUtil.clientOptions + " " + clientOptions + if TestUtil.debug: + print "(" + command +")", + clientPipe = os.popen(command + " 2>&1") print "ok" TestUtil.printOutputFromPipe(clientPipe) diff --git a/cs/test/IceGrid/simple/AllTests.cs b/cs/test/IceGrid/simple/AllTests.cs index 849c2da579a..bbfba606a6f 100644 --- a/cs/test/IceGrid/simple/AllTests.cs +++ b/cs/test/IceGrid/simple/AllTests.cs @@ -8,10 +8,57 @@ // ********************************************************************** using System; +using System.Threading; using Test; public class AllTests { + class SessionKeepAliveThread + { + public SessionKeepAliveThread(IceGrid.AdminSessionPrx session, int timeout) + { + _session = session; + _timeout = timeout; + _terminated = false; + } + + public void run() + { + lock(this) + { + while(!_terminated) + { + System.Threading.Monitor.Wait(this, _timeout); + if(_terminated) + { + break; + } + try + { + _session.keepAlive(); + } + catch(Ice.LocalException) + { + break; + } + } + } + } + + public void terminate() + { + lock(this) + { + _terminated = true; + System.Threading.Monitor.Pulse(this); + } + } + + private IceGrid.AdminSessionPrx _session; + private int _timeout; + private bool _terminated; + } + private static void test(bool b) { @@ -103,7 +150,24 @@ public class AllTests } Console.Out.WriteLine("ok"); - IceGrid.AdminPrx admin = IceGrid.AdminPrxHelper.checkedCast(communicator.stringToProxy("IceGrid/Admin")); + IceGrid.RegistryPrx registry = IceGrid.RegistryPrxHelper.checkedCast( + communicator.stringToProxy("IceGrid/Registry")); + test(registry != null); + IceGrid.AdminSessionPrx session = null; + try + { + session = registry.createAdminSession("foo", "bar"); + } + catch(IceGrid.PermissionDeniedException) + { + test(false); + } + + SessionKeepAliveThread keepAlive = new SessionKeepAliveThread(session, registry.getSessionTimeout()/2); + Thread keepAliveThread = new Thread(new ThreadStart(keepAlive.run)); + keepAliveThread.Start(); + + IceGrid.AdminPrx admin = session.getAdmin(); test(admin != null); try @@ -190,5 +254,9 @@ public class AllTests { test(false); } + + keepAlive.terminate(); + keepAliveThread.Join(); + session.destroy(); } } diff --git a/java/config/IceGridAdmin.py b/java/config/IceGridAdmin.py index 90ad3122601..13b17fabb85 100644 --- a/java/config/IceGridAdmin.py +++ b/java/config/IceGridAdmin.py @@ -11,6 +11,9 @@ import sys, os, TestUtil from threading import Thread +debug = 0 +#debug = 1 + for toplevel in [".", "..", "../..", "../../..", "../../../.."]: toplevel = os.path.normpath(toplevel) if os.path.exists(os.path.join(toplevel, "config", "TestUtil.py")): @@ -30,12 +33,12 @@ nodeOptions = r' --Ice.Warn.Connections=0' + \ r' --IceGrid.Node.Endpoints=default' + \ r' --IceGrid.Node.WaitTime=30' + \ r' --Ice.ProgramName=icegridnode' + \ + r' --IceGrid.Node.Trace.Replica=0' + \ r' --IceGrid.Node.Trace.Activator=0' + \ r' --IceGrid.Node.Trace.Adapter=0' + \ r' --IceGrid.Node.Trace.Server=0' + \ r' --IceGrid.Node.PrintServersReady=node' + \ r' --Ice.NullHandleAbort' + \ - r' --Ice.PrintProcessId' \ r' --Ice.ThreadPool.Server.Size=0'; registryOptions = r' --Ice.Warn.Connections=0' + \ @@ -43,17 +46,13 @@ registryOptions = r' --Ice.Warn.Connections=0' + \ r' --IceGrid.Registry.AdminPermissionsVerifier=IceGrid/NullPermissionsVerifier' + \ r' --IceGrid.Registry.Server.Endpoints=default' + \ r' --IceGrid.Registry.Internal.Endpoints=default' + \ - r' --IceGrid.Registry.Admin.Endpoints=default' + \ - r' --IceGrid.Registry.Server.Endpoints=default' + \ - r' --IceGrid.Registry.Internal.Endpoints=default' + \ - r' --IceGrid.Registry.Admin.Endpoints=default' + \ + r' --IceGrid.Registry.SessionManager.Endpoints=default' + \ r' --IceGrid.Registry.Trace.Session=0' + \ r' --IceGrid.Registry.Trace.Application=0' + \ r' --IceGrid.Registry.Trace.Adapter=0' + \ r' --IceGrid.Registry.Trace.Object=0' + \ r' --IceGrid.Registry.Trace.Server=0' + \ r' --IceGrid.Registry.Trace.Locator=0' + \ - r' --Ice.PrintProcessId' \ r' --Ice.ThreadPool.Server.Size=0'; def startIceGridRegistry(testdir, dynamicRegistration = False): @@ -77,7 +76,10 @@ def startIceGridRegistry(testdir, dynamicRegistration = False): if dynamicRegistration: command += ' --IceGrid.Registry.DynamicRegistration' - (stdin, iceGridPipe) = os.popen4(command) + if TestUtil.debug: + print "(" + command + ")" + + iceGridPipe = os.popen(command + " 2>&1") TestUtil.getServerPid(iceGridPipe) TestUtil.getAdapterReady(iceGridPipe, True, 4) print "ok" @@ -104,7 +106,10 @@ def startIceGridNode(testdir): r' --IceGrid.Node.Name=localnode' + \ r' --IceGrid.Node.PropertiesOverride=' + overrideOptions - (stdin, iceGridPipe) = os.popen4(command) + if TestUtil.debug: + print "(" + command +")", + + iceGridPipe = os.popen(command + " 2>&1") TestUtil.getServerPid(iceGridPipe) TestUtil.getAdapterReady(iceGridPipe, False) TestUtil.waitServiceReady(iceGridPipe, 'node') @@ -118,22 +123,31 @@ def iceGridAdmin(cmd, ignoreFailure = False): global iceGridPort iceGridAdmin = os.path.join(ice_home, "bin", "icegridadmin") + user = r"admin1" + if cmd == "shutdown": + user = r"shutdown" command = iceGridAdmin + TestUtil.cppClientOptions + \ r' --Ice.Default.Locator="IceGrid/Locator:default -p ' + iceGridPort + '" ' + \ - r' -e "' + cmd + '" 2>&1' + r" --IceGridAdmin.Username=" + user + " --IceGridAdmin.Password=test1 " + \ + r' -e "' + cmd + '"' + + if TestUtil.debug: + print "(" + command + ")", - iceGridAdminPipe = os.popen(command) + iceGridAdminPipe = os.popen(command + " 2>&1") output = iceGridAdminPipe.readlines() - iceGridAdminStatus = iceGridAdminPipe.close() + iceGridAdminStatus = TestUtil.closePipe(iceGridAdminPipe) if not ignoreFailure and iceGridAdminStatus: print "icegridadmin command failed: " + cmd + for line in output: + print line TestUtil.killServers() sys.exit(1) return output - + def killNodeServers(): global iceGridPort @@ -160,7 +174,10 @@ def iceGridTest(name, application, additionalOptions = "", applicationOptions = print "ok" print "starting client...", - clientPipe = os.popen(client + TestUtil.clientOptions + " " + clientOptions + " 2>&1") + command = client + TestUtil.clientOptions + " " + clientOptions + if TestUtil.debug: + print "(" + command +")", + clientPipe = os.popen(command + " 2>&1") print "ok" TestUtil.printOutputFromPipe(clientPipe) @@ -203,12 +220,18 @@ def iceGridClientServerTest(name, additionalClientOptions, additionalServerOptio iceGridRegistryPipe = startIceGridRegistry(testdir, True) print "starting server...", - serverPipe = os.popen(server + TestUtil.clientServerOptions + " " + serverOptions + " 2>&1") + command = server + TestUtil.clientServerOptions + " " + serverOptions + if TestUtil.debug: + print "(" + command +")", + serverPipe = os.popen(command + " 2>&1") TestUtil.getAdapterReady(serverPipe) print "ok" print "starting client...", - clientPipe = os.popen(client + TestUtil.clientOptions + " " + clientOptions + " 2>&1") + command = client + TestUtil.clientOptions + " " + clientOptions + if TestUtil.debug: + print "(" + command +")", + clientPipe = os.popen(command + " 2>&1") print "ok" TestUtil.printOutputFromPipe(clientPipe) diff --git a/java/test/IceGrid/simple/AllTests.java b/java/test/IceGrid/simple/AllTests.java index bae6662fd1b..10f67cf89e5 100644 --- a/java/test/IceGrid/simple/AllTests.java +++ b/java/test/IceGrid/simple/AllTests.java @@ -11,6 +11,53 @@ import Test.*; public class AllTests { + static private class SessionKeepAliveThread extends Thread + { + SessionKeepAliveThread(IceGrid.AdminSessionPrx session, long timeout) + { + _session = session; + _timeout = timeout; + _terminated = false; + } + + synchronized public void + run() + { + while(!_terminated) + { + try + { + wait(_timeout); + } + catch(InterruptedException e) + { + } + if(_terminated) + { + break; + } + try + { + _session.keepAlive(); + } + catch(Ice.LocalException ex) + { + break; + } + } + } + + synchronized private void + terminate() + { + _terminated = true; + notify(); + } + + final private IceGrid.AdminSessionPrx _session; + final private long _timeout; + private boolean _terminated; + } private static void test(boolean b) { @@ -103,7 +150,23 @@ public class AllTests } System.out.println("ok"); - IceGrid.AdminPrx admin = IceGrid.AdminPrxHelper.checkedCast(communicator.stringToProxy("IceGrid/Admin")); + IceGrid.RegistryPrx registry = IceGrid.RegistryPrxHelper.checkedCast( + communicator.stringToProxy("IceGrid/Registry")); + test(registry != null); + IceGrid.AdminSessionPrx session = null; + try + { + session = registry.createAdminSession("foo", "bar"); + } + catch(IceGrid.PermissionDeniedException e) + { + test(false); + } + + SessionKeepAliveThread keepAlive = new SessionKeepAliveThread(session, registry.getSessionTimeout()/2); + keepAlive.start(); + + IceGrid.AdminPrx admin = session.getAdmin(); test(admin != null); try @@ -202,5 +265,15 @@ public class AllTests { test(false); } + + keepAlive.terminate(); + try + { + keepAlive.join(); + } + catch(InterruptedException e) + { + } + session.destroy(); } } |