amqp1: re-organize TestFailover to be reused by TestSSL

This breaks out the generation of brokers and transport_url into
separate methods.  These methods are used in the next patch in this
series, where TestSSL is updated to inherit from TestFailover, and
TestSSL overrides the _gen_brokers and _gen_transport_url methods to
supply the necessary SSL-aware options.

Change-Id: Ia2f977795abc2e81a996e299867e05d41057f33f
This commit is contained in:
John Eckersberg 2021-08-10 16:40:52 -04:00
parent fc49e04e6d
commit 01f5b37874

@ -931,19 +931,14 @@ class TestFailover(test_utils.BaseTestCase):
# configure different addressing modes on the brokers to test failing
# over from one type of backend to another
self.config(addressing_mode='dynamic', group="oslo_messaging_amqp")
self._brokers = [FakeBroker(self.conf.oslo_messaging_amqp,
product="qpid-cpp"),
FakeBroker(self.conf.oslo_messaging_amqp,
product="routable")]
self._brokers = self._gen_brokers()
self._primary = 0
self._backup = 1
hosts = []
for broker in self._brokers:
hosts.append(oslo_messaging.TransportHost(hostname=broker.host,
port=broker.port))
self._broker_url = oslo_messaging.TransportURL(self.conf,
transport="amqp",
hosts=hosts)
self._broker_url = self._gen_transport_url(hosts)
def tearDown(self):
super(TestFailover, self).tearDown()
@ -951,6 +946,17 @@ class TestFailover(test_utils.BaseTestCase):
if broker.is_alive():
broker.stop()
def _gen_brokers(self):
return [FakeBroker(self.conf.oslo_messaging_amqp,
product="qpid-cpp"),
FakeBroker(self.conf.oslo_messaging_amqp,
product="routable")]
def _gen_transport_url(self, hosts):
return oslo_messaging.TransportURL(self.conf,
transport="amqp",
hosts=hosts)
def _failover(self, fail_broker):
self._brokers[0].start()
self._brokers[1].start()