functional: Wait for revert resize to complete

When reverting a resize, we need to wait for the migration status to
change to 'reverted', but we also need to wait for the relevant
versioned notification to be emitted. The reason for this is noted in a
couple of places, including the '_revert_resize' helper in the
'nova.tests.functional.integrated_helpers.InstanceHelperMixin' module:

  [T]he migration status is changed to "reverted" in the dest host
  revert_resize method but the allocations are cleaned up in the source
  host finish_revert_resize method so we need to wait for the
  finish_revert_resize method to complete.

Two tests in the 'test_cross_cell_migrate' test module were not doing
this wait, resulting in intermittent failures in CI due to the races.
Resolve this now.

Change-Id: I3ec6cae19b362ac9cc311a979f680cf64db4f458
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Closes-Bug: #1904051
This commit is contained in:
Stephen Finucane 2020-11-12 11:45:20 +00:00
parent dc93e3b510
commit 1d23b358d6

View File

@ -800,6 +800,8 @@ class TestMultiCellMigrate(integrated_helpers.ProviderUsageBaseTestCase):
self.api.post_server_action(server['id'], {'revertResize': None})
server = self._wait_for_state_change(server, 'ACTIVE')
self._wait_for_migration_status(server, ['reverted'])
fake_notifier.wait_for_versioned_notifications(
'instance.resize_revert.end')
self.assert_volume_is_detached(server['id'], uuids.fake_volume_id)
# Delete the server and make sure we did not leak anything.
self.delete_server_and_assert_cleanup(server)
@ -1070,6 +1072,8 @@ class TestMultiCellMigrate(integrated_helpers.ProviderUsageBaseTestCase):
self.assertEqual(4, server['OS-EXT-STS:power_state'],
"Unexpected power state after revertResize.")
self._wait_for_migration_status(server, ['reverted'])
fake_notifier.wait_for_versioned_notifications(
'instance.resize_revert.end')
# Now try cold-migrating to cell2 to make sure there is no
# duplicate entry error in the DB.