Add volume create from image test

This patch set adds tests for the following policy:

"volume:create_from_image" [0]

Note that this is mutually exclusive with "volume:create" [1]
so multi-policy is not needed for the new test:
test_create_volume_from_image

[0] fe69f67936/cinder/policies/volumes.py (L52)
[1] 4bb00dbcf6/cinder/volume/api.py (L210)

Change-Id: I27bdefa57ed60e9fb1764a65afec117e86e71cee
This commit is contained in:
Felipe Monteiro 2018-07-29 13:08:54 -04:00
parent 7fa1f735fa
commit 6925095992
1 changed files with 17 additions and 0 deletions

View File

@ -41,6 +41,23 @@ class VolumesBasicCrudV3RbacTest(rbac_base.BaseVolumeRbacTest):
with self.rbac_utils.override_role(self):
volume = self.volumes_client.create_volume(name=name, size=size)[
'volume']
# Use helper in base Tempest volume class which waits for deletion.
self.addCleanup(self.delete_volume, self.volumes_client, volume['id'])
waiters.wait_for_volume_resource_status(self.volumes_client,
volume['id'], 'available')
@decorators.idempotent_id('a009e6dc-e8bf-4412-99f5-8e45cffcffec')
@rbac_rule_validation.action(service="cinder",
rules=["volume:create_from_image"])
def test_create_volume_from_image(self):
name = data_utils.rand_name(self.__class__.__name__ + '-Volume')
size = CONF.volume.volume_size
img_uuid = CONF.compute.image_ref
with self.rbac_utils.override_role(self):
volume = self.volumes_client.create_volume(
name=name, size=size, imageRef=img_uuid)['volume']
# Use helper in base Tempest volume class which waits for deletion.
self.addCleanup(self.delete_volume, self.volumes_client, volume['id'])
waiters.wait_for_volume_resource_status(self.volumes_client,
volume['id'], 'available')