diff --git a/api-ref/source/v3/ext-backups.inc b/api-ref/source/v3/ext-backups.inc index f1139da7328..7d857a9641d 100644 --- a/api-ref/source/v3/ext-backups.inc +++ b/api-ref/source/v3/ext-backups.inc @@ -303,7 +303,7 @@ Request Request Example --------------- -.. literalinclude:: ./samples/backup-create-request.json +.. literalinclude:: ./samples/backups/backup-create-request.json :language: javascript Response Parameters @@ -320,7 +320,7 @@ Response Parameters Response Example ---------------- -.. literalinclude:: ./samples/backup-create-response.json +.. literalinclude:: ./samples/backups/backup-create-response.json :language: javascript Update a backup diff --git a/api-ref/source/v3/samples/backup-create-request.json b/api-ref/source/v3/samples/backup-create-request.json deleted file mode 100644 index 00ad677cd6e..00000000000 --- a/api-ref/source/v3/samples/backup-create-request.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "backup": { - "container": null, - "description": null, - "name": "backup001", - "volume_id": "64f5d2fb-d836-4063-b7e2-544d5c1ff607", - "incremental": true, - "availability_zone": "AZ2", - "metadata": null - } -} diff --git a/api-ref/source/v3/samples/backup-create-response.json b/api-ref/source/v3/samples/backup-create-response.json deleted file mode 100644 index 0924dcb2b5e..00000000000 --- a/api-ref/source/v3/samples/backup-create-response.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "backup": { - "id": "deac8b8c-35c9-4c71-acaa-889c2d5d5c8e", - "links": [ - { - "href": "http://localhost:8776/v3/c95fc3e4afe248a49a28828f286a7b38/backups/deac8b8c-35c9-4c71-acaa-889c2d5d5c8e", - "rel": "self" - }, - { - "href": "http://localhost:8776/c95fc3e4afe248a49a28828f286a7b38/backups/deac8b8c-35c9-4c71-acaa-889c2d5d5c8e", - "rel": "bookmark" - } - ], - "name": "backup001", - "metadata": {} - } -} diff --git a/api-ref/source/v3/samples/backups/backup-create-request.json b/api-ref/source/v3/samples/backups/backup-create-request.json new file mode 100644 index 00000000000..d0c0dbaf337 --- /dev/null +++ b/api-ref/source/v3/samples/backups/backup-create-request.json @@ -0,0 +1,11 @@ +{ + "backup": { + "container": null, + "description": "Test backup", + "name": "backup001", + "volume_id": "0aa67a0c-7339-4be6-b5d5-2afe21ca270c", + "incremental": false, + "snapshot_id": null, + "force": false + } +} \ No newline at end of file diff --git a/api-ref/source/v3/samples/backups/backup-create-response.json b/api-ref/source/v3/samples/backups/backup-create-response.json new file mode 100644 index 00000000000..cc9ade40ae7 --- /dev/null +++ b/api-ref/source/v3/samples/backups/backup-create-response.json @@ -0,0 +1,16 @@ +{ + "backup": { + "id": "b1f41f9b-741e-4992-a246-b97de7e6e87e", + "links": [ + { + "href": "http://127.0.0.1:40797/v3/89afd400-b646-4bbc-b12b-c0a4d63e5bd3/backups/b1f41f9b-741e-4992-a246-b97de7e6e87e", + "rel": "self" + }, + { + "href": "http://127.0.0.1:40797/89afd400-b646-4bbc-b12b-c0a4d63e5bd3/backups/b1f41f9b-741e-4992-a246-b97de7e6e87e", + "rel": "bookmark" + } + ], + "name": "backup001" + } +} \ No newline at end of file diff --git a/cinder/tests/functional/api_sample_tests/samples/backups/backup-create-request.json.tpl b/cinder/tests/functional/api_sample_tests/samples/backups/backup-create-request.json.tpl new file mode 100644 index 00000000000..4fc983cb90d --- /dev/null +++ b/cinder/tests/functional/api_sample_tests/samples/backups/backup-create-request.json.tpl @@ -0,0 +1,11 @@ +{ + "backup": { + "container": null, + "description": "Test backup", + "name": "backup001", + "volume_id": "%(volume_id)s", + "incremental": false, + "snapshot_id": null, + "force": false + } +} diff --git a/cinder/tests/functional/api_sample_tests/samples/backups/backup-create-response.json.tpl b/cinder/tests/functional/api_sample_tests/samples/backups/backup-create-response.json.tpl new file mode 100644 index 00000000000..7d830a2ed88 --- /dev/null +++ b/cinder/tests/functional/api_sample_tests/samples/backups/backup-create-response.json.tpl @@ -0,0 +1,16 @@ +{ + "backup": { + "id": "%(uuid)s", + "links": [ + { + "href": "%(host)s/v3/%(id)s/backups/%(uuid)s", + "rel": "self" + }, + { + "href": "%(host)s/%(id)s/backups/%(uuid)s", + "rel": "bookmark" + } + ], + "name": "backup001" + } +} diff --git a/cinder/tests/functional/api_sample_tests/test_backups.py b/cinder/tests/functional/api_sample_tests/test_backups.py new file mode 100644 index 00000000000..9e8cb62c5ef --- /dev/null +++ b/cinder/tests/functional/api_sample_tests/test_backups.py @@ -0,0 +1,36 @@ +# 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 as test_base + + +class BackupClassesSampleJsonTest(test_base.VolumesSampleBase): + sample_dir = "backups" + + def setUp(self): + super(BackupClassesSampleJsonTest, 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'] + } + with self.common_api_sample(): + self.response = self._do_post('backups', + 'backup-create-request', + self.subs) + + def test_backup_create(self): + self._verify_response('backup-create-response', + {}, self.response, 202)