diff options
author | Benoit Foucher <benoit@zeroc.com> | 2016-11-25 13:13:22 +0100 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2016-11-25 13:13:22 +0100 |
commit | dcdc32af1fced49d80a8ccd93230e15d91ab45d8 (patch) | |
tree | eb69e2555fbd54496fce8a33f4dd610e1473ff51 /cpp/test/IceStorm | |
parent | C# IceSSL/configuration log expired certificate exceptions. (diff) | |
download | ice-dcdc32af1fced49d80a8ccd93230e15d91ab45d8.tar.bz2 ice-dcdc32af1fced49d80a8ccd93230e15d91ab45d8.tar.xz ice-dcdc32af1fced49d80a8ccd93230e15d91ab45d8.zip |
Refactored test scripts
Diffstat (limited to 'cpp/test/IceStorm')
37 files changed, 889 insertions, 1166 deletions
diff --git a/cpp/test/IceStorm/federation/0.db/.gitignore b/cpp/test/IceStorm/federation/0.db/.gitignore deleted file mode 100644 index 72e8ffc0db8..00000000000 --- a/cpp/test/IceStorm/federation/0.db/.gitignore +++ /dev/null @@ -1 +0,0 @@ -* diff --git a/cpp/test/IceStorm/federation/1.db/.gitignore b/cpp/test/IceStorm/federation/1.db/.gitignore deleted file mode 100644 index 72e8ffc0db8..00000000000 --- a/cpp/test/IceStorm/federation/1.db/.gitignore +++ /dev/null @@ -1 +0,0 @@ -* diff --git a/cpp/test/IceStorm/federation/2.db/.gitignore b/cpp/test/IceStorm/federation/2.db/.gitignore deleted file mode 100644 index 72e8ffc0db8..00000000000 --- a/cpp/test/IceStorm/federation/2.db/.gitignore +++ /dev/null @@ -1 +0,0 @@ -* diff --git a/cpp/test/IceStorm/federation/Publisher.cpp b/cpp/test/IceStorm/federation/Publisher.cpp index 4cee72d4da7..befcf51b8dc 100644 --- a/cpp/test/IceStorm/federation/Publisher.cpp +++ b/cpp/test/IceStorm/federation/Publisher.cpp @@ -9,6 +9,7 @@ #include <Ice/Ice.h> #include <IceStorm/IceStorm.h> +#include <TestCommon.h> #include <Event.h> using namespace std; @@ -45,7 +46,7 @@ run(int, char* argv[], const CommunicatorPtr& communicator) { cerr << argv[0] << ": NoSuchTopic: " << e.name << endl; return EXIT_FAILURE; - + } TopicPrx fed2; @@ -57,7 +58,7 @@ run(int, char* argv[], const CommunicatorPtr& communicator) { cerr << argv[0] << ": NoSuchTopic: " << e.name << endl; return EXIT_FAILURE; - + } TopicPrx fed3; @@ -69,7 +70,7 @@ run(int, char* argv[], const CommunicatorPtr& communicator) { cerr << argv[0] << ": NoSuchTopic: " << e.name << endl; return EXIT_FAILURE; - + } EventPrx eventFed1 = EventPrx::uncheckedCast(fed1->getPublisher()->ice_oneway()); @@ -131,10 +132,10 @@ main(int argc, char* argv[]) { int status; CommunicatorPtr communicator; - + InitializationData initData = getTestInitData(argc, argv); try { - communicator = initialize(argc, argv); + communicator = initialize(argc, argv, initData); status = run(argc, argv, communicator); } catch(const Exception& ex) diff --git a/cpp/test/IceStorm/federation/Subscriber.cpp b/cpp/test/IceStorm/federation/Subscriber.cpp index f99a0722437..20ef6c29bc8 100644 --- a/cpp/test/IceStorm/federation/Subscriber.cpp +++ b/cpp/test/IceStorm/federation/Subscriber.cpp @@ -196,10 +196,10 @@ main(int argc, char* argv[]) { int status; CommunicatorPtr communicator; - + InitializationData initData = getTestInitData(argc, argv); try { - communicator = initialize(argc, argv); + communicator = initialize(argc, argv, initData); status = run(argc, argv, communicator); } catch(const Exception& ex) diff --git a/cpp/test/IceStorm/federation/run.py b/cpp/test/IceStorm/federation/run.py deleted file mode 100755 index 0681ac656db..00000000000 --- a/cpp/test/IceStorm/federation/run.py +++ /dev/null @@ -1,96 +0,0 @@ -#!/usr/bin/env python -# ********************************************************************** -# -# Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved. -# -# This copy of Ice is licensed to you under the terms described in the -# ICE_LICENSE file included in this distribution. -# -# ********************************************************************** - -import os, sys -import time - -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 RuntimeError("can't find toplevel directory!") -sys.path.append(os.path.join(path[0], "scripts")) -import TestUtil, IceStormUtil - -publisher = os.path.join(os.getcwd(), TestUtil.getTestExecutable("publisher")) -subscriber = os.path.join(os.getcwd(), TestUtil.getTestExecutable("subscriber")) - -targets = [] -if TestUtil.appverifier: - targets = [TestUtil.getIceBox(), publisher, subscriber, TestUtil.getIceBoxAdmin(), TestUtil.getIceStormAdmin()] - TestUtil.setAppVerifierSettings(targets, cwd = os.getcwd()) - -def doTest(icestorm, batch): - - if batch: - name = "batch subscriber" - batchOptions = " -b" - else: - name = "subscriber" - batchOptions = "" - - subscriberProc = TestUtil.startServer(subscriber, batchOptions + icestorm.reference()) - - # - # Start the publisher. This should publish events which eventually - # causes subscriber to terminate. - # - publisherProc = TestUtil.startClient(publisher, icestorm.reference()) - subscriberProc.waitTestSuccess() - publisherProc.waitTestSuccess() - -def runtest(type, **args): - icestorm = IceStormUtil.init(TestUtil.toplevel, os.getcwd(), type, **args) - - icestorm.start() - - sys.stdout.write("setting up topics... ") - sys.stdout.flush() - icestorm.admin("create fed1 fed2 fed3; link fed1 fed2 10; link fed2 fed3 5") - print("ok") - - # - # Test oneway subscribers. - # - sys.stdout.write("testing oneway subscribers... ") - sys.stdout.flush() - doTest(icestorm, 0) - print("ok") - - # - # Test batch oneway subscribers. - # - sys.stdout.write("testing batch subscribers... ") - sys.stdout.flush() - doTest(icestorm, 1) - print("ok") - - # - # Destroy the topics. - # - sys.stdout.write("destroying topics... ") - sys.stdout.flush() - icestorm.admin("destroy fed1 fed2 fed3") - print("ok") - - # - # Shutdown icestorm. - # - icestorm.stop() - -runtest("persistent") -runtest("transient") -runtest("replicated", replicatedPublisher = False) -runtest("replicated", replicatedPublisher = True) - -if TestUtil.appverifier: - TestUtil.appVerifierAfterTestEnd(targets, cwd = os.getcwd()) diff --git a/cpp/test/IceStorm/federation/test.py b/cpp/test/IceStorm/federation/test.py new file mode 100644 index 00000000000..e38f8d25a8c --- /dev/null +++ b/cpp/test/IceStorm/federation/test.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +# ********************************************************************** +# +# Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +class IceStormFederationTestCase(IceStormTestCase): + + def setupClientSide(self, current): + self.runadmin(current, "create fed1 fed2 fed3; link fed1 fed2 10; link fed2 fed3 5") + + def runClientSide(self, current): + current.write("testing oneway subscribers...") + ClientServerTestCase(client=Publisher(), server=Subscriber()).run(current) + current.writeln("ok") + + current.write("testing batch subscribers...") + ClientServerTestCase(client=Publisher(), server=Subscriber(args=["-b"])).run(current) + current.writeln("ok") + + def teardownClientSide(self, current, success): + self.runadmin(current, "destroy fed1 fed2 fed3") + self.shutdown(current) + +# Override ReplicatedPublishEndpoints property to empty for testing without replicated publisher +props = {'IceStorm.ReplicatedPublishEndpoints' : ''} + +TestSuite(__file__, [ + IceStormFederationTestCase("persistent", icestorm=IceStorm()), + IceStormFederationTestCase("transient", icestorm=IceStorm(transient=True)), + IceStormFederationTestCase("replicated with non-replicated publisher", + icestorm=[IceStorm(replica=i, nreplicas=3, props=props) for i in range(0,3)]), + IceStormFederationTestCase("replicated with replicated publisher", + icestorm=[IceStorm(replica=i, nreplicas=3) for i in range(0,3)]), +], multihost=False) diff --git a/cpp/test/IceStorm/federation2/0.db/.gitignore b/cpp/test/IceStorm/federation2/0.db/.gitignore deleted file mode 100644 index 72e8ffc0db8..00000000000 --- a/cpp/test/IceStorm/federation2/0.db/.gitignore +++ /dev/null @@ -1 +0,0 @@ -* diff --git a/cpp/test/IceStorm/federation2/Publisher.cpp b/cpp/test/IceStorm/federation2/Publisher.cpp index 8daf34a8297..c07f3df88c5 100644 --- a/cpp/test/IceStorm/federation2/Publisher.cpp +++ b/cpp/test/IceStorm/federation2/Publisher.cpp @@ -12,6 +12,7 @@ #include <Ice/Ice.h> #include <IceStorm/IceStorm.h> #include <Event.h> +#include <TestCommon.h> using namespace std; using namespace Ice; @@ -60,7 +61,7 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) { cerr << argv[0] << ": NoSuchTopic: " << e.name << endl; return EXIT_FAILURE; - + } EventPrx eventFed1 = EventPrx::uncheckedCast(fed1->getPublisher()->ice_oneway()); @@ -71,7 +72,7 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) { count = atoi(arg.c_str()); } - + while(true) { for(int i = 0; i < 10; ++i) @@ -100,10 +101,10 @@ main(int argc, char* argv[]) { int status; CommunicatorPtr communicator; - + InitializationData initData = getTestInitData(argc, argv); try { - communicator = initialize(argc, argv); + communicator = initialize(argc, argv, initData); status = run(argc, argv, communicator); } catch(const Exception& ex) diff --git a/cpp/test/IceStorm/federation2/Subscriber.cpp b/cpp/test/IceStorm/federation2/Subscriber.cpp index 28e006f7bf9..6bce9c9d84d 100644 --- a/cpp/test/IceStorm/federation2/Subscriber.cpp +++ b/cpp/test/IceStorm/federation2/Subscriber.cpp @@ -189,10 +189,10 @@ main(int argc, char* argv[]) { int status; CommunicatorPtr communicator; - + InitializationData initData = getTestInitData(argc, argv); try { - communicator = initialize(argc, argv); + communicator = initialize(argc, argv, initData); status = run(argc, argv, communicator); } catch(const Exception& ex) diff --git a/cpp/test/IceStorm/federation2/run.py b/cpp/test/IceStorm/federation2/run.py deleted file mode 100755 index f479c7b411c..00000000000 --- a/cpp/test/IceStorm/federation2/run.py +++ /dev/null @@ -1,275 +0,0 @@ -#!/usr/bin/env python -# ********************************************************************** -# -# Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved. -# -# This copy of Ice is licensed to you under the terms described in the -# ICE_LICENSE file included in this distribution. -# -# ********************************************************************** - -import os, sys, time, threading, re - -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 RuntimeError("can't find toplevel directory!") -sys.path.append(os.path.join(path[0], "scripts")) -import TestUtil, IceStormUtil, Expect - -iceStormAdmin = os.path.join(TestUtil.getCppBinDir(), "icestormadmin") - -publisher = os.path.join(os.getcwd(), TestUtil.getTestExecutable("publisher")) -subscriber = os.path.join(os.getcwd(), TestUtil.getTestExecutable("subscriber")) - -targets = [] -if TestUtil.appverifier: - targets = [TestUtil.getIceBox(), publisher, subscriber, TestUtil.getIceBoxAdmin(), TestUtil.getIceStormAdmin()] - TestUtil.setAppVerifierSettings(targets, cwd = os.getcwd()) - -def admin(ref, command): - proc = TestUtil.startClient(iceStormAdmin, ref + ' -e "%s"' % command, echo = False) - proc.waitTestSuccess() - return proc.buf - -def runPublisher(icestorm1, opt = ""): - proc = TestUtil.startClient(publisher, opt + icestorm1.reference()) - proc.waitTestSuccess() - -def doTest(icestorm1, icestorm2, batch, subscriberRef = None): - if batch: - name = "batch subscriber" - batchOptions = " -b" - else: - name = "subscriber" - batchOptions = "" - - if subscriberRef == None: - subscriberRef = icestorm2.reference() - - subscriberProc = TestUtil.startServer(subscriber, batchOptions + subscriberRef) - - # - # Start the publisher. This should publish events which eventually - # causes subscriber to terminate. - # - runPublisher(icestorm1) - - subscriberProc.waitTestSuccess() - -# -# Test #1: -# -# create a cross service link fed1->fed2 and ensure the events are -# published between them correctly. -# -def runtest(type, **args): - icestorm1 = IceStormUtil.init(TestUtil.toplevel, os.getcwd(), type, additional = '--IceStorm.Discard.Interval=2', - dbDir = "db", instanceName = "TestIceStorm1", port = 12000, **args) - icestorm1.start() - icestorm2 = IceStormUtil.init(TestUtil.toplevel, os.getcwd(), type, additional = '--IceStorm.Discard.Interval=2', - dbDir = "db2", instanceName = "TestIceStorm2", port = 12500, **args) - icestorm2.start() - - adminIceStormReference = ' --IceStormAdmin.TopicManager.Proxy="%s" --IceStormAdmin.TopicManager.Proxy2="%s"' % ( - icestorm1.proxy(), icestorm2.proxy()) - - sys.stdout.write("setting up the topics... ") - sys.stdout.flush() - admin(adminIceStormReference, "create TestIceStorm1/fed1 TestIceStorm2/fed1; link TestIceStorm1/fed1 TestIceStorm2/fed1") - print("ok") - - # - # Test oneway subscribers. - # - sys.stdout.write("testing federation with oneway subscribers... ") - sys.stdout.flush() - doTest(icestorm1, icestorm2, 0) - print("ok") - - # - # Test batch oneway subscribers. - # - sys.stdout.write("testing federation with batch subscribers... ") - sys.stdout.flush() - doTest(icestorm1, icestorm2, 1) - print("ok") - - # - # Test #2: - # - # Stop and restart the service and repeat the test. This ensures that - # the database is correct. - # - sys.stdout.write("restarting services to ensure that the database content is preserved... ") - sys.stdout.flush() - - # - # Shutdown icestorm. - # - icestorm1.stop() - icestorm2.stop() - - icestorm1.start(echo=False) - icestorm2.start(echo=False) - print("ok") - - # - # Test oneway subscribers. - # - sys.stdout.write("retesting federation with oneway subscribers... ") - sys.stdout.flush() - doTest(icestorm1, icestorm2, 0) - print("ok") - - # - # Test batch oneway subscribers. - # - sys.stdout.write("retesting federation with batch subscribers... ") - sys.stdout.flush() - doTest(icestorm1, icestorm2, 1) - print("ok") - - # - # Shutdown icestorm. - # - icestorm1.stop() - icestorm2.stop() - - # - # Restart the first server and publish some events. Attach a - # subscriber to the channel and make sure the events are received. - # - # Then re-start the linked downstream server and publish the events. - # Ensure they are received by the linked server. - # - if type != "replicated": - sys.stdout.write("restarting only one IceStorm server... ") - sys.stdout.flush() - proc = icestorm1.start(echo=False) - - #proc.expect("topic.fed1.*subscriber offline") - #proc.expect("connection refused") - print("ok") - - # - # Test oneway subscribers. - # - sys.stdout.write("testing that the federation link reports an error... ") - sys.stdout.flush() - doTest(icestorm1, icestorm2, 0, icestorm1.reference()) - - # Give some time for the output to be sent. - time.sleep(2) - - proc.expect("topic.fed1.*subscriber offline") - print("ok") - - sys.stdout.write("starting downstream icestorm server... ") - sys.stdout.flush() - icestorm2.start(echo=False) - print("ok") - - # - # Need to sleep for at least the discard interval. - # - time.sleep(3) - - # - # Test oneway subscribers. - # - sys.stdout.write("testing link is reestablished... ") - sys.stdout.flush() - doTest(icestorm1, icestorm2, 0) - print("ok") - - try: - proc.expect("topic.fed1.*subscriber offline") - assert False - except Expect.TIMEOUT: - pass - - icestorm1.stop() - icestorm2.stop() - - # - # Test #4: - # - # Trash the TestIceStorm2 database. Then restart the servers and - # verify that the link is removed. - # - sys.stdout.write("destroying the downstream IceStorm service database... ") - sys.stdout.flush() - icestorm2.clean() - - print("ok") - - sys.stdout.write("restarting IceStorm servers... ") - sys.stdout.flush() - icestorm1.start(echo = False) - icestorm2.start(echo = False) - print("ok") - - sys.stdout.write("checking link still exists... ") - sys.stdout.flush() - line = admin(adminIceStormReference, "links TestIceStorm1") - if not re.compile("fed1 with cost 0").search(line): - print(line) - sys.exit(1) - print("ok") - - sys.stdout.write("publishing some events... ") - sys.stdout.flush() - # The publisher must be run twice because all the events can be - # sent out in one batch to the linked subscriber which means that - # the link is not reaped until the next batch is - # sent. Furthermore, with a replicated IceStorm both sets of - # events must be set to the same replica. - runPublisher(icestorm1, opt = " --count 2") - print("ok") - - # Give the unsubscription time to propagate. - time.sleep(1) - - # Verify that the link has disappeared. - sys.stdout.write("verifying that the link has been destroyed... ") - sys.stdout.flush() - line = admin(adminIceStormReference, "links TestIceStorm1") - nRetry = 5 - while len(line) > 0 and nRetry > 0: - line = admin(adminIceStormReference, "links TestIceStorm1") - time.sleep(1) # Give more time for unsubscription to propagate. - nRetry -= 1 - if len(line) > 0: - print(line) - sys.exit(1) - print("ok") - - # - # Destroy the remaining topic. - # - sys.stdout.write("destroying topics... ") - sys.stdout.flush() - admin(adminIceStormReference, "destroy TestIceStorm1/fed1") - print("ok") - - # - # Shutdown icestorm. - # - sys.stdout.write("shutting down icestorm services... ") - sys.stdout.flush() - icestorm1.stop() - icestorm2.stop() - print("ok") - -runtest("persistent") -runtest("replicated", replicatedPublisher = False) -runtest("replicated", replicatedPublisher = True) - -if TestUtil.appverifier: - TestUtil.appVerifierAfterTestEnd(targets, cwd = os.getcwd()) - -sys.exit(0) diff --git a/cpp/test/IceStorm/federation2/test.py b/cpp/test/IceStorm/federation2/test.py new file mode 100644 index 00000000000..5ac2f315555 --- /dev/null +++ b/cpp/test/IceStorm/federation2/test.py @@ -0,0 +1,196 @@ +# -*- coding: utf-8 -*- +# ********************************************************************** +# +# Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +# +# Publisher/subscriber test cases, publisher publishes on TestIceStorm1 instance(s) and +# the subscriber subscribes to the TestIceStorm2 instance(s) +# +pub1Sub2Oneway=ClientServerTestCase(client=Publisher("TestIceStorm1"), server=Subscriber("TestIceStorm2")) +pub1Sub2Batch=ClientServerTestCase(client=Publisher("TestIceStorm1"), server=Subscriber("TestIceStorm2", args=["-b"])) + +pub1Sub1Oneway=ClientServerTestCase(client=Publisher("TestIceStorm1"), server=Subscriber("TestIceStorm1")) + +class IceStormFederation2TestCase(IceStormTestCase): + + def runClientSide(self, current): + + current.write("setting up the topics... ") + self.runadmin(current, "create TestIceStorm1/fed1 TestIceStorm2/fed1; link TestIceStorm1/fed1 TestIceStorm2/fed1") + current.writeln("ok") + + # + # Test oneway subscribers. + # + current.write("testing federation with oneway subscribers... ") + pub1Sub2Oneway.run(current) + current.writeln("ok") + + # + # Test batch oneway subscribers. + # + current.write("testing federation with batch subscribers... ") + pub1Sub2Batch.run(current) + current.writeln("ok") + + # + # Test #2: + # + # Stop and restart the service and repeat the test. This ensures that + # the database is correct. + # + current.write("restarting services to ensure that the database content is preserved... ") + self.restartIceStorm(current) + current.writeln("ok") + + # + # Test oneway subscribers. + # + current.write("retesting federation with oneway subscribers... ") + pub1Sub2Oneway.run(current) + current.writeln("ok") + + # + # Test batch oneway subscribers. + # + current.write("retesting federation with batch subscribers... ") + pub1Sub2Batch.run(current) + current.writeln("ok") + + # + # Shutdown icestorm. + # + self.stopIceStorm(current) + + icestorm1 = [icestorm for icestorm in self.icestorm if icestorm.getInstanceName() == "TestIceStorm1"] + icestorm2 = [icestorm for icestorm in self.icestorm if icestorm.getInstanceName() == "TestIceStorm2"] + + # + # Restart the first server and publish some events. Attach a + # subscriber to the channel and make sure the events are received. + # + # Then re-start the linked downstream server and publish the events. + # Ensure they are received by the linked server. + # + if self.getName().find("replicated") == -1: + + current.write("restarting only one IceStorm server... ") + icestorm1[0].start(current) + current.writeln("ok") + + # + # Test oneway subscribers. + # + current.write("testing that the federation link reports an error... ") + pub1Sub1Oneway.run(current) + + # Give some time for the output to be sent. + time.sleep(2) + + icestorm1[0].expect("topic.fed1.*subscriber offline") + current.writeln("ok") + + current.write("starting downstream icestorm server... ") + icestorm2[0].start(current) + current.writeln("ok") + + # + # Need to sleep for at least the discard interval. + # + time.sleep(3) + + # + # Test oneway subscribers. + # + current.write("testing link is reestablished... ") + pub1Sub2Oneway.run(current) + current.writeln("ok") + + try: + icestorm1[0].expect("topic.fed1.*subscriber offline", timeout=1) + assert False + except Expect.TIMEOUT: + pass + + self.stopIceStorm(current) + + # + # Test #4: + # + # Trash the TestIceStorm2 database. Then restart the servers and + # verify that the link is removed. + # + current.write("destroying the downstream IceStorm service database... ") + for s in icestorm2: + s.teardown(current, True) + s.setup(current) + + current.writeln("ok") + + current.write("restarting IceStorm servers... ") + self.startIceStorm(current) + current.writeln("ok") + + current.write("checking link still exists... ") + line = self.runadmin(current, "links TestIceStorm1", quiet=True) + if not re.compile("fed1 with cost 0").search(line): + raise RuntimeError("unexpected output (`{0}')".format(line)) + current.writeln("ok") + + current.write("publishing some events... ") + # The publisher must be run twice because all the events can be + # sent out in one batch to the linked subscriber which means that + # the link is not reaped until the next batch is + # sent. Furthermore, with a replicated IceStorm both sets of + # events must be set to the same replica. + Publisher("TestIceStorm1", args=["--count", 2]).run(current) + current.writeln("ok") + + # Give the unsubscription time to propagate. + time.sleep(1) + + # Verify that the link has disappeared. + current.write("verifying that the link has been destroyed... ") + line = self.runadmin(current, "links TestIceStorm1") + nRetry = 5 + while len(line) > 0 and nRetry > 0: + line = self.runadmin(current, "links TestIceStorm1") + time.sleep(1) # Give more time for unsubscription to propagate. + nRetry -= 1 + if len(line) > 0: + raise RuntimeError("unexpected output (`{0}')".format(line)) + current.writeln("ok") + + # + # Destroy the remaining topic. + # + current.write("destroying topics... ") + self.runadmin(current, "destroy TestIceStorm1/fed1links TestIceStorm1", quiet=True) + current.writeln("ok") + + self.stopIceStorm(current) + +# Override ReplicatedPublishEndpoints property to empty for testing without replicated publisher +props = { 'IceStorm.Discard.Interval' : 2 } +nonRepProps = { 'IceStorm.Discard.Interval' : 2, 'IceStorm.ReplicatedPublishEndpoints' : '' } + +TestSuite(__file__, [ + + IceStormFederation2TestCase("persistent", icestorm= + [IceStorm("TestIceStorm1", quiet=True, props=props), + IceStorm("TestIceStorm2", quiet=True,portnum=20, props=props)]), + + IceStormFederation2TestCase("replicated with non-replicated publisher", icestorm= + [IceStorm("TestIceStorm1", i, 3, quiet=True, props=nonRepProps) for i in range(0,3)] + + [IceStorm("TestIceStorm2", i, 3, quiet=True, portnum=20, props=nonRepProps) for i in range(0,3)]), + + IceStormFederation2TestCase("replicated with replicated publisher", icestorm= + [IceStorm("TestIceStorm1", i, 3, quiet=True, props=props) for i in range(0,3)] + + [IceStorm("TestIceStorm2", i, 3, quiet=True, portnum=20, props=props) for i in range(0,3)]), +], multihost=False) diff --git a/cpp/test/IceStorm/rep1/Publisher.cpp b/cpp/test/IceStorm/rep1/Publisher.cpp index a06662e4b29..b90f8f7300a 100644 --- a/cpp/test/IceStorm/rep1/Publisher.cpp +++ b/cpp/test/IceStorm/rep1/Publisher.cpp @@ -11,6 +11,7 @@ #include <IceUtil/Options.h> #include <IceUtil/IceUtil.h> #include <IceStorm/IceStorm.h> +#include <TestCommon.h> #include <Single.h> using namespace std; @@ -120,10 +121,10 @@ main(int argc, char* argv[]) { int status; CommunicatorPtr communicator; - + InitializationData initData = getTestInitData(argc, argv); try { - communicator = initialize(argc, argv); + communicator = initialize(argc, argv, initData); status = run(argc, argv, communicator); } catch(const Exception& ex) diff --git a/cpp/test/IceStorm/rep1/Sub.cpp b/cpp/test/IceStorm/rep1/Sub.cpp index 5192f61e548..55423322069 100644 --- a/cpp/test/IceStorm/rep1/Sub.cpp +++ b/cpp/test/IceStorm/rep1/Sub.cpp @@ -94,10 +94,10 @@ main(int argc, char* argv[]) { int status; CommunicatorPtr communicator; - + InitializationData initData = getTestInitData(argc, argv); try { - communicator = initialize(argc, argv); + communicator = initialize(argc, argv, initData); status = run(argc, argv, communicator); } catch(const Exception& ex) diff --git a/cpp/test/IceStorm/rep1/Subscriber.cpp b/cpp/test/IceStorm/rep1/Subscriber.cpp index fe23907529f..be1b8e0e36c 100644 --- a/cpp/test/IceStorm/rep1/Subscriber.cpp +++ b/cpp/test/IceStorm/rep1/Subscriber.cpp @@ -186,10 +186,10 @@ main(int argc, char* argv[]) { int status; CommunicatorPtr communicator; - + InitializationData initData = getTestInitData(argc, argv); try { - communicator = initialize(argc, argv); + communicator = initialize(argc, argv, initData); status = run(argc, argv, communicator); } catch(const Exception& ex) diff --git a/cpp/test/IceStorm/rep1/run.py b/cpp/test/IceStorm/rep1/run.py deleted file mode 100755 index 2d058a12d22..00000000000 --- a/cpp/test/IceStorm/rep1/run.py +++ /dev/null @@ -1,292 +0,0 @@ -#!/usr/bin/env python -# ********************************************************************** -# -# Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved. -# -# This copy of Ice is licensed to you under the terms described in the -# ICE_LICENSE file included in this distribution. -# -# ********************************************************************** - -import os, sys, time, re - -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 RuntimeError("can't find toplevel directory!") -sys.path.append(os.path.join(path[0], "scripts")) -import TestUtil, IceStormUtil - -publisher = os.path.join(os.getcwd(), TestUtil.getTestExecutable("publisher")) -subscriber = os.path.join(os.getcwd(), TestUtil.getTestExecutable("subscriber")) -subscriber2 = os.path.join(os.getcwd(), TestUtil.getTestExecutable("sub")) - -targets = [] -if TestUtil.appverifier: - targets = [TestUtil.getIceBox(), publisher, subscriber, subscriber2, TestUtil.getIceBoxAdmin(), \ - TestUtil.getIceStormAdmin()] - TestUtil.setAppVerifierSettings(targets, cwd = os.getcwd()) - -def runsub(opt, ref, arg = "", echo=False): - qos = "" - if opt == "twoway": - qos = " --twoway" - if opt == "ordered": - qos = " --ordered" - return TestUtil.startServer(subscriber, ref + arg + qos) - -def runpub(ref, arg = "", echo=False): - return TestUtil.startClient(publisher, ref + arg) - -def runtest(opt, ref, subopt="", pubopt=""): - subscriberProc = runsub(opt, ref, subopt) - publisherProc = runpub(ref, pubopt) - publisherProc.waitTestSuccess() - subscriberProc.waitTestSuccess() - -def runsub2(replica = -1, expect = None): - proc = TestUtil.startServer(subscriber2, icestorm.reference(replica) + ' --id foo', count=0, echo = False) - if expect: - proc.expect(expect) - proc.wait() - else: - proc.waitTestSuccess() - -def rununsub2(replica = -1, expect = None): - if replica == -1: - proc = TestUtil.startServer(subscriber2, icestorm.reference(replica) + ' --id foo --unsub', count=0) - proc.waitTestSuccess() - # Else we first subscribe to this replica, then unsub. We - # shouldn't get an AlreadySubscribedException. - proc = TestUtil.startServer(subscriber2, icestorm.reference(replica) + ' --id foo', count=0, echo = False) - if expect: - proc.expect(expect) - proc.wait() - return - else: - proc.waitTestSuccess() - proc = TestUtil.startServer(subscriber2, icestorm.reference(replica) + ' --id foo --unsub', count=0) - proc.waitTestSuccess() - -icestorm = IceStormUtil.init(TestUtil.toplevel, os.getcwd(), "replicated", replicatedPublisher=True, additional = - ' --IceStorm.Election.MasterTimeout=2' + - ' --IceStorm.Election.ElectionTimeout=2' + - ' --IceStorm.Election.ResponseTimeout=2') -icestorm.start() - -sys.stdout.write("testing topic creation across replicas... ") -sys.stdout.flush() -icestorm.admin("create single") - -for replica in range(0, 3): - icestorm.adminForReplica(replica, "create single", "error: topic `single' exists") -print("ok") - -sys.stdout.write("testing topic destruction across replicas... ") -sys.stdout.flush() -icestorm.admin("destroy single") - -for replica in range(0, 3): - icestorm.adminForReplica(replica, "destroy single", "error: couldn't find topic `single'") -print("ok") - -sys.stdout.write("testing topic creation without replica... ") -sys.stdout.flush() - -icestorm.stopReplica(0) -icestorm.admin("create single") - -for replica in range(1, 3): - icestorm.adminForReplica(replica, "create single", "error: topic `single' exists") - -icestorm.adminForReplica(0, "create single", ["ConnectionRefused", "ConnectFailed"]) - -icestorm.startReplica(0, echo=False) - -icestorm.adminForReplica(0, "create single", "error: topic `single' exists") -print("ok") - -icestorm.admin("destroy single") - -sys.stdout.write("testing topic creation without master... ") -sys.stdout.flush() -icestorm.stopReplica(2) - -icestorm.admin("create single") - -for replica in range(0, 2): - icestorm.adminForReplica(replica, "create single", "error: topic `single' exists") - -icestorm.adminForReplica(2, "create single", ["ConnectionRefused", "ConnectFailed"]) - -icestorm.startReplica(2, echo=False) - -icestorm.adminForReplica(2, "create single", "error: topic `single' exists") -print("ok") - -# All replicas are running - -sys.stdout.write("testing topic destruction without replica... ") -sys.stdout.flush() -icestorm.stopReplica(0) - -icestorm.admin("destroy single") - -for replica in range(1, 3): - icestorm.adminForReplica(replica, "destroy single", "error: couldn't find topic `single'") - -icestorm.adminForReplica(0, "destroy single", ["ConnectionRefused", "ConnectFailed"]) - -icestorm.startReplica(0, echo=False) - -icestorm.adminForReplica(0, "destroy single", "error: couldn't find topic `single'") -print("ok") - -sys.stdout.write("testing topic destruction without master... ") -sys.stdout.flush() - -icestorm.admin("create single") -icestorm.stopReplica(2) - -icestorm.admin("destroy single") - -for replica in range(0, 2): - icestorm.adminForReplica(replica, "destroy single", "error: couldn't find topic `single'") - -icestorm.adminForReplica(2, "destroy single", ["ConnectionRefused", "ConnectFailed"]) - -icestorm.startReplica(2, echo=False) - -icestorm.adminForReplica(2, "destroy single", "error: couldn't find topic `single'") -print("ok") - -# Now test subscription/unsubscription on all replicas. - -icestorm.admin("create single") - -sys.stdout.write("testing subscription across replicas... ") -sys.stdout.flush() -runsub2() - -for replica in range(0, 3): - runsub2(replica, "IceStorm::AlreadySubscribed") -print("ok") - -sys.stdout.write("testing unsubscription across replicas... ") -sys.stdout.flush() -rununsub2() - -for replica in range(0, 3): - rununsub2(replica) -print("ok") - -sys.stdout.write("testing subscription without master... ") -sys.stdout.flush() -icestorm.stopReplica(2) - -runsub2() - -for replica in range(0, 2): - runsub2(replica, "IceStorm::AlreadySubscribed") - -runsub2(2, ["ConnectionRefused", "ConnectFailed"]) - -icestorm.startReplica(2, echo=False) - -runsub2(2, "IceStorm::AlreadySubscribed") -print("ok") - -sys.stdout.write("testing unsubscription without master... ") -sys.stdout.flush() -icestorm.stopReplica(2) - -rununsub2() - -for replica in range(0, 2): - rununsub2(replica) - -rununsub2(2, ["ConnectionRefused", "ConnectFailed"]) - -icestorm.startReplica(2, echo=False) - -rununsub2(2) -print("ok") - -sys.stdout.write("testing subscription without replica... ") -sys.stdout.flush() -icestorm.stopReplica(0) - -runsub2() - -for replica in range(1, 3): - runsub2(replica, "IceStorm::AlreadySubscribed") - -runsub2(0, ["ConnectionRefused", "ConnectFailed"]) - -icestorm.startReplica(0, echo=False) - -runsub2(0, "IceStorm::AlreadySubscribed") -print("ok") - -sys.stdout.write("testing unsubscription without replica... ") -sys.stdout.flush() -icestorm.stopReplica(0) - -rununsub2() - -for replica in range(1, 3): - rununsub2(replica) - -rununsub2(0, ["ConnectionRefused", "ConnectFailed"]) - -icestorm.startReplica(0, echo=False) - -rununsub2(0) -print("ok") - -# All replicas are running - -sys.stdout.write("running twoway subscription test... ") -sys.stdout.flush() -runtest("twoway", icestorm.reference()) -print("ok") - -sys.stdout.write("running ordered subscription test... ") -sys.stdout.flush() -runtest("ordered", icestorm.reference()) -print("ok") - -icestorm.stopReplica(2) - -sys.stdout.write("running twoway, ordered subscription test without master... ") -sys.stdout.flush() -runtest("twoway", icestorm.reference()) -runtest("ordered", icestorm.reference()) -print("ok") - -icestorm.startReplica(2, echo = False) -icestorm.stopReplica(0) - -sys.stdout.write("running twoway, ordered subscription test without replica... ") -sys.stdout.flush() -runtest("twoway", icestorm.reference()) -runtest("ordered", icestorm.reference()) -print("ok") - -icestorm.startReplica(0, echo = False) - -sys.stdout.write("running cycle publishing test... ") -sys.stdout.flush() -runtest("twoway", icestorm.reference(), pubopt=" --cycle") -print("ok") - -sys.stdout.write("stopping replicas... ") -sys.stdout.flush() -icestorm.stop() -print("ok") - -if TestUtil.appverifier: - TestUtil.appVerifierAfterTestEnd(targets, cwd = os.getcwd()) diff --git a/cpp/test/IceStorm/rep1/test.py b/cpp/test/IceStorm/rep1/test.py new file mode 100644 index 00000000000..7385a9d8d25 --- /dev/null +++ b/cpp/test/IceStorm/rep1/test.py @@ -0,0 +1,290 @@ +# -*- coding: utf-8 -*- +# ********************************************************************** +# +# Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +# +# Make sure IceStorm and the subscriber use the same buffer size for +# sending/receiving datagrams. This ensures the test works with bogus +# OS configurations where the reicever buffer size is smaller than the +# send buffer size (causing the received messages to be +# truncated). See also bug #6070. +# +props = { + "IceStorm.Election.MasterTimeout" : 2, + "IceStorm.Election.ElectionTimeout" : 2, + "IceStorm.Election.ResponseTimeout" : 2 +} + +icestorm = [ IceStorm(replica=i, nreplicas=3, props = props) for i in range(0,3) ] + +class IceStormRep1TestCase(IceStormTestCase): + + def runClientSide(self, current): + + def checkExpect(output, expect): + if not expect: + return + + if type(expect) == str: + expect = [expect] + + for e in expect: + if output.find(e) >= 0: + return + else: + raise RuntimeError("unexected output `{0}' (expected `{1}')".format(output, expect)) + + def adminForReplica(replica, cmd, expect): + checkExpect(self.runadmin(current, cmd, instance=self.icestorm[replica], quiet=True, exitstatus=1), + expect) + + def stopReplica(num): + self.icestorm[num].shutdown(current) + self.icestorm[num].stop(current, True) + + def startReplica(num): + self.icestorm[num].start(current) + + def runtest(s="", p=""): + ClientServerTestCase(client=Publisher(args=p.split(" ")), + server=Subscriber(args=s.split(" "))).run(current) + + def runsub2(replica=None, expect=None): + subscriber = Subscriber(exe="sub", + instance=None if replica is None else self.icestorm[replica], + args=["--id", "foo"], + readyCount=0, + quiet=True) + subscriber.run(current, exitstatus=1 if expect else 0) + checkExpect(subscriber.getOutput(), expect) + + def rununsub2(replica=None, expect=None): + sub = Subscriber(exe="sub", + instance=None if replica is None else self.icestorm[replica], + args=["--id", "foo"], + readyCount=0, + quiet=True) + + if replica is None: + sub.run(current, args=["--unsub"]) + # Else we first subscribe to this replica, then unsub. We + # shouldn't get an AlreadySubscribedException. + sub.run(current, exitstatus=1 if expect else 0) + if expect: + checkExpect(sub.getOutput(), expect) + return + + sub.run(current, args=["--unsub"]) + + current.write("testing topic creation across replicas... ") + self.runadmin(current, "create single") + for replica in range(0, 3): + adminForReplica(replica, "create single", "error: topic `single' exists") + current.writeln("ok") + + current.write("testing topic destruction across replicas... ") + sys.stdout.flush() + self.runadmin(current, "destroy single") + + for replica in range(0, 3): + adminForReplica(replica, "destroy single", "error: couldn't find topic `single'") + current.writeln("ok") + + current.write("testing topic creation without replica... ") + + stopReplica(0) + + self.runadmin(current, "create single") + + for replica in range(1, 3): + adminForReplica(replica, "create single", "error: topic `single' exists") + + adminForReplica(0, "create single", ["ConnectionRefused", "ConnectFailed"]) + + startReplica(0) + + adminForReplica(0, "create single", "error: topic `single' exists") + current.writeln("ok") + + self.runadmin(current, "destroy single") + + current.write("testing topic creation without master... ") + sys.stdout.flush() + + stopReplica(2) + + self.runadmin(current, "create single") + + for replica in range(0, 2): + adminForReplica(replica, "create single", "error: topic `single' exists") + + adminForReplica(2, "create single", ["ConnectionRefused", "ConnectFailed"]) + + startReplica(2) + + adminForReplica(2, "create single", "error: topic `single' exists") + current.writeln("ok") + + # All replicas are running + + current.write("testing topic destruction without replica... ") + + stopReplica(0) + + self.runadmin(current, "destroy single") + + for replica in range(1, 3): + adminForReplica(replica, "destroy single", "error: couldn't find topic `single'") + + adminForReplica(0, "destroy single", ["ConnectionRefused", "ConnectFailed"]) + + startReplica(0) + + adminForReplica(0, "destroy single", "error: couldn't find topic `single'") + current.writeln("ok") + + current.write("testing topic destruction without master... ") + sys.stdout.flush() + + self.runadmin(current, "create single") + stopReplica(2) + + self.runadmin(current, "destroy single") + + for replica in range(0, 2): + adminForReplica(replica, "destroy single", "error: couldn't find topic `single'") + + adminForReplica(2, "destroy single", ["ConnectionRefused", "ConnectFailed"]) + + startReplica(2) + + adminForReplica(2, "destroy single", "error: couldn't find topic `single'") + current.writeln("ok") + + # Now test subscription/unsubscription on all replicas. + + self.runadmin(current, "create single") + + current.write("testing subscription across replicas... ") + sys.stdout.flush() + runsub2() + + for replica in range(0, 3): + runsub2(replica, "IceStorm::AlreadySubscribed") + current.writeln("ok") + + current.write("testing unsubscription across replicas... ") + sys.stdout.flush() + rununsub2() + + for replica in range(0, 3): + rununsub2(replica) + current.writeln("ok") + + current.write("testing subscription without master... ") + sys.stdout.flush() + stopReplica(2) + + runsub2() + + for replica in range(0, 2): + runsub2(replica, "IceStorm::AlreadySubscribed") + + runsub2(2, ["ConnectionRefused", "ConnectFailed"]) + + startReplica(2) + + runsub2(2, "IceStorm::AlreadySubscribed") + current.writeln("ok") + + current.write("testing unsubscription without master... ") + sys.stdout.flush() + stopReplica(2) + + rununsub2() + + for replica in range(0, 2): + rununsub2(replica) + + rununsub2(2, ["ConnectionRefused", "ConnectFailed"]) + + startReplica(2) + + rununsub2(2) + current.writeln("ok") + + current.write("testing subscription without replica... ") + sys.stdout.flush() + stopReplica(0) + + runsub2() + + for replica in range(1, 3): + runsub2(replica, "IceStorm::AlreadySubscribed") + + runsub2(0, ["ConnectionRefused", "ConnectFailed"]) + + startReplica(0) + + runsub2(0, "IceStorm::AlreadySubscribed") + current.writeln("ok") + + current.write("testing unsubscription without replica... ") + stopReplica(0) + + rununsub2() + + for replica in range(1, 3): + rununsub2(replica) + + rununsub2(0, ["ConnectionRefused", "ConnectFailed"]) + + startReplica(0) + + rununsub2(0) + current.writeln("ok") + + # All replicas are running + + current.write("running twoway subscription test... ") + runtest("--twoway") + current.writeln("ok") + + current.write("running ordered subscription test... ") + runtest("--ordered") + current.writeln("ok") + + stopReplica(2) + + current.write("running twoway, ordered subscription test without master... ") + runtest("--twoway") + runtest("--ordered") + current.writeln("ok") + + startReplica(2) + stopReplica(0) + + current.write("running twoway, ordered subscription test without replica... ") + runtest("--twoway") + runtest("--ordered") + current.writeln("ok") + + startReplica(0) + + current.write("running cycle publishing test... ") + sys.stdout.flush() + runtest("--twoway", "--cycle") + current.writeln("ok") + + current.write("stopping replicas... ") + sys.stdout.flush() + self.stopIceStorm(current) + current.writeln("ok") + +TestSuite(__file__, [ IceStormRep1TestCase("replicated", icestorm=icestorm) ], multihost=False) diff --git a/cpp/test/IceStorm/repgrid/Client.cpp b/cpp/test/IceStorm/repgrid/Client.cpp index 7941f6fea77..f13afb1cf46 100644 --- a/cpp/test/IceStorm/repgrid/Client.cpp +++ b/cpp/test/IceStorm/repgrid/Client.cpp @@ -117,10 +117,10 @@ main(int argc, char* argv[]) { int status; CommunicatorPtr communicator; - + InitializationData initData = getTestInitData(argc, argv); try { - communicator = initialize(argc, argv); + communicator = initialize(argc, argv, initData); status = run(argc, argv, communicator); } catch(const Exception& ex) diff --git a/cpp/test/IceStorm/repgrid/run.py b/cpp/test/IceStorm/repgrid/run.py deleted file mode 100755 index 5a798964755..00000000000 --- a/cpp/test/IceStorm/repgrid/run.py +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env python -# ********************************************************************** -# -# Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved. -# -# This copy of Ice is licensed to you under the terms described in the -# ICE_LICENSE file included in this distribution. -# -# ********************************************************************** - -import os, sys - -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 RuntimeError("can't find toplevel directory!") -sys.path.append(os.path.join(path[0], "scripts")) -import TestUtil, IceStormUtil, IceGridAdmin - -targets = [] -if TestUtil.appverifier: - targets = [TestUtil.getIceBox()] - TestUtil.setAppVerifierSettings(targets, cwd = os.getcwd()) - - -variables = "icebox.exe='%s'" % TestUtil.getIceBox() - -# -# Don't use a slave registry for this test. -# -IceGridAdmin.nreplicas=0 - -# -# Test client/server without on demand activation. -# -IceGridAdmin.iceGridTest("application.xml", "", variables) - -if TestUtil.appverifier: - TestUtil.appVerifierAfterTestEnd(targets, cwd = os.getcwd()) diff --git a/cpp/test/IceStorm/repgrid/test.py b/cpp/test/IceStorm/repgrid/test.py new file mode 100644 index 00000000000..5beb3296d89 --- /dev/null +++ b/cpp/test/IceStorm/repgrid/test.py @@ -0,0 +1,13 @@ +# -*- coding: utf-8 -*- +# ********************************************************************** +# +# Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +TestSuite(__file__, [ IceGridTestCase(icegridregistry=IceGridRegistryMaster(), + client=IceGridClient()) ], + runOnMainThread=True, multihost=False)
\ No newline at end of file diff --git a/cpp/test/IceStorm/repstress/Control.cpp b/cpp/test/IceStorm/repstress/Control.cpp index 1fe321b5533..c04289cdbad 100644 --- a/cpp/test/IceStorm/repstress/Control.cpp +++ b/cpp/test/IceStorm/repstress/Control.cpp @@ -9,6 +9,7 @@ #include <Ice/Ice.h> #include <Controller.h> +#include <TestCommon.h> using namespace std; using namespace Ice; @@ -34,10 +35,10 @@ main(int argc, char* argv[]) { int status; CommunicatorPtr communicator; - + InitializationData initData = getTestInitData(argc, argv); try { - communicator = initialize(argc, argv); + communicator = initialize(argc, argv, initData); status = run(argc, argv, communicator); } catch(const Exception& ex) diff --git a/cpp/test/IceStorm/repstress/Publisher.cpp b/cpp/test/IceStorm/repstress/Publisher.cpp index b38212ff427..b8a91876a9e 100644 --- a/cpp/test/IceStorm/repstress/Publisher.cpp +++ b/cpp/test/IceStorm/repstress/Publisher.cpp @@ -12,6 +12,7 @@ #include <IceStorm/IceStorm.h> #include <Single.h> #include <Controller.h> +#include <TestCommon.h> using namespace std; using namespace Ice; @@ -71,7 +72,7 @@ public: Lock sync(*this); _destroy = true; } - + private: const SinglePrx _single; @@ -109,7 +110,7 @@ run(int, char* argv[], const CommunicatorPtr& communicator) { cerr << argv[0] << ": NoSuchTopic: " << e.name << endl; return EXIT_FAILURE; - + } assert(topic); @@ -140,10 +141,10 @@ main(int argc, char* argv[]) { int status; CommunicatorPtr communicator; - + InitializationData initData = getTestInitData(argc, argv); try { - communicator = initialize(argc, argv); + communicator = initialize(argc, argv, initData); status = run(argc, argv, communicator); } catch(const Exception& ex) diff --git a/cpp/test/IceStorm/repstress/Subscriber.cpp b/cpp/test/IceStorm/repstress/Subscriber.cpp index a19aea9aca6..6ac382ce38c 100644 --- a/cpp/test/IceStorm/repstress/Subscriber.cpp +++ b/cpp/test/IceStorm/repstress/Subscriber.cpp @@ -132,10 +132,10 @@ main(int argc, char* argv[]) { int status; CommunicatorPtr communicator; - + InitializationData initData = getTestInitData(argc, argv); try { - communicator = initialize(argc, argv); + communicator = initialize(argc, argv, initData); status = run(argc, argv, communicator); } catch(const Exception& ex) diff --git a/cpp/test/IceStorm/repstress/run.py b/cpp/test/IceStorm/repstress/run.py deleted file mode 100755 index 6e616437cf1..00000000000 --- a/cpp/test/IceStorm/repstress/run.py +++ /dev/null @@ -1,125 +0,0 @@ -#!/usr/bin/env python -# ********************************************************************** -# -# Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved. -# -# This copy of Ice is licensed to you under the terms described in the -# ICE_LICENSE file included in this distribution. -# -# ********************************************************************** - -import os, sys, time, re - -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 RuntimeError("can't find toplevel directory!") -sys.path.append(os.path.join(path[0], "scripts")) -import TestUtil, IceStormUtil - -publisher = os.path.join(os.getcwd(), TestUtil.getTestExecutable("publisher")) -subscriber = os.path.join(os.getcwd(), TestUtil.getTestExecutable("subscriber")) -control = os.path.join(os.getcwd(), TestUtil.getTestExecutable("control")) - -targets = [] -if TestUtil.appverifier: - targets = [TestUtil.getIceBox(), publisher, subscriber, control, TestUtil.getIceBoxAdmin(), \ - TestUtil.getIceStormAdmin()] - TestUtil.setAppVerifierSettings(targets, cwd = os.getcwd()) - -def runcontrol(proxy): - proc = TestUtil.startClient(control, ' "%s"' % proxy) - proc.waitTestSuccess() - -icestorm = IceStormUtil.init(TestUtil.toplevel, os.getcwd(), "replicated", replicatedPublisher=True, additional = - ' --IceStorm.Election.MasterTimeout=2' + - ' --IceStorm.Election.ElectionTimeout=2' + - ' --IceStorm.Election.ResponseTimeout=2') -icestorm.start() - -sys.stdout.write("creating topic... ") -sys.stdout.flush() -icestorm.admin("create single") -print("ok") - -sys.stdout.write("running subscriber... ") -sys.stdout.flush() -subscriberProc = TestUtil.startServer(subscriber, ' --Ice.ServerIdleTime=0 ' + icestorm.reference(), echo = False) -subscriberProc.expect("([^\n]+)\n") -subControl = subscriberProc.match.group(1) -print("ok") - -sys.stdout.write("running publisher... ") -sys.stdout.flush() -publisherProc = TestUtil.startServer(publisher, ' --Ice.ServerIdleTime=0 ' + icestorm.reference(), echo = False) -publisherProc.expect("([^\n]+)\n") -pubControl = publisherProc.match.group(1) -print("ok") - -time.sleep(2) - -for i in range(0, 3): - # 0, 1 - sys.stdout.write("stopping replica 2 (0, 1 running)... ") - sys.stdout.flush() - icestorm.stopReplica(2) - print("ok") - time.sleep(2) - - # 1, 2 - sys.stdout.write("starting 2, stopping 0 (1, 2 running)... ") - sys.stdout.flush() - icestorm.startReplica(2, echo=False) - icestorm.stopReplica(0) - print("ok") - # This waits for the replication to startup - #icestorm.admin("list") - time.sleep(2) - - # 0, 2 - sys.stdout.write("starting 0, stopping 1 (0, 2 running)... ") - sys.stdout.flush() - icestorm.startReplica(0, echo=False) - icestorm.stopReplica(1) - print("ok") - # This waits for the replication to startup - #icestorm.admin("list") - time.sleep(2) - - sys.stdout.write("starting 1 (all running)... ") - sys.stdout.flush() - icestorm.startReplica(1, echo=False) - print("ok") - # This waits for the replication to startup - #icestorm.admin("list") - - time.sleep(2) - -sys.stdout.write("stopping publisher... ") -sys.stdout.flush() -runcontrol(pubControl) -publisherProc.expect("([^\n]+)\n") -publisherCount = publisherProc.match.group(1) -publisherProc.waitTestSuccess() -print("ok") - -sys.stdout.write("stopping replicas... ") -sys.stdout.flush() -icestorm.stop() -print("ok") - -sys.stdout.write("stopping subscriber... ") -sys.stdout.flush() -runcontrol(subControl) -subscriberProc.expect("([^\n]+)\n") -subscriberCount = subscriberProc.match.group(1) -subscriberProc.waitTestSuccess() -print("ok") - -print("publisher published %s events, subscriber received %s events" % (publisherCount, subscriberCount)) - -if TestUtil.appverifier: - TestUtil.appVerifierAfterTestEnd(targets, cwd = os.getcwd()) diff --git a/cpp/test/IceStorm/repstress/test.py b/cpp/test/IceStorm/repstress/test.py new file mode 100644 index 00000000000..f61befa8961 --- /dev/null +++ b/cpp/test/IceStorm/repstress/test.py @@ -0,0 +1,113 @@ +# -*- coding: utf-8 -*- +# ********************************************************************** +# +# Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +# +# Make sure IceStorm and the subscriber use the same buffer size for +# sending/receiving datagrams. This ensures the test works with bogus +# OS configurations where the reicever buffer size is smaller than the +# send buffer size (causing the received messages to be +# truncated). See also bug #6070. +# +props = { + "IceStorm.Election.MasterTimeout" : 2, + "IceStorm.Election.ElectionTimeout" : 2, + "IceStorm.Election.ResponseTimeout" : 2, + "Ice.Warn.Dispatch" : 0 +} + +icestorm = [ IceStorm(replica=i, nreplicas=3, props = props) for i in range(0,3) ] + +class IceStormRepStressTestCase(IceStormTestCase): + + def runClientSide(self, current): + + def stopReplica(num): + self.icestorm[num].shutdown(current) + self.icestorm[num].stop(current, True) + + def startReplica(num): + self.icestorm[num].start(current) + + current.write("creating topic... ") + self.runadmin(current, "create single") + current.writeln("ok") + + current.write("running subscriber... ") + subscriber = Subscriber(quiet=True) + subscriber.start(current) + subscriber.expect("([^\n]+)\n") + subControl = subscriber.process.match.group(1) + current.writeln("ok") + + current.write("running publisher... ") + publisher = Publisher(quiet=True) + publisher.start(current) + publisher.expect("([^\n]+)\n") + pubControl = publisher.process.match.group(1) + current.writeln("ok") + + time.sleep(2) + + for i in range(0, 3): + # 0, 1 + current.write("stopping replica 2 (0, 1 running)... ") + stopReplica(2) + current.writeln("ok") + time.sleep(2) + + # 1, 2 + current.write("starting 2, stopping 0 (1, 2 running)... ") + startReplica(2) + stopReplica(0) + current.writeln("ok") + # This waits for the replication to startup + #self.runadmin(current, "list") + time.sleep(2) + + # 0, 2 + current.write("starting 0, stopping 1 (0, 2 running)... ") + startReplica(0) + stopReplica(1) + current.writeln("ok") + # This waits for the replication to startup + #self.runadmin(current, "list") + time.sleep(2) + + current.write("starting 1 (all running)... ") + startReplica(1) + current.writeln("ok") + # This waits for the replication to startup + #self.runadmin(current, "list") + time.sleep(2) + + current.write("stopping publisher... ") + Client(exe="control", args=[pubControl]).run(current) + publisher.expect("([^\n]+)\n") + publisherCount = publisher.process.match.group(1) + publisher.stop(current, True) + current.writeln("ok") + + current.write("stopping replicas... ") + self.stopIceStorm(current) + current.writeln("ok") + + current.write("stopping subscriber... ") + Client(exe="control", args=[subControl]).run(current) + subscriber.expect("([^\n]+)\n") + subscriberCount = subscriber.process.match.group(1) + subscriber.stop(current, True) + current.writeln("ok") + + current.writeln("publisher published %s events, subscriber received %s events" % (publisherCount, subscriberCount)) + +TestSuite(__file__, + [ IceStormRepStressTestCase("replicated", icestorm=icestorm) ], + options={ "ipv6" : [False] }, + multihost=False) diff --git a/cpp/test/IceStorm/single/0.db/.gitignore b/cpp/test/IceStorm/single/0.db/.gitignore deleted file mode 100644 index 72e8ffc0db8..00000000000 --- a/cpp/test/IceStorm/single/0.db/.gitignore +++ /dev/null @@ -1 +0,0 @@ -* diff --git a/cpp/test/IceStorm/single/1.db/.gitignore b/cpp/test/IceStorm/single/1.db/.gitignore deleted file mode 100644 index 72e8ffc0db8..00000000000 --- a/cpp/test/IceStorm/single/1.db/.gitignore +++ /dev/null @@ -1 +0,0 @@ -* diff --git a/cpp/test/IceStorm/single/2.db/.gitignore b/cpp/test/IceStorm/single/2.db/.gitignore deleted file mode 100644 index 72e8ffc0db8..00000000000 --- a/cpp/test/IceStorm/single/2.db/.gitignore +++ /dev/null @@ -1 +0,0 @@ -* diff --git a/cpp/test/IceStorm/single/Publisher.cpp b/cpp/test/IceStorm/single/Publisher.cpp index 8c06e428955..a88dff82add 100644 --- a/cpp/test/IceStorm/single/Publisher.cpp +++ b/cpp/test/IceStorm/single/Publisher.cpp @@ -9,6 +9,7 @@ #include <Ice/Ice.h> #include <IceStorm/IceStorm.h> +#include <TestCommon.h> #include <Single.h> using namespace std; @@ -70,7 +71,8 @@ main(int argc, char* argv[]) try { - communicator = initialize(argc, argv); + Ice::InitializationData initData = getTestInitData(argc, argv); + communicator = initialize(argc, argv, initData); status = run(argc, argv, communicator); } catch(const Exception& ex) diff --git a/cpp/test/IceStorm/single/Subscriber.cpp b/cpp/test/IceStorm/single/Subscriber.cpp index f2ee78ee554..7b4c0a17351 100644 --- a/cpp/test/IceStorm/single/Subscriber.cpp +++ b/cpp/test/IceStorm/single/Subscriber.cpp @@ -251,7 +251,8 @@ main(int argc, char* argv[]) try { - communicator = initialize(argc, argv); + Ice::InitializationData initData = getTestInitData(argc, argv); + communicator = initialize(argc, argv, initData); status = run(argc, argv, communicator); } catch(const Exception& ex) diff --git a/cpp/test/IceStorm/single/db/.gitignore b/cpp/test/IceStorm/single/db/.gitignore deleted file mode 100644 index 39af5887579..00000000000 --- a/cpp/test/IceStorm/single/db/.gitignore +++ /dev/null @@ -1 +0,0 @@ -# Dummy file, so that git retains this otherwise empty directory. diff --git a/cpp/test/IceStorm/single/run.py b/cpp/test/IceStorm/single/run.py deleted file mode 100755 index 162854b9084..00000000000 --- a/cpp/test/IceStorm/single/run.py +++ /dev/null @@ -1,89 +0,0 @@ -#!/usr/bin/env python -# ********************************************************************** -# -# Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved. -# -# This copy of Ice is licensed to you under the terms described in the -# ICE_LICENSE file included in this distribution. -# -# ********************************************************************** - -import os, sys -import time - -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 RuntimeError("can't find toplevel directory!") -sys.path.append(os.path.join(path[0], "scripts")) -import TestUtil, IceStormUtil - -publisher = os.path.join(os.getcwd(), TestUtil.getTestExecutable("publisher")) -subscriber = os.path.join(os.getcwd(), TestUtil.getTestExecutable("subscriber")) - -# -# Make sure IceStorm and the subscriber use the same buffer size for -# sending/receiving datagrams. This ensures the test works with bogus -# OS configurations where the reicever buffer size is smaller than the -# send buffer size (causing the received messages to be -# truncated). See also bug #6070. -# -iceStormArgs = " --Ice.UDP.SndSize=4096" -subscriberArgs = " --Ice.UDP.RcvSize=4096" - -targets = [] -if TestUtil.appverifier: - targets = [TestUtil.getIceBox(), publisher, subscriber, TestUtil.getIceBoxAdmin(), TestUtil.getIceStormAdmin()] - TestUtil.setAppVerifierSettings(targets, cwd = os.getcwd()) - -def dotest(type): - icestorm = IceStormUtil.init(TestUtil.toplevel, os.getcwd(), type, additional=iceStormArgs) - icestorm.start() - - sys.stdout.write("creating topic... ") - sys.stdout.flush() - icestorm.admin("create single") - print("ok") - - sys.stdout.write("starting subscriber... ") - sys.stdout.flush() - subscriberProc = TestUtil.startServer(subscriber, icestorm.reference() + subscriberArgs + " " + type, count = 3) - print("ok") - - # - # Start the publisher. This should publish 10 events which eventually - # causes subscriber to terminate. - # - sys.stdout.write("starting publisher... ") - sys.stdout.flush() - publisherProc = TestUtil.startClient(publisher, icestorm.reference(), startReader = False) - print("ok") - publisherProc.startReader() - - subscriberProc.waitTestSuccess() - publisherProc.waitTestSuccess() - - # - # Destroy the topic. - # - sys.stdout.write("destroy topic... ") - sys.stdout.flush() - icestorm.admin("destroy single") - print("ok") - - # - # Shutdown icestorm. - # - icestorm.stop() - -dotest("persistent") -dotest("transient") -dotest("replicated") - -if TestUtil.appverifier: - TestUtil.appVerifierAfterTestEnd([targets], cwd = os.getcwd()) - -sys.exit(0) diff --git a/cpp/test/IceStorm/single/test.py b/cpp/test/IceStorm/single/test.py new file mode 100644 index 00000000000..b4e5848e2b0 --- /dev/null +++ b/cpp/test/IceStorm/single/test.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +# ********************************************************************** +# +# Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +# +# Make sure IceStorm and the subscriber use the same buffer size for +# sending/receiving datagrams. This ensures the test works with bogus +# OS configurations where the reicever buffer size is smaller than the +# send buffer size (causing the received messages to be +# truncated). See also bug #6070. +# +props = { "Ice.UDP.SndSize" : 4096, "Ice.Warn.Dispatch" : 0 } +persistent = IceStorm(props = props) +transient = IceStorm(props = props, transient=True) +replicated = [ IceStorm(replica=i, nreplicas=3, props = props) for i in range(0,3) ] + +sub = Subscriber(args=["{testcase.parent.name}"], props = { "Ice.UDP.RcvSize" : 4096 }, readyCount=3) +pub = Publisher(args=["{testcase.parent.name}"]) + +class IceStormSingleTestCase(IceStormTestCase): + + def setupClientSide(self, current): + self.runadmin(current, "create single") + + def teardownClientSide(self, current, success): + self.runadmin(current, "destroy single") + self.shutdown(current) + +TestSuite(__file__, [ + IceStormSingleTestCase("persistent", icestorm=persistent, client=ClientServerTestCase(client=pub, server=sub)), + IceStormSingleTestCase("transient", icestorm=transient, client=ClientServerTestCase(client=pub, server=sub)), + IceStormSingleTestCase("replicated", icestorm=replicated, client=ClientServerTestCase(client=pub, server=sub)), +], multihost=False) diff --git a/cpp/test/IceStorm/stress/Publisher.cpp b/cpp/test/IceStorm/stress/Publisher.cpp index 6b9c7801f68..7d41977191a 100644 --- a/cpp/test/IceStorm/stress/Publisher.cpp +++ b/cpp/test/IceStorm/stress/Publisher.cpp @@ -11,6 +11,7 @@ #include <IceUtil/Options.h> #include <IceStorm/IceStorm.h> #include <Event.h> +#include <TestCommon.h> using namespace std; using namespace Ice; @@ -117,10 +118,10 @@ main(int argc, char* argv[]) { int status; CommunicatorPtr communicator; - + InitializationData initData = getTestInitData(argc, argv); try { - communicator = initialize(argc, argv); + communicator = initialize(argc, argv, initData); status = run(argc, argv, communicator); } catch(const Exception& ex) diff --git a/cpp/test/IceStorm/stress/Subscriber.cpp b/cpp/test/IceStorm/stress/Subscriber.cpp index 132bd5c4d34..1baa978ae3f 100644 --- a/cpp/test/IceStorm/stress/Subscriber.cpp +++ b/cpp/test/IceStorm/stress/Subscriber.cpp @@ -515,10 +515,10 @@ main(int argc, char* argv[]) { int status; CommunicatorPtr communicator; - + InitializationData initData = getTestInitData(argc, argv); try { - communicator = initialize(argc, argv); + communicator = initialize(argc, argv, initData); status = run(argc, argv, communicator); } catch(const Exception& ex) diff --git a/cpp/test/IceStorm/stress/run.py b/cpp/test/IceStorm/stress/run.py deleted file mode 100755 index ea56f3ed0a5..00000000000 --- a/cpp/test/IceStorm/stress/run.py +++ /dev/null @@ -1,204 +0,0 @@ -#!/usr/bin/env python -# ********************************************************************** -# -# Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved. -# -# This copy of Ice is licensed to you under the terms described in the -# ICE_LICENSE file included in this distribution. -# -# ********************************************************************** - -import os, sys, time, threading, re - -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 RuntimeError("can't find toplevel directory!") -sys.path.append(os.path.join(path[0], "scripts")) -import TestUtil, IceStormUtil - -iceStormAdmin = TestUtil.getIceStormAdmin() - -publisher = os.path.join(os.getcwd(), TestUtil.getTestExecutable("publisher")) -subscriber = os.path.join(os.getcwd(), TestUtil.getTestExecutable("subscriber")) - -targets = [] -if TestUtil.appverifier: - targets = [TestUtil.getIceBox(), publisher, subscriber, TestUtil.getIceBoxAdmin(), \ - TestUtil.getIceStormAdmin()] - TestUtil.setAppVerifierSettings(targets, cwd = os.getcwd()) - -def doTest(server1, server2, subOpts, pubOpts): - - subscriberProcs = [] - if type(subOpts) != type([]): - subOpts = [ subOpts ] - for opts in subOpts: - # We don't want the subscribers to time out. - 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 - -def runAdmin(cmd, desc = None): - global iceStormAdmin - global iceStormAdminReference - if desc: - sys.stdout.write(desc + " ") - sys.stdout.flush() - proc = TestUtil.startClient(iceStormAdmin, adminIceStormReference + r' -e "%s"' % cmd, startReader = True) - proc.waitTestSuccess() - if desc: - print("ok") - -def runtest(type): - # Clear the idle timeout otherwise the IceBox ThreadPool will timeout. - 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()) - - sys.stdout.write("starting icestorm services... ") - sys.stdout.flush() - server1.start(echo=False) - server2.start(echo=False) - print("ok") - - runAdmin("create TestIceStorm1/fed1 TestIceStorm2/fed1", "setting up the topics...") - - sys.stdout.write("Sending 5000 ordered events... ") - sys.stdout.flush() - doTest(server1, server2, '--events 5000 --qos "reliability,ordered" ' + server1.reference(), '--events 5000') - print("ok") - - runAdmin("link TestIceStorm1/fed1 TestIceStorm2/fed1") - sys.stdout.write("Sending 5000 ordered events across a link... ") - sys.stdout.flush() - doTest(server1, server2, '--events 5000 --qos "reliability,ordered" ' + server2.reference(), '--events 5000') - print("ok") - - runAdmin("unlink TestIceStorm1/fed1 TestIceStorm2/fed1") - sys.stdout.write("Sending 20000 unordered events... ") - sys.stdout.flush() - doTest(server1, server2, '--events 20000 ' + server1.reference(), '--events 20000 --oneway') - print("ok") - - runAdmin("link TestIceStorm1/fed1 TestIceStorm2/fed1") - sys.stdout.write("Sending 20000 unordered events across a link... ") - sys.stdout.flush() - doTest(server1, server2, '--events 20000 ' + server2.reference(), '--events 20000 --oneway') - print("ok") - - runAdmin("unlink TestIceStorm1/fed1 TestIceStorm2/fed1") - sys.stdout.write("Sending 20000 unordered batch events... ") - sys.stdout.flush() - doTest(server1, server2, '--events 20000 --qos "reliability,batch" ' + server1.reference(), '--events 20000 --oneway') - print("ok") - - runAdmin("link TestIceStorm1/fed1 TestIceStorm2/fed1") - sys.stdout.write("Sending 20000 unordered batch events across a link... ") - sys.stdout.flush() - doTest(server1, server2, '--events 20000 --qos "reliability,batch" ' + server2.reference(), '--events 20000 --oneway') - print("ok") - - runAdmin("unlink TestIceStorm1/fed1 TestIceStorm2/fed1") - sys.stdout.write("Sending 20000 unordered events with slow subscriber... ") - sys.stdout.flush() - doTest(server1, server2, ['--events 2 --slow ' + server1.reference(), '--events 20000 ' + server1.reference()], '--events 20000 --oneway') - print("ok") - - runAdmin("link TestIceStorm1/fed1 TestIceStorm2/fed1") - sys.stdout.write("Sending 20000 unordered events with slow subscriber & link... ") - sys.stdout.flush() - 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") - - sys.stdout.write("shutting down icestorm services... ") - sys.stdout.flush() - server1.stop() - server2.stop() - print("ok") - - sys.stdout.write("starting icestorm services... ") - sys.stdout.flush() - # - # The erratic tests emit lots of connection warnings so they are - # disabled here. The IceStorm servers are stopped and restarted so the - # settings will take effect. - # - server1.start(echo=False, additionalOptions = ' --Ice.Warn.Connections=0') - server2.start(echo=False, additionalOptions = ' --Ice.Warn.Connections=0') - print("ok") - - runAdmin("unlink TestIceStorm1/fed1 TestIceStorm2/fed1") - - sys.stdout.write("Sending 20000 unordered events with erratic subscriber... ") - sys.stdout.flush() - 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') - print("ok") - - runAdmin("link TestIceStorm1/fed1 TestIceStorm2/fed1") - sys.stdout.write("Sending 20000 unordered events with erratic subscriber across a link... ") - sys.stdout.flush() - 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 ') - print("ok") - - # - # Shutdown icestorm. - # - sys.stdout.write("shutting down icestorm services... ") - sys.stdout.flush() - server1.stop() - server2.stop() - print("ok") - - sys.stdout.write("Sending 5000 ordered events with max queue size drop events... ") - sys.stdout.flush() - opts = " --IceStorm.Send.QueueSizeMax=2000 --IceStorm.Send.QueueSizeMaxPolicy=DropEvents" - server1.start(echo=False, additionalOptions = opts) - doTest(server1, server2, - '--events 5000 --qos "reliability,ordered" --maxQueueDropEvents=2000 ' + server1.reference(), - '--events 5000 --maxQueueTest') - server1.stop() - print("ok") - - sys.stdout.write("Sending 5000 ordered events with max queue size remove subscriber... ") - sys.stdout.flush() - opts = " --IceStorm.Send.QueueSizeMax=2000 --IceStorm.Send.QueueSizeMaxPolicy=RemoveSubscriber" - server1.start(echo=False, additionalOptions = opts) - doTest(server1, server2, - '--events 5000 --qos "reliability,ordered" --maxQueueRemoveSub=2000 ' + server1.reference(), - '--events 5000 --maxQueueTest') - server1.stop() - print("ok") - - - -runtest("persistent") -runtest("replicated") - -if TestUtil.appverifier: - TestUtil.appVerifierAfterTestEnd(targets, cwd = os.getcwd()) diff --git a/cpp/test/IceStorm/stress/test.py b/cpp/test/IceStorm/stress/test.py new file mode 100644 index 00000000000..16f30f28a30 --- /dev/null +++ b/cpp/test/IceStorm/stress/test.py @@ -0,0 +1,155 @@ +# -*- coding: utf-8 -*- +# ********************************************************************** +# +# Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +# +# Publisher/subscriber test cases, publisher publishes on TestIceStorm1 instance(s) and +# the subscriber subscribes to the TestIceStorm2 instance(s) +# +pubSub=lambda si, pi, s={}, p={}: ClientServerTestCase(client=Publisher(args=s), server=Subscriber(args=p)) + +class IceStormStressTestCase(IceStormTestCase): + + def runClientSide(self, current): + + icestorm1 = [icestorm for icestorm in self.icestorm if icestorm.getInstanceName() == "TestIceStorm1"] + icestorm2 = [icestorm for icestorm in self.icestorm if icestorm.getInstanceName() == "TestIceStorm2"] + + def doTest(subOpts, pubOpts): + # Create the subscribers + subscribers = [] + for (instanceName, opts) in subOpts if type(subOpts) == list else [subOpts]: + subscribers.append(Subscriber(instanceName or "TestIceStorm1", args=opts.split(" "))) + + # Create the publisher + publisher = Publisher("TestIceStorm1", args=pubOpts.split(" ")) + + # Run the test case + ClientServerTestCase(client=publisher, servers=subscribers).run(current) + + current.write("setting up the topics...") + self.runadmin(current, "create TestIceStorm1/fed1 TestIceStorm2/fed1") + current.writeln("ok") + + current.write("Sending 5000 ordered events... ") + doTest(("TestIceStorm1", '--events 5000 --qos "reliability,ordered"'), '--events 5000') + current.writeln("ok") + + self.runadmin(current, "link TestIceStorm1/fed1 TestIceStorm2/fed1") + current.write("Sending 5000 ordered events across a link... ") + doTest(("TestIceStorm2", '--events 5000 --qos "reliability,ordered"'), '--events 5000') + current.writeln("ok") + + self.runadmin(current, "unlink TestIceStorm1/fed1 TestIceStorm2/fed1") + current.write("Sending 20000 unordered events... ") + doTest(("TestIceStorm1", '--events 20000'), '--events 20000 --oneway') + current.writeln("ok") + + self.runadmin(current, "link TestIceStorm1/fed1 TestIceStorm2/fed1") + current.write("Sending 20000 unordered events across a link... ") + doTest(("TestIceStorm2", '--events 20000'), '--events 20000 --oneway') + current.writeln("ok") + + self.runadmin(current, "unlink TestIceStorm1/fed1 TestIceStorm2/fed1") + current.write("Sending 20000 unordered batch events... ") + doTest(("TestIceStorm1", '--events 20000 --qos "reliability,batch"'), '--events 20000 --oneway') + current.writeln("ok") + + self.runadmin(current, "link TestIceStorm1/fed1 TestIceStorm2/fed1") + current.write("Sending 20000 unordered batch events across a link... ") + doTest(("TestIceStorm2", '--events 20000 --qos "reliability,batch"'), '--events 20000 --oneway') + current.writeln("ok") + + self.runadmin(current, "unlink TestIceStorm1/fed1 TestIceStorm2/fed1") + current.write("Sending 20000 unordered events with slow subscriber... ") + doTest([("TestIceStorm1", '--events 2 --slow'), + ("TestIceStorm1", '--events 20000 ')], + '--events 20000 --oneway') + current.writeln("ok") + + self.runadmin(current, "link TestIceStorm1/fed1 TestIceStorm2/fed1") + current.write("Sending 20000 unordered events with slow subscriber & link... ") + doTest([("TestIceStorm1", '--events 2 --slow'), + ("TestIceStorm1", '--events 20000'), + ("TestIceStorm2", '--events 2 --slow'), + ("TestIceStorm2", '--events 20000')], + '--events 20000 --oneway') + current.writeln("ok") + + current.write("shutting down icestorm services... ") + self.stopIceStorm(current) + current.writeln("ok") + + current.write("starting icestorm services... ") + # + # The erratic tests emit lots of connection warnings so they are + # disabled here. The IceStorm servers are stopped and restarted so the + # settings will take effect. + # + self.startIceStorm(current) + current.writeln("ok") + + self.runadmin(current, "unlink TestIceStorm1/fed1 TestIceStorm2/fed1") + current.write("Sending 20000 unordered events with erratic subscriber... ") + doTest([ ("TestIceStorm1", '--erratic 5 --qos "reliability,ordered" --events 20000'), + ("TestIceStorm1", '--erratic 5 --events 20000'), + ("TestIceStorm1", '--events 20000')], + '--events 20000 --oneway') + current.writeln("ok") + + self.runadmin(current, "link TestIceStorm1/fed1 TestIceStorm2/fed1") + current.write("Sending 20000 unordered events with erratic subscriber across a link... ") + doTest([ ("TestIceStorm1", '--events 20000'), + ("TestIceStorm1", '--erratic 5 --qos "reliability,ordered" --events 20000 '), + ("TestIceStorm1", '--erratic 5 --events 20000 '), + ("TestIceStorm2", '--events 20000'), + ("TestIceStorm2", '--erratic 5 --qos "reliability,ordered" --events 20000 '), + ("TestIceStorm2", '--erratic 5 --events 20000 ')], + '--events 20000 --oneway ') + current.writeln("ok") + + # + # Shutdown icestorm. + # + current.write("shutting down icestorm services... ") + self.stopIceStorm(current) + current.writeln("ok") + + current.write("Sending 5000 ordered events with max queue size drop events... ") + opts = " --IceStorm.Send.QueueSizeMax=2000 --IceStorm.Send.QueueSizeMaxPolicy=DropEvents" + for s in icestorm1: + s.start(current, args=opts.split(" ")) + doTest(("TestIceStorm1", '--events 5000 --qos "reliability,ordered" --maxQueueDropEvents=2000'), + '--events 5000 --maxQueueTest') + for s in icestorm1: + s.shutdown(current) + s.stop(current, True) + current.writeln("ok") + + current.write("Sending 5000 ordered events with max queue size remove subscriber... ") + opts = " --IceStorm.Send.QueueSizeMax=2000 --IceStorm.Send.QueueSizeMaxPolicy=RemoveSubscriber" + for s in icestorm1: + s.start(current, args=opts.split(" ")) + doTest(("TestIceStorm1", '--events 5000 --qos "reliability,ordered" --maxQueueRemoveSub=2000'), + '--events 5000 --maxQueueTest') + for s in icestorm1: + s.shutdown(current) + s.stop(current, True) + current.writeln("ok") + +TestSuite(__file__, [ + + IceStormStressTestCase("persistent", icestorm=[IceStorm("TestIceStorm1", quiet=True), + IceStorm("TestIceStorm2", quiet=True, portnum=20)]), + + IceStormStressTestCase("replicated with replicated publisher", icestorm= + [IceStorm("TestIceStorm1", i, 3, quiet=True) for i in range(0,3)] + + [IceStorm("TestIceStorm2", i, 3, portnum=20, quiet=True) for i in range(0,3)]), + +], multihost=False) |