Remove rpc_backend and ConfFixture.transport_driver

Now that most projects have transitioned from using
ConfFixture.transport_driver, we can remove it and rpc_backend as a
whole. rpc_backend was first deprecated in 5.10.0, released during
Ocata.

Closes-Bug: #1712399
Change-Id: I193cc0e613459a6dbbfd54ed0901a54ded78d712
This commit is contained in:
Steve Kowalik 2018-09-13 15:01:27 -06:00
parent 3b1b08b74a
commit d3f6ca0b47
6 changed files with 20 additions and 99 deletions

View File

@ -114,15 +114,6 @@ class ConfFixture(fixtures.Fixture):
self.addCleanup(self._teardown_decorator)
self.addCleanup(self.conf.reset)
@property
def transport_driver(self):
"""The transport driver - for example 'rabbit', 'amqp' or 'fake'."""
return self.conf.rpc_backend
@transport_driver.setter
def transport_driver(self, value):
self.conf.set_override('rpc_backend', value)
@property
def transport_url(self):
"""The transport url"""

View File

@ -48,10 +48,7 @@ class TestConfFixture(test_utils.BaseTestCase):
def test_fixture_properties(self):
conf = self.messaging_conf.conf
self.messaging_conf.transport_driver = 'fake'
self.messaging_conf.transport_url = 'fake:/vhost'
self.assertEqual('fake', self.messaging_conf.transport_driver)
self.assertEqual('fake', conf.rpc_backend)
self.assertEqual('fake:/vhost', self.messaging_conf.transport_url)
self.assertEqual('fake:/vhost', conf.transport_url)

View File

@ -37,9 +37,6 @@ class OptsTestCase(test_utils.BaseTestCase):
self.assertIn('oslo_messaging_rabbit', groups)
self.assertIn('oslo_messaging_kafka', groups)
opt_names = [o.name for (g, l) in result for o in l]
self.assertIn('rpc_backend', opt_names)
def test_list_opts(self):
self._test_list_opts(opts.list_opts())

View File

