Add Tests for Groups Volume APIs - Part 4
Generic volume groups support was added to Cinder in the Newton release: https://blueprints.launchpad.net/cinder/+spec/generic-volume-group This is the 4th patch that adds the tempest tests for generic volume groups APIs in Cinder. It adds tests for the following API: * update group Change-Id: I7cc1b7978f24d6cb0e9b13b9387f000b9ca348b3 Co-Authored-By: Imran Ansari <imran.ansari@hpe.com>
This commit is contained in:
parent
66e11c58c4
commit
9ee9860759
@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
Add update_group to groups_client in the volume service library.
|
@ -258,3 +258,49 @@ class GroupsTest(base.BaseVolumeAdminTest):
|
|||||||
self.volumes_client, vol['id'], 'available')
|
self.volumes_client, vol['id'], 'available')
|
||||||
waiters.wait_for_volume_resource_status(
|
waiters.wait_for_volume_resource_status(
|
||||||
self.groups_client, grp2['id'], 'available')
|
self.groups_client, grp2['id'], 'available')
|
||||||
|
|
||||||
|
@decorators.idempotent_id('4a8a6fd2-8b3b-4641-8f54-6a6f99320006')
|
||||||
|
def test_group_update(self):
|
||||||
|
# Create volume type
|
||||||
|
volume_type = self.create_volume_type()
|
||||||
|
|
||||||
|
# Create group type
|
||||||
|
group_type = self.create_group_type()
|
||||||
|
|
||||||
|
# Create Group
|
||||||
|
grp = self._create_group(group_type, volume_type)
|
||||||
|
|
||||||
|
# Create a volume in the group
|
||||||
|
vol1 = self.create_volume(volume_type=volume_type['id'],
|
||||||
|
group_id=grp['id'])
|
||||||
|
# Create a volume not in the group
|
||||||
|
vol2 = self.create_volume(volume_type=volume_type['id'])
|
||||||
|
|
||||||
|
# Remove a volume from group and update name and description
|
||||||
|
new_grp_name = 'new_group'
|
||||||
|
new_desc = 'This is a new group'
|
||||||
|
grp_params = {'name': new_grp_name,
|
||||||
|
'description': new_desc,
|
||||||
|
'remove_volumes': vol1['id'],
|
||||||
|
'add_volumes': vol2['id']}
|
||||||
|
self.groups_client.update_group(grp['id'], **grp_params)
|
||||||
|
|
||||||
|
# Wait for group status to become available
|
||||||
|
waiters.wait_for_volume_resource_status(
|
||||||
|
self.groups_client, grp['id'], 'available')
|
||||||
|
|
||||||
|
# Get the updated Group
|
||||||
|
grp = self.groups_client.show_group(grp['id'])['group']
|
||||||
|
self.assertEqual(new_grp_name, grp['name'])
|
||||||
|
self.assertEqual(new_desc, grp['description'])
|
||||||
|
|
||||||
|
# Get volumes in the group
|
||||||
|
vols = self.volumes_client.list_volumes(
|
||||||
|
detail=True)['volumes']
|
||||||
|
grp_vols = []
|
||||||
|
for vol in vols:
|
||||||
|
if vol['group_id'] == grp['id']:
|
||||||
|
grp_vols.append(vol)
|
||||||
|
self.assertEqual(1, len(grp_vols))
|
||||||
|
self.assertEqual(vol2['id'], grp_vols[0]['id'])
|
||||||
|
self.assertNotEqual(vol1['id'], grp_vols[0]['id'])
|
||||||
|
@ -97,6 +97,18 @@ class GroupsClient(base_client.BaseClient):
|
|||||||
self.expected_success(202, resp.status)
|
self.expected_success(202, resp.status)
|
||||||
return rest_client.ResponseBody(resp, body)
|
return rest_client.ResponseBody(resp, body)
|
||||||
|
|
||||||
|
def update_group(self, group_id, **kwargs):
|
||||||
|
"""Updates the specified group.
|
||||||
|
|
||||||
|
For a full list of available parameters, please refer to the official
|
||||||
|
API reference:
|
||||||
|
https://developer.openstack.org/api-ref/block-storage/v3/#update-group
|
||||||
|
"""
|
||||||
|
put_body = json.dumps({'group': kwargs})
|
||||||
|
resp, body = self.put('groups/%s' % group_id, put_body)
|
||||||
|
self.expected_success(202, resp.status)
|
||||||
|
return rest_client.ResponseBody(resp, body)
|
||||||
|
|
||||||
def is_resource_deleted(self, id):
|
def is_resource_deleted(self, id):
|
||||||
try:
|
try:
|
||||||
self.show_group(id)
|
self.show_group(id)
|
||||||
|
@ -44,6 +44,17 @@ class TestGroupsClient(base.BaseServiceTest):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FAKE_UPDATE_GROUP = {
|
||||||
|
"group": {
|
||||||
|
"name": "new-group",
|
||||||
|
"description": "New test group",
|
||||||
|
"add_volumes": "27d45037-ade3-4a87-b729-dba3293c06f3,"
|
||||||
|
"6e7cd916-d961-41cc-b3bd-0601ca0c701f",
|
||||||
|
"remove_volumes": "4d580519-6467-448e-95e9-5b25c94d83c7,"
|
||||||
|
"ea22464c-f095-4a87-a31f-c5d34e0c6fc9"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FAKE_INFO_GROUP = {
|
FAKE_INFO_GROUP = {
|
||||||
"group": {
|
"group": {
|
||||||
"id": "0e701ab8-1bec-4b9f-b026-a7ba4af13578",
|
"id": "0e701ab8-1bec-4b9f-b026-a7ba4af13578",
|
||||||
@ -164,3 +175,12 @@ class TestGroupsClient(base.BaseServiceTest):
|
|||||||
'tempest.lib.common.rest_client.RestClient.post',
|
'tempest.lib.common.rest_client.RestClient.post',
|
||||||
self.FAKE_CREATE_GROUP_FROM_GROUP,
|
self.FAKE_CREATE_GROUP_FROM_GROUP,
|
||||||
status=202)
|
status=202)
|
||||||
|
|
||||||
|
def test_update_group(self):
|
||||||
|
self.check_service_client_function(
|
||||||
|
self.client.update_group,
|
||||||
|
'tempest.lib.common.rest_client.RestClient.put',
|
||||||
|
{},
|
||||||
|
group_id='0e701ab8-1bec-4b9f-b026-a7ba4af13578',
|
||||||
|
status=202,
|
||||||
|
**self.FAKE_UPDATE_GROUP['group'])
|
||||||
|
Loading…
Reference in New Issue
Block a user