Add qcow2 format to upload image test
When we test uploading a volume to image, we have a config option to specify the disk format. Currently the default disk format is 'raw' but most cinder backends store the volume in 'raw' format and we end up avoiding the conversion workflow which becomes an untested code path and could lead to bugs as recently discovered with [1]. This patch adds the 'raw' and 'qcow2' as the default formats. The config option is also updated to List so we have add multiple formats to be tested by the same test. [1] https://bugs.launchpad.net/cinder/+bug/2092534 Depends-On: https://review.opendev.org/c/openstack/cinder/+/938265 Related-Bug: #2092534 Change-Id: I5f0f005d9487d7cf59dfa818e2a327f6d3956d1b
This commit is contained in:
parent
b23e9fcc28
commit
fbd90e9639
@ -0,0 +1,8 @@
|
||||
---
|
||||
upgrade:
|
||||
- |
|
||||
The default value for ``[volume] disk_format``, which specifies the
|
||||
disk format of the image in a copy a volume to image operation,
|
||||
is changed from ``raw`` to ``[raw, qcow2]`` for which the type of
|
||||
the config option also needed to change from ``string`` type to
|
||||
``list`` type i.e. it accepts multiple values now.
|
@ -109,29 +109,37 @@ class VolumesActionsTest(base.BaseVolumeTest):
|
||||
# it is shared with the other tests. After it is uploaded in Glance,
|
||||
# there is no way to delete it from Cinder, so we delete it from Glance
|
||||
# using the Glance images_client and from Cinder via tearDownClass.
|
||||
image_name = data_utils.rand_name(self.__class__.__name__ + '-Image',
|
||||
prefix=CONF.resource_name_prefix)
|
||||
body = self.volumes_client.upload_volume(
|
||||
self.volume['id'], image_name=image_name,
|
||||
disk_format=CONF.volume.disk_format)['os-volume_upload_image']
|
||||
image_id = body["image_id"]
|
||||
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
|
||||
self.images_client.delete_image,
|
||||
image_id)
|
||||
waiters.wait_for_image_status(self.images_client, image_id, 'active')
|
||||
# This is required for the optimized upload volume path.
|
||||
# New location APIs are async so we need to wait for the location
|
||||
# import task to complete.
|
||||
# This should work with old location API since we don't fail if there
|
||||
# are no tasks for the image
|
||||
waiters.wait_for_image_tasks_status(self.images_client,
|
||||
image_id, 'success')
|
||||
waiters.wait_for_volume_resource_status(self.volumes_client,
|
||||
self.volume['id'], 'available')
|
||||
# NOTE: This looks really strange to loop through the disk formats
|
||||
# but similar implementation is done in test_volume_bootable test.
|
||||
# Also there is no trace of ddt usage in tempest so this looks like
|
||||
# the only way.
|
||||
for disk_format in CONF.volume.disk_format:
|
||||
image_name = data_utils.rand_name(
|
||||
self.__class__.__name__ + '-Image',
|
||||
prefix=CONF.resource_name_prefix)
|
||||
body = self.volumes_client.upload_volume(
|
||||
self.volume['id'], image_name=image_name,
|
||||
disk_format=disk_format)['os-volume_upload_image']
|
||||
image_id = body["image_id"]
|
||||
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
|
||||
self.images_client.delete_image,
|
||||
image_id)
|
||||
waiters.wait_for_image_status(self.images_client, image_id,
|
||||
'active')
|
||||
# This is required for the optimized upload volume path.
|
||||
# New location APIs are async so we need to wait for the location
|
||||
# import task to complete.
|
||||
# This should work with old location API since we don't fail if
|
||||
# there are no tasks for the image
|
||||
waiters.wait_for_image_tasks_status(self.images_client,
|
||||
image_id, 'success')
|
||||
waiters.wait_for_volume_resource_status(self.volumes_client,
|
||||
self.volume['id'],
|
||||
'available')
|
||||
|
||||
image_info = self.images_client.show_image(image_id)
|
||||
self.assertEqual(image_name, image_info['name'])
|
||||
self.assertEqual(CONF.volume.disk_format, image_info['disk_format'])
|
||||
image_info = self.images_client.show_image(image_id)
|
||||
self.assertEqual(image_name, image_info['name'])
|
||||
self.assertEqual(disk_format, image_info['disk_format'])
|
||||
|
||||
@decorators.idempotent_id('92c4ef64-51b2-40c0-9f7e-4749fbaaba33')
|
||||
def test_reserve_unreserve_volume(self):
|
||||
|
@ -1026,9 +1026,9 @@ VolumeGroup = [
|
||||
cfg.StrOpt('vendor_name',
|
||||
default='Open Source',
|
||||
help='Backend vendor to target when creating volume types'),
|
||||
cfg.StrOpt('disk_format',
|
||||
default='raw',
|
||||
help='Disk format to use when copying a volume to image'),
|
||||
cfg.ListOpt('disk_format',
|
||||
default=['raw', 'qcow2'],
|
||||
help='Disk format to use when copying a volume to image'),
|
||||
cfg.IntOpt('volume_size',
|
||||
default=1,
|
||||
help='Default size in GB for volumes created by volumes tests'),
|
||||
|
Loading…
x
Reference in New Issue
Block a user