diff --git a/oslo/messaging/_drivers/impl_rabbit.py b/oslo/messaging/_drivers/impl_rabbit.py index d602f0070..dd7aa5571 100644 --- a/oslo/messaging/_drivers/impl_rabbit.py +++ b/oslo/messaging/_drivers/impl_rabbit.py @@ -100,6 +100,12 @@ rabbit_opts = [ help='Use HA queues in RabbitMQ (x-ha-policy: all). ' 'If you change this option, you must wipe the ' 'RabbitMQ database.'), + + # NOTE(sileht): deprecated option since oslo.messaging 1.5.0, + cfg.BoolOpt('fake_rabbit', + default=False, + help='Deprecated, use rpc_backend=kombu+memory or ' + 'rpc_backend=fake'), ] LOG = logging.getLogger(__name__) @@ -441,7 +447,12 @@ class Connection(object): virtual_host = self.conf.rabbit_virtual_host self._url = '' - if url.hosts: + if self.conf.fake_rabbit: + LOG.warn("Deprecated: fake_rabbit option is deprecated, set " + "rpc_backend to kombu+memory or use the fake " + "driver instead.") + self._url = 'memory://%s/' % virtual_host + elif url.hosts: for host in url.hosts: transport = url.transport.replace('kombu+', '') transport = url.transport.replace('rabbit', 'amqp') diff --git a/tests/drivers/test_impl_rabbit.py b/tests/drivers/test_impl_rabbit.py index c15a3c956..577711171 100644 --- a/tests/drivers/test_impl_rabbit.py +++ b/tests/drivers/test_impl_rabbit.py @@ -24,6 +24,7 @@ import mock from oslotest import mockpatch import testscenarios +from oslo.config import cfg from oslo import messaging from oslo.messaging._drivers import amqpdriver from oslo.messaging._drivers import common as driver_common @@ -34,6 +35,24 @@ from tests import utils as test_utils load_tests = testscenarios.load_tests_apply_scenarios +class TestDeprecatedRabbitDriverLoad(test_utils.BaseTestCase): + + def setUp(self): + super(TestDeprecatedRabbitDriverLoad, self).setUp( + conf=cfg.ConfigOpts()) + self.messaging_conf.transport_driver = 'rabbit' + self.config(fake_rabbit=True) + + def test_driver_load(self): + transport = messaging.get_transport(self.conf) + self.addCleanup(transport.cleanup) + driver = transport._driver + url = driver._get_connection()._url + + self.assertIsInstance(driver, rabbit_driver.RabbitDriver) + self.assertEqual('memory:////', url) + + class TestRabbitDriverLoad(test_utils.BaseTestCase): def setUp(self):