Add update groups types API endpoint to volumes v3 library
This PS adds update group types API to v3 ``group_types_client`` library; min_microversion of this API is 3.11 [0]. Included in this PS: * Update group types API to group_types_client * Unit tests for update API * API test for update API [0] https://docs.openstack.org/cinder/latest/contributor/api_microversion_history.html#id11 Change-Id: Ie3834c1a4b3ebd1463cdaacc86cd21b7be9fa3ce
This commit is contained in:
parent
ce5f6094a1
commit
a2f69f11a7
releasenotes/notes
tempest
api/volume/admin
lib/services/volume/v3
tests/lib/services/volume/v3
@ -0,0 +1,5 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Add update group types API to v3 ``group_types_client`` library;
|
||||
min_microversion of this API is 3.11.
|
@ -24,7 +24,7 @@ class GroupTypesTest(base.BaseVolumeAdminTest):
|
||||
max_microversion = 'latest'
|
||||
|
||||
@decorators.idempotent_id('dd71e5f9-393e-4d4f-90e9-fa1b8d278864')
|
||||
def test_group_type_create_list_show(self):
|
||||
def test_group_type_create_list_update_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")
|
||||
@ -46,8 +46,19 @@ class GroupTypesTest(base.BaseVolumeAdminTest):
|
||||
self.assertIsInstance(group_list, list)
|
||||
self.assertNotEmpty(group_list)
|
||||
|
||||
update_params = {
|
||||
'name': data_utils.rand_name(
|
||||
self.__class__.__name__ + '-updated-group-type'),
|
||||
'description': 'updated-group-type-desc'
|
||||
}
|
||||
updated_group_type = self.admin_group_types_client.update_group_type(
|
||||
body['id'], **update_params)['group_type']
|
||||
for key, expected_val in update_params.items():
|
||||
self.assertEqual(expected_val, updated_group_type[key])
|
||||
|
||||
fetched_group_type = self.admin_group_types_client.show_group_type(
|
||||
body['id'])['group_type']
|
||||
params.update(update_params) # Add updated params to original params.
|
||||
for key in params.keys():
|
||||
self.assertEqual(params[key], fetched_group_type[key],
|
||||
'%s of the fetched group_type is different '
|
||||
|
@ -75,3 +75,16 @@ class GroupTypesClient(base_client.BaseClient):
|
||||
body = json.loads(body)
|
||||
self.expected_success(200, resp.status)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def update_group_type(self, group_type_id, **kwargs):
|
||||
"""Updates a group type.
|
||||
|
||||
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-type
|
||||
"""
|
||||
post_body = json.dumps({'group_type': kwargs})
|
||||
resp, body = self.put('group_types/%s' % group_type_id, post_body)
|
||||
self.expected_success(200, resp.status)
|
||||
body = json.loads(body)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
@ -12,6 +12,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import copy
|
||||
|
||||
from tempest.lib.services.volume.v3 import group_types_client
|
||||
from tempest.tests.lib import fake_auth_provider
|
||||
from tempest.tests.lib.services import base
|
||||
@ -97,6 +99,18 @@ class TestGroupTypesClient(base.BaseServiceTest):
|
||||
self.FAKE_LIST_GROUP_TYPES,
|
||||
bytes_body)
|
||||
|
||||
def _test_update_group_types(self, bytes_body=False):
|
||||
resp_body = copy.deepcopy(self.FAKE_INFO_GROUP_TYPE)
|
||||
resp_body['group_type'].pop('created_at')
|
||||
|
||||
self.check_service_client_function(
|
||||
self.client.update_group_type,
|
||||
'tempest.lib.common.rest_client.RestClient.put',
|
||||
resp_body,
|
||||
bytes_body,
|
||||
group_type_id="3fbbcccf-d058-4502-8844-6feeffdf4cb5",
|
||||
name='updated-group-type-name')
|
||||
|
||||
def test_create_group_type_with_str_body(self):
|
||||
self._test_create_group_type()
|
||||
|
||||
@ -122,3 +136,9 @@ class TestGroupTypesClient(base.BaseServiceTest):
|
||||
|
||||
def test_list_group_types_with_bytes_body(self):
|
||||
self._test_list_group_types(bytes_body=True)
|
||||
|
||||
def test_update_group_types_with_str_body(self):
|
||||
self._test_update_group_types()
|
||||
|
||||
def test_update_group_types_with_bytes_body(self):
|
||||
self._test_update_group_types(bytes_body=True)
|
||||
|
Loading…
x
Reference in New Issue
Block a user