Update snapshot api microversion docs and tests

Our docs and tests are not up to date with the changes introduced to the
snapshot details introduced by the different microversion.

This patch updates the docs, samples, and tests.

Change-Id: I46fa6e1f7a5d6ad0147f17c2bafbf4fb8fa89eb8
This commit is contained in:
Gorka Eguileor 2021-05-13 12:57:09 +02:00
parent a2f0f57a06
commit d29f12117e
19 changed files with 351 additions and 33 deletions

View File

@ -1283,6 +1283,13 @@ group_snapshot_id:
in: body
required: false
type: string
group_snapshot_id_3_14:
description: |
The ID of the group snapshot.
in: body
required: true
type: string
min_version: 3.14
group_snapshot_id_req:
description: |
The ID of the group snapshot.

View File

@ -0,0 +1,16 @@
{
"snapshot": {
"created_at": "2019-03-11T16:24:34.469003",
"description": "Daily backup",
"id": "b36476e5-d18b-47f9-ac69-4818cb43ee21",
"metadata": {
"key": "v3"
},
"name": "snap-001",
"size": 10,
"status": "creating",
"updated_at": null,
"volume_id": "d291b81c-6e40-4525-8231-90aa1588121e",
"group_snapshot_id": null
}
}

View File

@ -0,0 +1,18 @@
{
"snapshot": {
"created_at": "2019-03-12T04:42:00.809352",
"description": "Daily backup",
"id": "4a584cae-e4ce-429b-9154-d4c9eb8fda4c",
"metadata": {
"key": "v3"
},
"name": "snap-001",
"os-extended-snapshot-attributes:progress": "0%",
"os-extended-snapshot-attributes:project_id": "89afd400-b646-4bbc-b12b-c0a4d63e5bd3",
"size": 10,
"status": "creating",
"updated_at": null,
"volume_id": "b72c48f1-64b7-4cd8-9745-b12e0be82d37",
"group_snapshot_id": null
}
}

View File

@ -0,0 +1,16 @@
{
"snapshot": {
"created_at": "2019-03-12T04:53:53.426591",
"description": "This is yet, another snapshot.",
"id": "43666194-8e72-451a-b7bb-54fef763b2b8",
"metadata": {
"key": "v3"
},
"name": "snap-002",
"size": 10,
"status": "creating",
"updated_at": null,
"volume_id": "070c942d-9909-42e9-a467-7a781f150c58",
"group_snapshot_id": null
}
}

View File

@ -0,0 +1,20 @@
{
"snapshots": [
{
"created_at": "2019-03-11T16:24:36.464445",
"description": "Daily backup",
"id": "d0083dc5-8795-4c1a-bc9c-74f70006c205",
"metadata": {
"key": "v3"
},
"name": "snap-001",
"os-extended-snapshot-attributes:progress": "0%",
"os-extended-snapshot-attributes:project_id": "89afd400-b646-4bbc-b12b-c0a4d63e5bd3",
"size": 10,
"status": "creating",
"updated_at": null,
"volume_id": "7acd675e-4e06-4653-af9f-2ecd546342d6",
"group_snapshot_id": null
}
]
}

View File

@ -0,0 +1,17 @@
{
"snapshot": {
"created_at": "2019-03-11T16:24:34.469003",
"description": "Daily backup",
"id": "b36476e5-d18b-47f9-ac69-4818cb43ee21",
"metadata": {
"key": "v3"
},
"name": "snap-001",
"size": 10,
"status": "creating",
"updated_at": null,
"volume_id": "d291b81c-6e40-4525-8231-90aa1588121e",
"group_snapshot_id": null,
"user_id": "c853ca26-e8ea-4797-8a52-ee124a013d0e"
}
}

View File

@ -0,0 +1,19 @@
{
"snapshot": {
"created_at": "2019-03-12T04:42:00.809352",
"description": "Daily backup",
"id": "4a584cae-e4ce-429b-9154-d4c9eb8fda4c",
"metadata": {
"key": "v3"
},
"name": "snap-001",
"os-extended-snapshot-attributes:progress": "0%",
"os-extended-snapshot-attributes:project_id": "89afd400-b646-4bbc-b12b-c0a4d63e5bd3",
"size": 10,
"status": "creating",
"updated_at": null,
"volume_id": "b72c48f1-64b7-4cd8-9745-b12e0be82d37",
"group_snapshot_id": null,
"user_id": "c853ca26-e8ea-4797-8a52-ee124a013d0e"
}
}

View File

@ -0,0 +1,17 @@
{
"snapshot": {
"created_at": "2019-03-12T04:53:53.426591",
"description": "This is yet, another snapshot.",
"id": "43666194-8e72-451a-b7bb-54fef763b2b8",
"metadata": {
"key": "v3"
},
"name": "snap-002",
"size": 10,
"status": "creating",
"updated_at": null,
"volume_id": "070c942d-9909-42e9-a467-7a781f150c58",
"group_snapshot_id": null,
"user_id": "c853ca26-e8ea-4797-8a52-ee124a013d0e"
}
}

