Use get_rpc_transport instead of get_transport

With the added get_rpc_transport() function in oslo.messaging [1]
and the recent version bump of oslo.messaging to 5.24.2, we can
safely replace get_transport() with get_rpc_transport() which is much
cleaner.

[1] https://review.openstack.org/#/c/454194/

Change-Id: If0b5a61abfd84d18834fcc74259f290a5640c3c9
This commit is contained in:
rajat29 2017-06-07 10:52:21 +05:30 committed by Rajat Sharma
parent 6b75f8cc55
commit 12e0bf96ca
2 changed files with 7 additions and 7 deletions

View File

@ -36,8 +36,8 @@ EXTRA_EXMODS = []
def init(conf):
global TRANSPORT, NOTIFICATION_TRANSPORT, NOTIFIER
exmods = get_allowed_exmods()
TRANSPORT = messaging.get_transport(conf,
allowed_remote_exmods=exmods)
TRANSPORT = messaging.get_rpc_transport(conf,
allowed_remote_exmods=exmods)
NOTIFICATION_TRANSPORT = messaging.get_notification_transport(
conf,
allowed_remote_exmods=exmods)

View File

@ -27,15 +27,15 @@ class TestUtils(base.TestCase):
@mock.patch.object(messaging, 'Notifier', autospec=True)
@mock.patch.object(messaging, 'JsonPayloadSerializer', autospec=True)
@mock.patch.object(messaging, 'get_notification_transport', autospec=True)
@mock.patch.object(messaging, 'get_transport', autospec=True)
def test_init_globals_notifications(self, mock_get_transport,
@mock.patch.object(messaging, 'get_rpc_transport', autospec=True)
def test_init_globals_notifications(self, mock_get_rpc_transport,
mock_get_notification,
mock_json_serializer,
mock_notifier):
self._test_init_globals(mock_get_transport, mock_get_notification,
self._test_init_globals(mock_get_rpc_transport, mock_get_notification,
mock_json_serializer, mock_notifier)
def _test_init_globals(self, mock_get_transport, mock_get_notification,
def _test_init_globals(self, mock_get_rpc_transport, mock_get_notification,
mock_json_serializer, mock_notifier):
rpc.TRANSPORT = None
rpc.NOTIFICATION_TRANSPORT = None
@ -50,7 +50,7 @@ class TestUtils(base.TestCase):
rpc.init(CONF)
self.assertEqual(mock_get_transport.return_value, rpc.TRANSPORT)
self.assertEqual(mock_get_rpc_transport.return_value, rpc.TRANSPORT)
self.assertEqual(mock_get_notification.return_value,
rpc.NOTIFICATION_TRANSPORT)
self.assertTrue(mock_json_serializer.called)