From a85ce04fa39e60e672e4fa2d7912f6880079c6ef Mon Sep 17 00:00:00 2001 From: Balazs Gibizer Date: Tue, 2 Jul 2019 14:56:40 +0200 Subject: [PATCH] Stabilize unshelve notification sample tests The notification sample test for unshelve waits for the instance to reach ACTIVE state and then asserts if unshelve.end notification is emitted properly. However the instance.vm_state is set to ACTIVE earlier[1] than emitting the unshelve.end notification[2]. This can cause two different test case failure. 1) _test_unshelve_server() fails with no ushelve.end notification received. 2) _test_shelve_and_shelve_offload_server() also has a unshelve action at the end and that test step also only waits for the the ACTIVE state. So the unshelve.end notification from the end of _test_shelve_and_shelve_offload_server() can bleed into the _test_unshelve_server() step causing that it receive one more notifications. So this patch adds an extra self._wait_for_notification('instance.unshelve.end') call to each test step to prevent the instability. [1] https://github.com/openstack/nova/blob/5c6c1f8f/nova/compute/manager.py#L5322-L5326 [2] https://github.com/openstack/nova/blob/5c6c1f8f/nova/compute/manager.py#L5329 [3] https://github.com/openstack/nova/blob/5c6c1f8f/nova/tests/functional/notification_sample_tests/test_instance.py#L836 Conflicts: nova/tests/functional/notification_sample_tests/test_instance.py Conflicts due to: * I019e88fabd1d386c0d6395a7b1969315873485fd Closes-Bug: #1835070 Change-Id: Ie217523a8969326b27930d7f74e50e9b352ab7a1 (cherry picked from commit 40f1e7c4c22dc6023614b34f28bb7fc416b668a8) (cherry picked from commit 3bc6ff029ff24083844db363010988d8d08cff00) --- .../tests/functional/notification_sample_tests/test_instance.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nova/tests/functional/notification_sample_tests/test_instance.py b/nova/tests/functional/notification_sample_tests/test_instance.py index 4db2ef596975..9743f73627ff 100644 --- a/nova/tests/functional/notification_sample_tests/test_instance.py +++ b/nova/tests/functional/notification_sample_tests/test_instance.py @@ -752,6 +752,7 @@ class TestInstanceNotificationSample( self.api.post_server_action(server['id'], {'unshelve': None}) self._wait_for_state_change(self.api, server, 'ACTIVE') + self._wait_for_notification('instance.unshelve.end') def _test_unshelve_server(self, server): # setting the shelved_offload_time to 0 should set the @@ -769,6 +770,7 @@ class TestInstanceNotificationSample( post = {'unshelve': None} self.api.post_server_action(server['id'], post) self._wait_for_state_change(self.admin_api, server, 'ACTIVE') + self._wait_for_notification('instance.unshelve.end') self.assertEqual(7, len(fake_notifier.VERSIONED_NOTIFICATIONS)) self._verify_notification( 'instance-unshelve-start',