summaryrefslogtreecommitdiff
path: root/python/qpid/brokertest.py
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2009-11-18 17:26:43 +0000
committerAlan Conway <aconway@apache.org>2009-11-18 17:26:43 +0000
commit1674d80b61862e1054140c96f5db9eb401b11f11 (patch)
tree1169853cb8f8376d7ebb078d28b2e76523302742 /python/qpid/brokertest.py
parentbd3cae3b5691436369b4c37a570c766c1e8aafd2 (diff)
downloadqpid-python-1674d80b61862e1054140c96f5db9eb401b11f11.tar.gz
Added cluster option --cluster-size.
--cluster-size=N means that during start-up the cluster waits to have N members before accepting any clients. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@881839 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'python/qpid/brokertest.py')
-rw-r--r--python/qpid/brokertest.py26
1 files changed, 10 insertions, 16 deletions
diff --git a/python/qpid/brokertest.py b/python/qpid/brokertest.py
index b6046682de..01372bb802 100644
--- a/python/qpid/brokertest.py
+++ b/python/qpid/brokertest.py
@@ -206,7 +206,7 @@ class Cluster:
_cluster_lib = checkenv("CLUSTER_LIB")
_cluster_count = 0
- def __init__(self, test, count=0, args=[], expect=EXPECT_RUNNING):
+ def __init__(self, test, count=0, args=[], expect=EXPECT_RUNNING, wait_for_start=True):
self.test = test
self._brokers=[]
self.name = "cluster%d" % Cluster._cluster_count
@@ -215,21 +215,16 @@ class Cluster:
self.args = copy(args)
self.args += [ "--cluster-name", "%s-%s:%d" % (self.name, socket.gethostname(), os.getpid()) ]
self.args += [ "--load-module", self._cluster_lib ]
- self.start_n(count, expect=expect)
+ self.start_n(count, expect=expect, wait_for_start=wait_for_start)
- def start(self, name=None, expect=EXPECT_RUNNING):
+ def start(self, name=None, expect=EXPECT_RUNNING, wait_for_start=True):
"""Add a broker to the cluster. Returns the index of the new broker."""
if not name: name="%s-%d" % (self.name, len(self._brokers))
- self._brokers.append(self.test.broker(self.args, name, expect))
+ self._brokers.append(self.test.broker(self.args, name, expect, wait_for_start))
return self._brokers[-1]
- def start_n(self, count, expect=EXPECT_RUNNING):
- for i in range(count): self.start(expect=expect)
-
- def wait(self):
- """Wait for all cluster members to be ready"""
- for b in self._brokers:
- b.connect().close()
+ def start_n(self, count, expect=EXPECT_RUNNING, wait_for_start=True):
+ for i in range(count): self.start(expect=expect, wait_for_start=wait_for_start)
# Behave like a list of brokers.
def __len__(self): return len(self._brokers)
@@ -280,16 +275,15 @@ class BrokerTest(TestCase):
self.cleanup_stop(p)
return p
- def broker(self, args=[], name=None, expect=EXPECT_RUNNING):
+ def broker(self, args=[], name=None, expect=EXPECT_RUNNING,wait_for_start=True):
"""Create and return a broker ready for use"""
b = Broker(self, args=args, name=name, expect=expect)
- b.connect().close()
+ if (wait_for_start): b.connect().close()
return b
- def cluster(self, count=0, args=[], expect=EXPECT_RUNNING):
+ def cluster(self, count=0, args=[], expect=EXPECT_RUNNING, wait_for_start=True):
"""Create and return a cluster ready for use"""
- cluster = Cluster(self, count, args, expect=expect)
- cluster.wait()
+ cluster = Cluster(self, count, args, expect=expect, wait_for_start=wait_for_start)
return cluster
class RethrownException(Exception):