Tests for volume<->image dependencies

Detect problems related to Cinder volumes not allowing
Glance images to be deleted.

Change-Id: I5fee23951958fc0031b59ce437a963c4cea28529
This commit is contained in:
Eric Harney 2023-04-11 15:52:53 +00:00
parent 5a5e1bf665
commit ce01e35f16
1 changed files with 96 additions and 0 deletions

View File

@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from tempest.common import waiters
from tempest import config
from tempest.lib import decorators
@ -119,3 +120,98 @@ class VolumeDependencyTests(base.BaseVolumeTest):
self._delete_vol_and_wait(volume_1)
self._delete_vol_and_wait(volume_2)
self._delete_vol_and_wait(volume_3)
@classmethod
def del_image(cls, image_id):
images_client = cls.os_primary.image_client_v2
images_client.delete_image(image_id)
images_client.wait_for_resource_deletion(image_id)
@decorators.idempotent_id('0e20bd6e-440f-41d8-9b5d-fc047ac00423')
def test_image_volume_dependencies(self):
"""Tests deletion of images/volumes with cloned children.
This tests deletion of an image which has a cloned volume
from it that may be in the backend's trash (because it is
the base of another cloned volume).
"""
image_args = {
'disk_format': 'raw',
'container_format': 'bare',
'name': 'image-for-test-0e20bd6e-440f-41d8-9b5d-fc047ac00423'
}
image = self.create_image_with_data(**image_args)
# create a volume from the image
vol_args = {'name': ('volume1-for-test'
'0e20bd6e-440f-41d8-9b5d-fc047ac00423'),
'imageRef': image['id']}
volume1 = self.create_volume(**vol_args)
waiters.wait_for_volume_resource_status(self.volumes_client,
volume1['id'],
'available')
snapshot1 = self.create_snapshot(volume1['id'])
vol2_args = {'name': ('volume2-for-test-'
'0e20bd6e-440f-41d8-9b5d-fc047ac00423'),
'snapshot_id': snapshot1['id']}
volume2 = self.create_volume(**vol2_args)
waiters.wait_for_volume_resource_status(self.volumes_client,
volume2['id'],
'available')
self.snapshots_client.delete_snapshot(snapshot1['id'])
self.snapshots_client.wait_for_resource_deletion(snapshot1['id'])
self.volumes_client.delete_volume(volume1['id'])
self.volumes_client.wait_for_resource_deletion(volume1['id'])
self.del_image(image['id'])
@decorators.idempotent_id('e6050452-06bd-4c7f-9912-45178c83e379')
def test_image_volume_dependencies_2(self):
"""Tests deletion of images/volumes with cloned children.
This tests
a) deletion of an image with a volume cloned from it
and
b) deletion of a volume/snap with a volume cloned from the snapshot
"""
image_args = {
'disk_format': 'raw',
'container_format': 'bare',
'name': 'image-for-test-e6050452-06bd-4c7f-9912-45178c83e379'
}
image = self.create_image_with_data(**image_args)
# create a volume from the image
vol_args = {'name': ('volume1-for-test'
'e6050452-06bd-4c7f-9912-45178c83e379'),
'imageRef': image['id']}
volume1 = self.create_volume(**vol_args)
waiters.wait_for_volume_resource_status(self.volumes_client,
volume1['id'],
'available')
snapshot1 = self.create_snapshot(volume1['id'])
vol2_args = {'name': ('volume2-for-test-'
'e6050452-06bd-4c7f-9912-45178c83e379'),
'snapshot_id': snapshot1['id']}
volume2 = self.create_volume(**vol2_args)
waiters.wait_for_volume_resource_status(self.volumes_client,
volume2['id'],
'available')
self.snapshots_client.delete_snapshot(snapshot1['id'])
self.snapshots_client.wait_for_resource_deletion(snapshot1['id'])
self.volumes_client.delete_volume(volume2['id'])
self.volumes_client.wait_for_resource_deletion(volume2['id'])
self.del_image(image['id'])
self.volumes_client.delete_volume(volume1['id'])
self.volumes_client.wait_for_resource_deletion(volume1['id'])