Fix intermittently failing regression case

The test_unshelve_offloaded_fails_due_to_neutron could fail due to race
condition. The test case only waits for the first instance.save() call
at [1] but the allocation delete happens after it. This causes that the
test case can still see the allocation of the offloaded server in
placement.

The fix makes sure that the test waits for the second instance.save() by
checking for the host of the instance.

[1] https://github.com/openstack/nova/blob/stable/rocky/nova/compute/manager.py#L5274-L5288

Related-Bug #1862633

Change-Id: Ic1c3d35749fbdc7f5b6f6ec1e16b8fcf37c10de8
(cherry picked from commit 1dfb72e048)
(cherry picked from commit c48d621843)
This commit is contained in:
Balazs Gibizer 2020-03-16 14:58:46 +01:00
parent cef67a0be7
commit 763b7897f4
1 changed files with 4 additions and 2 deletions

View File

@ -59,7 +59,8 @@ class UnshelveNeutronErrorTest(
}
self.api.post_server_action(server['id'], req)
self._wait_for_server_parameter(
self.api, server, {'status': 'SHELVED_OFFLOADED'})
self.api, server, {'status': 'SHELVED_OFFLOADED',
'OS-EXT-SRV-ATTR:host': None})
allocations = self.placement_api.get(
'/allocations/%s' % server['id']).body['allocations']
self.assertEqual(0, len(allocations))
@ -85,7 +86,8 @@ class UnshelveNeutronErrorTest(
self.api,
server,
{'status': 'SHELVED_OFFLOADED',
'OS-EXT-STS:task_state': None})
'OS-EXT-STS:task_state': None,
'OS-EXT-SRV-ATTR:host': None})
# As the instance went back to offloaded state we expect no allocation
allocations = self.placement_api.get(