Use new get_rpc_client API from oslo.messaging
Use the new API that is consistent with the existing API instead of instantiating the client class directly. This was introduced in release 14.1.0 here [1] and added into oslo.messaging here [2] [1] https://review.opendev.org/c/openstack/requirements/+/869340 [2] https://review.opendev.org/c/openstack/oslo.messaging/+/862419 Change-Id: Ica14ddd31fa6be22b0d1f4bed26f266c6d9f660f
This commit is contained in:
parent
324fe6e69b
commit
73e35991ff
@ -132,9 +132,8 @@ class RequestContextSerializer(messaging.Serializer):
|
|||||||
def get_client(target, version_cap=None, serializer=None):
|
def get_client(target, version_cap=None, serializer=None):
|
||||||
assert TRANSPORT is not None
|
assert TRANSPORT is not None
|
||||||
serializer = RequestContextSerializer(serializer)
|
serializer = RequestContextSerializer(serializer)
|
||||||
return messaging.RPCClient(TRANSPORT,
|
return messaging.get_rpc_client(
|
||||||
target,
|
TRANSPORT, target, version_cap=version_cap,
|
||||||
version_cap=version_cap,
|
|
||||||
serializer=serializer)
|
serializer=serializer)
|
||||||
|
|
||||||
|
|
||||||
|
@ -87,18 +87,18 @@ class RPCAPITestCase(test.TestCase):
|
|||||||
self.assertEqual(['foo', 'bar'], exmods)
|
self.assertEqual(['foo', 'bar'], exmods)
|
||||||
|
|
||||||
@mock.patch.object(rpc, 'RequestContextSerializer')
|
@mock.patch.object(rpc, 'RequestContextSerializer')
|
||||||
@mock.patch.object(messaging, 'RPCClient')
|
@mock.patch.object(messaging, 'get_rpc_client')
|
||||||
def test_get_client(self, mock_client, mock_ser):
|
def test_get_client(self, mock_get, mock_ser):
|
||||||
rpc.TRANSPORT = mock.Mock()
|
rpc.TRANSPORT = mock.Mock()
|
||||||
tgt = mock.Mock()
|
tgt = mock.Mock()
|
||||||
ser = mock.Mock()
|
ser = mock.Mock()
|
||||||
mock_client.return_value = 'client'
|
mock_get.return_value = 'client'
|
||||||
mock_ser.return_value = ser
|
mock_ser.return_value = ser
|
||||||
|
|
||||||
client = rpc.get_client(tgt, version_cap='1.0', serializer='foo')
|
client = rpc.get_client(tgt, version_cap='1.0', serializer='foo')
|
||||||
|
|
||||||
mock_ser.assert_called_once_with('foo')
|
mock_ser.assert_called_once_with('foo')
|
||||||
mock_client.assert_called_once_with(rpc.TRANSPORT,
|
mock_get.assert_called_once_with(rpc.TRANSPORT,
|
||||||
tgt, version_cap='1.0',
|
tgt, version_cap='1.0',
|
||||||
serializer=ser)
|
serializer=ser)
|
||||||
self.assertEqual('client', client)
|
self.assertEqual('client', client)
|
||||||
|
@ -11,7 +11,7 @@ microversion-parse>=0.2.1 # Apache-2.0
|
|||||||
oslo.config>=5.2.0 # Apache-2.0
|
oslo.config>=5.2.0 # Apache-2.0
|
||||||
oslo.context>=2.19.2 # Apache-2.0
|
oslo.context>=2.19.2 # Apache-2.0
|
||||||
oslo.db>=4.44.0 # Apache-2.0
|
oslo.db>=4.44.0 # Apache-2.0
|
||||||
oslo.messaging>=5.29.0 # Apache-2.0
|
oslo.messaging>=14.1.0 # Apache-2.0
|
||||||
oslo.i18n>=3.15.3 # Apache-2.0
|
oslo.i18n>=3.15.3 # Apache-2.0
|
||||||
oslo.log>=3.36.0 # Apache-2.0
|
oslo.log>=3.36.0 # Apache-2.0
|
||||||
oslo.middleware>=3.31.0 # Apache-2.0
|
oslo.middleware>=3.31.0 # Apache-2.0
|
||||||
|
Loading…
Reference in New Issue
Block a user