Add test case for reset group snapshot status
Reset group snapshot status is a new api implemented in v3 group snapshots, min_microversion is 3.19. This patch adds test case for this new feature. Including: [1] Add reset group snapshot status api to v3 group_snapshots_client [2] Add unit test for reset group snapshot status api [3] Add test case: test_reset_group_snapshot_status [4] Add release note Change-Id: I14f5b8fd0f386ea5f84cc3a2decede430a7e7893
This commit is contained in:
parent
f5eba41158
commit
23df2c0ac5
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
Add reset group snapshot status API to v3 group_snapshots_client library,
|
||||||
|
min_microversion of this API is 3.19. This feature enables the possibility
|
||||||
|
to reset group snapshot status.
|
|
@ -63,9 +63,9 @@ class BaseGroupsTest(base.BaseVolumeAdminTest):
|
||||||
|
|
||||||
|
|
||||||
class GroupsTest(BaseGroupsTest):
|
class GroupsTest(BaseGroupsTest):
|
||||||
|
_api_version = 3
|
||||||
min_microversion = '3.14'
|
min_microversion = '3.14'
|
||||||
max_microversion = 'latest'
|
max_microversion = 'latest'
|
||||||
_api_version = 3
|
|
||||||
|
|
||||||
@decorators.idempotent_id('4b111d28-b73d-4908-9bd2-03dc2992e4d4')
|
@decorators.idempotent_id('4b111d28-b73d-4908-9bd2-03dc2992e4d4')
|
||||||
def test_group_create_show_list_delete(self):
|
def test_group_create_show_list_delete(self):
|
||||||
|
@ -316,6 +316,55 @@ class GroupsTest(BaseGroupsTest):
|
||||||
self.assertEqual(2, len(grp_vols))
|
self.assertEqual(2, len(grp_vols))
|
||||||
|
|
||||||
|
|
||||||
|
class GroupsV319Test(BaseGroupsTest):
|
||||||
|
_api_version = 3
|
||||||
|
min_microversion = '3.19'
|
||||||
|
max_microversion = 'latest'
|
||||||
|
|
||||||
|
@decorators.idempotent_id('3b42c9b9-c984-4444-816e-ca2e1ed30b40')
|
||||||
|
def test_reset_group_snapshot_status(self):
|
||||||
|
# Create volume type
|
||||||
|
volume_type = self.create_volume_type()
|
||||||
|
|
||||||
|
# Create group type
|
||||||
|
group_type = self.create_group_type()
|
||||||
|
|
||||||
|
# Create group
|
||||||
|
group = self._create_group(group_type, volume_type)
|
||||||
|
|
||||||
|
# Create volume
|
||||||
|
volume = self.create_volume(volume_type=volume_type['id'],
|
||||||
|
group_id=group['id'])
|
||||||
|
|
||||||
|
# Create group snapshot
|
||||||
|
group_snapshot_name = data_utils.rand_name('group_snapshot')
|
||||||
|
group_snapshot = (self.group_snapshots_client.create_group_snapshot(
|
||||||
|
group_id=group['id'], name=group_snapshot_name)['group_snapshot'])
|
||||||
|
self.addCleanup(self._delete_group_snapshot,
|
||||||
|
group_snapshot['id'], group['id'])
|
||||||
|
snapshots = self.snapshots_client.list_snapshots(
|
||||||
|
detail=True)['snapshots']
|
||||||
|
for snap in snapshots:
|
||||||
|
if volume['id'] == snap['volume_id']:
|
||||||
|
waiters.wait_for_volume_resource_status(
|
||||||
|
self.snapshots_client, snap['id'], 'available')
|
||||||
|
waiters.wait_for_volume_resource_status(
|
||||||
|
self.group_snapshots_client, group_snapshot['id'], 'available')
|
||||||
|
|
||||||
|
# Reset group snapshot status
|
||||||
|
self.addCleanup(waiters.wait_for_volume_resource_status,
|
||||||
|
self.group_snapshots_client,
|
||||||
|
group_snapshot['id'], 'available')
|
||||||
|
self.addCleanup(
|
||||||
|
self.admin_group_snapshots_client.reset_group_snapshot_status,
|
||||||
|
group_snapshot['id'], 'available')
|
||||||
|
for status in ['creating', 'available', 'error']:
|
||||||
|
self.admin_group_snapshots_client.reset_group_snapshot_status(
|
||||||
|
group_snapshot['id'], status)
|
||||||
|
waiters.wait_for_volume_resource_status(
|
||||||
|
self.group_snapshots_client, group_snapshot['id'], status)
|
||||||
|
|
||||||
|
|
||||||
class GroupsV320Test(BaseGroupsTest):
|
class GroupsV320Test(BaseGroupsTest):
|
||||||
_api_version = 3
|
_api_version = 3
|
||||||
min_microversion = '3.20'
|
min_microversion = '3.20'
|
||||||
|
|
|
@ -75,6 +75,18 @@ class GroupSnapshotsClient(base_client.BaseClient):
|
||||||
self.expected_success(200, resp.status)
|
self.expected_success(200, resp.status)
|
||||||
return rest_client.ResponseBody(resp, body)
|
return rest_client.ResponseBody(resp, body)
|
||||||
|
|
||||||
|
def reset_group_snapshot_status(self, group_snapshot_id, status_to_set):
|
||||||
|
"""Resets group snapshot status.
|
||||||
|
|
||||||
|
For more information, please refer to the official API reference:
|
||||||
|
https://developer.openstack.org/api-ref/block-storage/v3/#reset-group-snapshot-status
|
||||||
|
"""
|
||||||
|
post_body = json.dumps({'reset_status': {'status': status_to_set}})
|
||||||
|
resp, body = self.post('group_snapshots/%s/action' % group_snapshot_id,
|
||||||
|
post_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_snapshot(id)
|
self.show_group_snapshot(id)
|
||||||
|
|
|
@ -139,3 +139,12 @@ class TestGroupSnapshotsClient(base.BaseServiceTest):
|
||||||
{},
|
{},
|
||||||
group_snapshot_id='0e701ab8-1bec-4b9f-b026-a7ba4af13578',
|
group_snapshot_id='0e701ab8-1bec-4b9f-b026-a7ba4af13578',
|
||||||
status=202)
|
status=202)
|
||||||
|
|
||||||
|
def test_reset_group_snapshot_status(self):
|
||||||
|
self.check_service_client_function(
|
||||||
|
self.client.reset_group_snapshot_status,
|
||||||
|
'tempest.lib.common.rest_client.RestClient.post',
|
||||||
|
{},
|
||||||
|
status=202,
|
||||||
|
group_snapshot_id='0e701ab8-1bec-4b9f-b026-a7ba4af13578',
|
||||||
|
status_to_set='error')
|
||||||
|
|
Loading…
Reference in New Issue