summaryrefslogtreecommitdiff
path: root/qpid/cpp/src/tests/ha_tests.py
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2012-10-24 14:33:25 +0000
committerAlan Conway <aconway@apache.org>2012-10-24 14:33:25 +0000
commitf7245cd1c72954ef3827b837415c59f45d656167 (patch)
treed8f1a85a70f1fb7e966ccc845b7da9e883fe4343 /qpid/cpp/src/tests/ha_tests.py
parenta5d0e8d258023fa09dd727c48cb6c13974f8d093 (diff)
downloadqpid-python-f7245cd1c72954ef3827b837415c59f45d656167.tar.gz
Bug:868364 - QPID-4391: HA ignore stale responses.
Related issue discovered while fixing this bug: The BrokerReplicater pulls management events and query responses from different queues, there is no co-ordination between them. If a response is processed late, after create and delete events, it will incorrectly re-create the deleted queue. This patch ignores responses if we have already seen an event for the queue or exchange. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1401711 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src/tests/ha_tests.py')
-rwxr-xr-xqpid/cpp/src/tests/ha_tests.py33
1 files changed, 30 insertions, 3 deletions
diff --git a/qpid/cpp/src/tests/ha_tests.py b/qpid/cpp/src/tests/ha_tests.py
index edaced25c1..ba7b4cb638 100755
--- a/qpid/cpp/src/tests/ha_tests.py
+++ b/qpid/cpp/src/tests/ha_tests.py
@@ -29,7 +29,21 @@ from logging import getLogger, WARN, ERROR, DEBUG, INFO
from qpidtoollibs import BrokerAgent
from uuid import UUID
-class ReplicationTests(BrokerTest):
+log = getLogger(__name__)
+
+def grep(filename, regexp):
+ for line in open(filename).readlines():
+ if (regexp.search(line)): return True
+ return False
+
+class HaBrokerTest(BrokerTest):
+ """Base class for HA broker tests"""
+ def assert_log_no_errors(self, broker):
+ log = broker.get_log()
+ if grep(log, re.compile("] error|] critical")):
+ self.fail("Errors in log file %s"%(log))
+
+class ReplicationTests(HaBrokerTest):
"""Correctness tests for HA replication."""
def test_replication(self):
@@ -774,6 +788,19 @@ acl deny all all
cluster.start()
send_ttl_messages()
+ def test_stale_response(self):
+ """Check for race condition where a stale response is processed after an
+ event for the same queue/exchange """
+ cluster = HaCluster(self, 2)
+ s = cluster[0].connect().session()
+ s.sender("keep;{create:always}") # Leave this queue in place.
+ for i in xrange(100): # FIXME aconway 2012-10-23: ??? IS this an issue?
+ s.sender("deleteme%s;{create:always,delete:always}"%(i)).close()
+ # It is possible for the backup to attempt to subscribe after the queue
+ # is deleted. This is not an error, but is logged as an error on the primary.
+ # The backup does not log this as an error so we only check the backup log for errors.
+ self.assert_log_no_errors(cluster[1])
+
def fairshare(msgs, limit, levels):
"""
Generator to return prioritised messages in expected order for a given fairshare limit
@@ -808,7 +835,7 @@ def priority_level(value, levels):
offset = 5-math.ceil(levels/2.0)
return min(max(value - offset, 0), levels-1)
-class LongTests(BrokerTest):
+class LongTests(HaBrokerTest):
"""Tests that can run for a long time if -DDURATION=<minutes> is set"""
def duration(self):
@@ -891,7 +918,7 @@ class LongTests(BrokerTest):
if unexpected_dead:
raise Exception("Brokers not running: %s"%unexpected_dead)
-class RecoveryTests(BrokerTest):
+class RecoveryTests(HaBrokerTest):
"""Tests for recovery after a failure."""
def test_queue_hold(self):