@ -51,36 +51,29 @@ class _FakeManager(object):
class GetTransportTestCase(test_utils.BaseTestCase):
scenarios = [
('rpc_backend',
dict(url=None, transport_url=None, rpc_backend='testbackend',
control_exchange=None, allowed=None,
expect=dict(backend='testbackend',
exchange=None,
url='testbackend:',
allowed=[]))),
('transport_url',
dict(url=None, transport_url='testtransport:', rpc_backend=None,
dict(url=None, transport_url='testtransport:',
control_exchange=None, allowed=None,
expect=dict(backend='testtransport',
exchange=None,
url='testtransport:',
allowed=[]))),
('url_param',
dict(url='testtransport:', transport_url=None, rpc_backend=None,
dict(url='testtransport:', transport_url=None,
control_exchange=None, allowed=None,
expect=dict(backend='testtransport',
exchange=None,
url='testtransport:',
allowed=[]))),
('control_exchange',
dict(url=None, transport_url=None, rpc_backend='testbackend',
dict(url=None, transport_url='testbackend:',
control_exchange='testexchange', allowed=None,
expect=dict(backend='testbackend',
exchange='testexchange',
url='testbackend:',
allowed=[]))),
('allowed_remote_exmods',
dict(url=None, transport_url=None, rpc_backend='testbackend',
dict(url=None, transport_url='testbackend:',
control_exchange=None, allowed=['foo', 'bar'],
expect=dict(backend='testbackend',
exchange=None,
@ -90,8 +83,7 @@ class GetTransportTestCase(test_utils.BaseTestCase):
@mock.patch('oslo_messaging.transport.LOG')
def test_get_transport(self, fake_logger):
self.config(rpc_backend=self.rpc_backend,
control_exchange=self.control_exchange,
self.config(control_exchange=self.control_exchange,
transport_url=self.transport_url)
driver.DriverManager = mock.Mock()
@ -127,29 +119,27 @@ class GetTransportSadPathTestCase(test_utils.BaseTestCase):
scenarios = [
('invalid_transport_url',
dict(url=None, transport_url='invalid', rpc_backend=None,
dict(url=None, transport_url='invalid',
ex=dict(cls=oslo_messaging.InvalidTransportURL,
msg_contains='No scheme specified',
url='invalid'))),
('invalid_url_param',
dict(url='invalid', transport_url=None, rpc_backend=None,
dict(url='invalid', transport_url=None,
ex=dict(cls=oslo_messaging.InvalidTransportURL,
msg_contains='No scheme specified',
url='invalid'))),
('driver_load_failure',
dict(url=None, transport_url=None, rpc_backend='testbackend',
dict(url=None, transport_url='testbackend:/',
ex=dict(cls=oslo_messaging.DriverLoadFailure,
msg_contains='Failed to load',
driver='testbackend'))),
]
def test_get_transport_sad(self):
self.config(rpc_backend=self.rpc_backend,
transport_url=self.transport_url)
if self.rpc_backend:
driver.DriverManager = mock.Mock()
self.config(transport_url=self.transport_url)
driver.DriverManager = mock.Mock()
try:
invoke_args = [self.conf,
oslo_messaging.TransportURL.parse(self.conf,
self.url)]
@ -157,16 +147,10 @@ class GetTransportSadPathTestCase(test_utils.BaseTestCase):
allowed_remote_exmods=[])
driver.DriverManager.side_effect = RuntimeError()
try:
oslo_messaging.get_transport(self.conf, url=self.url)
self.assertFalse(True)
driver.DriverManager.\
assert_called_once_with('oslo.messaging.drivers',
self.rpc_backend,
invoke_on_load=True,
invoke_args=invoke_args,
invoke_kwds=invoke_kwds)
driver.DriverManager.assert_called_once_with(
'oslo.messaging.drivers', invoke_on_load=True,
invoke_args=invoke_args, invoke_kwds=invoke_kwds)
except Exception as ex:
ex_cls = self.ex.pop('cls')
ex_msg_contains = self.ex.pop('msg_contains')

View File

@ -131,8 +131,6 @@ class TestParseURL(test_utils.BaseTestCase):
]
def test_parse_url(self):
self.config(rpc_backend=None)
url = oslo_messaging.TransportURL.parse(self.conf, self.url)
hosts = []
@ -152,27 +150,18 @@ class TestParseURL(test_utils.BaseTestCase):
class TestFormatURL(test_utils.BaseTestCase):
scenarios = [
('rpc_backend',
dict(rpc_backend='testbackend',
transport=None,
virtual_host=None,
hosts=[],
expected='testbackend:///')),
('transport',
dict(rpc_backend=None,
transport='testtransport',
dict(transport='testtransport',
virtual_host=None,
hosts=[],
expected='testtransport:///')),
('virtual_host',
dict(rpc_backend=None,
transport='testtransport',
dict(transport='testtransport',
virtual_host='/vhost',
hosts=[],
expected='testtransport:////vhost')),
('host',
dict(rpc_backend=None,
transport='testtransport',
dict(transport='testtransport',
virtual_host='/',
hosts=[
dict(hostname='host',
@ -182,8 +171,7 @@ class TestFormatURL(test_utils.BaseTestCase):
],
expected='testtransport://bob:secret@host:10//')),
('multi_host',
dict(rpc_backend=None,
transport='testtransport',
dict(transport='testtransport',
virtual_host='',
hosts=[
dict(hostname='h1',
@ -197,8 +185,7 @@ class TestFormatURL(test_utils.BaseTestCase):
],
expected='testtransport://b1:s1@h1:1000,b2:s2@h2:2000/')),
('quoting',
dict(rpc_backend=None,
transport='testtransport',
dict(transport='testtransport',
virtual_host='/$',
hosts=[
dict(hostname='host',
@ -210,8 +197,6 @@ class TestFormatURL(test_utils.BaseTestCase):
]
def test_parse_url(self):
self.config(rpc_backend=self.rpc_backend)
hosts = []
for host in self.hosts:
hosts.append(oslo_messaging.TransportHost(host.get('hostname'),

View File

@ -53,12 +53,6 @@ _transport_opts = [
'documentation of oslo_messaging.TransportURL at '
'https://docs.openstack.org/oslo.messaging/latest/'
'reference/transport.html'),
cfg.StrOpt('rpc_backend',
deprecated_for_removal=True,
deprecated_reason="Replaced by [DEFAULT]/transport_url",
default='rabbit',
help='The messaging driver to use, defaults to rabbit. Other '
'drivers include amqp.'),
cfg.StrOpt('control_exchange',
default='openstack',
@ -339,7 +333,7 @@ class TransportURL(object):
query=None):
self.conf = conf
self.conf.register_opts(_transport_opts)
self._transport = transport
self.transport = transport
self.virtual_host = virtual_host
if hosts is None:
self.hosts = []
@ -350,33 +344,6 @@ class TransportURL(object):
else:
self.query = query
self._deprecation_logged = False
@property
def transport(self):
if self._transport is None:
transport = self.conf.rpc_backend
else:
transport = self._transport
final_transport = transport
if not self._deprecation_logged and final_transport != transport:
# NOTE(sileht): The first step is deprecate this one cycle.
# To ensure deployer have updated they configuration during Ocata
# Then in P we will deprecate aliases kwargs of TransportURL() and
# get_transport() for consuming application
LOG.warning('legacy "rpc_backend" is deprecated, '
'"%(legacy_transport)s" must be replaced by '
'"%(final_transport)s"' % {
'legacy_transport': transport,
'final_transport': final_transport})
self._deprecation_logged = True
return final_transport
@transport.setter
def transport(self, value):
self._transport = value
def __hash__(self):
return hash((tuple(self.hosts), self.transport, self.virtual_host))