Fix list_group_snapshots API in v3 group_snapshots_client
The API (list group snapshots with details) is wrongly implemented now. It uses the '?detail=True' to get group snapshots list with details, which only returns 'id' and 'name' elements of group snapshots. This patch fixes on group snapshots api and according api/unit tests to solve this problem. Closes-bug: #1715786 Change-Id: Ia869a7dc9654a6253c2209724afd2fe2f8519558
This commit is contained in:
parent
54d8f90496
commit
3b2a215df4
@ -0,0 +1,6 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
Fix list_group_snapshots API in v3 group_snapshots_client: Bug#1715786.
|
||||
The url path for list group snapshots with details API is changed from
|
||||
``?detail=True`` to ``/detail``.
|
@ -167,18 +167,20 @@ class GroupsTest(base.BaseVolumeAdminTest):
|
||||
group_snapshot['id'])['group_snapshot']
|
||||
self.assertEqual(group_snapshot_name, group_snapshot['name'])
|
||||
|
||||
# Get all group snapshots with detail
|
||||
group_snapshots = (
|
||||
self.group_snapshots_client.list_group_snapshots(
|
||||
detail=True)['group_snapshots'])
|
||||
# Get all group snapshots with details, check some detail-specific
|
||||
# elements, and look for the created group snapshot
|
||||
group_snapshots = (self.group_snapshots_client.list_group_snapshots(
|
||||
detail=True)['group_snapshots'])
|
||||
for grp_snapshot in group_snapshots:
|
||||
self.assertIn('created_at', grp_snapshot)
|
||||
self.assertIn('group_id', grp_snapshot)
|
||||
self.assertIn((group_snapshot['name'], group_snapshot['id']),
|
||||
[(m['name'], m['id']) for m in group_snapshots])
|
||||
|
||||
# Delete group snapshot
|
||||
self._delete_group_snapshot(group_snapshot['id'], grp['id'])
|
||||
group_snapshots = (
|
||||
self.group_snapshots_client.list_group_snapshots(
|
||||
detail=True)['group_snapshots'])
|
||||
group_snapshots = (self.group_snapshots_client.list_group_snapshots()
|
||||
['group_snapshots'])
|
||||
self.assertEmpty(group_snapshots)
|
||||
|
||||
@decorators.idempotent_id('eff52c70-efc7-45ed-b47a-4ad675d09b81')
|
||||
|
@ -60,7 +60,7 @@ class GroupSnapshotsClient(base_client.BaseClient):
|
||||
self.expected_success(200, resp.status)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def list_group_snapshots(self, **params):
|
||||
def list_group_snapshots(self, detail=False, **params):
|
||||
"""Information for all the tenant's group snapshots.
|
||||
|
||||
For more information, please refer to the official API reference:
|
||||
@ -68,6 +68,8 @@ class GroupSnapshotsClient(base_client.BaseClient):
|
||||
https://developer.openstack.org/api-ref/block-storage/v3/#list-group-snapshots-with-details
|
||||
"""
|
||||
url = "group_snapshots"
|
||||
if detail:
|
||||
url += "/detail"
|
||||
if params:
|
||||
url += '?%s' % urllib.urlencode(params)
|
||||
resp, body = self.get(url)
|
||||
|
@ -93,7 +93,8 @@ class TestGroupSnapshotsClient(base.BaseServiceTest):
|
||||
bytes_body,
|
||||
group_snapshot_id="3fbbcccf-d058-4502-8844-6feeffdf4cb5")
|
||||
|
||||
def _test_list_group_snapshots(self, bytes_body=False, detail=False):
|
||||
def _test_list_group_snapshots(self, detail=False, bytes_body=False,
|
||||
mock_args='group_snapshots', **params):
|
||||
resp_body = []
|
||||
if detail:
|
||||
resp_body = self.FAKE_LIST_GROUP_SNAPSHOTS
|
||||
@ -111,8 +112,10 @@ class TestGroupSnapshotsClient(base.BaseServiceTest):
|
||||
self.client.list_group_snapshots,
|
||||
'tempest.lib.common.rest_client.RestClient.get',
|
||||
resp_body,
|
||||
bytes_body,
|
||||
detail=detail)
|
||||
to_utf=bytes_body,
|
||||
mock_args=[mock_args],
|
||||
detail=detail,
|
||||
**params)
|
||||
|
||||
def test_create_group_snapshot_with_str_body(self):
|
||||
self._test_create_group_snapshot()
|
||||
@ -132,6 +135,25 @@ class TestGroupSnapshotsClient(base.BaseServiceTest):
|
||||
def test_list_group_snapshots_with_bytes_body(self):
|
||||
self._test_list_group_snapshots(bytes_body=True)
|
||||
|
||||
def test_list_group_snapshots_with_detail_with_str_body(self):
|
||||
mock_args = "group_snapshots/detail"
|
||||
self._test_list_group_snapshots(detail=True, mock_args=mock_args)
|
||||
|
||||
def test_list_group_snapshots_with_detail_with_bytes_body(self):
|
||||
mock_args = "group_snapshots/detail"
|
||||
self._test_list_group_snapshots(detail=True, bytes_body=True,
|
||||
mock_args=mock_args)
|
||||
|
||||
def test_list_group_snapshots_with_params(self):
|
||||
# Run the test separately for each param, to avoid assertion error
|
||||
# resulting from randomized params order.
|
||||
mock_args = 'group_snapshots?sort_key=name'
|
||||
self._test_list_group_snapshots(mock_args=mock_args, sort_key='name')
|
||||
|
||||
mock_args = 'group_snapshots/detail?limit=10'
|
||||
self._test_list_group_snapshots(detail=True, bytes_body=True,
|
||||
mock_args=mock_args, limit=10)
|
||||
|
||||
def test_delete_group_snapshot(self):
|
||||
self.check_service_client_function(
|
||||
self.client.delete_group_snapshot,
|
||||
|
Loading…
Reference in New Issue
Block a user