Skip to content

Commit

Permalink
Add Tests for Groups Volume APIs - Part 4
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
xing-yang and imran-ansari committed Aug 8, 2017
1 parent 66e11c5 commit 9ee9860
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 0 deletions.
@@ -0,0 +1,4 @@
---
features:
- |
Add update_group to groups_client in the volume service library.
46 changes: 46 additions & 0 deletions tempest/api/volume/admin/test_groups.py
Expand Up @@ -258,3 +258,49 @@ def test_create_group_from_group(self):
self.volumes_client, vol['id'], 'available')
waiters.wait_for_volume_resource_status(
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'])
12 changes: 12 additions & 0 deletions tempest/lib/services/volume/v3/groups_client.py
Expand Up @@ -97,6 +97,18 @@ def create_group_from_source(self, **kwargs):
self.expected_success(202, resp.status)
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):
try:
self.show_group(id)
Expand Down
20 changes: 20 additions & 0 deletions tempest/tests/lib/services/volume/v3/test_groups_client.py
Expand Up @@ -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 = {
"group": {
"id": "0e701ab8-1bec-4b9f-b026-a7ba4af13578",
Expand Down Expand Up @@ -164,3 +175,12 @@ def test_create_group_from_group(self):
'tempest.lib.common.rest_client.RestClient.post',
self.FAKE_CREATE_GROUP_FROM_GROUP,
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'])

0 comments on commit 9ee9860

Please sign in to comment.