View File

@ -0,0 +1,21 @@
{
"snapshots": [
{
"created_at": "2019-03-11T16:24:36.464445",
"description": "Daily backup",
"id": "d0083dc5-8795-4c1a-bc9c-74f70006c205",
"metadata": {
"key": "v3"
},
"name": "snap-001",
"os-extended-snapshot-attributes:progress": "0%",
"os-extended-snapshot-attributes:project_id": "89afd400-b646-4bbc-b12b-c0a4d63e5bd3",
"size": 10,
"status": "creating",
"updated_at": null,
"volume_id": "7acd675e-4e06-4653-af9f-2ecd546342d6",
"group_snapshot_id": null,
"user_id": "c853ca26-e8ea-4797-8a52-ee124a013d0e"
}
]
}

View File

@ -88,11 +88,12 @@ Response Parameters
- count: count
- updated_at: updated_at
- snapshots_links: links_snap
- group_snapshot_id: group_snapshot_id_3_14
Response Example
----------------
Response Example (v3.41)
------------------------
.. literalinclude:: ./samples/snapshots/snapshots-list-detailed-response.json
.. literalinclude:: ./samples/snapshots/v3.41/snapshots-list-detailed-response.json
:language: javascript
@ -147,11 +148,12 @@ Response Parameters
- id: id_snap
- size: size
- updated_at: updated_at
- group_snapshot_id: group_snapshot_id_3_14
Response Example
----------------
Response Example (v3.41)
------------------------
.. literalinclude:: ./samples/snapshots/snapshot-create-response.json
.. literalinclude:: ./samples/snapshots/v3.41/snapshot-create-response.json
:language: javascript
@ -385,11 +387,12 @@ Response Parameters
- id: id_snap
- metadata: metadata
- updated_at: updated_at
- group_snapshot_id: group_snapshot_id_3_14
Response Example
----------------
Response Example (v3.41)
------------------------
.. literalinclude:: ./samples/snapshots/snapshot-show-response.json
.. literalinclude:: ./samples/snapshots/v3.41/snapshot-show-response.json
:language: javascript
@ -442,11 +445,12 @@ Response Parameters
- volume_id: volume_id_snap
- user_id: user_id_min
- metadata: metadata
- group_snapshot_id: group_snapshot_id_3_14
Response Example
----------------
Response Example (v3.41)
------------------------
.. literalinclude:: ./samples/snapshots/snapshot-update-response.json
.. literalinclude:: ./samples/snapshots/v3.41/snapshot-update-response.json
:language: javascript

View File

@ -0,0 +1,16 @@
{
"snapshot": {
"created_at": "%(strtime)s",
"description": "Daily backup",
"id": "%(uuid)s",
"metadata": {
"key": "v3"
},
"name": "snap-001",
"size": 10,
"status": "creating",
"updated_at": null,
"volume_id": "%(uuid)s",
"group_snapshot_id": null
}
}

View File

@ -0,0 +1,18 @@
{
"snapshot": {
"created_at": "%(strtime)s",
"description": "Daily backup",
"id": "%(uuid)s",
"metadata": {
"key": "v3"
},
"name": "snap-001",
"os-extended-snapshot-attributes:progress": "0%",
"os-extended-snapshot-attributes:project_id": "%(uuid)s",
"size": 10,
"status": "creating",
"updated_at": null,
"volume_id": "%(uuid)s",
"group_snapshot_id": null
}
}

View File

@ -0,0 +1,16 @@
{
"snapshot": {
"created_at": "%(strtime)s",
"description": "This is yet, another snapshot.",
"id": "%(uuid)s",
"metadata": {
"key": "v3"
},
"name": "snap-002",
"size": 10,
"status": "creating",
"updated_at": null,
"volume_id": "%(uuid)s",
"group_snapshot_id": null
}
}

View File

@ -0,0 +1,20 @@
{
"snapshots": [
{
"created_at": "%(strtime)s",
"description": "Daily backup",
"id": "%(uuid)s",
"metadata": {
"key": "v3"
},
"name": "snap-001",
"os-extended-snapshot-attributes:progress": "0%",
"os-extended-snapshot-attributes:project_id": "%(uuid)s",
"size": 10,
"status": "creating",
"updated_at": null,
"volume_id": "%(uuid)s",
"group_snapshot_id": null
}
]
}

View File

@ -0,0 +1,17 @@
{
"snapshot": {
"created_at": "%(strtime)s",
"description": "Daily backup",
"id": "%(uuid)s",
"metadata": {
"key": "v3"
},
"name": "snap-001",
"size": 10,
"status": "creating",
"updated_at": null,
"volume_id": "%(uuid)s",
"group_snapshot_id": null,
"user_id": "%(uuid)s"
}
}

View File

