diff options
author | Alan Conway <aconway@apache.org> | 2013-03-12 14:23:08 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2013-03-12 14:23:08 +0000 |
commit | b0bde87b083479062cdd32d7e3bb64907a211f34 (patch) | |
tree | 840a5fc720a3834a0b2b25aeb385f8a4009cebe5 | |
parent | a0840419fe1d786f962ea0ca68fe43442a4c9305 (diff) | |
download | qpid-python-b0bde87b083479062cdd32d7e3bb64907a211f34.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@1455540 13f79535-47bb-0310-9956-ffa450edef68
-rwxr-xr-x | qpid/cpp/src/tests/ha_tests.py | 71 |
1 files changed, 36 insertions, 35 deletions
diff --git a/qpid/cpp/src/tests/ha_tests.py b/qpid/cpp/src/tests/ha_tests.py index 77399bf2e2..549dc0972e 100755 --- a/qpid/cpp/src/tests/ha_tests.py +++ b/qpid/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() |