[openstack-dev] [nova] How to enforce that no new legacy notification is added

Balázs Gibizer balazs.gibizer at ericsson.com
Fri Feb 5 14:41:00 UTC 2016


Hi, 

Background: Versioned notification infra [1] is merged and 
on the midcycle we agreed that we don't allow new legacy notification [2].

I promised to create some automated way to detect if a new legacy
notification is proposed in a review. I implemented [3] a monkey patch
in the test that checks the event_type passed to the legacy notifier
against a whitelist. This approach has obvious limitations when the
new event_type is not detected:
- if there is no test for the new event_type
- if there is test but it mocks the nova.rpc.get_notifier directly [4]
(fake_notifier is not a problem)

To overcome these limitations I investigated if a new hacking rule
can be added but I didn't find the way to detect the missing cases.
The main problem is that the result of the nova.rpc.get_notifier is
often wrapped, renamed and passed around. So with only syntactic
information available in hacking the new calls on that notifier object
is impossible to detect.

I tried to monkey patch the mock library itself (I know I'm evil) to detect
at least the second case but I failed. [5]

Now I'm out of ideas. So any suggestion what to try next is appreciated.

Cheers,
Gibi

[1] https://review.openstack.org/#/q/status:merged+project:openstack/nova+branch:master+topic:bp/versioned-notification-api 
[2] https://review.openstack.org/#/c/273506/ 
[3] https://review.openstack.org/#/c/276363/ 
[4] https://github.com/openstack/nova/blob/master/nova/tests/unit/compute/test_resource_tracker.py#L1233 
[5] https://review.openstack.org/#/c/276759 





More information about the OpenStack-dev mailing list