Refactor volume groups and group snapshots tests
According to api microversion history of Cinder[1], min microversion for
volume groups (create/delete/update/list/show) is 3.13, min microversion
for group snapshots(create/delete/list/show) and create group from group
or group snapshot is 3.14.
While in GroupsTest in Tempest, the min microversion for volume groups is
set to 3.14. This patch aims to refactor the original GroupsTest to correct
the min microversion for volume groups, and also spilt it into two parts,
one for groups tests and the other for group snapshot tests, which will make
the code more clear and readable.
[1] https://docs.openstack.org/cinder/latest/contributor/api_microversion_history.html
Change-Id: Ic98e8892c4a44850d7a7afac9be1aa59ab38bb8c
diff --git a/tempest/api/volume/base.py b/tempest/api/volume/base.py
index 63ef85b..ea3bb5a 100644
--- a/tempest/api/volume/base.py
+++ b/tempest/api/volume/base.py
@@ -242,6 +242,27 @@
self.servers_client.delete_server, body['id'])
return body
+ def create_group(self, **kwargs):
+ if 'name' not in kwargs:
+ kwargs['name'] = data_utils.rand_name(
+ self.__class__.__name__ + '-Group')
+
+ group = self.groups_client.create_group(**kwargs)['group']
+ self.addCleanup(test_utils.call_and_ignore_notfound_exc,
+ self.delete_group, group['id'])
+ waiters.wait_for_volume_resource_status(
+ self.groups_client, group['id'], 'available')
+ return group
+
+ def delete_group(self, group_id, delete_volumes=True):
+ self.groups_client.delete_group(group_id, delete_volumes)
+ if delete_volumes:
+ vols = self.volumes_client.list_volumes(detail=True)['volumes']
+ for vol in vols:
+ if vol['group_id'] == group_id:
+ self.volumes_client.wait_for_resource_deletion(vol['id'])
+ self.groups_client.wait_for_resource_deletion(group_id)
+
class BaseVolumeAdminTest(BaseVolumeTest):
"""Base test case class for all Volume Admin API tests."""