Update multiattach tests

Multiattach tests use legacy format to create multiattach
volumes i.e. provide "multiattach=True" in request body of
a create volume operation.
This patch updates the multiattach tests to use multiattach
volume type, which is the standard and only way[1], to create
multiattach volumes.
Note that the old functionality will be changed by patch[2] and
passing multiattach=True in volume create request body will
error out with BadRequest.

Devstack will create the multiattach volume type, like an
operator will create in a real deployment, and set it as a
tempest config option (see depends on patch).

We are adding a new config option `volume_type_multiattach`
which is used as the multiattach volume type to create
multiattach volumes.

[1] https://docs.openstack.org/cinder/latest/admin/volume-multiattach.html#how-to-create-a-multiattach-volume
[2] https://review.opendev.org/c/openstack/cinder/+/874865

Depends-On: https://review.opendev.org/c/openstack/devstack/+/877337
Depends-On: https://review.opendev.org/c/openstack/devstack/+/877497
Depends-On: https://review.opendev.org/c/openstack/devstack/+/877548
Depends-On: https://review.opendev.org/c/openstack/devstack/+/877498
Depends-On: https://review.opendev.org/c/openstack/devstack/+/877499

Change-Id: I5f68ef56fcc55dfc636936dabb5e6ad761579519
This commit is contained in:
whoami-rajat 2023-02-27 09:41:22 +00:00 committed by Rajat Dhasmana
parent 310c87856b
commit b04b102984
4 changed files with 14 additions and 5 deletions

View File

@ -199,11 +199,12 @@ class TestMultiAttachVolumeSwap(TestVolumeSwapBase):
"server1" "server1"
8. Check "volume2" is attached to "server1". 8. Check "volume2" is attached to "server1".
""" """
multiattach_vol_type = CONF.volume.volume_type_multiattach
# Create two volumes. # Create two volumes.
# NOTE(gmann): Volumes are created before server creation so that # NOTE(gmann): Volumes are created before server creation so that
# volumes cleanup can happen successfully irrespective of which volume # volumes cleanup can happen successfully irrespective of which volume
# is attached to server. # is attached to server.
volume1 = self.create_volume(multiattach=True) volume1 = self.create_volume(volume_type=multiattach_vol_type)
# Make volume1 read-only since you can't swap from a volume with # Make volume1 read-only since you can't swap from a volume with
# multiple read/write attachments, and you can't change the readonly # multiple read/write attachments, and you can't change the readonly
# flag on an in-use volume so we have to do this before attaching # flag on an in-use volume so we have to do this before attaching
@ -211,7 +212,7 @@ class TestMultiAttachVolumeSwap(TestVolumeSwapBase):
# attach modes, then we can handle this differently. # attach modes, then we can handle this differently.
self.admin_volumes_client.update_volume_readonly( self.admin_volumes_client.update_volume_readonly(
volume1['id'], readonly=True) volume1['id'], readonly=True)
volume2 = self.create_volume(multiattach=True) volume2 = self.create_volume(volume_type=multiattach_vol_type)
# Create two servers and wait for them to be ACTIVE. # Create two servers and wait for them to be ACTIVE.
validation_resources = self.get_class_validation_resources( validation_resources = self.get_class_validation_resources(

View File

@ -115,9 +115,11 @@ class UpdateMultiattachVolumeNegativeTest(base.BaseV2ComputeAdminTest):
5. Check "vol1" is still attached to both servers 5. Check "vol1" is still attached to both servers
6. Check "vol2" is not attached to any server 6. Check "vol2" is not attached to any server
""" """
multiattach_vol_type = CONF.volume.volume_type_multiattach
# Create two multiattach capable volumes. # Create two multiattach capable volumes.
vol1 = self.create_volume(multiattach=True) vol1 = self.create_volume(volume_type=multiattach_vol_type)
vol2 = self.create_volume(multiattach=True) vol2 = self.create_volume(volume_type=multiattach_vol_type)
# Create two instances. # Create two instances.
validation_resources = self.get_class_validation_resources( validation_resources = self.get_class_validation_resources(

View File

@ -369,7 +369,9 @@ class AttachVolumeMultiAttachTest(BaseAttachVolumeTest):
kwargs = {} kwargs = {}
if bootable: if bootable:
kwargs['image_ref'] = CONF.compute.image_ref kwargs['image_ref'] = CONF.compute.image_ref
return self.create_volume(multiattach=True, **kwargs) multiattach_vol_type = CONF.volume.volume_type_multiattach
return self.create_volume(volume_type=multiattach_vol_type,
**kwargs)
def _create_and_multiattach(self): def _create_and_multiattach(self):
"""Creates two server instances and a volume and attaches to both. """Creates two server instances and a volume and attaches to both.

View File

@ -1015,6 +1015,10 @@ VolumeGroup = [
cfg.StrOpt('volume_type', cfg.StrOpt('volume_type',
default='', default='',
help='Volume type to be used while creating volume.'), help='Volume type to be used while creating volume.'),
cfg.StrOpt('volume_type_multiattach',
default='',
help='Multiattach volume type used while creating multiattach '
'volume.'),
cfg.StrOpt('storage_protocol', cfg.StrOpt('storage_protocol',
default='iSCSI', default='iSCSI',
help='Backend protocol to target when creating volume types'), help='Backend protocol to target when creating volume types'),