Reintroduces fake_rabbit config option

This change reintroduces the fake_rabbit only for backward compatibility,
but mark it as deprecated.

Now, to use the kombu in-memory driver (that is not thread safe) we must
set the transport_url config option to 'kombu+memory:////" or the
rpc_backend to kombu+memory.

Or we can use the fake driver of oslo.messaging by setting the
transport_url to 'fake:///' or the rpc_backend to 'fake'

This is effectively reverting commit bcb3b23b8f.

Closes-bug: #1399085

Change-Id: I7b6fb3811fc6f695f75ecd350e04e69afd26c428
This commit is contained in:
Mehdi Abaakouk 2014-12-04 08:10:13 +01:00 committed by Doug Hellmann
parent 554ad9d035
commit 712f6e3c5e
2 changed files with 31 additions and 1 deletions

View File

@ -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')

View File

@ -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):