From b5dca17f74b7a789e16b78178ae5874a30f3e0da Mon Sep 17 00:00:00 2001 From: Balazs Gibizer Date: Thu, 5 Oct 2017 14:01:35 +0200 Subject: [PATCH] fix unstable shelve offload functional tests The functional tests that are shelved offloaded instances and asserted that the resource allocation of the instance are freed were unstable. These tests only waited for the instance state to become SHELVED_OFFLOADED before checked the allocations. However the compute manager sets the instance state to SHELVED_OFFLOADED before deleting the allocations[1]. Therefore these tests were racy. With this patch the test will wait not only for the instance status to change but also for the instance host to be nulled as that happens after the resources are freed. [1] https://github.com/openstack/nova/blob/e4f89ed5dd4259188d020749fa8fb1c77be2c03a/nova/compute/manager.py#L4502-L4521 Change-Id: Ibb90571907cafcb649284e4ea30810a307f1737e Closes-Bug: #1721514 --- nova/tests/functional/test_servers.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/nova/tests/functional/test_servers.py b/nova/tests/functional/test_servers.py index 9b641d6ddc73..b42bf6348771 100644 --- a/nova/tests/functional/test_servers.py +++ b/nova/tests/functional/test_servers.py @@ -1963,7 +1963,9 @@ class ServerMovingTests(ProviderUsageBaseTestCase): 'shelveOffload': {} } self.api.post_server_action(server['id'], req) - self._wait_for_state_change(self.api, server, 'SHELVED_OFFLOADED') + self._wait_for_server_parameter( + self.api, server, {'status': 'SHELVED_OFFLOADED', + 'OS-EXT-SRV-ATTR:host': None}) source_usages = self._get_provider_usages(source_rp_uuid) self.assertEqual({'VCPU': 0, 'MEMORY_MB': 0, @@ -2656,7 +2658,9 @@ class ServerUnshelveSpawnFailTests(ProviderUsageBaseTestCase): # shelve offload the server self.flags(shelved_offload_time=0) self.api.post_server_action(server['id'], {'shelve': None}) - self._wait_for_state_change(self.api, server, 'SHELVED_OFFLOADED') + self._wait_for_server_parameter( + self.api, server, {'status': 'SHELVED_OFFLOADED', + 'OS-EXT-SRV-ATTR:host': None}) # assert allocations were removed from the host usages = self._get_provider_usages(rp_uuid)