Add Tests for Create/Delete/Show/List Group Types

Generic volume groups support was added to Cinder in the
Newton release. Group types APIs were added as part of that.
https://blueprints.launchpad.net/cinder/+spec/generic-volume-group

This patch adds the tempest tests for group types APIs
in Cinder. It tests the following APIs:

  * create group type
  * delete group type
  * show group type
  * list group types

Change-Id: Ic409db6f1258befc6f1772ea19e7e634170269f8
This commit is contained in:
xing-yang 2017-07-01 14:21:42 -07:00
parent e1e6e7825d
commit 6891411395
4 changed files with 155 additions and 0 deletions

View File

@ -0,0 +1,5 @@
---
features:
- |
Add list_group_type and show_group_type in the group_types client for
the volume service. Add tests for create/delete/show/list group types.

View File

@ -0,0 +1,54 @@
# Copyright (C) 2017 Dell Inc. or its subsidiaries.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from tempest.api.volume import base
from tempest.lib.common.utils import data_utils
from tempest.lib import decorators
class GroupTypesTest(base.BaseVolumeAdminTest):
_api_version = 3
min_microversion = '3.11'
max_microversion = 'latest'
@decorators.idempotent_id('dd71e5f9-393e-4d4f-90e9-fa1b8d278864')
def test_group_type_create_list_show(self):
# Create/list/show group type.
name = data_utils.rand_name(self.__class__.__name__ + '-group-type')
description = data_utils.rand_name("group-type-description")
group_specs = {"consistent_group_snapshot_enabled": "<is> False"}
params = {'name': name,
'description': description,
'group_specs': group_specs,
'is_public': True}
body = self.create_group_type(**params)
self.assertIn('name', body)
err_msg = ("The created group_type %(var)s is not equal to the "
"requested %(var)s")
self.assertEqual(name, body['name'], err_msg % {"var": "name"})
self.assertEqual(description, body['description'],
err_msg % {"var": "description"})
group_list = (
self.admin_group_types_client.list_group_types()['group_types'])
self.assertIsInstance(group_list, list)
self.assertNotEmpty(group_list)
fetched_group_type = self.admin_group_types_client.show_group_type(
body['id'])['group_type']
for key in params.keys():
self.assertEqual(params[key], fetched_group_type[key],
'%s of the fetched group_type is different '
'from the created group_type' % key)

View File

@ -14,6 +14,7 @@
# under the License.
from oslo_serialization import jsonutils as json
from six.moves.urllib import parse as urllib
from tempest.lib.common import rest_client
from tempest.lib.services.volume import base_client
@ -46,3 +47,31 @@ class GroupTypesClient(base_client.BaseClient):
resp, body = self.delete("group_types/%s" % group_type_id)
self.expected_success(202, resp.status)
return rest_client.ResponseBody(resp, body)
def list_group_types(self, **params):
"""List all the group_types created.
For a full list of available parameters, please refer to the official
API reference:
https://developer.openstack.org/api-ref/block-storage/v3/#list-group-types
"""
url = 'group_types'
if params:
url += '?%s' % urllib.urlencode(params)
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
return rest_client.ResponseBody(resp, body)
def show_group_type(self, group_type_id):
"""Returns the details of a single group_type.
For more information, please refer to the official API reference:
https://developer.openstack.org/api-ref/block-storage/v3/#show-group-type-details
"""
url = "group_types/%s" % group_type_id
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
return rest_client.ResponseBody(resp, body)

View File

@ -27,6 +27,46 @@ class TestGroupTypesClient(base.BaseServiceTest):
}
}
FAKE_INFO_GROUP_TYPE = {
"group_type": {
"id": "0e701ab8-1bec-4b9f-b026-a7ba4af13578",
"name": "group-type-001",
"description": "Test group type 1",
"is_public": True,
"created_at": "20127-06-20T03:50:07Z",
"group_specs": {},
}
}
FAKE_LIST_GROUP_TYPES = {
"group_types": [
{
"id": "0e701ab8-1bec-4b9f-b026-a7ba4af13578",
"name": "group-type-001",
"description": "Test group type 1",
"is_public": True,
"created_at": "2017-06-20T03:50:07Z",
"group_specs": {},
},
{
"id": "e479997c-650b-40a4-9dfe-77655818b0d2",
"name": "group-type-002",
"description": "Test group type 2",
"is_public": True,
"created_at": "2017-06-19T01:52:47Z",
"group_specs": {},
},
{
"id": "c5c4769e-213c-40a6-a568-8e797bb691d4",
"name": "group-type-003",
"description": "Test group type 3",
"is_public": True,
"created_at": "2017-06-18T06:34:32Z",
"group_specs": {},
}
]
}
def setUp(self):
super(TestGroupTypesClient, self).setUp()
fake_auth = fake_auth_provider.FakeAuthProvider()
@ -42,6 +82,21 @@ class TestGroupTypesClient(base.BaseServiceTest):
bytes_body,
status=202)
def _test_show_group_type(self, bytes_body=False):
self.check_service_client_function(
self.client.show_group_type,
'tempest.lib.common.rest_client.RestClient.get',
self.FAKE_INFO_GROUP_TYPE,
bytes_body,
group_type_id="3fbbcccf-d058-4502-8844-6feeffdf4cb5")
def _test_list_group_types(self, bytes_body=False):
self.check_service_client_function(
self.client.list_group_types,
'tempest.lib.common.rest_client.RestClient.get',
self.FAKE_LIST_GROUP_TYPES,
bytes_body)
def test_create_group_type_with_str_body(self):
self._test_create_group_type()
@ -55,3 +110,15 @@ class TestGroupTypesClient(base.BaseServiceTest):
{},
group_type_id='0e58433f-d108-4bf3-a22c-34e6b71ef86b',
status=202)
def test_show_group_type_with_str_body(self):
self._test_show_group_type()
def test_show_group_type_with_bytes_body(self):
self._test_show_group_type(bytes_body=True)
def test_list_group_types_with_str_body(self):
self._test_list_group_types()
def test_list_group_types_with_bytes_body(self):
self._test_list_group_types(bytes_body=True)