From 507d0dec2c61f428bdb919b86c7fb5beaf8b1acf Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Thu, 26 Sep 2024 06:59:19 -0700 Subject: [PATCH] Stop violating image disk_format rules Glance is going to start enforcing that if you upload something and claim it is a different format than the content, the upload will fail. Tempest currently just almost universally uses disk_formats[0], despite not actually uploading content that matches that format. In most cases it is using random data, which means the format it uses should be "raw". This converts those cases to use raw, and does so assuming raw is always available (as many other tests already do). Change-Id: I06d66b969306b53cd177c2d95c23762db3bc72ea Needed-By: https://review.opendev.org/c/openstack/glance/+/930492 --- .../api/compute/flavors/test_flavors_negative.py | 2 +- tempest/api/image/v2/admin/test_images.py | 2 +- tempest/api/image/v2/test_images.py | 13 ++++++++++--- tempest/api/volume/test_volumes_negative.py | 2 +- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/tempest/api/compute/flavors/test_flavors_negative.py b/tempest/api/compute/flavors/test_flavors_negative.py index 09f54b5859..efd9cdd8a8 100644 --- a/tempest/api/compute/flavors/test_flavors_negative.py +++ b/tempest/api/compute/flavors/test_flavors_negative.py @@ -47,7 +47,7 @@ class FlavorsV2NegativeTest(base.BaseV2ComputeTest): 'name': data_utils.rand_name( prefix=CONF.resource_name_prefix, name='image'), 'container_format': CONF.image.container_formats[0], - 'disk_format': CONF.image.disk_formats[0], + 'disk_format': 'raw', 'min_ram': min_img_ram, 'visibility': 'private' } diff --git a/tempest/api/image/v2/admin/test_images.py b/tempest/api/image/v2/admin/test_images.py index 2b1c4fb250..2c2e9a8f05 100644 --- a/tempest/api/image/v2/admin/test_images.py +++ b/tempest/api/image/v2/admin/test_images.py @@ -112,7 +112,7 @@ class ImportCopyImagesTest(base.BaseV2ImageAdminTest): image_name = data_utils.rand_name( prefix=CONF.resource_name_prefix, name='copy-image') container_format = CONF.image.container_formats[0] - disk_format = CONF.image.disk_formats[0] + disk_format = 'raw' image = self.create_image(name=image_name, container_format=container_format, disk_format=disk_format, diff --git a/tempest/api/image/v2/test_images.py b/tempest/api/image/v2/test_images.py index 5bb8eef062..f6ca3175ec 100644 --- a/tempest/api/image/v2/test_images.py +++ b/tempest/api/image/v2/test_images.py @@ -56,7 +56,14 @@ class ImportImagesTest(base.BaseV2ImageTest): image_name = data_utils.rand_name( prefix=CONF.resource_name_prefix, name='image') container_format = container_format or CONF.image.container_formats[0] - disk_format = disk_format or CONF.image.disk_formats[0] + disk_format = disk_format or 'raw' + if disk_format not in CONF.image.disk_formats: + # If the test asked for some disk format that is not available, + # consider that a programming error. Tests with specific + # requirements should be checking to see if it is available and + # skipping themselves instead of this helper doing it. + raise RuntimeError('Test requires unavailable disk_format %s, ' + 'but did not skip' % disk_format) image = self.create_image(name=image_name, container_format=container_format, disk_format=disk_format, @@ -390,7 +397,7 @@ class BasicOperationsImagesTest(base.BaseV2ImageTest): image_name = data_utils.rand_name( prefix=CONF.resource_name_prefix, name='image') container_format = CONF.image.container_formats[0] - disk_format = CONF.image.disk_formats[0] + disk_format = 'raw' image = self.create_image(name=image_name, container_format=container_format, disk_format=disk_format, @@ -754,7 +761,7 @@ class ListSharedImagesTest(base.BaseV2ImageTest): # Create an image to be shared using default visibility image_file = io.BytesIO(data_utils.random_bytes(2048)) container_format = CONF.image.container_formats[0] - disk_format = CONF.image.disk_formats[0] + disk_format = 'raw' image = self.create_image(container_format=container_format, disk_format=disk_format) self.client.store_image_file(image['id'], data=image_file) diff --git a/tempest/api/volume/test_volumes_negative.py b/tempest/api/volume/test_volumes_negative.py index d8480df16d..754b6767b5 100644 --- a/tempest/api/volume/test_volumes_negative.py +++ b/tempest/api/volume/test_volumes_negative.py @@ -45,7 +45,7 @@ class VolumesNegativeTest(base.BaseVolumeTest): image = self.images_client.create_image( name=image_name, container_format=CONF.image.container_formats[0], - disk_format=CONF.image.disk_formats[0], + disk_format='raw', visibility='private', min_disk=CONF.volume.volume_size + CONF.volume.volume_size_extend) self.addCleanup(test_utils.call_and_ignore_notfound_exc,