Merge "Test image <-> volume <-> server dependency"

This commit is contained in:
Zuul 2024-07-04 21:36:40 +00:00 committed by Gerrit Code Review
commit aa57d98fc4

View File

@ -56,9 +56,10 @@ class ImageDependencyTests(image_base.BaseV2ImageTest,
"not enabled" % (cls.__name__)) "not enabled" % (cls.__name__))
raise cls.skipException(skip_msg) raise cls.skipException(skip_msg)
def _create_instance_snapshot(self): def _create_instance_snapshot(self, bfv=False):
"""Create instance from image and then snapshot the instance.""" """Create instance from image and then snapshot the instance."""
# Create image and store data to image # Create image and store data to image
source = 'volume' if bfv else 'image'
image_name = data_utils.rand_name( image_name = data_utils.rand_name(
prefix=CONF.resource_name_prefix, prefix=CONF.resource_name_prefix,
name='image-dependency-test') name='image-dependency-test')
@ -71,12 +72,20 @@ class ImageDependencyTests(image_base.BaseV2ImageTest,
self.client.store_image_file(image['id'], image_file) self.client.store_image_file(image['id'], image_file)
waiters.wait_for_image_status( waiters.wait_for_image_status(
self.client, image['id'], 'active') self.client, image['id'], 'active')
# Create instance if bfv:
instance = self.create_test_server( # Create instance
name='instance-depend-image', instance = self.create_test_server(
image_id=image['id'], name='instance-depend-image',
wait_until='ACTIVE') image_id=image['id'],
LOG.info("Instance from image is created %s", instance) volume_backed=True,
wait_until='ACTIVE')
else:
# Create instance
instance = self.create_test_server(
name='instance-depend-image',
image_id=image['id'],
wait_until='ACTIVE')
LOG.info("Instance from %s is created %s", source, instance)
instance_observed = \ instance_observed = \
self.servers_client.show_server(instance['id'])['server'] self.servers_client.show_server(instance['id'])['server']
# Create instance snapshot # Create instance snapshot
@ -101,3 +110,26 @@ class ImageDependencyTests(image_base.BaseV2ImageTest,
fetched_images_id = [img['id'] for img in images_list] fetched_images_id = [img['id'] for img in images_list]
self.assertNotIn(base_image_id, fetched_images_id) self.assertNotIn(base_image_id, fetched_images_id)
self.assertIn(snapshot_image_id, fetched_images_id) self.assertIn(snapshot_image_id, fetched_images_id)
@utils.services('compute', 'volume')
@decorators.idempotent_id('f0c8a35d-8f8f-443c-8bcb-85a9c0f87d19')
def test_image_volume_server_snapshot_dependency(self):
"""Test with image > volume > instance > snapshot dependency.
We are going to perform the following steps in the test:
* Create image
* Create a bootable volume from Image
* Launch an instance from the bootable volume
* Take snapshot of the instance -- which creates the volume snapshot
* Delete the image.
This will test the dependency chain of image -> volume -> snapshot.
"""
base_image_id, snapshot_image_id = self._create_instance_snapshot(
bfv=True)
self.client.delete_image(base_image_id)
self.client.wait_for_resource_deletion(base_image_id)
images_list = self.client.list_images()['images']
fetched_images_id = [img['id'] for img in images_list]
self.assertNotIn(base_image_id, fetched_images_id)
self.assertIn(snapshot_image_id, fetched_images_id)