diff options
Diffstat (limited to 'cpp/test/IceStorm/stress/run.py')
-rwxr-xr-x | cpp/test/IceStorm/stress/run.py | 157 |
1 files changed, 44 insertions, 113 deletions
diff --git a/cpp/test/IceStorm/stress/run.py b/cpp/test/IceStorm/stress/run.py index 1f1c15f2357..39915064c8e 100755 --- a/cpp/test/IceStorm/stress/run.py +++ b/cpp/test/IceStorm/stress/run.py @@ -10,60 +10,35 @@ import os, sys, time, threading, re -for toplevel in [".", "..", "../..", "../../..", "../../../.."]: - toplevel = os.path.normpath(toplevel) - if os.path.exists(os.path.join(toplevel, "config", "TestUtil.py")): - break -else: +path = [ ".", "..", "../..", "../../..", "../../../.." ] +head = os.path.dirname(sys.argv[0]) +if len(head) > 0: + path = [os.path.join(head, p) for p in path] +path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] +if len(path) == 0: raise "can't find toplevel directory!" +sys.path.append(os.path.join(path[0])) +from scripts import * -sys.path.append(os.path.join(toplevel, "config")) -import TestUtil -TestUtil.processCmdLine() - -name = os.path.join("IceStorm", "stress") -testdir = os.path.dirname(os.path.abspath(__file__)) - -iceBox = TestUtil.getIceBox(testdir) -iceBoxAdmin = os.path.join(TestUtil.getCppBinDir(), "iceboxadmin") iceStormAdmin = os.path.join(TestUtil.getCppBinDir(), "icestormadmin") -import IceStormUtil - def doTest(server1, server2, subOpts, pubOpts): - global testdir - - publisher = os.path.join(testdir, "publisher") - subscriber = os.path.join(testdir, "subscriber") + publisher = os.path.join(os.getcwd(), "publisher") + subscriber = os.path.join(os.getcwd(), "subscriber") - subscriberPipes = [] + subscriberProcs = [] if type(subOpts) != type([]): subOpts = [ subOpts ] for opts in subOpts: # We don't want the subscribers to time out. - pipe = TestUtil.startServer(subscriber, r' --Ice.ServerIdleTime=0 ' + opts) - TestUtil.getServerPid(pipe) - TestUtil.getAdapterReady(pipe) - subscriberPipes.append(pipe) - - publisherPipe = TestUtil.startClient(publisher, server1.reference() + r' ' + pubOpts) - - TestUtil.printOutputFromPipe(publisherPipe) - - publisherStatus = TestUtil.closePipe(publisherPipe) - if publisherStatus: - print "(publisher failed)", - return publisherStatus - for p in subscriberPipes: - try: - sys.stdout.flush() - subscriberStatus = TestUtil.specificServerStatus(p) - except: - print "(subscriber failed)", - return 1 - if subscriberStatus: - print "(subscriber failed)", - return subscriberStatus + proc = TestUtil.startServer(subscriber, ' --Ice.ServerIdleTime=0 ' + opts) + subscriberProcs.append(proc) + + publisherProc = TestUtil.startClient(publisher, server1.reference() + r' ' + pubOpts) + publisherProc.waitTestSuccess() + for p in subscriberProcs: + sys.stdout.flush() + p.waitTestSuccess() return 0 @@ -73,18 +48,17 @@ def runAdmin(cmd, desc = None): if desc: print desc, sys.stdout.flush() - pipe = TestUtil.startClient(iceStormAdmin, adminIceStormReference + r' -e "' + cmd + '"') - status = TestUtil.closePipe(pipe) - if status: - TestUtil.killServers() - sys.exit(1) + proc = TestUtil.startClient(iceStormAdmin, adminIceStormReference + r' -e "%s"' % cmd) + proc.waitTestSuccess() if desc: print "ok" def runtest(type): # Clear the idle timeout otherwise the IceBox ThreadPool will timeout. - server1 = IceStormUtil.init(toplevel, testdir, type, dbDir = "db", instanceName = "TestIceStorm1", port = 12000) - server2 = IceStormUtil.init(toplevel, testdir, type, dbDir = "db2", instanceName = "TestIceStorm2", port = 12500) + server1 = IceStormUtil.init(TestUtil.toplevel, os.getcwd(), type, dbDir = "db", instanceName = "TestIceStorm1", + port = 12000) + server2 = IceStormUtil.init(TestUtil.toplevel, os.getcwd(), type, dbDir = "db2", instanceName = "TestIceStorm2", + port = 12500) global adminIceStormReference adminIceStormReference = ' --IceStormAdmin.TopicManager.Proxy="%s" --IceStormAdmin.TopicManager.Proxy2="%s"' % ( server1.proxy(), server2.proxy()) @@ -99,76 +73,47 @@ def runtest(type): print "Sending 5000 ordered events... ", sys.stdout.flush() - status = doTest(server1, server2, '--events 5000 --qos "reliability,ordered" ' + server1.reference(), '--events 5000') - if status: - print "failed!" - TestUtil.killServers() - sys.exit(1) + doTest(server1, server2, '--events 5000 --qos "reliability,ordered" ' + server1.reference(), '--events 5000') print "ok" runAdmin("link TestIceStorm1/fed1 TestIceStorm2/fed1") print "Sending 5000 ordered events across a link... ", sys.stdout.flush() - status = doTest(server1, server2, '--events 5000 --qos "reliability,ordered" ' + server2.reference(), '--events 5000') - if status: - TestUtil.killServers() - sys.exit(1) + doTest(server1, server2, '--events 5000 --qos "reliability,ordered" ' + server2.reference(), '--events 5000') print "ok" runAdmin("unlink TestIceStorm1/fed1 TestIceStorm2/fed1") print "Sending 20000 unordered events... ", sys.stdout.flush() - status = doTest(server1, server2, '--events 20000 ' + server1.reference(), '--events 20000 --oneway') - if status: - print "failed!" - TestUtil.killServers() - sys.exit(1) + doTest(server1, server2, '--events 20000 ' + server1.reference(), '--events 20000 --oneway') print "ok" runAdmin("link TestIceStorm1/fed1 TestIceStorm2/fed1") print "Sending 20000 unordered events across a link... ", sys.stdout.flush() - status = doTest(server1, server2, '--events 20000 ' + server2.reference(), '--events 20000 --oneway') - if status: - TestUtil.killServers() - sys.exit(1) + doTest(server1, server2, '--events 20000 ' + server2.reference(), '--events 20000 --oneway') print "ok" runAdmin("unlink TestIceStorm1/fed1 TestIceStorm2/fed1") print "Sending 20000 unordered batch events... ", sys.stdout.flush() - status = doTest(server1, server2, '--events 20000 --qos "reliability,batch" ' + server1.reference(), '--events 20000 --oneway') - if status: - print "failed!" - TestUtil.killServers() - sys.exit(1) + doTest(server1, server2, '--events 20000 --qos "reliability,batch" ' + server1.reference(), '--events 20000 --oneway') print "ok" runAdmin("link TestIceStorm1/fed1 TestIceStorm2/fed1") print "Sending 20000 unordered batch events across a link... ", sys.stdout.flush() - status = doTest(server1, server2, '--events 20000 --qos "reliability,batch" ' + server2.reference(), '--events 20000 --oneway') - if status: - TestUtil.killServers() - sys.exit(1) + doTest(server1, server2, '--events 20000 --qos "reliability,batch" ' + server2.reference(), '--events 20000 --oneway') print "ok" runAdmin("unlink TestIceStorm1/fed1 TestIceStorm2/fed1") print "Sending 20000 unordered events with slow subscriber... ", - status = doTest(server1, server2, ['--events 2 --slow ' + server1.reference(), '--events 20000 ' + server1.reference()], '--events 20000 --oneway') - if status: - print "failed!" - TestUtil.killServers() - sys.exit(1) + doTest(server1, server2, ['--events 2 --slow ' + server1.reference(), '--events 20000 ' + server1.reference()], '--events 20000 --oneway') print "ok" runAdmin("link TestIceStorm1/fed1 TestIceStorm2/fed1") print "Sending 20000 unordered events with slow subscriber & link... ", - status = doTest(server1, server2, ['--events 2 --slow' + server1.reference(), '--events 20000' + server1.reference(), '--events 2 --slow' + server2.reference(), '--events 20000' + server2.reference()], '--events 20000 --oneway') - if status: - print "failed!" - TestUtil.killServers() - sys.exit(1) + doTest(server1, server2, ['--events 2 --slow' + server1.reference(), '--events 20000' + server1.reference(), '--events 2 --slow' + server2.reference(), '--events 20000' + server2.reference()], '--events 20000 --oneway') print "ok" @@ -193,32 +138,24 @@ def runtest(type): print "Sending 20000 unordered events with erratic subscriber... ", sys.stdout.flush() - status = doTest(server1, server2, \ - [ '--erratic 5 --qos "reliability,ordered" --events 20000' + server1.reference(), \ - '--erratic 5 --events 20000' + server1.reference(), \ - '--events 20000' + server1.reference()], \ + doTest(server1, server2, + [ '--erratic 5 --qos "reliability,ordered" --events 20000' + server1.reference(), + '--erratic 5 --events 20000' + server1.reference(), + '--events 20000' + server1.reference()], '--events 20000 --oneway') - if status: - print "failed!" - TestUtil.killServers() - sys.exit(1) print "ok" runAdmin("link TestIceStorm1/fed1 TestIceStorm2/fed1") print "Sending 20000 unordered events with erratic subscriber across a link... ", sys.stdout.flush() - status = doTest(server1, server2, \ - [ '--events 20000' + server1.reference(), \ - '--erratic 5 --qos "reliability,ordered" --events 20000 ' + server1.reference(), \ - '--erratic 5 --events 20000 ' + server1.reference(), \ - '--events 20000' + server2.reference(), \ - '--erratic 5 --qos "reliability,ordered" --events 20000 ' + server2.reference(), \ - '--erratic 5 --events 20000 ' + server2.reference()], \ + doTest(server1, server2, + [ '--events 20000' + server1.reference(), + '--erratic 5 --qos "reliability,ordered" --events 20000 ' + server1.reference(), + '--erratic 5 --events 20000 ' + server1.reference(), + '--events 20000' + server2.reference(), + '--erratic 5 --qos "reliability,ordered" --events 20000 ' + server2.reference(), + '--erratic 5 --events 20000 ' + server2.reference()], '--events 20000 --oneway ') - if status: - print "failed!" - TestUtil.killServers() - sys.exit(1) print "ok" # @@ -230,11 +167,5 @@ def runtest(type): server2.stop() print "ok" - if TestUtil.serverStatus(): - TestUtil.killServers() - sys.exit(1) - runtest("persistent") runtest("replicated") - -sys.exit(0) |