Merge "Add test case for reset group snapshot status"

This commit is contained in:
Jenkins 2017-09-27 14:28:53 +00:00 committed by Gerrit Code Review
commit e2412107e4
4 changed files with 77 additions and 1 deletions

View File

@ -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.

View File

@ -63,9 +63,9 @@ class BaseGroupsTest(base.BaseVolumeAdminTest):
class GroupsTest(BaseGroupsTest):
_api_version = 3
min_microversion = '3.14'
max_microversion = 'latest'
_api_version = 3
@decorators.idempotent_id('4b111d28-b73d-4908-9bd2-03dc2992e4d4')
def test_group_create_show_list_delete(self):
@ -318,6 +318,55 @@ class GroupsTest(BaseGroupsTest):
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):
_api_version = 3
min_microversion = '3.20'

View File

@ -77,6 +77,18 @@ class GroupSnapshotsClient(base_client.BaseClient):
self.expected_success(200, resp.status)
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):
try:
self.show_group_snapshot(id)

View File

@ -161,3 +161,12 @@ class TestGroupSnapshotsClient(base.BaseServiceTest):
{},
group_snapshot_id='0e701ab8-1bec-4b9f-b026-a7ba4af13578',
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')