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] https://github.com/openstack/cinder/blob/fe69f679369057a7c381178f770bf68d0bc1cee0/cinder/policies/volumes.py#L52
[1] https://github.com/openstack/cinder/blob/4bb00dbcf6af2f140694eb535696f0f6fe3ae80e/cinder/volume/api.py#L210
Change-Id: I27bdefa57ed60e9fb1764a65afec117e86e71cee
diff --git a/patrole_tempest_plugin/tests/api/volume/test_volume_basic_crud_rbac.py b/patrole_tempest_plugin/tests/api/volume/test_volume_basic_crud_rbac.py
index 2172fbb..ac2255a 100644
--- a/patrole_tempest_plugin/tests/api/volume/test_volume_basic_crud_rbac.py
+++ b/patrole_tempest_plugin/tests/api/volume/test_volume_basic_crud_rbac.py
@@ -41,6 +41,23 @@
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')