[oslo] How to properly cleanup FakeExchangeManager between test cases

Doug Hellmann doug at doughellmann.com
Mon Feb 18 13:47:11 UTC 2019


Balázs Gibizer <balazs.gibizer at ericsson.com> writes:

> Hi,
>
> Nova has tests that are using the oslo.messaging FakeDriver 
> implementation by providing the 'fake://' transport url. The 
> FakeExchangeManager keeps a class level dict of FakeExchange objects 
> keyed by the communication topic[1]. This can cause that an RPC message 
> sent by a test case is received by a later test case running in the 
> same process. I did not find any proper way to clean up the 
> FakeExchangeManager at the end of each test case to prevent this. To 
> fix the problem in the nova test I did a hackish cleanup by overwriting 
> FakeExchangeManager._exchanges directly during test case cleanup [2]. 
> Is there a better way to do this cleanup?
>
> Cheers,
> gibi
>
> [1] 
> https://github.com/openstack/oslo.messaging/blob/0a784d260465bc7ba878bedeb5c1f184e5ff6e2e/oslo_messaging/_drivers/impl_fake.py#L149
> [2] https://review.openstack.org/#/c/637233/1/nova/tests/fixtures.py

It sounds like we need a test fixture to manage that, added to
oslo.messaging so if the internal implementation of the fake driver
changes we can update the fixture without breaking consumers of the
library (and where it would be deemed "safe" to modify private
properties of the class).

I'm sure the Oslo team would be happy to review patches to create that.

-- 
Doug



More information about the openstack-discuss mailing list