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:
parent
554ad9d035
commit
712f6e3c5e
@ -100,6 +100,12 @@ rabbit_opts = [
|
|||||||
help='Use HA queues in RabbitMQ (x-ha-policy: all). '
|
help='Use HA queues in RabbitMQ (x-ha-policy: all). '
|
||||||
'If you change this option, you must wipe the '
|
'If you change this option, you must wipe the '
|
||||||
'RabbitMQ database.'),
|
'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__)
|
LOG = logging.getLogger(__name__)
|
||||||
@ -441,7 +447,12 @@ class Connection(object):
|
|||||||
virtual_host = self.conf.rabbit_virtual_host
|
virtual_host = self.conf.rabbit_virtual_host
|
||||||
|
|
||||||
self._url = ''
|
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:
|
for host in url.hosts:
|
||||||
transport = url.transport.replace('kombu+', '')
|
transport = url.transport.replace('kombu+', '')
|
||||||
transport = url.transport.replace('rabbit', 'amqp')
|
transport = url.transport.replace('rabbit', 'amqp')
|
||||||
|
@ -24,6 +24,7 @@ import mock
|
|||||||
from oslotest import mockpatch
|
from oslotest import mockpatch
|
||||||
import testscenarios
|
import testscenarios
|
||||||
|
|
||||||
|
from oslo.config import cfg
|
||||||
from oslo import messaging
|
from oslo import messaging
|
||||||
from oslo.messaging._drivers import amqpdriver
|
from oslo.messaging._drivers import amqpdriver
|
||||||
from oslo.messaging._drivers import common as driver_common
|
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
|
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):
|
class TestRabbitDriverLoad(test_utils.BaseTestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user