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 <sfinucan@redhat.com>
Closes-Bug: #1885923
This commit is contained in:
Stephen Finucane 2020-07-01 15:01:00 +01:00
parent 7e406c312a
commit afb035d971
1 changed files with 9 additions and 6 deletions

View File

@ -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,