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/repstress | |
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/repstress')
-rw-r--r-- | cpp/test/IceStorm/repstress/Control.cpp | 5 | ||||
-rw-r--r-- | cpp/test/IceStorm/repstress/Publisher.cpp | 9 | ||||
-rw-r--r-- | cpp/test/IceStorm/repstress/Subscriber.cpp | 4 | ||||
-rwxr-xr-x | cpp/test/IceStorm/repstress/run.py | 125 | ||||
-rw-r--r-- | cpp/test/IceStorm/repstress/test.py | 113 |
5 files changed, 123 insertions, 133 deletions
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) |