From eeb614c47759fa9a01e6d886ed07acceb8d9ff61 Mon Sep 17 00:00:00 2001 From: Akihiro Motoki Date: Sun, 21 May 2017 03:36:23 +0000 Subject: volume functest: ensure snapshots deleted when volume delete Deleting snapshot may take time. The current volume API does not allow to delete volumes with snapshots, so if deleting snapshot may take time, a delete request for a parent volume will fail. This sometimes causes functional test failures in slow environments. wait_for_status() checks whether volume status is in error statuses but previously the expected error status was wrong. Cinder API uses lower case as volume status, so it did not work expectedly. Change-Id: I095894ba39f23bf81d71351818d24dbb5ca459fb --- .../tests/functional/compute/v2/common.py | 8 ++++---- .../tests/functional/compute/v2/test_server.py | 24 ++++++++++------------ 2 files changed, 15 insertions(+), 17 deletions(-) (limited to 'openstackclient/tests/functional/compute') diff --git a/openstackclient/tests/functional/compute/v2/common.py b/openstackclient/tests/functional/compute/v2/common.py index 99d87bb4..851664c8 100644 --- a/openstackclient/tests/functional/compute/v2/common.py +++ b/openstackclient/tests/functional/compute/v2/common.py @@ -125,12 +125,12 @@ class ComputeTestCase(base.TestCase): name )) status = cmd_output['status'] - print('Waiting for {}, current status: {}'.format( - expected_status, - status, - )) if status == expected_status: + print('Server {} now has status {}'.format( + name, status)) break + print('Server {}: Waiting for {}, current status: {}'.format( + name, expected_status, status)) self.assertNotIn(status, failures) time.sleep(interval) total_sleep += interval diff --git a/openstackclient/tests/functional/compute/v2/test_server.py b/openstackclient/tests/functional/compute/v2/test_server.py index a4b29024..c9f4d62c 100644 --- a/openstackclient/tests/functional/compute/v2/test_server.py +++ b/openstackclient/tests/functional/compute/v2/test_server.py @@ -17,7 +17,7 @@ from tempest.lib import exceptions from openstackclient.tests.functional import base from openstackclient.tests.functional.compute.v2 import common -from openstackclient.tests.functional.volume.v2 import test_volume +from openstackclient.tests.functional.volume.v2 import common as volume_common class ServerTests(common.ComputeTestCase): @@ -282,9 +282,7 @@ class ServerTests(common.ComputeTestCase): def test_server_boot_from_volume(self): """Test server create from volume, server delete""" # get volume status wait function - volume_wait_for = test_volume.VolumeTests( - methodName='wait_for', - ).wait_for + volume_wait_for = volume_common.BaseVolumeTests.wait_for_status # get image size cmd_output = json.loads(self.openstack( @@ -391,9 +389,8 @@ class ServerTests(common.ComputeTestCase): def test_server_boot_with_bdm_snapshot(self): """Test server create from image with bdm snapshot, server delete""" # get volume status wait function - volume_wait_for = test_volume.VolumeTests( - methodName='wait_for', - ).wait_for + volume_wait_for = volume_common.BaseVolumeTests.wait_for_status + volume_wait_for_delete = volume_common.BaseVolumeTests.wait_for_delete # create source empty volume empty_volume_name = uuid.uuid4().hex @@ -419,6 +416,13 @@ class ServerTests(common.ComputeTestCase): empty_snapshot_name )) self.assertIsNotNone(cmd_output["id"]) + # Deleting volume snapshot take time, so we need to wait until the + # snapshot goes. Entries registered by self.addCleanup will be called + # in the reverse order, so we need to register wait_for_delete first. + self.addCleanup(volume_wait_for_delete, + 'volume snapshot', empty_snapshot_name) + self.addCleanup(self.openstack, + 'volume snapshot delete ' + empty_snapshot_name) self.assertEqual( empty_snapshot_name, cmd_output['name'], @@ -489,12 +493,6 @@ class ServerTests(common.ComputeTestCase): # the attached volume had been deleted pass - # clean up volume snapshot manually, make sure the snapshot and volume - # can be deleted sequentially, self.addCleanup so fast, that cause - # volume service API 400 error and the volume is left over at the end. - self.openstack('volume snapshot delete ' + empty_snapshot_name) - volume_wait_for('volume snapshot', empty_snapshot_name, 'disappear') - def test_server_create_with_none_network(self): """Test server create with none network option.""" server_name = uuid.uuid4().hex -- cgit v1.2.1