From d29f12117e220eda6f2e8a3d4288701c7e98096f Mon Sep 17 00:00:00 2001 From: Gorka Eguileor Date: Thu, 13 May 2021 12:57:09 +0200 Subject: [PATCH] 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 --- api-ref/source/v3/parameters.yaml | 7 +++ .../v3.14/snapshot-create-response.json | 16 +++++ .../v3.14/snapshot-show-response.json | 18 ++++++ .../v3.14/snapshot-update-response.json | 16 +++++ .../snapshots-list-detailed-response.json | 20 ++++++ .../v3.41/snapshot-create-response.json | 17 ++++++ .../v3.41/snapshot-show-response.json | 19 ++++++ .../v3.41/snapshot-update-response.json | 17 ++++++ .../snapshots-list-detailed-response.json | 21 +++++++ api-ref/source/v3/volumes-v3-snapshots.inc | 28 +++++---- .../v3.14/snapshot-create-response.json.tpl | 16 +++++ .../v3.14/snapshot-show-response.json.tpl | 18 ++++++ .../v3.14/snapshot-update-response.json.tpl | 16 +++++ .../snapshots-list-detailed-response.json.tpl | 20 ++++++ .../v3.41/snapshot-create-response.json.tpl | 17 ++++++ .../v3.41/snapshot-show-response.json.tpl | 19 ++++++ .../v3.41/snapshot-update-response.json.tpl | 17 ++++++ .../snapshots-list-detailed-response.json.tpl | 21 +++++++ .../api_sample_tests/test_snapshots.py | 61 ++++++++++++------- 19 files changed, 351 insertions(+), 33 deletions(-) create mode 100644 api-ref/source/v3/samples/snapshots/v3.14/snapshot-create-response.json create mode 100644 api-ref/source/v3/samples/snapshots/v3.14/snapshot-show-response.json create mode 100644 api-ref/source/v3/samples/snapshots/v3.14/snapshot-update-response.json create mode 100644 api-ref/source/v3/samples/snapshots/v3.14/snapshots-list-detailed-response.json create mode 100644 api-ref/source/v3/samples/snapshots/v3.41/snapshot-create-response.json create mode 100644 api-ref/source/v3/samples/snapshots/v3.41/snapshot-show-response.json create mode 100644 api-ref/source/v3/samples/snapshots/v3.41/snapshot-update-response.json create mode 100644 api-ref/source/v3/samples/snapshots/v3.41/snapshots-list-detailed-response.json create mode 100644 cinder/tests/functional/api_sample_tests/samples/snapshots/v3.14/snapshot-create-response.json.tpl create mode 100644 cinder/tests/functional/api_sample_tests/samples/snapshots/v3.14/snapshot-show-response.json.tpl create mode 100644 cinder/tests/functional/api_sample_tests/samples/snapshots/v3.14/snapshot-update-response.json.tpl create mode 100644 cinder/tests/functional/api_sample_tests/samples/snapshots/v3.14/snapshots-list-detailed-response.json.tpl create mode 100644 cinder/tests/functional/api_sample_tests/samples/snapshots/v3.41/snapshot-create-response.json.tpl create mode 100644 cinder/tests/functional/api_sample_tests/samples/snapshots/v3.41/snapshot-show-response.json.tpl create mode 100644 cinder/tests/functional/api_sample_tests/samples/snapshots/v3.41/snapshot-update-response.json.tpl create mode 100644 cinder/tests/functional/api_sample_tests/samples/snapshots/v3.41/snapshots-list-detailed-response.json.tpl diff --git a/api-ref/source/v3/parameters.yaml b/api-ref/source/v3/parameters.yaml index fac755ba550..3551f330122 100644 --- a/api-ref/source/v3/parameters.yaml +++ b/api-ref/source/v3/parameters.yaml @@ -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. diff --git a/api-ref/source/v3/samples/snapshots/v3.14/snapshot-create-response.json b/api-ref/source/v3/samples/snapshots/v3.14/snapshot-create-response.json new file mode 100644 index 00000000000..84e3a98e840 --- /dev/null +++ b/api-ref/source/v3/samples/snapshots/v3.14/snapshot-create-response.json @@ -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 + } +} diff --git a/api-ref/source/v3/samples/snapshots/v3.14/snapshot-show-response.json b/api-ref/source/v3/samples/snapshots/v3.14/snapshot-show-response.json new file mode 100644 index 00000000000..b7c09aa7663 --- /dev/null +++ b/api-ref/source/v3/samples/snapshots/v3.14/snapshot-show-response.json @@ -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 + } +} diff --git a/api-ref/source/v3/samples/snapshots/v3.14/snapshot-update-response.json b/api-ref/source/v3/samples/snapshots/v3.14/snapshot-update-response.json new file mode 100644 index 00000000000..fc310783c55 --- /dev/null +++ b/api-ref/source/v3/samples/snapshots/v3.14/snapshot-update-response.json @@ -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 + } +} diff --git a/api-ref/source/v3/samples/snapshots/v3.14/snapshots-list-detailed-response.json b/api-ref/source/v3/samples/snapshots/v3.14/snapshots-list-detailed-response.json new file mode 100644 index 00000000000..2d1e4b960f0 --- /dev/null +++ b/api-ref/source/v3/samples/snapshots/v3.14/snapshots-list-detailed-response.json @@ -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 + } + ] +} diff --git a/api-ref/source/v3/samples/snapshots/v3.41/snapshot-create-response.json b/api-ref/source/v3/samples/snapshots/v3.41/snapshot-create-response.json new file mode 100644 index 00000000000..08e06f6739b --- /dev/null +++ b/api-ref/source/v3/samples/snapshots/v3.41/snapshot-create-response.json @@ -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" + } +} diff --git a/api-ref/source/v3/samples/snapshots/v3.41/snapshot-show-response.json b/api-ref/source/v3/samples/snapshots/v3.41/snapshot-show-response.json new file mode 100644 index 00000000000..71368b011c2 --- /dev/null +++ b/api-ref/source/v3/samples/snapshots/v3.41/snapshot-show-response.json @@ -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" + } +} diff --git a/api-ref/source/v3/samples/snapshots/v3.41/snapshot-update-response.json b/api-ref/source/v3/samples/snapshots/v3.41/snapshot-update-response.json new file mode 100644 index 00000000000..307e694ab26 --- /dev/null +++ b/api-ref/source/v3/samples/snapshots/v3.41/snapshot-update-response.json @@ -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" + } +} diff --git a/api-ref/source/v3/samples/snapshots/v3.41/snapshots-list-detailed-response.json b/api-ref/source/v3/samples/snapshots/v3.41/snapshots-list-detailed-response.json new file mode 100644 index 00000000000..1f9b123aaa3 --- /dev/null +++ b/api-ref/source/v3/samples/snapshots/v3.41/snapshots-list-detailed-response.json @@ -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" + } + ] +} diff --git a/api-ref/source/v3/volumes-v3-snapshots.inc b/api-ref/source/v3/volumes-v3-snapshots.inc index e53750a0766..c7a63793f1e 100644 --- a/api-ref/source/v3/volumes-v3-snapshots.inc +++ b/api-ref/source/v3/volumes-v3-snapshots.inc @@ -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 diff --git a/cinder/tests/functional/api_sample_tests/samples/snapshots/v3.14/snapshot-create-response.json.tpl b/cinder/tests/functional/api_sample_tests/samples/snapshots/v3.14/snapshot-create-response.json.tpl new file mode 100644 index 00000000000..da31a31ca7b --- /dev/null +++ b/cinder/tests/functional/api_sample_tests/samples/snapshots/v3.14/snapshot-create-response.json.tpl @@ -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 + } +} diff --git a/cinder/tests/functional/api_sample_tests/samples/snapshots/v3.14/snapshot-show-response.json.tpl b/cinder/tests/functional/api_sample_tests/samples/snapshots/v3.14/snapshot-show-response.json.tpl new file mode 100644 index 00000000000..cc464d95d29 --- /dev/null +++ b/cinder/tests/functional/api_sample_tests/samples/snapshots/v3.14/snapshot-show-response.json.tpl @@ -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 + } +} diff --git a/cinder/tests/functional/api_sample_tests/samples/snapshots/v3.14/snapshot-update-response.json.tpl b/cinder/tests/functional/api_sample_tests/samples/snapshots/v3.14/snapshot-update-response.json.tpl new file mode 100644 index 00000000000..aa72b90411c --- /dev/null +++ b/cinder/tests/functional/api_sample_tests/samples/snapshots/v3.14/snapshot-update-response.json.tpl @@ -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 + } +} diff --git a/cinder/tests/functional/api_sample_tests/samples/snapshots/v3.14/snapshots-list-detailed-response.json.tpl b/cinder/tests/functional/api_sample_tests/samples/snapshots/v3.14/snapshots-list-detailed-response.json.tpl new file mode 100644 index 00000000000..b17308bbcd2 --- /dev/null +++ b/cinder/tests/functional/api_sample_tests/samples/snapshots/v3.14/snapshots-list-detailed-response.json.tpl @@ -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 + } + ] +} diff --git a/cinder/tests/functional/api_sample_tests/samples/snapshots/v3.41/snapshot-create-response.json.tpl b/cinder/tests/functional/api_sample_tests/samples/snapshots/v3.41/snapshot-create-response.json.tpl new file mode 100644 index 00000000000..406e817cfe0 --- /dev/null +++ b/cinder/tests/functional/api_sample_tests/samples/snapshots/v3.41/snapshot-create-response.json.tpl @@ -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" + } +} diff --git a/cinder/tests/functional/api_sample_tests/samples/snapshots/v3.41/snapshot-show-response.json.tpl b/cinder/tests/functional/api_sample_tests/samples/snapshots/v3.41/snapshot-show-response.json.tpl new file mode 100644 index 00000000000..72a38365ae1 --- /dev/null +++ b/cinder/tests/functional/api_sample_tests/samples/snapshots/v3.41/snapshot-show-response.json.tpl @@ -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" + } +} diff --git a/cinder/tests/functional/api_sample_tests/samples/snapshots/v3.41/snapshot-update-response.json.tpl b/cinder/tests/functional/api_sample_tests/samples/snapshots/v3.41/snapshot-update-response.json.tpl new file mode 100644 index 00000000000..fde8c104a31 --- /dev/null +++ b/cinder/tests/functional/api_sample_tests/samples/snapshots/v3.41/snapshot-update-response.json.tpl @@ -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" + } +} diff --git a/cinder/tests/functional/api_sample_tests/samples/snapshots/v3.41/snapshots-list-detailed-response.json.tpl b/cinder/tests/functional/api_sample_tests/samples/snapshots/v3.41/snapshots-list-detailed-response.json.tpl new file mode 100644 index 00000000000..96b8ed93dec --- /dev/null +++ b/cinder/tests/functional/api_sample_tests/samples/snapshots/v3.41/snapshots-list-detailed-response.json.tpl @@ -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" + } + ] +} diff --git a/cinder/tests/functional/api_sample_tests/test_snapshots.py b/cinder/tests/functional/api_sample_tests/test_snapshots.py index c7545c1711a..abec1251a99 100644 --- a/cinder/tests/functional/api_sample_tests/test_snapshots.py +++ b/cinder/tests/functional/api_sample_tests/test_snapshots.py @@ -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']