Merge "Automate generation of backups api-ref samples"

This commit is contained in:
Zuul 2023-05-25 21:17:15 +00:00 committed by Gerrit Code Review
commit 77b6035e4f
8 changed files with 92 additions and 30 deletions

View File

@ -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

View File

@ -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
}
}

View File

@ -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": {}
}
}

View File

@ -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
}
}

View File

@ -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"
}
}

View File

@ -0,0 +1,11 @@
{
"backup": {
"container": null,
"description": "Test backup",
"name": "backup001",
"volume_id": "%(volume_id)s",
"incremental": false,
"snapshot_id": null,
"force": false
}
}

View File

@ -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"
}
}

View File

@ -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)