Fix nova migration tests - update nova client microversion to 2.56
This patch includes several changes: - nova client microversion is updated to 2.56 in order to test properly the destination host when VMs are migrated - tests test_6_migrate_server_with_host and test_7_live_migrate_server_with_host are skipped unless tobiko runs on an Openstack environment with 3 or more computes, since testing VM migration to a specific destination host with only 2 computes is not useful - the disk_over_commit parameter was removed in microversion 2.25, so this patch removes it from tobiko - tests test_8_live_migrate_server_with_block_migration and test_9_live_migrate_server_with_no_block_migration are removed because the block_migration parameter is deprecated - its default value "auto" is added to the tobiko live_migration method [1] https://docs.openstack.org/nova/latest/reference/api-microversion-history.html Change-Id: Ia6bd96a69fe8492c49ab085067c738671b81e7b6
This commit is contained in:
parent
88f925ff20
commit
44de728cb6
|
@ -38,7 +38,7 @@ NovaHypervisor = typing.Union[novaclient.v2.hypervisors.Hypervisor]
|
|||
class NovaClientFixture(_client.OpenstackClientFixture):
|
||||
|
||||
def init_client(self, session) -> NovaClient:
|
||||
return novaclient.client.Client('2', session=session)
|
||||
return novaclient.client.Client('2.56', session=session)
|
||||
|
||||
|
||||
class NovaClientManager(_client.OpenstackClientManager):
|
||||
|
@ -190,36 +190,20 @@ def live_migrate_server(server: ServerType = None,
|
|||
server_id: str = None,
|
||||
host: str = None,
|
||||
block_migration: bool = None,
|
||||
disk_over_commit=False,
|
||||
client: NovaClientType = None,
|
||||
**params):
|
||||
server_id = get_server_id(server=server, server_id=server_id)
|
||||
params.update(host=host)
|
||||
if block_migration is None:
|
||||
# some setups work only with block migration and some only
|
||||
# with without
|
||||
try:
|
||||
return live_migrate_server(server_id=server_id,
|
||||
host=host,
|
||||
block_migration=False,
|
||||
disk_over_commit=disk_over_commit,
|
||||
client=client,
|
||||
**params)
|
||||
except NotInSharedStorageMigrateServerError:
|
||||
return live_migrate_server(server_id=server_id,
|
||||
host=host,
|
||||
block_migration=True,
|
||||
disk_over_commit=disk_over_commit,
|
||||
client=client,
|
||||
**params)
|
||||
params.update(block_migration='auto')
|
||||
else:
|
||||
params.update(host=host,
|
||||
block_migration=block_migration,
|
||||
disk_over_commit=disk_over_commit)
|
||||
LOG.debug(f"Start server '{server_id}' live migration...\n" +
|
||||
f"{params}")
|
||||
with handle_migration_errors(server_id=server_id, **params):
|
||||
return nova_client(client).servers.live_migrate(server=server_id,
|
||||
**params)
|
||||
params.update(block_migration=block_migration)
|
||||
|
||||
LOG.debug(f"Start server '{server_id}' live migration...\n" +
|
||||
f"{params}")
|
||||
with handle_migration_errors(server_id=server_id, **params):
|
||||
return nova_client(client).servers.live_migrate(server=server_id,
|
||||
**params)
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
|
|
|
@ -45,14 +45,14 @@ class ClientTest(testtools.TestCase):
|
|||
@nova.skip_if_missing_hypervisors(count=1)
|
||||
def test_list_hypervisors(self):
|
||||
hypervisor = nova.list_hypervisors().first
|
||||
self.assertIsInstance(hypervisor.id, int)
|
||||
self.assertIsInstance(hypervisor.id, str)
|
||||
self.assertTrue(hypervisor.hypervisor_hostname)
|
||||
netaddr.IPAddress(hypervisor.host_ip)
|
||||
|
||||
@nova.skip_if_missing_hypervisors(count=1)
|
||||
def test_list_hypervisors_without_details(self):
|
||||
hypervisor = nova.list_hypervisors(detailed=False).first
|
||||
self.assertIsInstance(hypervisor.id, int)
|
||||
self.assertIsInstance(hypervisor.id, str)
|
||||
self.assertTrue(hypervisor.hypervisor_hostname)
|
||||
self.assertFalse(hasattr(hypervisor, 'host_ip'))
|
||||
|
||||
|
|
|
@ -72,27 +72,17 @@ class BaseServerTest(testtools.TestCase):
|
|||
self._test_migrate_server(live=True)
|
||||
|
||||
@pytest.mark.server_migrate
|
||||
@nova.skip_if_missing_hypervisors(count=2)
|
||||
@nova.skip_if_missing_hypervisors(count=3)
|
||||
def test_6_migrate_server_with_host(self):
|
||||
"""Tests cold migration actually ends on target hypervisor
|
||||
"""
|
||||
self._test_migrate_server_with_host(live=False)
|
||||
|
||||
@pytest.mark.server_migrate
|
||||
@nova.skip_if_missing_hypervisors(count=2)
|
||||
@nova.skip_if_missing_hypervisors(count=3)
|
||||
def test_7_live_migrate_server_with_host(self):
|
||||
self._test_migrate_server_with_host(live=True)
|
||||
|
||||
@pytest.mark.server_migrate
|
||||
@nova.skip_if_missing_hypervisors(count=2)
|
||||
def test_8_live_migrate_server_with_block_migration(self):
|
||||
self._test_migrate_server(live=True, block_migration=True)
|
||||
|
||||
@pytest.mark.server_migrate
|
||||
@nova.skip_if_missing_hypervisors(count=2)
|
||||
def test_9_live_migrate_server_with_no_block_migration(self):
|
||||
self._test_migrate_server(live=True, block_migration=False)
|
||||
|
||||
def _test_migrate_server(self,
|
||||
live: bool,
|
||||
block_migration: bool = None):
|
||||
|
|
Loading…
Reference in New Issue