[oslo] How to properly cleanup FakeExchangeManager between test cases

Balázs Gibizer balazs.gibizer at ericsson.com
Mon Feb 18 09:59:56 UTC 2019


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




More information about the openstack-discuss mailing list