@ -0,0 +1,19 @@
{
"snapshot": {
"created_at": "%(strtime)s",
"description": "Daily backup",
"id": "%(uuid)s",
"metadata": {
"key": "v3"
},
"name": "snap-001",
"os-extended-snapshot-attributes:progress": "0%",
"os-extended-snapshot-attributes:project_id": "%(uuid)s",
"size": 10,
"status": "creating",
"updated_at": null,
"volume_id": "%(uuid)s",
"group_snapshot_id": null,
"user_id": "%(uuid)s"
}
}

View File

@ -0,0 +1,17 @@
{
"snapshot": {
"created_at": "%(strtime)s",
"description": "This is yet, another snapshot.",
"id": "%(uuid)s",
"metadata": {
"key": "v3"
},
"name": "snap-002",
"size": 10,
"status": "creating",
"updated_at": null,
"volume_id": "%(uuid)s",
"group_snapshot_id": null,
"user_id": "%(uuid)s"
}
}

View File

@ -0,0 +1,21 @@
{
"snapshots": [
{
"created_at": "%(strtime)s",
"description": "Daily backup",
"id": "%(uuid)s",
"metadata": {
"key": "v3"
},
"name": "snap-001",
"os-extended-snapshot-attributes:progress": "0%",
"os-extended-snapshot-attributes:project_id": "%(uuid)s",
"size": 10,
"status": "creating",
"updated_at": null,
"volume_id": "%(uuid)s",
"group_snapshot_id": null,
"user_id": "%(uuid)s"
}
]
}

View File

@ -12,21 +12,22 @@
from oslo_serialization import jsonutils
from cinder.api import microversions as mv
from cinder.tests.functional import api_samples_test_base as test_base
class VolumeSnapshotsSampleJsonTest(test_base.VolumesSampleBase):
class SnapshotBaseTest(test_base.VolumesSampleBase):
sample_dir = "snapshots"
def setUp(self):
super(VolumeSnapshotsSampleJsonTest, self).setUp()
def setup(self):
res = self._create_volume()
res = jsonutils.loads(res.content)['volume']
self._poll_volume_while(res['id'], ['creating'])
self.subs = {
"volume_id": res['id']
}
self.response = self._create_snapshot(self.subs)
with self.common_api_sample():
self.response = self._create_snapshot(self.subs)
def _create_snapshot(self, subs=None):
response = self._do_post('snapshots',
@ -34,17 +35,50 @@ class VolumeSnapshotsSampleJsonTest(test_base.VolumesSampleBase):
subs)
return response
def test_snapshot_list_detail(self):
@test_base.VolumesSampleBase.use_versions(
mv.BASE_VERSION, # 3.0
mv.GROUP_SNAPSHOTS, # 3.14
mv.SNAPSHOT_LIST_USER_ID) # 3.41
class SnapshotDetailTests(SnapshotBaseTest):
"""Test snapshot details returned for operations with different MVs.
The details of a snapshot have changed in the different microversions, and
we have multiple operations that return them, so we should confirm that
each microversion returns the right values for all these different
operations.
"""
def test_snapshot_list_detail(self):
response = self._do_get('snapshots/detail')
self._verify_response('snapshots-list-detailed-response',
{}, response, 200)
def test_snapshot_create(self):
self._verify_response('snapshot-create-response',
{}, self.response, 202)
def test_snapshot_show(self):
res = jsonutils.loads(self.response.content)['snapshot']
response = self._do_get('snapshots/%s' % res['id'])
self._verify_response('snapshot-show-response',
{}, response, 200)
def test_snapshot_update(self):
res = jsonutils.loads(self.response.content)['snapshot']
# Use the request sample from the common API, since the request didn't
# change with the microversion, what changes is the response.
with self.common_api_sample():
response = self._do_put('snapshots/%s' % res['id'],
'snapshot-update-request')
self._verify_response('snapshot-update-response',
{}, response, 200)
class VolumeSnapshotsSampleJsonTest(SnapshotBaseTest):
def setUp(self):
super(VolumeSnapshotsSampleJsonTest, self).setUp()
self.setup()
def test_snapshot_list(self):
response = self._do_get('snapshots')
@ -74,21 +108,6 @@ class VolumeSnapshotsSampleJsonTest(test_base.VolumesSampleBase):
self._verify_response('snapshot-metadata-update-response',
{}, response, 200)
def test_snapshot_show(self):
res = jsonutils.loads(self.response.content)['snapshot']
response = self._do_get('snapshots/%s' % res['id'])
self._verify_response('snapshot-show-response',
{}, response, 200)
def test_snapshot_update(self):
res = jsonutils.loads(self.response.content)['snapshot']
response = self._do_put('snapshots/%s' % res['id'],
'snapshot-update-request')
self._verify_response('snapshot-update-response',
{}, response, 200)
def test_snapshot_metadata_show_specific_key(self):
res = jsonutils.loads(self.response.content)['snapshot']