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]. But neutron-lib needs the 14.2.0 [3] version to override the client class. [1] https://review.opendev.org/c/openstack/requirements/+/869340 [2] https://review.opendev.org/c/openstack/oslo.messaging/+/862419 [3] https://review.opendev.org/c/openstack/releases/+/872383 Depends-On: https://review.opendev.org/c/openstack/oslo.messaging/+/869899 Depends-On: https://review.opendev.org/c/openstack/releases/+/872383 Change-Id: I591c366df99e371659ee46d45c1c77dd3f6c74a1
This commit is contained in:
parent
b1a4f783da
commit
12380e9304
@ -213,10 +213,9 @@ def get_client(target, version_cap=None, serializer=None):
|
||||
if TRANSPORT is None:
|
||||
raise AssertionError(_("'TRANSPORT' must not be None"))
|
||||
serializer = RequestContextSerializer(serializer)
|
||||
return BackingOffClient(TRANSPORT,
|
||||
target,
|
||||
version_cap=version_cap,
|
||||
serializer=serializer)
|
||||
return oslo_messaging.get_rpc_client(
|
||||
TRANSPORT, target, version_cap=version_cap,
|
||||
serializer=serializer, client_cls=BackingOffClient)
|
||||
|
||||
|
||||
def get_server(target, endpoints, serializer=None):
|
||||
|
@ -104,20 +104,21 @@ class TestRPC(base.BaseTestCase):
|
||||
rpc.NOTIFICATION_TRANSPORT = mock.Mock()
|
||||
|
||||
@mock.patch.object(rpc, 'RequestContextSerializer')
|
||||
@mock.patch.object(rpc, 'BackingOffClient')
|
||||
def test_get_client(self, mock_client, mock_ser):
|
||||
@mock.patch.object(messaging, 'get_rpc_client')
|
||||
def test_get_client(self, mock_get, mock_ser):
|
||||
rpc.TRANSPORT = mock.Mock()
|
||||
tgt = mock.Mock()
|
||||
ser = mock.Mock()
|
||||
mock_client.return_value = 'client'
|
||||
mock_get.return_value = 'client'
|
||||
mock_ser.return_value = ser
|
||||
|
||||
client = rpc.get_client(tgt, version_cap='1.0', serializer='foo')
|
||||
|
||||
mock_ser.assert_called_once_with('foo')
|
||||
mock_client.assert_called_once_with(rpc.TRANSPORT,
|
||||
tgt, version_cap='1.0',
|
||||
serializer=ser)
|
||||
mock_get.assert_called_once_with(rpc.TRANSPORT,
|
||||
tgt, version_cap='1.0',
|
||||
serializer=ser,
|
||||
client_cls=rpc.BackingOffClient)
|
||||
self.assertEqual('client', client)
|
||||
|
||||
@mock.patch.object(rpc, 'RequestContextSerializer')
|
||||
|
@ -20,7 +20,7 @@ oslo.context>=2.22.0 # Apache-2.0
|
||||
oslo.db>=4.44.0 # Apache-2.0
|
||||
oslo.i18n>=3.20.0 # Apache-2.0
|
||||
oslo.log>=4.3.0 # Apache-2.0
|
||||
oslo.messaging>=7.0.0 # Apache-2.0
|
||||
oslo.messaging>=14.2.0 # Apache-2.0
|
||||
oslo.policy>=3.6.2 # Apache-2.0
|
||||
oslo.serialization>=2.25.0 # Apache-2.0
|
||||
oslo.service!=1.28.1,>=1.24.0 # Apache-2.0
|
||||
|
Loading…
Reference in New Issue
Block a user