func: Introduce a server_expected_state kwarg to InstanceHelperMixin._live_migrate

Useful when testing live migration failures that leave the server in an
non ACTIVE state. This change also renames the migration_final_status
arg to migration_expected_state within the method to keep it in line
with _create_server.

Change-Id: Ie0852a89fc9423a92baa7c29a8806c0628cae220
This commit is contained in:
Lee Yarwood 2020-07-29 10:51:34 +01:00
parent 1f81c08657
commit e70ddd621c
2 changed files with 6 additions and 9 deletions

View File

@ -162,16 +162,12 @@ class TestVolAttachmentsDuringLiveMigration(
# Migrate the instance and wait until the migration errors out thanks
# to our mocked version of live_migration raising TestingException
self.api.post_server_action(
server['id'],
{'os-migrateLive': {'host': None, 'block_migration': 'auto'}})
self._wait_for_migration_status(server, ['error'])
self._live_migrate(server, 'error', server_expected_state='ERROR')
# Assert that we called the fake live_migration method
mock_lm.assert_called_once()
# Assert that the instance is listed as ERROR on the source
self._wait_for_state_change(server, 'ERROR')
# Assert that the instance is on the source
server = self.api.get_server(server['id'])
self.assertEqual(src_host, server['OS-EXT-SRV-ATTR:host'])

View File

@ -430,13 +430,14 @@ class InstanceHelperMixin:
}
self._migrate_or_resize(server, resize_req)
def _live_migrate(self, server, migration_final_status):
def _live_migrate(self, server, migration_expected_state,
server_expected_state='ACTIVE'):
self.api.post_server_action(
server['id'],
{'os-migrateLive': {'host': None,
'block_migration': 'auto'}})
self._wait_for_state_change(server, 'ACTIVE')
self._wait_for_migration_status(server, [migration_final_status])
self._wait_for_state_change(server, server_expected_state)
self._wait_for_migration_status(server, [migration_expected_state])
class PlacementHelperMixin: