From afb035d97185fa9c622bdb9b4c31c71f01160370 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Wed, 1 Jul 2020 15:01:00 +0100 Subject: [PATCH] tests: Resolves issues with kombu > 4.6.8 The 'kombu.connection.Connection.ensure_connection' method has changed from calling 'retry_over_time' on 'self.connect' to calling it on 'self._connection_factory' [1], meaning our mocks are outdated. Address this change. [1] https://github.com/celery/kombu/pull/1193/commits/398aa5b8cd1fe1fc Change-Id: Ibbcf21a57ab1e3f90c21901296e5c088b645127c Signed-off-by: Stephen Finucane Closes-Bug: #1885923 --- oslo_messaging/tests/drivers/test_impl_rabbit.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/oslo_messaging/tests/drivers/test_impl_rabbit.py b/oslo_messaging/tests/drivers/test_impl_rabbit.py index 2966bb52a..e70a778fe 100644 --- a/oslo_messaging/tests/drivers/test_impl_rabbit.py +++ b/oslo_messaging/tests/drivers/test_impl_rabbit.py @@ -17,11 +17,11 @@ import ssl import sys import threading import time -import unittest import uuid import fixtures import kombu +import kombu.connection import kombu.transport.memory from oslo_serialization import jsonutils from oslo_utils import eventletutils @@ -973,16 +973,21 @@ class RpcKombuHATestCase(test_utils.BaseTestCase): 'kombu.connection.Connection.connection')) self.useFixture(fixtures.MockPatch( 'kombu.connection.Connection.channel')) + # TODO(stephenfin): Drop hasattr when we drop support for kombo < 4.6.8 + if hasattr(kombu.connection.Connection, '_connection_factory'): + self.useFixture(fixtures.MockPatch( + 'kombu.connection.Connection._connection_factory')) # starting from the first broker in the list url = oslo_messaging.TransportURL.parse(self.conf, None) self.connection = rabbit_driver.Connection(self.conf, url, driver_common.PURPOSE_SEND) - self.useFixture(fixtures.MockPatch( - 'kombu.connection.Connection.connect')) + # TODO(stephenfin): Remove when we drop support for kombo < 4.6.8 + if hasattr(kombu.connection.Connection, 'connect'): + self.useFixture(fixtures.MockPatch( + 'kombu.connection.Connection.connect')) self.addCleanup(self.connection.close) - @unittest.skip("bug #1885923") def test_ensure_four_retry(self): mock_callback = mock.Mock(side_effect=IOError) self.assertRaises(oslo_messaging.MessageDeliveryFailure, @@ -990,7 +995,6 @@ class RpcKombuHATestCase(test_utils.BaseTestCase): retry=4) self.assertEqual(6, mock_callback.call_count) - @unittest.skip("bug #1885923") def test_ensure_one_retry(self): mock_callback = mock.Mock(side_effect=IOError) self.assertRaises(oslo_messaging.MessageDeliveryFailure, @@ -998,7 +1002,6 @@ class RpcKombuHATestCase(test_utils.BaseTestCase): retry=1) self.assertEqual(3, mock_callback.call_count) - @unittest.skip("bug #1885923") def test_ensure_no_retry(self): mock_callback = mock.Mock(side_effect=IOError) self.assertRaises(oslo_messaging.MessageDeliveryFailure,