Add missing v3 volume tests for which v2 tests exist
This commit adds missing v3 volume tests for which corresponding
v2 tests exist, and if the v2 API is also present in v3.
This commit is necessary for partially deprecating the v2 volume
RBAC tests -- but before that can be done, we need to ensure
that v3 has at least the exact same coverage v2 does, plus
additional coverage for v3 APIs.
This commit specifically adds v3 tests for:
- test_qos_rbac
- test_volume_basic_crud_rbac
- test_volume_hosts_rbac
- test_volume_metadata_rbac
This commit also adds a missing RBAC test for showing a volume
host for both v2 and v3.
Depends-On: I09ad8200f73273dae8e5d926939620b71d9210e8
Change-Id: I443dfb8e1032ff327f03eb8e8b257df124ad6180
Partially Implements: blueprint test-v3-volume-api-only
diff --git a/patrole_tempest_plugin/tests/api/volume/rbac_base.py b/patrole_tempest_plugin/tests/api/volume/rbac_base.py
index c43c552..6db364e 100644
--- a/patrole_tempest_plugin/tests/api/volume/rbac_base.py
+++ b/patrole_tempest_plugin/tests/api/volume/rbac_base.py
@@ -35,14 +35,8 @@
super(BaseVolumeRbacTest, cls).setup_clients()
cls.rbac_utils = rbac_utils.RbacUtils(cls)
- version_checker = {
- 2: [cls.os_primary.volume_hosts_v2_client,
- cls.os_primary.volume_types_v2_client],
- 3: [cls.os_primary.volume_hosts_v2_client,
- cls.os_primary.volume_types_v2_client]
- }
- cls.volume_hosts_client, cls.volume_types_client = \
- version_checker[cls._api_version]
+ cls.volume_hosts_client = cls.os_primary.volume_hosts_v2_client
+ cls.volume_types_client = cls.os_primary.volume_types_v2_client
cls.groups_client = cls.os_primary.groups_v3_client
cls.group_types_client = cls.os_primary.group_types_v3_client
diff --git a/patrole_tempest_plugin/tests/api/volume/test_qos_rbac.py b/patrole_tempest_plugin/tests/api/volume/test_qos_rbac.py
index 7d9ec0f..2327de8 100644
--- a/patrole_tempest_plugin/tests/api/volume/test_qos_rbac.py
+++ b/patrole_tempest_plugin/tests/api/volume/test_qos_rbac.py
@@ -146,3 +146,7 @@
self.qos_client.disassociate_all_qos(qos['id'])
waiters.wait_for_qos_operations(self.admin_qos_client, qos['id'],
'disassociate-all')
+
+
+class VolumeQOSV3RbacTest(VolumeQOSRbacTest):
+ _api_version = 3
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 d780de7..3f5227e 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
@@ -20,11 +20,11 @@
from patrole_tempest_plugin.tests.api.volume import rbac_base
-class VolumesV2BasicCrudRbacTest(rbac_base.BaseVolumeRbacTest):
+class VolumesBasicCrudRbacTest(rbac_base.BaseVolumeRbacTest):
@classmethod
def resource_setup(cls):
- super(VolumesV2BasicCrudRbacTest, cls).resource_setup()
+ super(VolumesBasicCrudRbacTest, cls).resource_setup()
cls.volume = cls.create_volume()
@rbac_rule_validation.action(service="cinder",
@@ -72,5 +72,5 @@
self.volumes_client.list_volumes(detail=True)
-class VolumesV3BasicCrudRbacTest(VolumesV2BasicCrudRbacTest):
+class VolumesBasicCrudV3RbacTest(VolumesBasicCrudRbacTest):
_api_version = 3
diff --git a/patrole_tempest_plugin/tests/api/volume/test_volume_hosts_rbac.py b/patrole_tempest_plugin/tests/api/volume/test_volume_hosts_rbac.py
index 18a2768..ee0a0be 100644
--- a/patrole_tempest_plugin/tests/api/volume/test_volume_hosts_rbac.py
+++ b/patrole_tempest_plugin/tests/api/volume/test_volume_hosts_rbac.py
@@ -27,3 +27,19 @@
def test_list_hosts(self):
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
self.volume_hosts_client.list_hosts()
+
+ @decorators.idempotent_id('9ddf321e-788f-4787-b8cc-dfa59e264143')
+ @rbac_rule_validation.action(service="cinder",
+ rule="volume_extension:hosts")
+ def test_show_host(self):
+ hosts = self.volume_hosts_client.list_hosts()['hosts']
+ host_names = [host['host_name'] for host in hosts]
+ self.assertNotEmpty(host_names, "No available volume host was found, "
+ "all hosts found were: %s" % hosts)
+
+ self.rbac_utils.switch_role(self, toggle_rbac_role=True)
+ self.volume_hosts_client.show_host(host_names[0])
+
+
+class VolumeHostsV3RbacTest(VolumeHostsRbacTest):
+ _api_version = 3
diff --git a/patrole_tempest_plugin/tests/api/volume/test_volume_metadata_rbac.py b/patrole_tempest_plugin/tests/api/volume/test_volume_metadata_rbac.py
index 8c4185b..f9114a8 100644
--- a/patrole_tempest_plugin/tests/api/volume/test_volume_metadata_rbac.py
+++ b/patrole_tempest_plugin/tests/api/volume/test_volume_metadata_rbac.py
@@ -103,3 +103,7 @@
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
self.volumes_client.update_volume_image_metadata(
self.volume['id'], image_id=self.image_id)
+
+
+class VolumeMetadataV3RbacTest(VolumeMetadataRbacTest):
+ _api_version = 3