Merge "Avoid image format tests if glance is enforcing"

This commit is contained in:
Zuul 2024-11-04 10:56:01 +00:00 committed by Gerrit Code Review
commit 4f3b086b66
5 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,8 @@
---
features:
- |
Add a new config option
`[image_feature_enabled]/image_format_enforcement` which tells tempest
that glance will do image format inspection and enforcement on upload. This
will disable tests that require glance to accept a bad image in order to
test another service (i.e. nova).

View File

@ -536,6 +536,15 @@ class ListUserImagesTest(base.BaseV2ImageTest):
for container_fmt in container_fmts
for disk_fmt in disk_fmts]
# NOTE(danms): This tests depends on being able to lie about image
# content. We can probably improve this in some way, but without a
# valid sample of each image format in each container format, there is
# no easy solution.
if CONF.image_feature_enabled.image_format_enforcement:
raise cls.skipException(
'Image format enforcement prevents testing with '
'bogus image data')
for (container_fmt, disk_fmt) in all_pairs[:6]:
LOG.debug("Creating an image "
"(Container format: %s, Disk format: %s).",

View File

@ -166,6 +166,12 @@ class ImagesFormatTest(base.BaseV2ImageTest,
# a properly-formatted image for it, so skip it.
self.skipTest(
'Format %s not allowed by config' % self.imgdef['format'])
if CONF.image_feature_enabled.image_format_enforcement:
# If glance rejects bad images during upload, we cannot get them
# registered so that we can test nova.
self.skipTest(
'Unable to test compute image formats if glance does not '
'allow them to be uploaded')
# VMDK with footer was not supported by earlier service versions,
# so we need to tolerate it passing and failing (skip for the latter).
@ -191,6 +197,12 @@ class ImagesFormatTest(base.BaseV2ImageTest,
@decorators.idempotent_id('ffe21610-e801-4992-9b81-e2d646e2e2e9')
def test_compute_rejects_format_mismatch(self):
"""Make sure compute rejects any image with a format mismatch."""
if CONF.image_feature_enabled.image_format_enforcement:
# If glance rejects bad images during upload, we cannot get them
# registered so that we can test nova.
self.skipTest(
'Unable to test compute image formats if glance does not '
'allow them to be uploaded')
# Lying about the disk_format should always fail
override_fmt = (
self.imgdef['format'] in ('raw', 'gpt') and 'qcow2' or 'raw')

View File

@ -728,6 +728,11 @@ ImageFeaturesGroup = [
cfg.BoolOpt('image_conversion',
default=False,
help=('Is image_conversion enabled in glance.')),
cfg.BoolOpt('image_format_enforcement',
default=True,
help=('Indicates that image format is enforced by glance, '
'such that we should not expect to be able to upload '
'bad images for testing other services.')),
]
network_group = cfg.OptGroup(name='network',

View File

@ -330,6 +330,7 @@
devstack_localrc:
CINDER_ENABLED_BACKENDS: lvm:lvmdriver-1,lvm:lvmdriver-2
ENABLE_VOLUME_MULTIATTACH: true
GLANCE_ENFORCE_IMAGE_FORMAT: false
devstack_plugins:
neutron: https://opendev.org/openstack/neutron
devstack_services: