From 6b844af57eebda6317b1ed3bf5a2f85dcba0bc13 Mon Sep 17 00:00:00 2001 From: Balazs Gibizer Date: Fri, 15 Feb 2019 18:28:29 +0100 Subject: [PATCH] Cleanup inflight rpc messages between test cases The oslo_messaging._drivers.impl_fake.FakeExchangeManager._exchanges [1] is a dict keyed by exchange name, "nova" for the nova services, and the value is a FakeExchange that simulate a message bus for our tests. It is basically a queue holding messages between FakeDriver instances running in our rpc servers. As FakeExchangeManager._exchanges is a class level variable it does not get re-initialized between test cases that are running in the same process. So one test case can put an rpc message in the exchange that gets delivered to the rpc server in a subsequent test case. This issue made visible by the first patch set of the patch[2] [1] https://github.com/openstack/oslo.messaging/blob/648ad56c8652d83d3b1cae745488bb8e0450febd/oslo_messaging/_drivers/impl_fake.py#L149 [2] https://review.openstack.org/#/c/635859/1 Change-Id: Ie60d783a970029371ec834aa26ca98252cdab83b --- nova/tests/fixtures.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nova/tests/fixtures.py b/nova/tests/fixtures.py index 73584726cf..24db14a451 100644 --- a/nova/tests/fixtures.py +++ b/nova/tests/fixtures.py @@ -788,6 +788,11 @@ class RPCFixture(fixtures.Fixture): mock_gtu.return_value = None rpc.init(CONF) + def cleanup_in_flight_rpc_messages(): + messaging._drivers.impl_fake.FakeExchangeManager._exchanges = {} + + self.addCleanup(cleanup_in_flight_rpc_messages) + class WarningsFixture(fixtures.Fixture): """Filters out warnings during test runs."""