Add related test to Bug #1732428
Reproduce data loss when migrating unshelved qcow2 instance.
Add also [compute-feature-enabled]/shelve_migrate config, to enable this
test only on supported environment.
Depends-On: https://review.opendev.org/#/c/696084/
Depends-On: https://review.opendev.org/#/c/752463/
Change-Id: I3044d59b4f1505accefdaafafecef685cb9a9af5
Related-Bug: #1732428
diff --git a/releasenotes/notes/add-compute-feature-shelve-migrate-fdbd3633abe65c4e.yaml b/releasenotes/notes/add-compute-feature-shelve-migrate-fdbd3633abe65c4e.yaml
new file mode 100644
index 0000000..121e060
--- /dev/null
+++ b/releasenotes/notes/add-compute-feature-shelve-migrate-fdbd3633abe65c4e.yaml
@@ -0,0 +1,6 @@
+---
+features:
+ - |
+ Add a new config option ``[compute-feature-enabled] shelve_migrate``
+ which enable test for environment that support cold migration of qcow2
+ unshelved instance.
diff --git a/tempest/config.py b/tempest/config.py
index 36ad405..77b5ce2 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -447,6 +447,10 @@
cfg.BoolOpt('shelve',
default=True,
help="Does the test environment support shelving/unshelving?"),
+ cfg.BoolOpt('shelve_migrate',
+ default=False,
+ help="Does the test environment support "
+ "cold migration of unshelved server?"),
cfg.BoolOpt('suspend',
default=True,
help="Does the test environment support suspend/resume?"),
diff --git a/tempest/scenario/test_shelve_instance.py b/tempest/scenario/test_shelve_instance.py
index d6b6d14..ed06898 100644
--- a/tempest/scenario/test_shelve_instance.py
+++ b/tempest/scenario/test_shelve_instance.py
@@ -33,9 +33,18 @@
* shelve the instance
* unshelve the instance
* check the existence of the timestamp file in the unshelved instance
+ * check the existence of the timestamp file in the unshelved instance,
+ after a cold migrate
"""
+ credentials = ['primary', 'admin']
+
+ @classmethod
+ def setup_clients(cls):
+ super(TestShelveInstance, cls).setup_clients()
+ cls.admin_servers_client = cls.os_admin.servers_client
+
@classmethod
def skip_checks(cls):
super(TestShelveInstance, cls).skip_checks()
@@ -50,7 +59,21 @@
waiters.wait_for_server_status(self.servers_client, server['id'],
'ACTIVE')
- def _create_server_then_shelve_and_unshelve(self, boot_from_volume=False):
+ def _cold_migrate_server(self, server):
+ src_host = self.get_host_for_server(server['id'])
+
+ self.admin_servers_client.migrate_server(server['id'])
+ waiters.wait_for_server_status(self.servers_client,
+ server['id'], 'VERIFY_RESIZE')
+ self.servers_client.confirm_resize_server(server['id'])
+ waiters.wait_for_server_status(self.servers_client,
+ server['id'], 'ACTIVE')
+
+ dst_host = self.get_host_for_server(server['id'])
+ self.assertNotEqual(src_host, dst_host)
+
+ def _create_server_then_shelve_and_unshelve(self, boot_from_volume=False,
+ cold_migrate=False):
keypair = self.create_keypair()
security_group = self._create_security_group()
@@ -71,6 +94,10 @@
# with the instance snapshot
self._shelve_then_unshelve_server(server)
+ if cold_migrate:
+ # Prevent bug #1732428 from coming back
+ self._cold_migrate_server(server)
+
timestamp2 = self.get_timestamp(instance_ip,
private_key=keypair['private_key'],
server=server)
@@ -91,3 +118,18 @@
@utils.services('compute', 'volume', 'network', 'image')
def test_shelve_volume_backed_instance(self):
self._create_server_then_shelve_and_unshelve(boot_from_volume=True)
+
+ @decorators.attr(type='slow')
+ @decorators.idempotent_id('1295fd9e-193a-4cf8-b211-55358e021bae')
+ @testtools.skipUnless(CONF.network.public_network_id,
+ 'The public_network_id option must be specified.')
+ @testtools.skipUnless(CONF.compute_feature_enabled.cold_migration,
+ 'Cold migration not available.')
+ @testtools.skipUnless(CONF.compute_feature_enabled.shelve_migrate,
+ 'Shelve migrate not available.')
+ @testtools.skipUnless(CONF.compute.min_compute_nodes > 1,
+ 'Less than 2 compute nodes, skipping multinode '
+ 'tests.')
+ @utils.services('compute', 'network', 'image')
+ def test_cold_migrate_unshelved_instance(self):
+ self._create_server_then_shelve_and_unshelve(cold_migrate=True)