Fix race in test_vcpu_to_pcpu_reshape

This test uses the ServersTestBase._wait_for_state_change method
which waits for the status to change *from* what is provided, so
when creating a server and waiting for the status to change from
ACTIVE makes _wait_for_state_change return immediately since the
status starts as BUILD. This can lead to a failure when the test
tries to migrate a server that is in BUILD status rather than
ACTIVE status.

This fixes the test by using this version of  _wait_for_state_change
correctly, not to be confused with the same method in
InstanceHelperMixin which is more accurate (it waits for the
terminal status of the server operation).

Change-Id: I56ff050194d0eb465b8c41795fdea2a8b0d764d6
Closes-Bug: #1850514
This commit is contained in:
Matt Riedemann 2019-10-29 14:29:52 -04:00
parent 9742a64403
commit 56a391aafc
1 changed files with 12 additions and 4 deletions

View File

@ -584,10 +584,14 @@ class ReshapeForPCPUsTest(NUMAServersTestBase):
server_req['networks'] = 'auto'
created_server1 = self.api.post_server({'server': server_req})
server1 = self._wait_for_state_change(created_server1, 'ACTIVE')
# _wait_for_state_change waits for the status to go from BUILD which
# should then be ACTIVE.
server1 = self._wait_for_state_change(created_server1, 'BUILD')
self.assertEqual('ACTIVE', server1['status'])
created_server2 = self.api.post_server({'server': server_req})
server2 = self._wait_for_state_change(created_server2, 'ACTIVE')
server2 = self._wait_for_state_change(created_server2, 'BUILD')
self.assertEqual('ACTIVE', server2['status'])
# sanity check usages
@ -624,7 +628,10 @@ class ReshapeForPCPUsTest(NUMAServersTestBase):
post = {'migrate': None}
self.api.post_server_action(server2['id'], post)
server2 = self._wait_for_state_change(server2, 'VERIFY_RESIZE')
# _wait_for_state_change waits for the status to go from ACTIVE which
# should then be VERIFY_RESIZE.
server2 = self._wait_for_state_change(server2, 'ACTIVE')
self.assertEqual('VERIFY_RESIZE', server2['status'])
# verify that the inventory, usages and allocation are correct before
# the reshape. Note that the value of 8 VCPUs is derived from
@ -755,7 +762,8 @@ class ReshapeForPCPUsTest(NUMAServersTestBase):
# reshaped tree which should result in PCPU allocations
created_server = self.api.post_server({'server': server_req})
server3 = self._wait_for_state_change(created_server, 'ACTIVE')
server3 = self._wait_for_state_change(created_server, 'BUILD')
self.assertEqual('ACTIVE', server3['status'])
compute_rp_uuid = self.compute_rp_uuids['test_compute0']