diff options
Diffstat (limited to 'qpid/cpp/src/tests/ha_tests.py')
-rwxr-xr-x | qpid/cpp/src/tests/ha_tests.py | 67 |
1 files changed, 60 insertions, 7 deletions
diff --git a/qpid/cpp/src/tests/ha_tests.py b/qpid/cpp/src/tests/ha_tests.py index bc5566ae63..b29ff42627 100755 --- a/qpid/cpp/src/tests/ha_tests.py +++ b/qpid/cpp/src/tests/ha_tests.py @@ -279,11 +279,13 @@ class ReplicationTests(HaBrokerTest): """Test replication of individual queues outside of cluster mode""" l = LogLevel(ERROR) # Hide expected WARNING log messages from failover. try: - primary = HaBroker(self, name="primary", ha_cluster=False) + primary = HaBroker(self, name="primary", ha_cluster=False, + args=["--ha-queue-replication=yes"]); pc = primary.connect() ps = pc.session().sender("q;{create:always}") pr = pc.session().receiver("q;{create:always}") - backup = HaBroker(self, name="backup", ha_cluster=False) + backup = HaBroker(self, name="backup", ha_cluster=False, + args=["--ha-queue-replication=yes"]) br = backup.connect().session().receiver("q;{create:always}") # Set up replication with qpid-ha @@ -304,7 +306,8 @@ class ReplicationTests(HaBrokerTest): finally: l.restore() def test_queue_replica_failover(self): - """Test individual queue replication from a cluster to a standalone backup broker, verify it fails over.""" + """Test individual queue replication from a cluster to a standalone + backup broker, verify it fails over.""" l = LogLevel(ERROR) # Hide expected WARNING log messages from failover. try: cluster = HaCluster(self, 2) @@ -312,7 +315,8 @@ class ReplicationTests(HaBrokerTest): pc = cluster.connect(0) ps = pc.session().sender("q;{create:always}") pr = pc.session().receiver("q;{create:always}") - backup = HaBroker(self, name="backup", ha_cluster=False) + backup = HaBroker(self, name="backup", ha_cluster=False, + args=["--ha-queue-replication=yes"]) br = backup.connect().session().receiver("q;{create:always}") backup.replicate(cluster.url, "q") ps.send("a") @@ -474,6 +478,23 @@ class ReplicationTests(HaBrokerTest): self.fail("Excpected no-such-queue exception") except NotFound: pass + def test_replicate_binding(self): + """Verify that binding replication can be disabled""" + primary = HaBroker(self, name="primary", expect=EXPECT_EXIT_FAIL) + primary.promote() + backup = HaBroker(self, name="backup", brokers_url=primary.host_port()) + ps = primary.connect().session() + ps.sender("ex;{create:always,node:{type:topic,x-declare:{arguments:{'qpid.replicate':all}, type:'fanout'}}}") + ps.sender("q;{create:always,node:{type:queue,x-declare:{arguments:{'qpid.replicate':all}},x-bindings:[{exchange:'ex',queue:'q',key:'',arguments:{'qpid.replicate':none}}]}}") + backup.wait_backup("q") + + primary.kill() + assert retry(lambda: not is_running(primary.pid)) # Wait for primary to die + backup.promote() + bs = backup.connect_admin().session() + bs.sender("ex").send(Message("msg")) + self.assert_browse_retry(bs, "q", []) + def test_invalid_replication(self): """Verify that we reject an attempt to declare a queue with invalid replication value.""" cluster = HaCluster(self, 1, ha_replicate="all") @@ -761,9 +782,9 @@ acl deny all all cluster[1].wait_queue("q0") cluster[1].wait_queue("q1") cluster[0].kill() - cluster[1].wait_queue("q1") # Not timed out yet - cluster[1].wait_no_queue("q1", timeout=2) # Wait for timeout - cluster[1].wait_no_queue("q0", timeout=2) + cluster[1].wait_queue("q1") # Not timed out yet + cluster[1].wait_no_queue("q1") # Wait for timeout + cluster[1].wait_no_queue("q0") def test_alt_exchange_dup(self): """QPID-4349: if a queue has an alterante exchange and is deleted the @@ -1114,6 +1135,38 @@ class RecoveryTests(HaBrokerTest): cluster.bounce(0, promote_next=False) cluster[0].promote() + +class ConfigurationTests(HaBrokerTest): + """Tests for configuration settings.""" + + def test_client_broker_url(self): + """Check that setting of broker and public URLs obeys correct defaulting + and precedence""" + + def check(broker, brokers, public): + qmf = broker.qmf() + self.assertEqual(brokers, qmf.brokersUrl) + self.assertEqual(public, qmf.publicUrl) + + def start(brokers, public, known=None): + args=[] + if brokers: args.append("--ha-brokers-url="+brokers) + if public: args.append("--ha-public-url="+public) + if known: args.append("--known-hosts-url="+known) + return HaBroker(self, args=args) + + # Both set explictily, no defaulting + b = start("foo:123", "bar:456") + check(b, "amqp:tcp:foo:123", "amqp:tcp:bar:456") + b.set_brokers_url("foo:999") + check(b, "amqp:tcp:foo:999", "amqp:tcp:bar:456") + b.set_public_url("bar:999") + check(b, "amqp:tcp:foo:999", "amqp:tcp:bar:999") + + # Allow "none" to mean "not set" + b = start("none", "none") + check(b, "", "") + if __name__ == "__main__": shutil.rmtree("brokertest.tmp", True) qpid_ha = os.getenv("QPID_HA_EXEC") |