Add ConfFixture.transport_url
As the first step towards removing rpc_backend, we need all of the test fixtures to stop setting/using it via ConfFixture.transport_driver. Add ConfFixture.transport_url, and move the tests over to setting it rather than transport_driver. Partial-Bug: #1712399 Change-Id: I6e2ae2b511fdc52790d5755a9aecaf2f427ab706
This commit is contained in:
parent
fe6e031be3
commit
7e4ca449a0
@ -37,7 +37,7 @@ class ConfFixture(fixtures.Fixture):
|
|||||||
An example usage::
|
An example usage::
|
||||||
|
|
||||||
self.messaging_conf = self.useFixture(messaging.ConfFixture(cfg.CONF))
|
self.messaging_conf = self.useFixture(messaging.ConfFixture(cfg.CONF))
|
||||||
self.messaging_conf.transport_driver = 'fake'
|
self.messaging_conf.transport_url = 'fake://'
|
||||||
|
|
||||||
:param conf: a ConfigOpts instance
|
:param conf: a ConfigOpts instance
|
||||||
:type conf: oslo.config.cfg.ConfigOpts
|
:type conf: oslo.config.cfg.ConfigOpts
|
||||||
@ -131,6 +131,15 @@ class ConfFixture(fixtures.Fixture):
|
|||||||
def transport_driver(self, value):
|
def transport_driver(self, value):
|
||||||
self.conf.set_override('rpc_backend', value)
|
self.conf.set_override('rpc_backend', value)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def transport_url(self):
|
||||||
|
"""The transport url"""
|
||||||
|
return self.conf.transport_url
|
||||||
|
|
||||||
|
@transport_url.setter
|
||||||
|
def transport_url(self, value):
|
||||||
|
self.conf.set_override('transport_url', value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def response_timeout(self):
|
def response_timeout(self):
|
||||||
"""Default number of seconds to wait for a response from a call."""
|
"""Default number of seconds to wait for a response from a call."""
|
||||||
|
@ -119,7 +119,7 @@ class TestProtonDriverLoad(test_utils.BaseTestCase):
|
|||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestProtonDriverLoad, self).setUp()
|
super(TestProtonDriverLoad, self).setUp()
|
||||||
self.messaging_conf.transport_driver = 'amqp'
|
self.messaging_conf.transport_url = 'amqp://'
|
||||||
|
|
||||||
def test_driver_load(self):
|
def test_driver_load(self):
|
||||||
transport = oslo_messaging.get_transport(self.conf)
|
transport = oslo_messaging.get_transport(self.conf)
|
||||||
@ -750,7 +750,7 @@ mech_list: ${mechs}
|
|||||||
sasl_config_dir=_dir,
|
sasl_config_dir=_dir,
|
||||||
sasl_config_name="openstack")
|
sasl_config_name="openstack")
|
||||||
self._broker.start()
|
self._broker.start()
|
||||||
self.messaging_conf.transport_driver = 'amqp'
|
self.messaging_conf.transport_url = 'amqp://'
|
||||||
self.conf = self.messaging_conf.conf
|
self.conf = self.messaging_conf.conf
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
|
@ -27,7 +27,7 @@ class TestKafkaDriverLoad(test_utils.BaseTestCase):
|
|||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestKafkaDriverLoad, self).setUp()
|
super(TestKafkaDriverLoad, self).setUp()
|
||||||
self.messaging_conf.transport_driver = 'kafka'
|
self.messaging_conf.transport_url = 'kafka:/'
|
||||||
|
|
||||||
def test_driver_load(self):
|
def test_driver_load(self):
|
||||||
transport = oslo_messaging.get_notification_transport(self.conf)
|
transport = oslo_messaging.get_notification_transport(self.conf)
|
||||||
@ -41,7 +41,7 @@ class TestKafkaTransportURL(test_utils.BaseTestCase):
|
|||||||
expected=dict(hostaddrs=['localhost:9092'],
|
expected=dict(hostaddrs=['localhost:9092'],
|
||||||
username=None,
|
username=None,
|
||||||
password=None,
|
password=None,
|
||||||
vhost=None))),
|
vhost=''))),
|
||||||
('empty', dict(url='kafka:///',
|
('empty', dict(url='kafka:///',
|
||||||
expected=dict(hostaddrs=['localhost:9092'],
|
expected=dict(hostaddrs=['localhost:9092'],
|
||||||
username=None,
|
username=None,
|
||||||
@ -84,7 +84,7 @@ class TestKafkaTransportURL(test_utils.BaseTestCase):
|
|||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestKafkaTransportURL, self).setUp()
|
super(TestKafkaTransportURL, self).setUp()
|
||||||
self.messaging_conf.transport_driver = 'kafka'
|
self.messaging_conf.transport_url = 'kafka:/'
|
||||||
|
|
||||||
def test_transport_url(self):
|
def test_transport_url(self):
|
||||||
transport = oslo_messaging.get_notification_transport(self.conf,
|
transport = oslo_messaging.get_notification_transport(self.conf,
|
||||||
@ -104,7 +104,7 @@ class TestKafkaDriver(test_utils.BaseTestCase):
|
|||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestKafkaDriver, self).setUp()
|
super(TestKafkaDriver, self).setUp()
|
||||||
self.messaging_conf.transport_driver = 'kafka'
|
self.messaging_conf.transport_url = 'kafka:/'
|
||||||
transport = oslo_messaging.get_notification_transport(self.conf)
|
transport = oslo_messaging.get_notification_transport(self.conf)
|
||||||
self.driver = transport._driver
|
self.driver = transport._driver
|
||||||
|
|
||||||
@ -164,7 +164,7 @@ class TestKafkaConnection(test_utils.BaseTestCase):
|
|||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestKafkaConnection, self).setUp()
|
super(TestKafkaConnection, self).setUp()
|
||||||
self.messaging_conf.transport_driver = 'kafka'
|
self.messaging_conf.transport_url = 'kafka:/'
|
||||||
transport = oslo_messaging.get_notification_transport(self.conf)
|
transport = oslo_messaging.get_notification_transport(self.conf)
|
||||||
self.driver = transport._driver
|
self.driver = transport._driver
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ class TestDeprecatedRabbitDriverLoad(test_utils.BaseTestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestDeprecatedRabbitDriverLoad, self).setUp(
|
super(TestDeprecatedRabbitDriverLoad, self).setUp(
|
||||||
conf=cfg.ConfigOpts())
|
conf=cfg.ConfigOpts())
|
||||||
self.messaging_conf.transport_driver = 'rabbit'
|
self.messaging_conf.transport_url = 'rabbit:/'
|
||||||
self.config(fake_rabbit=True, group="oslo_messaging_rabbit")
|
self.config(fake_rabbit=True, group="oslo_messaging_rabbit")
|
||||||
|
|
||||||
def test_driver_load(self):
|
def test_driver_load(self):
|
||||||
@ -52,7 +52,7 @@ class TestDeprecatedRabbitDriverLoad(test_utils.BaseTestCase):
|
|||||||
url = driver._get_connection()._url
|
url = driver._get_connection()._url
|
||||||
|
|
||||||
self.assertIsInstance(driver, rabbit_driver.RabbitDriver)
|
self.assertIsInstance(driver, rabbit_driver.RabbitDriver)
|
||||||
self.assertEqual('memory:////', url)
|
self.assertEqual('memory:///', url)
|
||||||
|
|
||||||
|
|
||||||
class TestHeartbeat(test_utils.BaseTestCase):
|
class TestHeartbeat(test_utils.BaseTestCase):
|
||||||
@ -137,12 +137,9 @@ class TestRabbitQos(test_utils.BaseTestCase):
|
|||||||
class TestRabbitDriverLoad(test_utils.BaseTestCase):
|
class TestRabbitDriverLoad(test_utils.BaseTestCase):
|
||||||
|
|
||||||
scenarios = [
|
scenarios = [
|
||||||
('rabbit', dict(transport_driver='rabbit',
|
('rabbit', dict(transport_url='rabbit:/guest:guest@localhost:5672//')),
|
||||||
url='amqp://guest:guest@localhost:5672//')),
|
('kombu', dict(transport_url='kombu:/guest:guest@localhost:5672//')),
|
||||||
('kombu', dict(transport_driver='kombu',
|
('rabbit+memory', dict(transport_url='kombu+memory:/'))
|
||||||
url='amqp://guest:guest@localhost:5672//')),
|
|
||||||
('rabbit+memory', dict(transport_driver='kombu+memory',
|
|
||||||
url='memory:///'))
|
|
||||||
]
|
]
|
||||||
|
|
||||||
@mock.patch('oslo_messaging._drivers.impl_rabbit.Connection.ensure')
|
@mock.patch('oslo_messaging._drivers.impl_rabbit.Connection.ensure')
|
||||||
@ -150,14 +147,12 @@ class TestRabbitDriverLoad(test_utils.BaseTestCase):
|
|||||||
def test_driver_load(self, fake_ensure, fake_reset):
|
def test_driver_load(self, fake_ensure, fake_reset):
|
||||||
self.config(heartbeat_timeout_threshold=60,
|
self.config(heartbeat_timeout_threshold=60,
|
||||||
group='oslo_messaging_rabbit')
|
group='oslo_messaging_rabbit')
|
||||||
self.messaging_conf.transport_driver = self.transport_driver
|
self.messaging_conf.transport_url = self.transport_url
|
||||||
transport = oslo_messaging.get_transport(self.conf)
|
transport = oslo_messaging.get_transport(self.conf)
|
||||||
self.addCleanup(transport.cleanup)
|
self.addCleanup(transport.cleanup)
|
||||||
driver = transport._driver
|
driver = transport._driver
|
||||||
url = driver._get_connection()._url
|
|
||||||
|
|
||||||
self.assertIsInstance(driver, rabbit_driver.RabbitDriver)
|
self.assertIsInstance(driver, rabbit_driver.RabbitDriver)
|
||||||
self.assertEqual(self.url, url)
|
|
||||||
|
|
||||||
|
|
||||||
class TestRabbitDriverLoadSSL(test_utils.BaseTestCase):
|
class TestRabbitDriverLoadSSL(test_utils.BaseTestCase):
|
||||||
@ -389,7 +384,7 @@ class TestRabbitTransportURL(test_utils.BaseTestCase):
|
|||||||
|
|
||||||
scenarios = [
|
scenarios = [
|
||||||
('none', dict(url=None,
|
('none', dict(url=None,
|
||||||
expected=["amqp://guest:guest@localhost:5672//"])),
|
expected=["amqp://guest:guest@localhost:5672/"])),
|
||||||
('memory', dict(url='kombu+memory:////',
|
('memory', dict(url='kombu+memory:////',
|
||||||
expected=["memory:///"])),
|
expected=["memory:///"])),
|
||||||
('empty',
|
('empty',
|
||||||
@ -426,7 +421,7 @@ class TestRabbitTransportURL(test_utils.BaseTestCase):
|
|||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestRabbitTransportURL, self).setUp()
|
super(TestRabbitTransportURL, self).setUp()
|
||||||
self.messaging_conf.transport_driver = 'rabbit'
|
self.messaging_conf.transport_url = 'rabbit:/'
|
||||||
self.config(heartbeat_timeout_threshold=0,
|
self.config(heartbeat_timeout_threshold=0,
|
||||||
group='oslo_messaging_rabbit')
|
group='oslo_messaging_rabbit')
|
||||||
|
|
||||||
|
@ -49,10 +49,11 @@ class TestConfFixture(test_utils.BaseTestCase):
|
|||||||
def test_fixture_properties(self):
|
def test_fixture_properties(self):
|
||||||
conf = self.messaging_conf.conf
|
conf = self.messaging_conf.conf
|
||||||
self.messaging_conf.transport_driver = 'fake'
|
self.messaging_conf.transport_driver = 'fake'
|
||||||
self.assertEqual('fake',
|
self.messaging_conf.transport_url = 'fake:/vhost'
|
||||||
self.messaging_conf.transport_driver)
|
self.assertEqual('fake', self.messaging_conf.transport_driver)
|
||||||
self.assertEqual('fake',
|
self.assertEqual('fake', conf.rpc_backend)
|
||||||
conf.rpc_backend)
|
self.assertEqual('fake:/vhost', self.messaging_conf.transport_url)
|
||||||
|
self.assertEqual('fake:/vhost', conf.transport_url)
|
||||||
|
|
||||||
def test_old_notifications_config_override(self):
|
def test_old_notifications_config_override(self):
|
||||||
conf = self.messaging_conf.conf
|
conf = self.messaging_conf.conf
|
||||||
|
@ -35,7 +35,7 @@ class BaseTestCase(base.BaseTestCase):
|
|||||||
|
|
||||||
from oslo_messaging import conffixture
|
from oslo_messaging import conffixture
|
||||||
self.messaging_conf = self.useFixture(conffixture.ConfFixture(conf))
|
self.messaging_conf = self.useFixture(conffixture.ConfFixture(conf))
|
||||||
self.messaging_conf.transport_driver = 'fake'
|
self.messaging_conf.transport_url = 'fake:/'
|
||||||
self.conf = self.messaging_conf.conf
|
self.conf = self.messaging_conf.conf
|
||||||
|
|
||||||
self.conf.project = 'project'
|
self.conf.project = 'project'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user