From 6ba39e4a9e4e1711cc498ec70c1ffa3e589e62cb Mon Sep 17 00:00:00 2001 From: whoami-rajat Date: Mon, 3 Dec 2018 11:38:09 +0530 Subject: [PATCH] Automate generation of volumes api-ref samples This patch adds the following tests: 1) Volumes 2) volume-type access Change-Id: Iad7932337647274dbbbc35045b4febbbc8d9d36d Partially-Implements: blueprint generating-sample-files --- .../versions/version-show-response.json | 2 +- .../v3/samples/volume-create-response.json | 34 ------- .../volume-metadata-show-key-response.json | 5 - .../v3/samples/volume-show-response.json | 31 ------ .../volume-type-access-add-request.json | 5 - .../volume-type-access-list-response.json | 6 -- .../volume-type-access-add-request.json | 5 + .../volume-type-access-list-response.json | 8 ++ .../volumes/volume-create-request.json | 22 +++++ .../volumes/volume-create-response.json | 34 +++++++ .../volume-metadata-create-request.json | 5 + .../volume-metadata-create-response.json | 2 +- .../volume-metadata-show-key-response.json | 5 + .../volume-metadata-show-response.json | 2 +- .../volume-metadata-update-key-request.json | 5 + .../volume-metadata-update-key-response.json | 2 +- .../volume-metadata-update-request.json | 5 + .../volume-metadata-update-response.json | 2 +- .../samples/volumes/volume-show-response.json | 38 ++++++++ .../volumes/volume-update-request.json | 9 ++ .../{ => volumes}/volume-update-response.json | 44 ++++----- .../volumes-list-detailed-response.json | 40 ++++++++ .../volumes/volumes-list-response.json | 18 ++++ api-ref/source/v3/volume-type-access.inc | 4 +- api-ref/source/v3/volumes-v3-volumes.inc | 30 +++--- .../volume-type-access-add-request.json.tpl | 5 + .../volume-type-access-list-response.json.tpl | 8 ++ .../volume-type-create-request.json.tpl | 2 +- .../volumes/volume-create-request.json.tpl | 0 .../volumes/volume-create-response.json.tpl | 34 +++++++ .../volume-metadata-create-request.json.tpl | 0 .../volume-metadata-create-response.json.tpl | 5 + ...volume-metadata-show-key-response.json.tpl | 5 + .../volume-metadata-show-response.json.tpl | 3 + ...olume-metadata-update-key-request.json.tpl | 0 ...lume-metadata-update-key-response.json.tpl | 5 + .../volume-metadata-update-request.json.tpl | 0 .../volume-metadata-update-response.json.tpl | 5 + .../volumes/volume-show-response.json.tpl | 38 ++++++++ .../volumes/volume-update-request.json.tpl | 0 .../volumes/volume-update-response.json.tpl | 36 +++++++ .../volumes-list-detailed-response.json.tpl | 40 ++++++++ .../volumes/volumes-list-response.json.tpl | 18 ++++ .../api_sample_tests/test_volume_types.py | 19 +++- .../api_sample_tests/test_volumes.py | 94 +++++++++++++++++++ 45 files changed, 552 insertions(+), 128 deletions(-) delete mode 100644 api-ref/source/v3/samples/volume-create-response.json delete mode 100644 api-ref/source/v3/samples/volume-metadata-show-key-response.json delete mode 100644 api-ref/source/v3/samples/volume-show-response.json delete mode 100644 api-ref/source/v3/samples/volume-type-access-add-request.json delete mode 100644 api-ref/source/v3/samples/volume-type-access-list-response.json create mode 100644 api-ref/source/v3/samples/volume_type/volume-type-access-add-request.json create mode 100644 api-ref/source/v3/samples/volume_type/volume-type-access-list-response.json create mode 100644 api-ref/source/v3/samples/volumes/volume-create-request.json create mode 100644 api-ref/source/v3/samples/volumes/volume-create-response.json create mode 100644 api-ref/source/v3/samples/volumes/volume-metadata-create-request.json rename api-ref/source/v3/samples/{ => volumes}/volume-metadata-create-response.json (96%) create mode 100644 api-ref/source/v3/samples/volumes/volume-metadata-show-key-response.json rename api-ref/source/v3/samples/{ => volumes}/volume-metadata-show-response.json (91%) create mode 100644 api-ref/source/v3/samples/volumes/volume-metadata-update-key-request.json rename api-ref/source/v3/samples/{ => volumes}/volume-metadata-update-key-response.json (96%) create mode 100644 api-ref/source/v3/samples/volumes/volume-metadata-update-request.json rename api-ref/source/v3/samples/{ => volumes}/volume-metadata-update-response.json (96%) create mode 100644 api-ref/source/v3/samples/volumes/volume-show-response.json create mode 100644 api-ref/source/v3/samples/volumes/volume-update-request.json rename api-ref/source/v3/samples/{ => volumes}/volume-update-response.json (50%) create mode 100644 api-ref/source/v3/samples/volumes/volumes-list-detailed-response.json create mode 100644 api-ref/source/v3/samples/volumes/volumes-list-response.json create mode 100644 cinder/tests/functional/api_sample_tests/samples/volume_type/volume-type-access-add-request.json.tpl create mode 100644 cinder/tests/functional/api_sample_tests/samples/volume_type/volume-type-access-list-response.json.tpl rename api-ref/source/v3/samples/volume-create-request.json => cinder/tests/functional/api_sample_tests/samples/volumes/volume-create-request.json.tpl (100%) create mode 100644 cinder/tests/functional/api_sample_tests/samples/volumes/volume-create-response.json.tpl rename api-ref/source/v3/samples/volume-metadata-create-request.json => cinder/tests/functional/api_sample_tests/samples/volumes/volume-metadata-create-request.json.tpl (100%) create mode 100644 cinder/tests/functional/api_sample_tests/samples/volumes/volume-metadata-create-response.json.tpl create mode 100644 cinder/tests/functional/api_sample_tests/samples/volumes/volume-metadata-show-key-response.json.tpl create mode 100644 cinder/tests/functional/api_sample_tests/samples/volumes/volume-metadata-show-response.json.tpl rename api-ref/source/v3/samples/volume-metadata-update-key-request.json => cinder/tests/functional/api_sample_tests/samples/volumes/volume-metadata-update-key-request.json.tpl (100%) create mode 100644 cinder/tests/functional/api_sample_tests/samples/volumes/volume-metadata-update-key-response.json.tpl rename api-ref/source/v3/samples/volume-metadata-update-request.json => cinder/tests/functional/api_sample_tests/samples/volumes/volume-metadata-update-request.json.tpl (100%) create mode 100644 cinder/tests/functional/api_sample_tests/samples/volumes/volume-metadata-update-response.json.tpl create mode 100644 cinder/tests/functional/api_sample_tests/samples/volumes/volume-show-response.json.tpl rename api-ref/source/v3/samples/volume-update-request.json => cinder/tests/functional/api_sample_tests/samples/volumes/volume-update-request.json.tpl (100%) create mode 100644 cinder/tests/functional/api_sample_tests/samples/volumes/volume-update-response.json.tpl create mode 100644 cinder/tests/functional/api_sample_tests/samples/volumes/volumes-list-detailed-response.json.tpl create mode 100644 cinder/tests/functional/api_sample_tests/samples/volumes/volumes-list-response.json.tpl create mode 100644 cinder/tests/functional/api_sample_tests/test_volumes.py diff --git a/api-ref/source/v3/samples/versions/version-show-response.json b/api-ref/source/v3/samples/versions/version-show-response.json index 6d34b3dfc3e..337caab9a5c 100644 --- a/api-ref/source/v3/samples/versions/version-show-response.json +++ b/api-ref/source/v3/samples/versions/version-show-response.json @@ -25,4 +25,4 @@ "version": "3.56" } ] -} \ No newline at end of file +} diff --git a/api-ref/source/v3/samples/volume-create-response.json b/api-ref/source/v3/samples/volume-create-response.json deleted file mode 100644 index 57441f030a4..00000000000 --- a/api-ref/source/v3/samples/volume-create-response.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "volume": { - "status": "creating", - "migration_status": null, - "user_id": "0eea4eabcf184061a3b6db1e0daaf010", - "attachments": [], - "links": [ - { - "href": "http://23.253.248.171:8776/v3/bab7d5c60cd041a0a36f7c4b6e1dd978/volumes/6edbc2f4-1507-44f8-ac0d-eed1d2608d38", - "rel": "self" - }, - { - "href": "http://23.253.248.171:8776/bab7d5c60cd041a0a36f7c4b6e1dd978/volumes/6edbc2f4-1507-44f8-ac0d-eed1d2608d38", - "rel": "bookmark" - } - ], - "availability_zone": "nova", - "bootable": "false", - "encrypted": false, - "created_at": "2015-11-29T03:01:44.000000", - "description": null, - "updated_at": null, - "volume_type": "lvmdriver-1", - "name": "test-volume-attachments", - "replication_status": "disabled", - "consistencygroup_id": null, - "source_volid": null, - "snapshot_id": null, - "multiattach": false, - "metadata": {}, - "id": "6edbc2f4-1507-44f8-ac0d-eed1d2608d38", - "size": 2 - } -} diff --git a/api-ref/source/v3/samples/volume-metadata-show-key-response.json b/api-ref/source/v3/samples/volume-metadata-show-key-response.json deleted file mode 100644 index 0a98eb72dc5..00000000000 --- a/api-ref/source/v3/samples/volume-metadata-show-key-response.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "meta": { - "name": "test" - } -} diff --git a/api-ref/source/v3/samples/volume-show-response.json b/api-ref/source/v3/samples/volume-show-response.json deleted file mode 100644 index ad5c45091fb..00000000000 --- a/api-ref/source/v3/samples/volume-show-response.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "volume": { - "status": "available", - "attachments": [], - "links": [ - { - "href": "http://localhost:8776/v3/0c2eba2c5af04d3f9e9d0d410b371fde/volumes/5aa119a8-d25b-45a7-8d1b-88e127885635", - "rel": "self" - }, - { - "href": "http://localhost:8776/0c2eba2c5af04d3f9e9d0d410b371fde/volumes/5aa119a8-d25b-45a7-8d1b-88e127885635", - "rel": "bookmark" - } - ], - "availability_zone": "nova", - "bootable": "false", - "os-vol-host-attr:host": "ip-10-168-107-25", - "source_volid": null, - "snapshot_id": null, - "id": "5aa119a8-d25b-45a7-8d1b-88e127885635", - "description": "Super volume.", - "name": "vol-002", - "created_at": "2013-02-25T02:40:21.000000", - "volume_type": null, - "os-vol-tenant-attr:tenant_id": "0c2eba2c5af04d3f9e9d0d410b371fde", - "size": 1, - "metadata": { - "contents": "not junk" - } - } -} diff --git a/api-ref/source/v3/samples/volume-type-access-add-request.json b/api-ref/source/v3/samples/volume-type-access-add-request.json deleted file mode 100644 index b7481edbbf3..00000000000 --- a/api-ref/source/v3/samples/volume-type-access-add-request.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "addProjectAccess": { - "project": "f270b245cb11498ca4031deb7e141cfa" - } -} diff --git a/api-ref/source/v3/samples/volume-type-access-list-response.json b/api-ref/source/v3/samples/volume-type-access-list-response.json deleted file mode 100644 index afcffb0810b..00000000000 --- a/api-ref/source/v3/samples/volume-type-access-list-response.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "volume_type_access": { - "volume_type_id": "3c67e124-39ad-4ace-a507-8bb7bf510c26", - "project_id": "f270b245cb11498ca4031deb7e141cfa" - } -} diff --git a/api-ref/source/v3/samples/volume_type/volume-type-access-add-request.json b/api-ref/source/v3/samples/volume_type/volume-type-access-add-request.json new file mode 100644 index 00000000000..5bbce19afdf --- /dev/null +++ b/api-ref/source/v3/samples/volume_type/volume-type-access-add-request.json @@ -0,0 +1,5 @@ +{ + "addProjectAccess": { + "project": "6f70656e737461636b20342065766572" + } +} \ No newline at end of file diff --git a/api-ref/source/v3/samples/volume_type/volume-type-access-list-response.json b/api-ref/source/v3/samples/volume_type/volume-type-access-list-response.json new file mode 100644 index 00000000000..d96bb13cab5 --- /dev/null +++ b/api-ref/source/v3/samples/volume_type/volume-type-access-list-response.json @@ -0,0 +1,8 @@ +{ + "volume_type_access": [ + { + "project_id": "6f70656e737461636b20342065766572", + "volume_type_id": "a5082c24-2a27-43a4-b48e-fcec1240e36b" + } + ] +} \ No newline at end of file diff --git a/api-ref/source/v3/samples/volumes/volume-create-request.json b/api-ref/source/v3/samples/volumes/volume-create-request.json new file mode 100644 index 00000000000..827c47ba10c --- /dev/null +++ b/api-ref/source/v3/samples/volumes/volume-create-request.json @@ -0,0 +1,22 @@ +{ + "volume": { + "size": 10, + "availability_zone": null, + "source_volid": null, + "description": null, + "multiattach": false, + "snapshot_id": null, + "backup_id": null, + "name": null, + "imageRef": null, + "volume_type": null, + "metadata": {}, + "consistencygroup_id": null + }, + "OS-SCH-HNT:scheduler_hints": { + "same_host": [ + "a0cf03a5-d921-4877-bb5c-86d26cf818e1", + "8c19174f-4220-44f0-824a-cd1eeef10287" + ] + } +} \ No newline at end of file diff --git a/api-ref/source/v3/samples/volumes/volume-create-response.json b/api-ref/source/v3/samples/volumes/volume-create-response.json new file mode 100644 index 00000000000..8a6f47665eb --- /dev/null +++ b/api-ref/source/v3/samples/volumes/volume-create-response.json @@ -0,0 +1,34 @@ +{ + "volume": { + "attachments": [], + "availability_zone": "nova", + "bootable": "false", + "consistencygroup_id": null, + "created_at": "2018-11-28T06:21:12.715987", + "description": null, + "encrypted": false, + "id": "2b955850-f177-45f7-9f49-ecb2c256d161", + "links": [ + { + "href": "http://127.0.0.1:33951/v3/89afd400-b646-4bbc-b12b-c0a4d63e5bd3/volumes/2b955850-f177-45f7-9f49-ecb2c256d161", + "rel": "self" + }, + { + "href": "http://127.0.0.1:33951/89afd400-b646-4bbc-b12b-c0a4d63e5bd3/volumes/2b955850-f177-45f7-9f49-ecb2c256d161", + "rel": "bookmark" + } + ], + "metadata": {}, + "migration_status": null, + "multiattach": false, + "name": null, + "replication_status": null, + "size": 10, + "snapshot_id": null, + "source_volid": null, + "status": "creating", + "updated_at": null, + "user_id": "c853ca26-e8ea-4797-8a52-ee124a013d0e", + "volume_type": null + } +} \ No newline at end of file diff --git a/api-ref/source/v3/samples/volumes/volume-metadata-create-request.json b/api-ref/source/v3/samples/volumes/volume-metadata-create-request.json new file mode 100644 index 00000000000..f175f3d3c39 --- /dev/null +++ b/api-ref/source/v3/samples/volumes/volume-metadata-create-request.json @@ -0,0 +1,5 @@ +{ + "metadata": { + "name": "metadata0" + } +} \ No newline at end of file diff --git a/api-ref/source/v3/samples/volume-metadata-create-response.json b/api-ref/source/v3/samples/volumes/volume-metadata-create-response.json similarity index 96% rename from api-ref/source/v3/samples/volume-metadata-create-response.json rename to api-ref/source/v3/samples/volumes/volume-metadata-create-response.json index 1ff9aae2788..f175f3d3c39 100644 --- a/api-ref/source/v3/samples/volume-metadata-create-response.json +++ b/api-ref/source/v3/samples/volumes/volume-metadata-create-response.json @@ -2,4 +2,4 @@ "metadata": { "name": "metadata0" } -} +} \ No newline at end of file diff --git a/api-ref/source/v3/samples/volumes/volume-metadata-show-key-response.json b/api-ref/source/v3/samples/volumes/volume-metadata-show-key-response.json new file mode 100644 index 00000000000..35d39547253 --- /dev/null +++ b/api-ref/source/v3/samples/volumes/volume-metadata-show-key-response.json @@ -0,0 +1,5 @@ +{ + "meta": { + "name": "metadata1" + } +} \ No newline at end of file diff --git a/api-ref/source/v3/samples/volume-metadata-show-response.json b/api-ref/source/v3/samples/volumes/volume-metadata-show-response.json similarity index 91% rename from api-ref/source/v3/samples/volume-metadata-show-response.json rename to api-ref/source/v3/samples/volumes/volume-metadata-show-response.json index 5937a866595..fa2211263bb 100644 --- a/api-ref/source/v3/samples/volume-metadata-show-response.json +++ b/api-ref/source/v3/samples/volumes/volume-metadata-show-response.json @@ -1,3 +1,3 @@ { "metadata": {} -} +} \ No newline at end of file diff --git a/api-ref/source/v3/samples/volumes/volume-metadata-update-key-request.json b/api-ref/source/v3/samples/volumes/volume-metadata-update-key-request.json new file mode 100644 index 00000000000..73b5f9bd64d --- /dev/null +++ b/api-ref/source/v3/samples/volumes/volume-metadata-update-key-request.json @@ -0,0 +1,5 @@ +{ + "meta": { + "name": "new_name" + } +} \ No newline at end of file diff --git a/api-ref/source/v3/samples/volume-metadata-update-key-response.json b/api-ref/source/v3/samples/volumes/volume-metadata-update-key-response.json similarity index 96% rename from api-ref/source/v3/samples/volume-metadata-update-key-response.json rename to api-ref/source/v3/samples/volumes/volume-metadata-update-key-response.json index 5041c187ef5..73b5f9bd64d 100644 --- a/api-ref/source/v3/samples/volume-metadata-update-key-response.json +++ b/api-ref/source/v3/samples/volumes/volume-metadata-update-key-response.json @@ -2,4 +2,4 @@ "meta": { "name": "new_name" } -} +} \ No newline at end of file diff --git a/api-ref/source/v3/samples/volumes/volume-metadata-update-request.json b/api-ref/source/v3/samples/volumes/volume-metadata-update-request.json new file mode 100644 index 00000000000..8dcf8916d24 --- /dev/null +++ b/api-ref/source/v3/samples/volumes/volume-metadata-update-request.json @@ -0,0 +1,5 @@ +{ + "metadata": { + "name": "metadata1" + } +} \ No newline at end of file diff --git a/api-ref/source/v3/samples/volume-metadata-update-response.json b/api-ref/source/v3/samples/volumes/volume-metadata-update-response.json similarity index 96% rename from api-ref/source/v3/samples/volume-metadata-update-response.json rename to api-ref/source/v3/samples/volumes/volume-metadata-update-response.json index 4d96ad8484a..8dcf8916d24 100644 --- a/api-ref/source/v3/samples/volume-metadata-update-response.json +++ b/api-ref/source/v3/samples/volumes/volume-metadata-update-response.json @@ -2,4 +2,4 @@ "metadata": { "name": "metadata1" } -} +} \ No newline at end of file diff --git a/api-ref/source/v3/samples/volumes/volume-show-response.json b/api-ref/source/v3/samples/volumes/volume-show-response.json new file mode 100644 index 00000000000..269130f731a --- /dev/null +++ b/api-ref/source/v3/samples/volumes/volume-show-response.json @@ -0,0 +1,38 @@ +{ + "volume": { + "attachments": [], + "availability_zone": "nova", + "bootable": "false", + "consistencygroup_id": null, + "created_at": "2018-11-29T06:50:07.770785", + "description": null, + "encrypted": false, + "id": "f7223234-1afc-4d19-bfa3-d19deb6235ef", + "links": [ + { + "href": "http://127.0.0.1:45839/v3/89afd400-b646-4bbc-b12b-c0a4d63e5bd3/volumes/f7223234-1afc-4d19-bfa3-d19deb6235ef", + "rel": "self" + }, + { + "href": "http://127.0.0.1:45839/89afd400-b646-4bbc-b12b-c0a4d63e5bd3/volumes/f7223234-1afc-4d19-bfa3-d19deb6235ef", + "rel": "bookmark" + } + ], + "metadata": {}, + "migration_status": null, + "multiattach": false, + "name": null, + "os-vol-host-attr:host": null, + "os-vol-mig-status-attr:migstat": null, + "os-vol-mig-status-attr:name_id": null, + "os-vol-tenant-attr:tenant_id": "89afd400-b646-4bbc-b12b-c0a4d63e5bd3", + "replication_status": null, + "size": 10, + "snapshot_id": null, + "source_volid": null, + "status": "creating", + "updated_at": null, + "user_id": "c853ca26-e8ea-4797-8a52-ee124a013d0e", + "volume_type": null + } +} \ No newline at end of file diff --git a/api-ref/source/v3/samples/volumes/volume-update-request.json b/api-ref/source/v3/samples/volumes/volume-update-request.json new file mode 100644 index 00000000000..2ef61267b6c --- /dev/null +++ b/api-ref/source/v3/samples/volumes/volume-update-request.json @@ -0,0 +1,9 @@ +{ + "volume": { + "name": "vol-003", + "description": "This is yet, another volume.", + "metadata": { + "name": "metadata0" + } + } +} \ No newline at end of file diff --git a/api-ref/source/v3/samples/volume-update-response.json b/api-ref/source/v3/samples/volumes/volume-update-response.json similarity index 50% rename from api-ref/source/v3/samples/volume-update-response.json rename to api-ref/source/v3/samples/volumes/volume-update-response.json index 1fc925e915a..56c544ee4e8 100644 --- a/api-ref/source/v3/samples/volume-update-response.json +++ b/api-ref/source/v3/samples/volumes/volume-update-response.json @@ -1,36 +1,36 @@ { "volume": { - "status": "available", - "migration_status": null, - "user_id": "0eea4eabcf184061a3b6db1e0daaf010", "attachments": [], + "availability_zone": "nova", + "bootable": "false", + "consistencygroup_id": null, + "created_at": "2018-11-29T06:59:23.679903", + "description": "This is yet, another volume.", + "encrypted": false, + "id": "8b2459d1-0059-4e14-a89f-dfa73a452af6", "links": [ { - "href": "http://localhost:8776/v3/0c2eba2c5af04d3f9e9d0d410b371fde/volumes/5aa119a8-d25b-45a7-8d1b-88e127885635", + "href": "http://127.0.0.1:41467/v3/89afd400-b646-4bbc-b12b-c0a4d63e5bd3/volumes/8b2459d1-0059-4e14-a89f-dfa73a452af6", "rel": "self" }, { - "href": "http://localhost:8776/0c2eba2c5af04d3f9e9d0d410b371fde/volumes/5aa119a8-d25b-45a7-8d1b-88e127885635", + "href": "http://127.0.0.1:41467/89afd400-b646-4bbc-b12b-c0a4d63e5bd3/volumes/8b2459d1-0059-4e14-a89f-dfa73a452af6", "rel": "bookmark" } ], - "availability_zone": "nova", - "bootable": "false", - "encrypted": false, - "created_at": "2015-11-29T03:01:44.000000", - "description": "This is yet, another volume.", - "updated_at": null, - "volume_type": "lvmdriver-1", - "name": "vol-003", - "replication_status": "disabled", - "consistencygroup_id": null, - "source_volid": null, - "snapshot_id": null, - "multiattach": false, "metadata": { - "contents": "not junk" + "name": "metadata0" }, - "id": "5aa119a8-d25b-45a7-8d1b-88e127885635", - "size": 1 + "migration_status": null, + "multiattach": false, + "name": "vol-003", + "replication_status": null, + "size": 10, + "snapshot_id": null, + "source_volid": null, + "status": "creating", + "updated_at": null, + "user_id": "c853ca26-e8ea-4797-8a52-ee124a013d0e", + "volume_type": null } -} +} \ No newline at end of file diff --git a/api-ref/source/v3/samples/volumes/volumes-list-detailed-response.json b/api-ref/source/v3/samples/volumes/volumes-list-detailed-response.json new file mode 100644 index 00000000000..4204a9a06d7 --- /dev/null +++ b/api-ref/source/v3/samples/volumes/volumes-list-detailed-response.json @@ -0,0 +1,40 @@ +{ + "volumes": [ + { + "attachments": [], + "availability_zone": "nova", + "bootable": "false", + "consistencygroup_id": null, + "created_at": "2018-11-28T06:25:15.288987", + "description": null, + "encrypted": false, + "id": "cb49b381-9012-40cb-b8ee-80c19a4801b5", + "links": [ + { + "href": "http://127.0.0.1:43543/v3/89afd400-b646-4bbc-b12b-c0a4d63e5bd3/volumes/cb49b381-9012-40cb-b8ee-80c19a4801b5", + "rel": "self" + }, + { + "href": "http://127.0.0.1:43543/89afd400-b646-4bbc-b12b-c0a4d63e5bd3/volumes/cb49b381-9012-40cb-b8ee-80c19a4801b5", + "rel": "bookmark" + } + ], + "metadata": {}, + "migration_status": null, + "multiattach": false, + "name": null, + "os-vol-host-attr:host": null, + "os-vol-mig-status-attr:migstat": null, + "os-vol-mig-status-attr:name_id": null, + "os-vol-tenant-attr:tenant_id": "89afd400-b646-4bbc-b12b-c0a4d63e5bd3", + "replication_status": null, + "size": 10, + "snapshot_id": null, + "source_volid": null, + "status": "creating", + "updated_at": null, + "user_id": "c853ca26-e8ea-4797-8a52-ee124a013d0e", + "volume_type": null + } + ] +} \ No newline at end of file diff --git a/api-ref/source/v3/samples/volumes/volumes-list-response.json b/api-ref/source/v3/samples/volumes/volumes-list-response.json new file mode 100644 index 00000000000..eec24a99792 --- /dev/null +++ b/api-ref/source/v3/samples/volumes/volumes-list-response.json @@ -0,0 +1,18 @@ +{ + "volumes": [ + { + "id": "efa54464-8fab-47cd-a05a-be3e6b396188", + "links": [ + { + "href": "http://127.0.0.1:37097/v3/89afd400-b646-4bbc-b12b-c0a4d63e5bd3/volumes/efa54464-8fab-47cd-a05a-be3e6b396188", + "rel": "self" + }, + { + "href": "http://127.0.0.1:37097/89afd400-b646-4bbc-b12b-c0a4d63e5bd3/volumes/efa54464-8fab-47cd-a05a-be3e6b396188", + "rel": "bookmark" + } + ], + "name": null + } + ] +} \ No newline at end of file diff --git a/api-ref/source/v3/volume-type-access.inc b/api-ref/source/v3/volume-type-access.inc index 5139096b20f..08fb855abcd 100644 --- a/api-ref/source/v3/volume-type-access.inc +++ b/api-ref/source/v3/volume-type-access.inc @@ -41,7 +41,7 @@ Request Request Example --------------- -.. literalinclude:: ./samples/volume-type-access-add-request.json +.. literalinclude:: ./samples/volume_type/volume-type-access-add-request.json :language: javascript @@ -115,5 +115,5 @@ Response Parameters Response Example ---------------- -.. literalinclude:: ./samples/volume-type-access-list-response.json +.. literalinclude:: ./samples/volume_type/volume-type-access-list-response.json :language: javascript diff --git a/api-ref/source/v3/volumes-v3-volumes.inc b/api-ref/source/v3/volumes-v3-volumes.inc index ae22d5ed272..e6c0cc96f75 100644 --- a/api-ref/source/v3/volumes-v3-volumes.inc +++ b/api-ref/source/v3/volumes-v3-volumes.inc @@ -137,7 +137,7 @@ Response Parameters Response Example ---------------- -.. literalinclude:: ./samples/volumes-list-detailed-response.json +.. literalinclude:: ./samples/volumes/volumes-list-detailed-response.json :language: javascript @@ -211,7 +211,7 @@ Request Request Example --------------- -.. literalinclude:: ./samples/volume-create-request.json +.. literalinclude:: ./samples/volumes/volume-create-request.json :language: javascript @@ -248,7 +248,7 @@ Response Parameters Response Example ---------------- -.. literalinclude:: ./samples/volume-create-response.json +.. literalinclude:: ./samples/volumes/volume-create-response.json :language: javascript @@ -305,7 +305,7 @@ Response Parameters Response Example ---------------- -.. literalinclude:: ./samples/volumes-list-response.json +.. literalinclude:: ./samples/volumes/volumes-list-response.json :language: javascript @@ -378,7 +378,7 @@ Response Parameters Response Example ---------------- -.. literalinclude:: ./samples/volume-show-response.json +.. literalinclude:: ./samples/volumes/volume-show-response.json :language: javascript @@ -414,7 +414,7 @@ Request Request Example --------------- -.. literalinclude:: ./samples/volume-update-request.json +.. literalinclude:: ./samples/volumes/volume-update-request.json :language: javascript @@ -451,7 +451,7 @@ Response Parameters Response Example ---------------- -.. literalinclude:: ./samples/volume-update-response.json +.. literalinclude:: ./samples/volumes/volume-update-response.json :language: javascript @@ -535,7 +535,7 @@ Request Request Example --------------- -.. literalinclude:: ./samples/volume-metadata-create-request.json +.. literalinclude:: ./samples/volumes/volume-metadata-create-request.json :language: javascript @@ -551,7 +551,7 @@ Response Parameters Response Example ---------------- -.. literalinclude:: ./samples/volume-metadata-create-response.json +.. literalinclude:: ./samples/volumes/volume-metadata-create-response.json :language: javascript @@ -592,7 +592,7 @@ Response Parameters Response Example ---------------- -.. literalinclude:: ./samples/volume-metadata-show-response.json +.. literalinclude:: ./samples/volumes/volume-metadata-show-response.json :language: javascript @@ -624,7 +624,7 @@ Request Request Example --------------- -.. literalinclude:: ./samples/volume-metadata-update-request.json +.. literalinclude:: ./samples/volumes/volume-metadata-update-request.json :language: javascript @@ -641,7 +641,7 @@ Response Parameters Response Example ---------------- -.. literalinclude:: ./samples/volume-metadata-update-response.json +.. literalinclude:: ./samples/volumes/volume-metadata-update-response.json :language: javascript @@ -682,7 +682,7 @@ Response Parameters Response Example ---------------- -.. literalinclude:: ./samples/volume-metadata-show-key-response.json +.. literalinclude:: ./samples/volumes/volume-metadata-show-key-response.json :language: javascript @@ -741,7 +741,7 @@ Request Request Example --------------- -.. literalinclude:: ./samples/volume-metadata-update-key-request.json +.. literalinclude:: ./samples/volumes/volume-metadata-update-key-request.json :language: javascript Response Parameters @@ -754,7 +754,7 @@ Response Parameters Response Example ---------------- -.. literalinclude:: ./samples/volume-metadata-update-key-response.json +.. literalinclude:: ./samples/volumes/volume-metadata-update-key-response.json :language: javascript diff --git a/cinder/tests/functional/api_sample_tests/samples/volume_type/volume-type-access-add-request.json.tpl b/cinder/tests/functional/api_sample_tests/samples/volume_type/volume-type-access-add-request.json.tpl new file mode 100644 index 00000000000..e6feff7f7c0 --- /dev/null +++ b/cinder/tests/functional/api_sample_tests/samples/volume_type/volume-type-access-add-request.json.tpl @@ -0,0 +1,5 @@ +{ + "addProjectAccess": { + "project": "6f70656e737461636b20342065766572" + } +} diff --git a/cinder/tests/functional/api_sample_tests/samples/volume_type/volume-type-access-list-response.json.tpl b/cinder/tests/functional/api_sample_tests/samples/volume_type/volume-type-access-list-response.json.tpl new file mode 100644 index 00000000000..65cd7e2202e --- /dev/null +++ b/cinder/tests/functional/api_sample_tests/samples/volume_type/volume-type-access-list-response.json.tpl @@ -0,0 +1,8 @@ +{ + "volume_type_access": [ + { + "project_id": "%(user_id)s", + "volume_type_id": "%(uuid)s" + } + ] +} \ No newline at end of file diff --git a/cinder/tests/functional/api_sample_tests/samples/volume_type/volume-type-create-request.json.tpl b/cinder/tests/functional/api_sample_tests/samples/volume_type/volume-type-create-request.json.tpl index c3bec491991..c21a710fc88 100644 --- a/cinder/tests/functional/api_sample_tests/samples/volume_type/volume-type-create-request.json.tpl +++ b/cinder/tests/functional/api_sample_tests/samples/volume_type/volume-type-create-request.json.tpl @@ -2,7 +2,7 @@ "volume_type": { "name": "%(name)s", "description": "%(description)s", - "os-volume-type-access:is_public": true, + "os-volume-type-access:is_public": "%(bool)s", "extra_specs": { "capabilities": "gpu" } diff --git a/api-ref/source/v3/samples/volume-create-request.json b/cinder/tests/functional/api_sample_tests/samples/volumes/volume-create-request.json.tpl similarity index 100% rename from api-ref/source/v3/samples/volume-create-request.json rename to cinder/tests/functional/api_sample_tests/samples/volumes/volume-create-request.json.tpl diff --git a/cinder/tests/functional/api_sample_tests/samples/volumes/volume-create-response.json.tpl b/cinder/tests/functional/api_sample_tests/samples/volumes/volume-create-response.json.tpl new file mode 100644 index 00000000000..c94c0dfd840 --- /dev/null +++ b/cinder/tests/functional/api_sample_tests/samples/volumes/volume-create-response.json.tpl @@ -0,0 +1,34 @@ +{ + "volume": { + "attachments": [], + "availability_zone": "nova", + "bootable": "false", + "consistencygroup_id": null, + "created_at": "%(strtime)s", + "description": null, + "encrypted": false, + "id": "%(uuid)s", + "links": [ + { + "href": "%(host)s/v3/89afd400-b646-4bbc-b12b-c0a4d63e5bd3/volumes/%(uuid)s", + "rel": "self" + }, + { + "href": "%(host)s/89afd400-b646-4bbc-b12b-c0a4d63e5bd3/volumes/%(uuid)s", + "rel": "bookmark" + } + ], + "metadata": {}, + "migration_status": null, + "multiattach": false, + "name": null, + "replication_status": null, + "size": 10, + "snapshot_id": null, + "source_volid": null, + "status": "creating", + "updated_at": null, + "user_id": "%(uuid)s", + "volume_type": null + } +} \ No newline at end of file diff --git a/api-ref/source/v3/samples/volume-metadata-create-request.json b/cinder/tests/functional/api_sample_tests/samples/volumes/volume-metadata-create-request.json.tpl similarity index 100% rename from api-ref/source/v3/samples/volume-metadata-create-request.json rename to cinder/tests/functional/api_sample_tests/samples/volumes/volume-metadata-create-request.json.tpl diff --git a/cinder/tests/functional/api_sample_tests/samples/volumes/volume-metadata-create-response.json.tpl b/cinder/tests/functional/api_sample_tests/samples/volumes/volume-metadata-create-response.json.tpl new file mode 100644 index 00000000000..f175f3d3c39 --- /dev/null +++ b/cinder/tests/functional/api_sample_tests/samples/volumes/volume-metadata-create-response.json.tpl @@ -0,0 +1,5 @@ +{ + "metadata": { + "name": "metadata0" + } +} \ No newline at end of file diff --git a/cinder/tests/functional/api_sample_tests/samples/volumes/volume-metadata-show-key-response.json.tpl b/cinder/tests/functional/api_sample_tests/samples/volumes/volume-metadata-show-key-response.json.tpl new file mode 100644 index 00000000000..35d39547253 --- /dev/null +++ b/cinder/tests/functional/api_sample_tests/samples/volumes/volume-metadata-show-key-response.json.tpl @@ -0,0 +1,5 @@ +{ + "meta": { + "name": "metadata1" + } +} \ No newline at end of file diff --git a/cinder/tests/functional/api_sample_tests/samples/volumes/volume-metadata-show-response.json.tpl b/cinder/tests/functional/api_sample_tests/samples/volumes/volume-metadata-show-response.json.tpl new file mode 100644 index 00000000000..fa2211263bb --- /dev/null +++ b/cinder/tests/functional/api_sample_tests/samples/volumes/volume-metadata-show-response.json.tpl @@ -0,0 +1,3 @@ +{ + "metadata": {} +} \ No newline at end of file diff --git a/api-ref/source/v3/samples/volume-metadata-update-key-request.json b/cinder/tests/functional/api_sample_tests/samples/volumes/volume-metadata-update-key-request.json.tpl similarity index 100% rename from api-ref/source/v3/samples/volume-metadata-update-key-request.json rename to cinder/tests/functional/api_sample_tests/samples/volumes/volume-metadata-update-key-request.json.tpl diff --git a/cinder/tests/functional/api_sample_tests/samples/volumes/volume-metadata-update-key-response.json.tpl b/cinder/tests/functional/api_sample_tests/samples/volumes/volume-metadata-update-key-response.json.tpl new file mode 100644 index 00000000000..73b5f9bd64d --- /dev/null +++ b/cinder/tests/functional/api_sample_tests/samples/volumes/volume-metadata-update-key-response.json.tpl @@ -0,0 +1,5 @@ +{ + "meta": { + "name": "new_name" + } +} \ No newline at end of file diff --git a/api-ref/source/v3/samples/volume-metadata-update-request.json b/cinder/tests/functional/api_sample_tests/samples/volumes/volume-metadata-update-request.json.tpl similarity index 100% rename from api-ref/source/v3/samples/volume-metadata-update-request.json rename to cinder/tests/functional/api_sample_tests/samples/volumes/volume-metadata-update-request.json.tpl diff --git a/cinder/tests/functional/api_sample_tests/samples/volumes/volume-metadata-update-response.json.tpl b/cinder/tests/functional/api_sample_tests/samples/volumes/volume-metadata-update-response.json.tpl new file mode 100644 index 00000000000..8dcf8916d24 --- /dev/null +++ b/cinder/tests/functional/api_sample_tests/samples/volumes/volume-metadata-update-response.json.tpl @@ -0,0 +1,5 @@ +{ + "metadata": { + "name": "metadata1" + } +} \ No newline at end of file diff --git a/cinder/tests/functional/api_sample_tests/samples/volumes/volume-show-response.json.tpl b/cinder/tests/functional/api_sample_tests/samples/volumes/volume-show-response.json.tpl new file mode 100644 index 00000000000..7daac81db48 --- /dev/null +++ b/cinder/tests/functional/api_sample_tests/samples/volumes/volume-show-response.json.tpl @@ -0,0 +1,38 @@ +{ + "volume": { + "attachments": [], + "availability_zone": "nova", + "bootable": "false", + "consistencygroup_id": null, + "created_at": "%(strtime)s", + "description": null, + "encrypted": false, + "id": "%(uuid)s", + "links": [ + { + "href": "%(host)s/v3/89afd400-b646-4bbc-b12b-c0a4d63e5bd3/volumes/%(uuid)s", + "rel": "self" + }, + { + "href": "%(host)s/89afd400-b646-4bbc-b12b-c0a4d63e5bd3/volumes/%(uuid)s", + "rel": "bookmark" + } + ], + "metadata": {}, + "migration_status": null, + "multiattach": false, + "name": null, + "os-vol-host-attr:host": null, + "os-vol-mig-status-attr:migstat": null, + "os-vol-mig-status-attr:name_id": null, + "os-vol-tenant-attr:tenant_id": "%(uuid)s", + "replication_status": null, + "size": 10, + "snapshot_id": null, + "source_volid": null, + "status": "creating", + "updated_at": null, + "user_id": "%(uuid)s", + "volume_type": null + } +} \ No newline at end of file diff --git a/api-ref/source/v3/samples/volume-update-request.json b/cinder/tests/functional/api_sample_tests/samples/volumes/volume-update-request.json.tpl similarity index 100% rename from api-ref/source/v3/samples/volume-update-request.json rename to cinder/tests/functional/api_sample_tests/samples/volumes/volume-update-request.json.tpl diff --git a/cinder/tests/functional/api_sample_tests/samples/volumes/volume-update-response.json.tpl b/cinder/tests/functional/api_sample_tests/samples/volumes/volume-update-response.json.tpl new file mode 100644 index 00000000000..c6ce7a552d1 --- /dev/null +++ b/cinder/tests/functional/api_sample_tests/samples/volumes/volume-update-response.json.tpl @@ -0,0 +1,36 @@ +{ + "volume": { + "attachments": [], + "availability_zone": "nova", + "bootable": "false", + "consistencygroup_id": null, + "created_at": "%(strtime)s", + "description": "This is yet, another volume.", + "encrypted": false, + "id": "%(uuid)s", + "links": [ + { + "href": "%(host)s/v3/89afd400-b646-4bbc-b12b-c0a4d63e5bd3/volumes/%(uuid)s", + "rel": "self" + }, + { + "href": "%(host)s/89afd400-b646-4bbc-b12b-c0a4d63e5bd3/volumes/%(uuid)s", + "rel": "bookmark" + } + ], + "metadata": { + "name": "metadata0" + }, + "migration_status": null, + "multiattach": false, + "name": "vol-003", + "replication_status": null, + "size": 10, + "snapshot_id": null, + "source_volid": null, + "status": "creating", + "updated_at": null, + "user_id": "%(uuid)s", + "volume_type": null + } +} \ No newline at end of file diff --git a/cinder/tests/functional/api_sample_tests/samples/volumes/volumes-list-detailed-response.json.tpl b/cinder/tests/functional/api_sample_tests/samples/volumes/volumes-list-detailed-response.json.tpl new file mode 100644 index 00000000000..9157e537e67 --- /dev/null +++ b/cinder/tests/functional/api_sample_tests/samples/volumes/volumes-list-detailed-response.json.tpl @@ -0,0 +1,40 @@ +{ + "volumes": [ + { + "attachments": [], + "availability_zone": "nova", + "bootable": "false", + "consistencygroup_id": null, + "created_at": "%(strtime)s", + "description": null, + "encrypted": false, + "id": "%(uuid)s", + "links": [ + { + "href": "%(host)s/v3/89afd400-b646-4bbc-b12b-c0a4d63e5bd3/volumes/%(uuid)s", + "rel": "self" + }, + { + "href": "%(host)s/89afd400-b646-4bbc-b12b-c0a4d63e5bd3/volumes/%(uuid)s", + "rel": "bookmark" + } + ], + "metadata": {}, + "migration_status": null, + "multiattach": false, + "name": null, + "os-vol-host-attr:host": null, + "os-vol-mig-status-attr:migstat": null, + "os-vol-mig-status-attr:name_id": null, + "os-vol-tenant-attr:tenant_id": "%(uuid)s", + "replication_status": null, + "size": 10, + "snapshot_id": null, + "source_volid": null, + "status": "creating", + "updated_at": null, + "user_id": "%(uuid)s", + "volume_type": null + } + ] +} \ No newline at end of file diff --git a/cinder/tests/functional/api_sample_tests/samples/volumes/volumes-list-response.json.tpl b/cinder/tests/functional/api_sample_tests/samples/volumes/volumes-list-response.json.tpl new file mode 100644 index 00000000000..10d88cf15bf --- /dev/null +++ b/cinder/tests/functional/api_sample_tests/samples/volumes/volumes-list-response.json.tpl @@ -0,0 +1,18 @@ +{ + "volumes": [ + { + "id": "%(uuid)s", + "links": [ + { + "href": "%(host)s/v3/89afd400-b646-4bbc-b12b-c0a4d63e5bd3/volumes/%(uuid)s", + "rel": "self" + }, + { + "href": "%(host)s/89afd400-b646-4bbc-b12b-c0a4d63e5bd3/volumes/%(uuid)s", + "rel": "bookmark" + } + ], + "name": null + } + ] +} \ No newline at end of file diff --git a/cinder/tests/functional/api_sample_tests/test_volume_types.py b/cinder/tests/functional/api_sample_tests/test_volume_types.py index 51f761c1008..98d6fb0aa05 100644 --- a/cinder/tests/functional/api_sample_tests/test_volume_types.py +++ b/cinder/tests/functional/api_sample_tests/test_volume_types.py @@ -26,7 +26,8 @@ class VolumeTypesSampleJsonTest(api_samples_test_base.ApiSampleTestBase): self.volume_type_name = "vol-type-001" self.subs = { "name": self.volume_type_name, - "description": "volume type 0001" + "description": "volume type 0001", + "bool": "True" } CONF.set_override("default_volume_type", "vol-type-001") @@ -101,7 +102,8 @@ class VolumeTypesSampleJsonTest(api_samples_test_base.ApiSampleTestBase): subs = { "name": "vol-type-002", - "description": "volume type 0002" + "description": "volume type 0002", + "bool": "True" } self._volume_type_create() self._volume_type_create(subs) @@ -144,3 +146,16 @@ class VolumeTypesSampleJsonTest(api_samples_test_base.ApiSampleTestBase): 'encryption-type-update-request') self._verify_response('encryption-type-update-response', self.subs, response, 200) + + def test_private_volume_type_access_add_list(self): + + subs = self.subs + subs['bool'] = "False" + res = self._volume_type_create(subs) + res = jsonutils.loads(res.content)['volume_type'] + self._do_post('types/%s/action' % res['id'], + 'volume-type-access-add-request') + response = self._do_get( + 'types/%s/os-volume-type-access' % res['id']) + self._verify_response('volume-type-access-list-response', + {}, response, 200) diff --git a/cinder/tests/functional/api_sample_tests/test_volumes.py b/cinder/tests/functional/api_sample_tests/test_volumes.py new file mode 100644 index 00000000000..696a4ac10f1 --- /dev/null +++ b/cinder/tests/functional/api_sample_tests/test_volumes.py @@ -0,0 +1,94 @@ +# 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 import api_samples_test_base + + +class VolumesSampleJsonTest(api_samples_test_base.ApiSampleTestBase): + sample_dir = "volumes" + + def setUp(self): + super(VolumesSampleJsonTest, self).setUp() + self.response = self._create_volume() + + def _create_volume(self, subs=None): + + response = self._do_post('volumes', + 'volume-create-request', + subs) + return response + + def test_volume_list_detail(self): + + response = self._do_get('volumes/detail') + self._verify_response('volumes-list-detailed-response', + {}, response, 200) + + def test_volume_create(self): + + self._verify_response('volume-create-response', + {}, self.response, 202) + + def test_volume_list(self): + + response = self._do_get('volumes') + self._verify_response('volumes-list-response', + {}, response, 200) + + def test_volume_show_detail(self): + + res = jsonutils.loads(self.response.content)['volume'] + response = self._do_get('volumes/%s' % res['id']) + self._verify_response('volume-show-response', + {}, response, 200) + + def test_volume_update(self): + + res = jsonutils.loads(self.response.content)['volume'] + response = self._do_put('volumes/%s' % res['id'], + 'volume-update-request') + self._verify_response('volume-update-response', + {}, response, 200) + + def test_volume_metadata_create(self): + + res = jsonutils.loads(self.response.content)['volume'] + response = self._do_post('volumes/%s/metadata' % res['id'], + 'volume-metadata-create-request') + self._verify_response('volume-metadata-create-response', + {}, response, 200) + + def test_volume_metadata_show(self): + + res = jsonutils.loads(self.response.content)['volume'] + response = self._do_get('volumes/%s/metadata' % res['id']) + self._verify_response('volume-metadata-show-response', + {}, response, 200) + + def test_volume_metadata_update(self): + + res = jsonutils.loads(self.response.content)['volume'] + response = self._do_put('volumes/%s/metadata' % res['id'], + 'volume-metadata-update-request') + self._verify_response('volume-metadata-update-response', + {}, response, 200) + + def test_volume_metadata_show_specific_key(self): + + res = jsonutils.loads(self.response.content)['volume'] + self._do_put('volumes/%s/metadata' % res['id'], + 'volume-metadata-update-request') + response = self._do_get('volumes/%s/metadata/name' % res['id']) + self._verify_response('volume-metadata-show-key-response', + {}, response, 200)