diff --git a/api-ref/source/v3/samples/snapshot-create-response.json b/api-ref/source/v3/samples/snapshot-create-response.json deleted file mode 100644 index 15a139531a7..00000000000 --- a/api-ref/source/v3/samples/snapshot-create-response.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "snapshot": { - "status": "creating", - "description": "Daily backup", - "created_at": "2013-02-25T03:56:53.081642", - "metadata": {}, - "updated_at": "2013-02-25T03:58:53.081642", - "volume_id": "5aa119a8-d25b-45a7-8d1b-88e127885635", - "size": 1, - "user_id": "40c2102f4a554b848d96b14f3eec39ed", - "id": "ffa9bc5e-1172-4021-acaf-cdcd78a9584d", - "name": "snap-001" - } -} - diff --git a/api-ref/source/v3/samples/snapshot-metadata-show-key-response.json b/api-ref/source/v3/samples/snapshot-metadata-show-key-response.json deleted file mode 100644 index 0a98eb72dc5..00000000000 --- a/api-ref/source/v3/samples/snapshot-metadata-show-key-response.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "meta": { - "name": "test" - } -} diff --git a/api-ref/source/v3/samples/snapshot-metadata-update-key-request.json b/api-ref/source/v3/samples/snapshot-metadata-update-key-request.json deleted file mode 100644 index 023712fce45..00000000000 --- a/api-ref/source/v3/samples/snapshot-metadata-update-key-request.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "meta": { - "name": "new_name" - } -} diff --git a/api-ref/source/v3/samples/snapshot-metadata-update-key-response.json b/api-ref/source/v3/samples/snapshot-metadata-update-key-response.json deleted file mode 100644 index 5041c187ef5..00000000000 --- a/api-ref/source/v3/samples/snapshot-metadata-update-key-response.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "meta": { - "name": "new_name" - } -} diff --git a/api-ref/source/v3/samples/snapshot-show-response.json b/api-ref/source/v3/samples/snapshot-show-response.json deleted file mode 100644 index 51b32a5b4f8..00000000000 --- a/api-ref/source/v3/samples/snapshot-show-response.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "snapshot": { - "status": "available", - "os-extended-snapshot-attributes:progress": "100%", - "description": "Daily backup", - "created_at": "2013-02-25T04:13:17.000000", - "metadata": {}, - "user_id": "40c2102f4a554b848d96b14f3eec39ed", - "volume_id": "5aa119a8-d25b-45a7-8d1b-88e127885635", - "os-extended-snapshot-attributes:project_id": "0c2eba2c5af04d3f9e9d0d410b371fde", - "size": 1, - "id": "2bb856e1-b3d8-4432-a858-09e4ce939389", - "name": "snap-001", - "updated_at": "2013-03-11T07:24:57Z" - } -} diff --git a/api-ref/source/v3/samples/snapshot-update-response.json b/api-ref/source/v3/samples/snapshot-update-response.json deleted file mode 100644 index 7b621b53940..00000000000 --- a/api-ref/source/v3/samples/snapshot-update-response.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "snapshot": { - "created_at": "2013-02-20T08:11:34.000000", - "description": "This is yet, another snapshot", - "name": "snap-002", - "id": "4b502fcb-1f26-45f8-9fe5-3b9a0a52eaf2", - "size": 1, - "status": "available", - "metadata": {}, - "user_id": "40c2102f4a554b848d96b14f3eec39ed", - "volume_id": "2402b902-0b7a-458c-9c07-7435a826f794" - } -} diff --git a/api-ref/source/v3/samples/snapshots-list-detailed-response.json b/api-ref/source/v3/samples/snapshots-list-detailed-response.json deleted file mode 100644 index 62f65cde5b6..00000000000 --- a/api-ref/source/v3/samples/snapshots-list-detailed-response.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "snapshots": [ - { - "status": "available", - "metadata": { - "name": "test" - }, - "os-extended-snapshot-attributes:progress": "100%", - "name": "test-volume-snapshot", - "user_id": "40c2102f4a554b848d96b14f3eec39ed", - "volume_id": "173f7b48-c4c1-4e70-9acc-086b39073506", - "os-extended-snapshot-attributes:project_id": "bab7d5c60cd041a0a36f7c4b6e1dd978", - "created_at": "2015-11-29T02:25:51.000000", - "size": 1, - "id": "b1323cda-8e4b-41c1-afc5-2fc791809c8c", - "description": "volume snapshot", - "updated_at": "2015-12-11T07:24:57Z" - } - ], - "snapshots_links": [ - { - "href": "https://10.43.176.164:8776/v3/d55fb90e300b436cb2714a17137be023/snapshots?limit=1&marker=2e0cd28e-d7a2-4cdb-87e6-cd37c417c06d", - "rel": "next" - } - ], - "count": 10 -} diff --git a/api-ref/source/v3/samples/snapshots-list-response.json b/api-ref/source/v3/samples/snapshots-list-response.json deleted file mode 100644 index 4ae84abb231..00000000000 --- a/api-ref/source/v3/samples/snapshots-list-response.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "snapshots": [ - { - "status": "available", - "metadata": { - "name": "test" - }, - "name": "test-volume-snapshot", - "user_id": "40c2102f4a554b848d96b14f3eec39ed", - "volume_id": "173f7b48-c4c1-4e70-9acc-086b39073506", - "created_at": "2015-11-29T02:25:51.000000", - "size": 1, - "updated_at": "2015-11-20T05:36:40.000000", - "os-extended-snapshot-attributes:progress": "100%", - "os-extended-snapshot-attributes:project_id": "0892d23df5c5471da88299517a412b90", - "id": "b1323cda-8e4b-41c1-afc5-2fc791809c8c", - "description": "volume snapshot", - "updated_at": "2015-12-11T07:24:57Z" - } - ], - "snapshots_links": [ - { - "href": "https://10.43.176.164:8776/v3/d55fb90e300b436cb2714a17137be023/snapshots?limit=1&marker=2e0cd28e-d7a2-4cdb-87e6-cd37c417c06d", - "rel": "next" - } - ], - "count": 10 -} diff --git a/api-ref/source/v3/samples/snapshot-create-request.json b/api-ref/source/v3/samples/snapshots/snapshot-create-request.json similarity index 76% rename from api-ref/source/v3/samples/snapshot-create-request.json rename to api-ref/source/v3/samples/snapshots/snapshot-create-request.json index 5fb46cd0c29..c7d2b0fd891 100644 --- a/api-ref/source/v3/samples/snapshot-create-request.json +++ b/api-ref/source/v3/samples/snapshots/snapshot-create-request.json @@ -4,6 +4,8 @@ "description": "Daily backup", "volume_id": "5aa119a8-d25b-45a7-8d1b-88e127885635", "force": true, - "metadata": null + "metadata": { + "key": "v3" + } } } diff --git a/api-ref/source/v3/samples/snapshots/snapshot-create-response.json b/api-ref/source/v3/samples/snapshots/snapshot-create-response.json new file mode 100644 index 00000000000..8819dd94a89 --- /dev/null +++ b/api-ref/source/v3/samples/snapshots/snapshot-create-response.json @@ -0,0 +1,15 @@ +{ + "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" + } +} \ No newline at end of file diff --git a/api-ref/source/v3/samples/snapshot-metadata-create-request.json b/api-ref/source/v3/samples/snapshots/snapshot-metadata-create-request.json similarity index 100% rename from api-ref/source/v3/samples/snapshot-metadata-create-request.json rename to api-ref/source/v3/samples/snapshots/snapshot-metadata-create-request.json diff --git a/api-ref/source/v3/samples/snapshot-metadata-show-response.json b/api-ref/source/v3/samples/snapshots/snapshot-metadata-create-response.json similarity index 50% rename from api-ref/source/v3/samples/snapshot-metadata-show-response.json rename to api-ref/source/v3/samples/snapshots/snapshot-metadata-create-response.json index cbfe4ef7a8e..2c39c723473 100644 --- a/api-ref/source/v3/samples/snapshot-metadata-show-response.json +++ b/api-ref/source/v3/samples/snapshots/snapshot-metadata-create-response.json @@ -1,5 +1,5 @@ { "metadata": { - "name": "test" + "key": "value" } -} +} \ No newline at end of file diff --git a/api-ref/source/v3/samples/snapshots/snapshot-metadata-show-key-response.json b/api-ref/source/v3/samples/snapshots/snapshot-metadata-show-key-response.json new file mode 100644 index 00000000000..8c562e2a4fb --- /dev/null +++ b/api-ref/source/v3/samples/snapshots/snapshot-metadata-show-key-response.json @@ -0,0 +1,5 @@ +{ + "meta": { + "key": "v3" + } +} \ No newline at end of file diff --git a/api-ref/source/v3/samples/snapshot-metadata-create-response.json b/api-ref/source/v3/samples/snapshots/snapshot-metadata-show-response.json similarity index 95% rename from api-ref/source/v3/samples/snapshot-metadata-create-response.json rename to api-ref/source/v3/samples/snapshots/snapshot-metadata-show-response.json index 97cd30d5e1e..9420904896c 100644 --- a/api-ref/source/v3/samples/snapshot-metadata-create-response.json +++ b/api-ref/source/v3/samples/snapshots/snapshot-metadata-show-response.json @@ -2,4 +2,4 @@ "metadata": { "key": "v3" } -} +} \ No newline at end of file diff --git a/api-ref/source/v3/samples/snapshots/snapshot-metadata-update-key-request.json b/api-ref/source/v3/samples/snapshots/snapshot-metadata-update-key-request.json new file mode 100644 index 00000000000..0bcc1ce930f --- /dev/null +++ b/api-ref/source/v3/samples/snapshots/snapshot-metadata-update-key-request.json @@ -0,0 +1,5 @@ +{ + "meta": { + "key": "new_value" + } +} \ No newline at end of file diff --git a/api-ref/source/v3/samples/snapshots/snapshot-metadata-update-key-response.json b/api-ref/source/v3/samples/snapshots/snapshot-metadata-update-key-response.json new file mode 100644 index 00000000000..9020089152f --- /dev/null +++ b/api-ref/source/v3/samples/snapshots/snapshot-metadata-update-key-response.json @@ -0,0 +1,5 @@ +{ + "meta": { + "key": "new_value" + } +} \ No newline at end of file diff --git a/api-ref/source/v3/samples/snapshots/snapshot-metadata-update-request.json b/api-ref/source/v3/samples/snapshots/snapshot-metadata-update-request.json new file mode 100644 index 00000000000..f6363cbfc1f --- /dev/null +++ b/api-ref/source/v3/samples/snapshots/snapshot-metadata-update-request.json @@ -0,0 +1,5 @@ +{ + "metadata": { + "new_key": "new_value" + } +} \ No newline at end of file diff --git a/api-ref/source/v3/samples/snapshots/snapshot-metadata-update-response.json b/api-ref/source/v3/samples/snapshots/snapshot-metadata-update-response.json new file mode 100644 index 00000000000..f6363cbfc1f --- /dev/null +++ b/api-ref/source/v3/samples/snapshots/snapshot-metadata-update-response.json @@ -0,0 +1,5 @@ +{ + "metadata": { + "new_key": "new_value" + } +} \ No newline at end of file diff --git a/api-ref/source/v3/samples/snapshots/snapshot-show-response.json b/api-ref/source/v3/samples/snapshots/snapshot-show-response.json new file mode 100644 index 00000000000..da7e68da1f3 --- /dev/null +++ b/api-ref/source/v3/samples/snapshots/snapshot-show-response.json @@ -0,0 +1,17 @@ +{ + "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" + } +} \ No newline at end of file diff --git a/api-ref/source/v3/samples/snapshots/snapshot-update-request.json b/api-ref/source/v3/samples/snapshots/snapshot-update-request.json new file mode 100644 index 00000000000..ceb4167d8e3 --- /dev/null +++ b/api-ref/source/v3/samples/snapshots/snapshot-update-request.json @@ -0,0 +1,6 @@ +{ + "snapshot": { + "name": "snap-002", + "description": "This is yet, another snapshot." + } +} \ No newline at end of file diff --git a/api-ref/source/v3/samples/snapshots/snapshot-update-response.json b/api-ref/source/v3/samples/snapshots/snapshot-update-response.json new file mode 100644 index 00000000000..5d9c9bb4d76 --- /dev/null +++ b/api-ref/source/v3/samples/snapshots/snapshot-update-response.json @@ -0,0 +1,15 @@ +{ + "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" + } +} \ No newline at end of file diff --git a/api-ref/source/v3/samples/snapshots/snapshots-list-detailed-response.json b/api-ref/source/v3/samples/snapshots/snapshots-list-detailed-response.json new file mode 100644 index 00000000000..9c452f38783 --- /dev/null +++ b/api-ref/source/v3/samples/snapshots/snapshots-list-detailed-response.json @@ -0,0 +1,19 @@ +{ + "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" + } + ] +} \ No newline at end of file diff --git a/api-ref/source/v3/samples/snapshots/snapshots-list-response.json b/api-ref/source/v3/samples/snapshots/snapshots-list-response.json new file mode 100644 index 00000000000..d73ef703eb5 --- /dev/null +++ b/api-ref/source/v3/samples/snapshots/snapshots-list-response.json @@ -0,0 +1,17 @@ +{ + "snapshots": [ + { + "created_at": "2019-03-11T16:29:08.973832", + "description": "Daily backup", + "id": "2c228773-50eb-422d-be7e-b5c6ced0c7a9", + "metadata": { + "key": "v3" + }, + "name": "snap-001", + "size": 10, + "status": "creating", + "updated_at": null, + "volume_id": "428ec041-b999-40d8-8a54-9e98b19406cc" + } + ] +} \ No newline at end of file diff --git a/api-ref/source/v3/volumes-v3-snapshots.inc b/api-ref/source/v3/volumes-v3-snapshots.inc index c9ed2ba9310..4563724384d 100644 --- a/api-ref/source/v3/volumes-v3-snapshots.inc +++ b/api-ref/source/v3/volumes-v3-snapshots.inc @@ -92,7 +92,7 @@ Response Parameters Response Example ---------------- -.. literalinclude:: ./samples/snapshots-list-detailed-response.json +.. literalinclude:: ./samples/snapshots/snapshots-list-detailed-response.json :language: javascript @@ -128,7 +128,7 @@ Request Request Example --------------- -.. literalinclude:: ./samples/snapshot-create-request.json +.. literalinclude:: ./samples/snapshots/snapshot-create-request.json :language: javascript Response Parameters @@ -151,7 +151,7 @@ Response Parameters Response Example ---------------- -.. literalinclude:: ./samples/snapshot-create-response.json +.. literalinclude:: ./samples/snapshots/snapshot-create-response.json :language: javascript @@ -211,7 +211,7 @@ Response Parameters Response Example ---------------- -.. literalinclude:: ./samples/snapshots-list-response.json +.. literalinclude:: ./samples/snapshots/snapshots-list-response.json :language: javascript @@ -249,7 +249,7 @@ Response Parameters Response Example ---------------- -.. literalinclude:: ./samples/snapshot-metadata-show-response.json +.. literalinclude:: ./samples/snapshots/snapshot-metadata-show-response.json :language: javascript @@ -283,7 +283,7 @@ Request Request Example --------------- -.. literalinclude:: ./samples/snapshot-metadata-create-request.json +.. literalinclude:: ./samples/snapshots/snapshot-metadata-create-request.json :language: javascript Response Parameters @@ -296,7 +296,7 @@ Response Parameters Response Example ---------------- -.. literalinclude:: ./samples/snapshot-metadata-create-response.json +.. literalinclude:: ./samples/snapshots/snapshot-metadata-create-response.json :language: javascript Update a snapshot's metadata @@ -326,7 +326,7 @@ Request Request Example --------------- -.. literalinclude:: ./samples/snapshot-metadata-update-request.json +.. literalinclude:: ./samples/snapshots/snapshot-metadata-update-request.json :language: javascript @@ -340,7 +340,7 @@ Response Parameters Response Example ---------------- -.. literalinclude:: ./samples/snapshot-metadata-update-response.json +.. literalinclude:: ./samples/snapshots/snapshot-metadata-update-response.json :language: javascript @@ -390,7 +390,7 @@ Response Parameters Response Example ---------------- -.. literalinclude:: ./samples/snapshot-show-response.json +.. literalinclude:: ./samples/snapshots/snapshot-show-response.json :language: javascript @@ -423,7 +423,7 @@ Request Request Example --------------- -.. literalinclude:: ./samples/snapshot-update-request.json +.. literalinclude:: ./samples/snapshots/snapshot-update-request.json :language: javascript @@ -447,7 +447,7 @@ Response Parameters Response Example ---------------- -.. literalinclude:: ./samples/snapshot-update-response.json +.. literalinclude:: ./samples/snapshots/snapshot-update-response.json :language: javascript @@ -520,7 +520,7 @@ Response Parameters Response Example ---------------- -.. literalinclude:: ./samples/snapshot-metadata-show-key-response.json +.. literalinclude:: ./samples/snapshots/snapshot-metadata-show-key-response.json :language: javascript @@ -578,7 +578,7 @@ Request Request Example --------------- -.. literalinclude:: ./samples/snapshot-metadata-update-key-request.json +.. literalinclude:: ./samples/snapshots/snapshot-metadata-update-key-request.json :language: javascript Response Parameters @@ -591,5 +591,5 @@ Response Parameters Response Example ---------------- -.. literalinclude:: ./samples/snapshot-metadata-update-key-response.json +.. literalinclude:: ./samples/snapshots/snapshot-metadata-update-key-response.json :language: javascript diff --git a/cinder/tests/functional/api_sample_tests/samples/snapshots/snapshot-create-request.json.tpl b/cinder/tests/functional/api_sample_tests/samples/snapshots/snapshot-create-request.json.tpl new file mode 100644 index 00000000000..cde4bc09d1a --- /dev/null +++ b/cinder/tests/functional/api_sample_tests/samples/snapshots/snapshot-create-request.json.tpl @@ -0,0 +1,11 @@ +{ + "snapshot": { + "name": "snap-001", + "description": "Daily backup", + "volume_id": "%(volume_id)s", + "force": true, + "metadata": { + "key": "v3" + } + } +} diff --git a/cinder/tests/functional/api_sample_tests/samples/snapshots/snapshot-create-response.json.tpl b/cinder/tests/functional/api_sample_tests/samples/snapshots/snapshot-create-response.json.tpl new file mode 100644 index 00000000000..7945270c852 --- /dev/null +++ b/cinder/tests/functional/api_sample_tests/samples/snapshots/snapshot-create-response.json.tpl @@ -0,0 +1,15 @@ +{ + "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" + } +} \ No newline at end of file diff --git a/api-ref/source/v3/samples/snapshot-metadata-update-request.json b/cinder/tests/functional/api_sample_tests/samples/snapshots/snapshot-metadata-create-request.json.tpl similarity index 54% rename from api-ref/source/v3/samples/snapshot-metadata-update-request.json rename to cinder/tests/functional/api_sample_tests/samples/snapshots/snapshot-metadata-create-request.json.tpl index 4373b0018da..52d700c0bf2 100644 --- a/api-ref/source/v3/samples/snapshot-metadata-update-request.json +++ b/cinder/tests/functional/api_sample_tests/samples/snapshots/snapshot-metadata-create-request.json.tpl @@ -1,5 +1,5 @@ { "metadata": { - "key": "v2" + "key": "value" } } diff --git a/cinder/tests/functional/api_sample_tests/samples/snapshots/snapshot-metadata-create-response.json.tpl b/cinder/tests/functional/api_sample_tests/samples/snapshots/snapshot-metadata-create-response.json.tpl new file mode 100644 index 00000000000..2c39c723473 --- /dev/null +++ b/cinder/tests/functional/api_sample_tests/samples/snapshots/snapshot-metadata-create-response.json.tpl @@ -0,0 +1,5 @@ +{ + "metadata": { + "key": "value" + } +} \ No newline at end of file diff --git a/cinder/tests/functional/api_sample_tests/samples/snapshots/snapshot-metadata-show-key-response.json.tpl b/cinder/tests/functional/api_sample_tests/samples/snapshots/snapshot-metadata-show-key-response.json.tpl new file mode 100644 index 00000000000..8c562e2a4fb --- /dev/null +++ b/cinder/tests/functional/api_sample_tests/samples/snapshots/snapshot-metadata-show-key-response.json.tpl @@ -0,0 +1,5 @@ +{ + "meta": { + "key": "v3" + } +} \ No newline at end of file diff --git a/api-ref/source/v3/samples/snapshot-metadata-update-response.json b/cinder/tests/functional/api_sample_tests/samples/snapshots/snapshot-metadata-show-response.json.tpl similarity index 54% rename from api-ref/source/v3/samples/snapshot-metadata-update-response.json rename to cinder/tests/functional/api_sample_tests/samples/snapshots/snapshot-metadata-show-response.json.tpl index 4373b0018da..9420904896c 100644 --- a/api-ref/source/v3/samples/snapshot-metadata-update-response.json +++ b/cinder/tests/functional/api_sample_tests/samples/snapshots/snapshot-metadata-show-response.json.tpl @@ -1,5 +1,5 @@ { "metadata": { - "key": "v2" + "key": "v3" } -} +} \ No newline at end of file diff --git a/cinder/tests/functional/api_sample_tests/samples/snapshots/snapshot-metadata-update-key-request.json.tpl b/cinder/tests/functional/api_sample_tests/samples/snapshots/snapshot-metadata-update-key-request.json.tpl new file mode 100644 index 00000000000..42487ae76d4 --- /dev/null +++ b/cinder/tests/functional/api_sample_tests/samples/snapshots/snapshot-metadata-update-key-request.json.tpl @@ -0,0 +1,5 @@ +{ + "meta": { + "key": "new_value" + } +} diff --git a/cinder/tests/functional/api_sample_tests/samples/snapshots/snapshot-metadata-update-key-response.json.tpl b/cinder/tests/functional/api_sample_tests/samples/snapshots/snapshot-metadata-update-key-response.json.tpl new file mode 100644 index 00000000000..9020089152f --- /dev/null +++ b/cinder/tests/functional/api_sample_tests/samples/snapshots/snapshot-metadata-update-key-response.json.tpl @@ -0,0 +1,5 @@ +{ + "meta": { + "key": "new_value" + } +} \ No newline at end of file diff --git a/cinder/tests/functional/api_sample_tests/samples/snapshots/snapshot-metadata-update-request.json.tpl b/cinder/tests/functional/api_sample_tests/samples/snapshots/snapshot-metadata-update-request.json.tpl new file mode 100644 index 00000000000..c31d0208636 --- /dev/null +++ b/cinder/tests/functional/api_sample_tests/samples/snapshots/snapshot-metadata-update-request.json.tpl @@ -0,0 +1,5 @@ +{ + "metadata": { + "new_key": "new_value" + } +} diff --git a/cinder/tests/functional/api_sample_tests/samples/snapshots/snapshot-metadata-update-response.json.tpl b/cinder/tests/functional/api_sample_tests/samples/snapshots/snapshot-metadata-update-response.json.tpl new file mode 100644 index 00000000000..f6363cbfc1f --- /dev/null +++ b/cinder/tests/functional/api_sample_tests/samples/snapshots/snapshot-metadata-update-response.json.tpl @@ -0,0 +1,5 @@ +{ + "metadata": { + "new_key": "new_value" + } +} \ No newline at end of file diff --git a/cinder/tests/functional/api_sample_tests/samples/snapshots/snapshot-show-response.json.tpl b/cinder/tests/functional/api_sample_tests/samples/snapshots/snapshot-show-response.json.tpl new file mode 100644 index 00000000000..2870829791f --- /dev/null +++ b/cinder/tests/functional/api_sample_tests/samples/snapshots/snapshot-show-response.json.tpl @@ -0,0 +1,17 @@ +{ + "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" + } +} \ No newline at end of file diff --git a/api-ref/source/v3/samples/snapshot-update-request.json b/cinder/tests/functional/api_sample_tests/samples/snapshots/snapshot-update-request.json.tpl similarity index 100% rename from api-ref/source/v3/samples/snapshot-update-request.json rename to cinder/tests/functional/api_sample_tests/samples/snapshots/snapshot-update-request.json.tpl diff --git a/cinder/tests/functional/api_sample_tests/samples/snapshots/snapshot-update-response.json.tpl b/cinder/tests/functional/api_sample_tests/samples/snapshots/snapshot-update-response.json.tpl new file mode 100644 index 00000000000..dd56f6da3d7 --- /dev/null +++ b/cinder/tests/functional/api_sample_tests/samples/snapshots/snapshot-update-response.json.tpl @@ -0,0 +1,15 @@ +{ + "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" + } +} \ No newline at end of file diff --git a/cinder/tests/functional/api_sample_tests/samples/snapshots/snapshots-list-detailed-response.json.tpl b/cinder/tests/functional/api_sample_tests/samples/snapshots/snapshots-list-detailed-response.json.tpl new file mode 100644 index 00000000000..fa0c34cf2df --- /dev/null +++ b/cinder/tests/functional/api_sample_tests/samples/snapshots/snapshots-list-detailed-response.json.tpl @@ -0,0 +1,19 @@ +{ + "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" + } + ] +} \ No newline at end of file diff --git a/cinder/tests/functional/api_sample_tests/samples/snapshots/snapshots-list-response.json.tpl b/cinder/tests/functional/api_sample_tests/samples/snapshots/snapshots-list-response.json.tpl new file mode 100644 index 00000000000..0655482fea6 --- /dev/null +++ b/cinder/tests/functional/api_sample_tests/samples/snapshots/snapshots-list-response.json.tpl @@ -0,0 +1,17 @@ +{ + "snapshots": [ + { + "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" + } + ] +} \ No newline at end of file diff --git a/cinder/tests/functional/api_sample_tests/test_snapshots.py b/cinder/tests/functional/api_sample_tests/test_snapshots.py new file mode 100644 index 00000000000..4306c001bc8 --- /dev/null +++ b/cinder/tests/functional/api_sample_tests/test_snapshots.py @@ -0,0 +1,105 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from oslo_serialization import jsonutils + +from cinder.tests.functional.api_sample_tests import test_volumes + + +class VolumeSnapshotsSampleJsonTest(test_volumes.VolumesSampleBase): + sample_dir = "snapshots" + + def setUp(self): + super(VolumeSnapshotsSampleJsonTest, self).setUp() + 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) + + def _create_snapshot(self, subs=None): + response = self._do_post('snapshots', + 'snapshot-create-request', + subs) + return response + + 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_list(self): + + response = self._do_get('snapshots') + self._verify_response('snapshots-list-response', + {}, response, 200) + + def test_snapshot_metadata_show(self): + + res = jsonutils.loads(self.response.content)['snapshot'] + response = self._do_get('snapshots/%s/metadata' % res['id']) + self._verify_response('snapshot-metadata-show-response', + {}, response, 200) + + def test_snapshot_metadata_create(self): + + res = jsonutils.loads(self.response.content)['snapshot'] + response = self._do_post('snapshots/%s/metadata' % res['id'], + 'snapshot-metadata-create-request') + self._verify_response('snapshot-metadata-create-response', + {}, response, 200) + + def test_snapshot_metadata_update(self): + + res = jsonutils.loads(self.response.content)['snapshot'] + response = self._do_put('snapshots/%s/metadata' % res['id'], + 'snapshot-metadata-update-request') + 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'] + response = self._do_get('snapshots/%s/metadata/key' % res['id']) + self._verify_response('snapshot-metadata-show-key-response', + {}, response, 200) + + def test_snapshot_metadata_update_specific_key(self): + + res = jsonutils.loads(self.response.content)['snapshot'] + response = self._do_put('snapshots/%s/metadata/key' % res['id'], + 'snapshot-metadata-update-key-request') + self._verify_response('snapshot-metadata-update-key-response', + {}, response, 200) diff --git a/cinder/tests/functional/api_samples_test_base.py b/cinder/tests/functional/api_samples_test_base.py index fed4aa32f61..6d72d581d17 100644 --- a/cinder/tests/functional/api_samples_test_base.py +++ b/cinder/tests/functional/api_samples_test_base.py @@ -244,7 +244,7 @@ class ApiSampleTestBase(functional_helpers._FunctionalTestBase): {'expected': expected, 'result_str': result_str, 'result': result}) try: - matched_value = match.group('id') + matched_value = match.group() except IndexError: if match.groups(): matched_value = match.groups()[0] @@ -270,8 +270,17 @@ class ApiSampleTestBase(functional_helpers._FunctionalTestBase): expected, result, result_str, matched_value) # template string elif isinstance(expected, six.string_types) and '%' in expected: - matched_value = self._compare_template( - expected, result, result_str, matched_value) + if expected[-1] == '%': + if result != expected: + raise NoMatch( + 'Values do not match:\n' + 'Template: %(expected)s\n%(result_str)s: ' + '%(result)s' % {'expected': expected, + 'result_str': result_str, + 'result': result}) + else: + matched_value = self._compare_template( + expected, result, result_str, matched_value) # string elif isinstance(expected, six.string_types):