From d37b6a7cb055bd245c39c231760822d39c65b45f Mon Sep 17 00:00:00 2001 From: zhufl Date: Tue, 29 Nov 2016 16:56:01 +0800 Subject: [PATCH] Delete volume first before deleting snapshot In test_volume_from_snapshot, the test steps are: 1) create a volume (named src_vol) 2) create a snapshot based on src_vol 3) create a volume based on snapshot (named dst_vol) Because in volume.base.resource_cleanup, the deleting sequence is: cls.clear_snapshots() cls.clear_volumes() So it will delete snapshots first and then delete volumes, but dst_vol is created based on snapshot, so deleting snapshot will end with status 'error-deleting' because the volume created based on it(dst_vol) is not deleted yet. Whether "snapshot can be deleted if there exists volume that is created based on the snapshot" depends on the implementation mechanism of vendors, and generally speaking, some verdors will use "virtual disk clone" which will promote disk clone speed, and in "virtual disk clone" situation, volume should be deleted before deleting snapshot because the "disk clone" is just a relationship between volume and snapshot. So we should add immediate cleanup of volume dst_vol to avoid deleting snapshot failure for some vendors. And for those vendors that don't use "virtual clone", to delete volume in testcase teardown will do no harm. Change-Id: I0d9ad9556748dafddefe3680417290f9b798488d --- tempest/api/volume/test_volumes_snapshots.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tempest/api/volume/test_volumes_snapshots.py b/tempest/api/volume/test_volumes_snapshots.py index 3c7a2c80fb..6f85891679 100644 --- a/tempest/api/volume/test_volumes_snapshots.py +++ b/tempest/api/volume/test_volumes_snapshots.py @@ -140,6 +140,14 @@ class VolumesV2SnapshotTestJSON(base.BaseVolumeTest): # Destination volume bigger than source snapshot dst_vol = self.create_volume(snapshot_id=src_snap['id'], size=src_size + 1) + # NOTE(zhufl): dst_vol is created based on snapshot, so dst_vol + # should be deleted before deleting snapshot, otherwise deleting + # snapshot will end with status 'error-deleting'. This depends on + # the implementation mechanism of vendors, generally speaking, + # some verdors will use "virtual disk clone" which will promote + # disk clone speed, and in this situation the "disk clone" + # is just a relationship between volume and snapshot. + self.addCleanup(self.delete_volume, self.volumes_client, dst_vol['id']) volume = self.volumes_client.show_volume(dst_vol['id'])['volume'] # Should allow