From 723513a9d95b6d7678cc851afdfafba41120693c Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Tue, 5 Apr 2022 17:19:13 +0100 Subject: tests: Fix test failures with kombu >= 5.2.4 kombu 5.2.4 fixed an off-by-one issue that meant we were attempting retries more than once [1]. We need to handle this to unblock the gate. This was discovered by examining the call stack and comparing this with recent changes in openstack/requirements. [1] https://github.com/celery/kombu/commit/5bed2a8f983a3bf61c12443e7704ffd89991ef9a Change-Id: I476e3c573523d5991c56b31ad4df1172196aa7f1 Signed-off-by: Stephen Finucane --- oslo_messaging/tests/drivers/test_impl_rabbit.py | 27 ++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/oslo_messaging/tests/drivers/test_impl_rabbit.py b/oslo_messaging/tests/drivers/test_impl_rabbit.py index 8955661..34c396b 100644 --- a/oslo_messaging/tests/drivers/test_impl_rabbit.py +++ b/oslo_messaging/tests/drivers/test_impl_rabbit.py @@ -1008,21 +1008,36 @@ class RpcKombuHATestCase(test_utils.BaseTestCase): self.assertRaises(oslo_messaging.MessageDeliveryFailure, self.connection.ensure, mock_callback, retry=4) - self.assertEqual(6, mock_callback.call_count) + # TODO(stephenfin): Remove when we drop support for kombu < 5.2.4 + expected = 5 + if kombu.VERSION < (5, 2, 4): + expected = 6 + self.assertEqual(expected, mock_callback.call_count) def test_ensure_one_retry(self): mock_callback = mock.Mock(side_effect=IOError) self.assertRaises(oslo_messaging.MessageDeliveryFailure, self.connection.ensure, mock_callback, retry=1) - self.assertEqual(3, mock_callback.call_count) + # TODO(stephenfin): Remove when we drop support for kombu < 5.2.4 + expected = 2 + if kombu.VERSION < (5, 2, 4): + expected = 3 + self.assertEqual(expected, mock_callback.call_count) def test_ensure_no_retry(self): mock_callback = mock.Mock(side_effect=IOError) - self.assertRaises(oslo_messaging.MessageDeliveryFailure, - self.connection.ensure, mock_callback, - retry=0) - self.assertEqual(2, mock_callback.call_count) + self.assertRaises( + oslo_messaging.MessageDeliveryFailure, + self.connection.ensure, + mock_callback, + retry=0, + ) + # TODO(stephenfin): Remove when we drop support for kombu < 5.2.4 + expected = 1 + if kombu.VERSION < (5, 2, 4): + expected = 2 + self.assertEqual(expected, mock_callback.call_count) class ConnectionLockTestCase(test_utils.BaseTestCase): -- cgit v1.2.1