From 943be8560dd9410de6b0f507d9dbc85df0c1d928 Mon Sep 17 00:00:00 2001 From: Matt Riedemann Date: Wed, 6 Sep 2017 15:52:51 -0400 Subject: [PATCH] Fix test_rpc_consumer_isolation for oslo.messaging 5.31.0 With this change in oslo.messaging 5.31.0: I0bbf9fca0ecbe71efa87c9613ffd32eb718f2c0e The endpoint passed in is going to be checked for a 'target' attribute and check it's type if set, so looking for it has to be ignored. There are also some services tests that are mocking out what is eventually an rpc endpoint and those need to specifically set the target attribute to None otherwise .get() on the Mock will return another Mock and cause a failure. Change-Id: Ic12df8b12b1379f902137d49b605daaf0b89801d Closes-Bug: #1715470 --- nova/tests/unit/test_service.py | 6 +++--- nova/tests/unit/test_test.py | 9 +++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/nova/tests/unit/test_service.py b/nova/tests/unit/test_service.py index 7d08bfb42275..5b83d5496aad 100644 --- a/nova/tests/unit/test_service.py +++ b/nova/tests/unit/test_service.py @@ -118,7 +118,7 @@ class ServiceTestCase(test.NoDBTestCase): def test_init_and_start_hooks(self, mock_get_by_host_and_binary, mock_create): mock_get_by_host_and_binary.return_value = None - mock_manager = mock.Mock() + mock_manager = mock.Mock(target=None) serv = service.Service(self.host, self.binary, self.topic, @@ -195,7 +195,7 @@ class ServiceTestCase(test.NoDBTestCase): mock_get_by_host_and_binary, mock_create): mock_get_by_host_and_binary.return_value = None - mock_manager = mock.Mock() + mock_manager = mock.Mock(target=None) serv = service.Service(self.host, self.binary, self.topic, @@ -218,7 +218,7 @@ class ServiceTestCase(test.NoDBTestCase): @mock.patch('nova.objects.service.Service.get_by_host_and_binary') def test_parent_graceful_shutdown_with_cleanup_host( self, mock_svc_get_by_host_and_binary, mock_API): - mock_manager = mock.Mock() + mock_manager = mock.Mock(target=None) serv = service.Service(self.host, self.binary, diff --git a/nova/tests/unit/test_test.py b/nova/tests/unit/test_test.py index e07cb8c75464..2a2d75e1b446 100644 --- a/nova/tests/unit/test_test.py +++ b/nova/tests/unit/test_test.py @@ -44,8 +44,13 @@ class IsolationTestCase(test.TestCase): def test_rpc_consumer_isolation(self): class NeverCalled(object): - def __getattribute__(*args): - assert False, "I should never get called." + def __getattribute__(self, name): + if name == 'target': + # oslo.messaging 5.31.0 explicitly looks for 'target' + # on the endpoint and checks it's type, so we can't avoid + # it here, just ignore it if that's the case. + return + assert False, "I should never get called. name: %s" % name server = rpc.get_server(messaging.Target(topic='compute', server=CONF.host),