diff options
Diffstat (limited to 'java/config/TestUtil.py')
-rw-r--r-- | java/config/TestUtil.py | 176 |
1 files changed, 88 insertions, 88 deletions
diff --git a/java/config/TestUtil.py b/java/config/TestUtil.py index d686022c37b..83ca94bff02 100644 --- a/java/config/TestUtil.py +++ b/java/config/TestUtil.py @@ -67,17 +67,17 @@ except getopt.GetoptError: for o, a in opts: if o == "--debug": - debug = 1 + debug = 1 if o == "--protocol": - if a not in ( "tcp", "ssl"): - usage() - protocol = a + if a not in ( "tcp", "ssl"): + usage() + protocol = a if o == "--compress": - compress = 1 + compress = 1 if o == "--threadPerConnection": - threadPerConnection = 1 + threadPerConnection = 1 if o == "--host": - host = a + host = a # # If we are using SSL as the default protocol, we need to examine @@ -89,22 +89,22 @@ jdk14 = False if protocol == "ssl": javaPipeIn, javaPipeOut = os.popen4("java -version") if not javaPipeIn or not javaPipeOut: - print "unable to get Java version!" + print "unable to get Java version!" sys.exit(1) version = javaPipeOut.readline() if not version: - print "unable to get Java version!" + print "unable to get Java version!" sys.exit(1) if version.startswith("java version \"1.4"): - # - # IceSSL requires JDK thread-per-connection when used with JDK 1.4. - # - threadPerConnection = 1 - # - # To avoid the potential for long delays at startup under JDK 1.4, - # we direct the JVM to use /dev/urandom instead of its default. - # - javaCmd = "java -Djava.security.egd=file:/dev/urandom" + # + # IceSSL requires JDK thread-per-connection when used with JDK 1.4. + # + threadPerConnection = 1 + # + # To avoid the potential for long delays at startup under JDK 1.4, + # we direct the JVM to use /dev/urandom instead of its default. + # + javaCmd = "java -Djava.security.egd=file:/dev/urandom" jdk14 = True javaPipeIn.close() javaPipeOut.close() @@ -137,13 +137,13 @@ def isWin9x(): def closePipe(pipe): try: - status = pipe.close() + status = pipe.close() except IOError, ex: - # TODO: There's a waitpid problem on CentOS, so we have to ignore ECHILD. - if ex.errno == errno.ECHILD: - status = 0 - else: - raise + # TODO: There's a waitpid problem on CentOS, so we have to ignore ECHILD. + if ex.errno == errno.ECHILD: + status = 0 + else: + raise return status @@ -158,16 +158,16 @@ class ReaderThread(Thread): while 1: line = self.pipe.readline() if not line: break - # Suppress "adapter ready" messages. Under windows the eol isn't \n. - if not line.endswith(" ready\n") and not line.endswith(" ready\r\n"): - print line, + # Suppress "adapter ready" messages. Under windows the eol isn't \n. + if not line.endswith(" ready\n") and not line.endswith(" ready\r\n"): + print line, except IOError: pass - self.status = closePipe(self.pipe) + self.status = closePipe(self.pipe) def getStatus(self): - return self.status + return self.status serverPids = [] serverThreads = [] @@ -177,18 +177,18 @@ def joinServers(): global serverThreads global allServerThreads for t in serverThreads: - t.join() - allServerThreads.append(t) + t.join() + allServerThreads.append(t) serverThreads = [] def serverStatus(): global allServerThreads joinServers() for t in allServerThreads: - status = t.getStatus() - if status: - print "server " + str(t) + " status: " + str(status) - return status + status = t.getStatus() + if status: + print "server " + str(t) + " status: " + str(status) + return status return 0 def killServers(): @@ -226,32 +226,32 @@ def getServerPid(pipe): global serverThreads while 1: - output = pipe.readline().strip() - if not output: - print "failed!" - killServers() - sys.exit(1) - if output.startswith("warning: "): - continue - break + output = pipe.readline().strip() + if not output: + print "failed!" + killServers() + sys.exit(1) + if output.startswith("warning: "): + continue + break try: - serverPids.append(int(output)) + serverPids.append(int(output)) except ValueError: - print "Output is not a PID: " + output - raise + print "Output is not a PID: " + output + raise def ignorePid(pipe): while 1: - output = pipe.readline().strip() - if not output: - print "failed!" - killServers() - sys.exit(1) - if output.startswith("warning: "): - continue - break + output = pipe.readline().strip() + if not output: + print "failed!" + killServers() + sys.exit(1) + if output.startswith("warning: "): + continue + break def getAdapterReady(pipe, createThread = True, count = 1): global serverThreads @@ -267,9 +267,9 @@ def getAdapterReady(pipe, createThread = True, count = 1): # Start a thread for this server. if createThread: - serverThread = ReaderThread(pipe) - serverThread.start() - serverThreads.append(serverThread) + serverThread = ReaderThread(pipe) + serverThread.start() + serverThreads.append(serverThread) def waitServiceReady(pipe, token, createThread = True): global serverThreads @@ -284,9 +284,9 @@ def waitServiceReady(pipe, token, createThread = True): # Start a thread for this server. if createThread: - serverThread = ReaderThread(pipe) - serverThread.start() - serverThreads.append(serverThread) + serverThread = ReaderThread(pipe) + serverThread.start() + serverThreads.append(serverThread) def printOutputFromPipe(pipe): @@ -313,29 +313,29 @@ os.environ["CLASSPATH"] = os.path.join(toplevel, "lib", "Ice.jar") + sep + os.ge os.environ["CLASSPATH"] = os.path.join(toplevel, "lib") + sep + os.getenv("CLASSPATH", "") if protocol == "ssl": - plugin = " --Ice.Plugin.IceSSL=IceSSL.PluginFactory" + plugin = " --Ice.Plugin.IceSSL=IceSSL.PluginFactory" clientProtocol = plugin + " --Ice.Default.Protocol=ssl" + \ - " --IceSSL.DefaultDir=" + os.path.join(toplevel, "certs") + \ + " --IceSSL.DefaultDir=" + os.path.join(toplevel, "certs") + \ " --IceSSL.Keystore=client.jks" + \ " --IceSSL.Truststore=certs.jks" + \ " --IceSSL.Password=password" serverProtocol = plugin + " --Ice.Default.Protocol=ssl" + \ - " --IceSSL.DefaultDir=" + os.path.join(toplevel, "certs") + \ + " --IceSSL.DefaultDir=" + os.path.join(toplevel, "certs") + \ " --IceSSL.Keystore=server.jks" + \ " --IceSSL.Truststore=certs.jks" + \ " --IceSSL.Password=password" clientServerProtocol = clientProtocol - cppPlugin = " --Ice.Plugin.IceSSL=IceSSL:createIceSSL" + cppPlugin = " --Ice.Plugin.IceSSL=IceSSL:createIceSSL" cppClientProtocol = cppPlugin + " --Ice.Default.Protocol=ssl" + \ - " --IceSSL.DefaultDir=" + os.path.join(toplevel, "certs") + \ - " --IceSSL.CertFile=c_rsa1024_pub.pem" + \ - " --IceSSL.KeyFile=c_rsa1024_priv.pem" + \ - " --IceSSL.CertAuthFile=cacert.pem" + " --IceSSL.DefaultDir=" + os.path.join(toplevel, "certs") + \ + " --IceSSL.CertFile=c_rsa1024_pub.pem" + \ + " --IceSSL.KeyFile=c_rsa1024_priv.pem" + \ + " --IceSSL.CertAuthFile=cacert.pem" cppServerProtocol = cppPlugin + " --Ice.Default.Protocol=ssl" + \ - " --IceSSL.DefaultDir=" + os.path.join(toplevel, "certs") + \ - " --IceSSL.CertFile=s_rsa1024_pub.pem" + \ - " --IceSSL.KeyFile=s_rsa1024_priv.pem" + \ - " --IceSSL.CertAuthFile=cacert.pem" + " --IceSSL.DefaultDir=" + os.path.join(toplevel, "certs") + \ + " --IceSSL.CertFile=s_rsa1024_pub.pem" + \ + " --IceSSL.KeyFile=s_rsa1024_priv.pem" + \ + " --IceSSL.CertAuthFile=cacert.pem" cppClientServerProtocol = cppClientProtocol else: clientProtocol = "" @@ -372,7 +372,7 @@ commonServerOptions = " --Ice.PrintAdapterReady --Ice.Warn.Connections" if not threadPerConnection: commonServerOptions += " --Ice.ThreadPool.Server.Size=1 --Ice.ThreadPool.Server.SizeMax=3" + \ - " --Ice.ThreadPool.Server.SizeWarn=0 --Ice.ServerIdleTime=30" + " --Ice.ThreadPool.Server.SizeWarn=0 --Ice.ServerIdleTime=30" clientOptions = clientProtocol + defaultHost + commonClientOptions serverOptions = serverProtocol + defaultHost + commonServerOptions @@ -396,7 +396,7 @@ def clientServerTestWithOptions(additionalServerOptions, additionalClientOptions print "starting server...", serverCmd = server + serverOptions + additionalServerOptions if debug: - print "(" + serverCmd + ")", + print "(" + serverCmd + ")", serverPipe = os.popen(serverCmd + " 2>&1") getAdapterReady(serverPipe) print "ok" @@ -404,7 +404,7 @@ def clientServerTestWithOptions(additionalServerOptions, additionalClientOptions print "starting client...", clientCmd = client + clientOptions + additionalClientOptions if debug: - print "(" + clientCmd + ")", + print "(" + clientCmd + ")", clientPipe = os.popen(clientCmd + " 2>&1") print "ok" @@ -413,8 +413,8 @@ def clientServerTestWithOptions(additionalServerOptions, additionalClientOptions clientStatus = closePipe(clientPipe) if clientStatus or serverStatus(): - killServers() - sys.exit(1) + killServers() + sys.exit(1) def clientServerTestWithClasspath(serverClasspath, clientClasspath): @@ -429,7 +429,7 @@ def clientServerTestWithClasspath(serverClasspath, clientClasspath): os.environ["CLASSPATH"] = scp serverCmd = server + serverOptions if debug: - print "(" + serverCmd + ")", + print "(" + serverCmd + ")", serverPipe = os.popen(serverCmd + " 2>&1") os.environ["CLASSPATH"] = classpath getAdapterReady(serverPipe) @@ -439,7 +439,7 @@ def clientServerTestWithClasspath(serverClasspath, clientClasspath): os.environ["CLASSPATH"] = ccp clientCmd = client + clientOptions if debug: - print "(" + clientCmd + ")", + print "(" + clientCmd + ")", clientPipe = os.popen(clientCmd + " 2>&1") os.environ["CLASSPATH"] = classpath print "ok" @@ -449,8 +449,8 @@ def clientServerTestWithClasspath(serverClasspath, clientClasspath): clientStatus = closePipe(clientPipe) if clientStatus or serverStatus(): - killServers() - sys.exit(1) + killServers() + sys.exit(1) def clientServerTest(): @@ -464,7 +464,7 @@ def mixedClientServerTestWithOptions(additionalServerOptions, additionalClientOp print "starting server...", serverCmd = server + clientServerOptions + additionalServerOptions if debug: - print "(" + serverCmd + ")", + print "(" + serverCmd + ")", serverPipe = os.popen(serverCmd + " 2>&1") getAdapterReady(serverPipe) print "ok" @@ -472,7 +472,7 @@ def mixedClientServerTestWithOptions(additionalServerOptions, additionalClientOp print "starting client...", clientCmd = client + clientServerOptions + additionalClientOptions if debug: - print "(" + clientCmd + ")", + print "(" + clientCmd + ")", clientPipe = os.popen(clientCmd + " 2>&1") print "ok" @@ -481,8 +481,8 @@ def mixedClientServerTestWithOptions(additionalServerOptions, additionalClientOp clientStatus = closePipe(clientPipe) if clientStatus or serverStatus(): - killServers() - sys.exit(1) + killServers() + sys.exit(1) def mixedClientServerTest(): @@ -495,7 +495,7 @@ def collocatedTestWithOptions(additionalOptions): print "starting collocated...", command = collocated + collocatedOptions + additionalOptions if debug: - print "(" + command + ")", + print "(" + command + ")", collocatedPipe = os.popen(command + " 2>&1") print "ok" @@ -504,8 +504,8 @@ def collocatedTestWithOptions(additionalOptions): collocatedStatus = closePipe(collocatedPipe) if collocatedStatus: - killServers() - sys.exit(1) + killServers() + sys.exit(1) def collocatedTest(): |