summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2013-03-12 14:23:08 +0000
committerAlan Conway <aconway@apache.org>2013-03-12 14:23:08 +0000
commit7a1f2a8d48331604cd6155444a4af006074fe917 (patch)
tree33735c7944dd37bc4fde38fbf9ef0541b3935f73 /cpp
parentc6ecad2dba4a6a865b623a6ca7053a407616e87a (diff)
downloadqpid-python-7a1f2a8d48331604cd6155444a4af006074fe917.tar.gz
NO-JIRA: Separate catch/finally blocks in ha_tests.py to work on older python.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1455540 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp')
-rwxr-xr-xcpp/src/tests/ha_tests.py71
1 files changed, 36 insertions, 35 deletions
diff --git a/cpp/src/tests/ha_tests.py b/cpp/src/tests/ha_tests.py
index 77399bf2e2..549dc0972e 100755
--- a/cpp/src/tests/ha_tests.py
+++ b/cpp/src/tests/ha_tests.py
@@ -970,42 +970,43 @@ class LongTests(HaBrokerTest):
i = 0
primary = 0
try:
- while time.time() < endtime or i < 3: # At least 3 iterations
- # Precondition: All 3 brokers running,
- # primary = index of promoted primary
- # one or two backups are running,
- for s in senders: s.sender.assert_running()
- for r in receivers: r.receiver.assert_running()
- checkpoint = [ r.received+100 for r in receivers ]
- dead = None
- victim = random.randint(0,2)
- if victim == primary:
- # Don't kill primary till it is active and the next
- # backup is ready, otherwise we can lose messages.
- brokers[victim].wait_status("active")
- next = (victim+1)%3
- brokers[next].wait_status("ready")
- brokers.bounce(victim) # Next one is promoted
- primary = next
- else:
- brokers.kill(victim, False)
- dead = victim
-
- # At this point the primary is running with 1 or 2 backups
- # Make sure we are not stalled
- map(wait_passed, receivers, checkpoint)
- # Run another checkpoint to ensure things work in this configuration
- checkpoint = [ r.received+100 for r in receivers ]
- map(wait_passed, receivers, checkpoint)
-
- if dead is not None:
- brokers.restart(dead) # Restart backup
- brokers[dead].ready()
+ try:
+ while time.time() < endtime or i < 3: # At least 3 iterations
+ # Precondition: All 3 brokers running,
+ # primary = index of promoted primary
+ # one or two backups are running,
+ for s in senders: s.sender.assert_running()
+ for r in receivers: r.receiver.assert_running()
+ checkpoint = [ r.received+100 for r in receivers ]
dead = None
- i += 1
- except:
- traceback.print_exc()
- raise
+ victim = random.randint(0,2)
+ if victim == primary:
+ # Don't kill primary till it is active and the next
+ # backup is ready, otherwise we can lose messages.
+ brokers[victim].wait_status("active")
+ next = (victim+1)%3
+ brokers[next].wait_status("ready")
+ brokers.bounce(victim) # Next one is promoted
+ primary = next
+ else:
+ brokers.kill(victim, False)
+ dead = victim
+
+ # At this point the primary is running with 1 or 2 backups
+ # Make sure we are not stalled
+ map(wait_passed, receivers, checkpoint)
+ # Run another checkpoint to ensure things work in this configuration
+ checkpoint = [ r.received+100 for r in receivers ]
+ map(wait_passed, receivers, checkpoint)
+
+ if dead is not None:
+ brokers.restart(dead) # Restart backup
+ brokers[dead].ready()
+ dead = None
+ i += 1
+ except:
+ traceback.print_exc()
+ raise
finally:
for s in senders: s.stop()
for r in receivers: r.stop()