From 9d1b90c7f5eeeba2409bd9371e72ed334ecf1cf7 Mon Sep 17 00:00:00 2001 From: Mehdi Abaakouk Date: Thu, 1 Dec 2016 20:27:14 +0100 Subject: [PATCH] Remove ordering assumption from functional test oslo.messaging doesn't ensure ordering of notification. By chance that works for some driver/setup. But for example zmq job often fail this one. This changes removes this assumption. That fixes the zmq gate job Change-Id: I2087f0a219a4a5b8fb30bb8ed84e1a72f8d9e0ab --- .../tests/functional/test_functional.py | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/oslo_messaging/tests/functional/test_functional.py b/oslo_messaging/tests/functional/test_functional.py index 9851a4c7c..83116482b 100644 --- a/oslo_messaging/tests/functional/test_functional.py +++ b/oslo_messaging/tests/functional/test_functional.py @@ -297,19 +297,15 @@ class NotifyTestCase(utils.SkipIfNoTransportURL): for event_type, payload in b_out: b.info({}, event_type, payload) - for expected in a_out: - actual = listener_a.events.get(timeout=0.5) - self.assertEqual('info', actual[0]) - self.assertEqual(expected[0], actual[1]) - self.assertEqual(expected[1], actual[2]) - self.assertEqual('pub-1', actual[3]) + def check_received(listener, publisher, messages): + actuals = sorted([listener.events.get(timeout=0.5) + for __ in range(len(a_out))]) + expected = sorted([['info', m[0], m[1], publisher] + for m in messages]) + self.assertEqual(expected, actuals) - for expected in b_out: - actual = listener_b.events.get(timeout=0.5) - self.assertEqual('info', actual[0]) - self.assertEqual(expected[0], actual[1]) - self.assertEqual(expected[1], actual[2]) - self.assertEqual('pub-2', actual[3]) + check_received(listener_a, "pub-1", a_out) + check_received(listener_b, "pub-2", b_out) def test_all_categories(self): listener = self.useFixture(utils.NotificationFixture(