From d8bbaba415bc5cc027079b1b45aa5ee6e75faddf Mon Sep 17 00:00:00 2001 From: Balazs Gibizer Date: Tue, 17 May 2022 17:15:40 +0200 Subject: [PATCH] Wait for guest after resize To stabilize test_resize_server_with_multiattached_volume we need to wait for the guest OS to fully boot after the resize and before the test attempts to detach the volume. Closes-Bug #1960346 Change-Id: I85ee21868c9281d081c491ee590fe1457f5aa997 --- tempest/api/compute/base.py | 18 +++++++++++++++++- .../api/compute/volumes/test_attach_volume.py | 16 ++++++++++++++-- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/tempest/api/compute/base.py b/tempest/api/compute/base.py index 41e73ecdf6..74601dceec 100644 --- a/tempest/api/compute/base.py +++ b/tempest/api/compute/base.py @@ -456,15 +456,31 @@ class BaseV2ComputeTest(api_version_utils.BaseMicroversionTest, except Exception: LOG.exception('Failed to delete server %s', server_id) - def resize_server(self, server_id, new_flavor_id, **kwargs): + def resize_server( + self, server_id, new_flavor_id, wait_until='ACTIVE', **kwargs + ): """resize and confirm_resize an server, waits for it to be ACTIVE.""" self.servers_client.resize_server(server_id, new_flavor_id, **kwargs) 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') server = self.servers_client.show_server(server_id)['server'] + + validation_resources = self.get_class_validation_resources( + self.os_primary) + if ( + validation_resources and + wait_until in ("SSHABLE", "PINGABLE") and + CONF.validation.run_validation + ): + tenant_network = self.get_tenant_network() + compute.wait_for_ssh_or_ping( + server, self.os_primary, tenant_network, + True, validation_resources, wait_until, True) + self.assert_flavor_equal(new_flavor_id, server['flavor']) def reboot_server(self, server_id, type): diff --git a/tempest/api/compute/volumes/test_attach_volume.py b/tempest/api/compute/volumes/test_attach_volume.py index e4ec209b7d..5380c67326 100644 --- a/tempest/api/compute/volumes/test_attach_volume.py +++ b/tempest/api/compute/volumes/test_attach_volume.py @@ -378,10 +378,19 @@ class AttachVolumeMultiAttachTest(BaseAttachVolumeTest): the created volume, and dict of server ID to volumeAttachment dict entries """ + validation_resources = self.get_class_validation_resources( + self.os_primary) + servers = [] for x in range(2): name = 'multiattach-server-%i' % x - servers.append(self.create_test_server(name=name)) + servers.append( + self.create_test_server( + name=name, + validatable=True, + validation_resources=validation_resources + ) + ) # Now wait for the servers to be ACTIVE. for server in servers: @@ -492,7 +501,10 @@ class AttachVolumeMultiAttachTest(BaseAttachVolumeTest): servers, volume, _ = self._create_and_multiattach() for server in servers: - self.resize_server(server['id'], self.flavor_ref_alt) + # We need to wait until the guest OS fully boots up as we are going + # to detach volumes after the resize. See bug #1960346. + self.resize_server( + server['id'], self.flavor_ref_alt, wait_until='SSHABLE') for server in servers: self._detach_multiattach_volume(volume['id'], server['id'])