Add response schema validation for volume manage
This is to add response schema validation for volume manage.
As gmann pointed out in https://review.opendev.org/#/c/616783/,
the response of volume_manage is same as that of show_volume,
so here we use common_show_volume directly.
Change-Id: I5e26d0cca87c303ebb9a2fe93ad0b13b73eb41a6
partially-implements: blueprint volume-response-schema-validation
diff --git a/tempest/lib/api_schema/response/volume/manage_volume.py b/tempest/lib/api_schema/response/volume/manage_volume.py
new file mode 100644
index 0000000..d3acfd9
--- /dev/null
+++ b/tempest/lib/api_schema/response/volume/manage_volume.py
@@ -0,0 +1,27 @@
+# Copyright 2018 ZTE Corporation. All rights reserved.
+#
+# 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 tempest.lib.api_schema.response.volume import volumes
+
+
+manage_volume = {
+ 'status_code': [202],
+ 'response_body': {
+ 'type': 'object',
+ 'properties': {
+ 'volume': volumes.common_show_volume},
+ 'additionalProperties': False,
+ 'required': ['volume']
+ }
+}
diff --git a/tempest/lib/services/volume/v3/volume_manage_client.py b/tempest/lib/services/volume/v3/volume_manage_client.py
index 85b1b82..f6642c5 100644
--- a/tempest/lib/services/volume/v3/volume_manage_client.py
+++ b/tempest/lib/services/volume/v3/volume_manage_client.py
@@ -15,6 +15,7 @@
from oslo_serialization import jsonutils as json
+from tempest.lib.api_schema.response.volume import manage_volume as schema
from tempest.lib.common import rest_client
@@ -30,6 +31,6 @@
"""
post_body = json.dumps({'volume': kwargs})
resp, body = self.post('os-volume-manage', post_body)
- self.expected_success(202, resp.status)
body = json.loads(body)
+ self.validate_response(schema.manage_volume, resp, body)
return rest_client.ResponseBody(resp, body)
diff --git a/tempest/tests/lib/services/volume/v3/test_volume_manage_client.py b/tempest/tests/lib/services/volume/v3/test_volume_manage_client.py
index d4313a2..3d47caf 100644
--- a/tempest/tests/lib/services/volume/v3/test_volume_manage_client.py
+++ b/tempest/tests/lib/services/volume/v3/test_volume_manage_client.py
@@ -54,7 +54,6 @@
}
],
"availability_zone": "nova",
- "os-vol-host-attr:host": "controller1@rbd#rbd",
"encrypted": False,
"updated_at": None,
"replication_status": None,
@@ -62,15 +61,12 @@
"id": "c07cd4a4-b52b-4511-a176-fbaa2011a227",
"size": 0,
"user_id": "142d8663efce464c89811c63e45bd82e",
- "os-vol-tenant-attr:tenant_id": "f21a9c86d7114bf99c711f4874d80474",
- "os-vol-mig-status-attr:migstat": None,
"metadata": {},
"status": "creating",
"description": "volume-manage-description",
"multiattach": False,
"source_volid": None,
"consistencygroup_id": None,
- "os-vol-mig-status-attr:name_id": None,
"name": "volume-managed",
"bootable": "false",
"created_at": "2017-07-11T09:14:01.000000",