summaryrefslogtreecommitdiff
path: root/cpp/src/tests/cluster_tests.py
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2011-02-02 19:58:38 +0000
committerAlan Conway <aconway@apache.org>2011-02-02 19:58:38 +0000
commit631f18ae666cbcaf0f06112eb01f1b78f0c8f8f4 (patch)
treed43def80d80139b6ef32786f103bfaddca9310e8 /cpp/src/tests/cluster_tests.py
parentb9438b1b151ab8f3a7f03caf1905cf46aa630aa5 (diff)
downloadqpid-python-631f18ae666cbcaf0f06112eb01f1b78f0c8f8f4.tar.gz
Do one long run in cluster_tests.py test_management.
Instead of all short runs, use duration/4 for the first runs, then use 5 secs for remaining runs to get plenty of broker kills. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1066599 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/tests/cluster_tests.py')
-rwxr-xr-xcpp/src/tests/cluster_tests.py30
1 files changed, 16 insertions, 14 deletions
diff --git a/cpp/src/tests/cluster_tests.py b/cpp/src/tests/cluster_tests.py
index 992aaa6b9b..cbad4010b4 100755
--- a/cpp/src/tests/cluster_tests.py
+++ b/cpp/src/tests/cluster_tests.py
@@ -7,9 +7,9 @@
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -290,7 +290,7 @@ acl allow all all
if pattern.search(l): self.found = True; return
scanner = Scanner()
scanner.start()
- start = time.time()
+ start = time.time()
try:
# Wait up to 5 second timeout for scanner to find expected output
while not scanner.found and time.time() < start + 5:
@@ -402,7 +402,7 @@ class LongTests(BrokerTest):
# Use store if present.
if BrokerTest.store_lib: args +=["--load-module", BrokerTest.store_lib]
cluster = self.cluster(3, args)
-
+
clients = [] # Per-broker list of clients that only connect to one broker.
mclients = [] # Management clients that connect to every broker in the cluster.
@@ -422,18 +422,20 @@ class LongTests(BrokerTest):
mclients.append(ClientLoop(broker, cmd))
endtime = time.time() + self.duration()
+ runtime = self.duration() / 4 # First run is longer, use quarter of duration.
alive = 0 # First live cluster member
for i in range(len(cluster)): start_clients(cluster[i])
start_mclients(cluster[alive])
while time.time() < endtime:
- time.sleep(5)
+ time.sleep(runtime)
+ runtime = 5 # Remaining runs 5 seconds, frequent broker kills
for b in cluster[alive:]: b.ready() # Check if a broker crashed.
- # Kill the first broker, expect the clients to fail.
+ # Kill the first broker, expect the clients to fail.
b = cluster[alive]
b.expect = EXPECT_EXIT_FAIL
b.kill()
- # Stop the brokers clients and all the mclients.
+ # Stop the brokers clients and all the mclients.
for c in clients[alive] + mclients:
try: c.stop()
except: pass # Ignore expected errors due to broker shutdown.
@@ -460,14 +462,14 @@ class LongTests(BrokerTest):
while (time.time() < end): # Get a management interval
for i in xrange(1000): cluster[0].connect().close()
cluster_test_logs.verify_logs()
-
+
class StoreTests(BrokerTest):
"""
Cluster tests that can only be run if there is a store available.
"""
def args(self):
- assert BrokerTest.store_lib
+ assert BrokerTest.store_lib
return ["--load-module", BrokerTest.store_lib]
def test_store_loaded(self):
@@ -532,7 +534,7 @@ class StoreTests(BrokerTest):
b = cluster.start("b", wait=False)
c = cluster.start("c", wait=True)
self.assertEqual(a.get_message("q").content, "clean")
-
+
def test_wrong_cluster_id(self):
# Start a cluster1 broker, then try to restart in cluster2
cluster1 = self.cluster(0, args=self.args())
@@ -591,16 +593,16 @@ class StoreTests(BrokerTest):
c = cluster.start("c", expect=EXPECT_EXIT_FAIL)
self.assertEqual(b.store_state(), "dirty")
self.assertEqual(c.store_state(), "dirty")
- retry(lambda: a.store_state() == "dirty")
+ retry(lambda: a.store_state() == "dirty")
a.send_message("q", Message("x", durable=True))
a.kill()
b.kill() # c is last man, will mark store clean
- retry(lambda: c.store_state() == "clean")
+ retry(lambda: c.store_state() == "clean")
a = cluster.start("a", expect=EXPECT_EXIT_FAIL) # c no longer last man
- retry(lambda: c.store_state() == "dirty")
+ retry(lambda: c.store_state() == "dirty")
c.kill() # a is now last man
- retry(lambda: a.store_state() == "clean")
+ retry(lambda: a.store_state() == "clean")
a.kill()
self.assertEqual(a.store_state(), "clean")
self.assertEqual(b.store_state(), "dirty")