Verify the create/delete volume APIs attributes
This patch adds the JSON schema for volume create & delete APIs
and validate the response of Nova Volume list APIs with added JSON
schema to block the backward incompatibility change in the future.
The response body of Nova API volume create is the below:
{
"volume": {
"id": "%(uuid)s",
"status": "in-use",
"displayName": "%(volume_name)s", null
"availabilityZone": "zone1:host1",
"createdAt": "%(timestamp)s",
"displayDescription": "%(volume_desc)s",
"volumeType": "Backup",
"snapshotId": null,
"metadata": {},
"size": 100,
"attachments": [
{ "device": "/",
"serverId": "%(uuid)s",
"id": "%(uuid)s",
"volumeId": "%(uuid)s"
}
]
}
}
delete volume API does not return any response body.
Partially implements blueprint nova-api-attribute-test
Change-Id: I84069dae64a70bc2a4f2313bb3da4e86630e4b1b
diff --git a/tempest/api_schema/compute/v2/volumes.py b/tempest/api_schema/compute/v2/volumes.py
index 9cfd7e3..84a659c 100644
--- a/tempest/api_schema/compute/v2/volumes.py
+++ b/tempest/api_schema/compute/v2/volumes.py
@@ -12,7 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
-get_volume = {
+create_get_volume = {
'status_code': [200],
'response_body': {
'type': 'object',
@@ -108,3 +108,7 @@
'required': ['volumes']
}
}
+
+delete_volume = {
+ 'status_code': [202]
+}
diff --git a/tempest/services/compute/json/volumes_extensions_client.py b/tempest/services/compute/json/volumes_extensions_client.py
index 17468eb..d1014af 100644
--- a/tempest/services/compute/json/volumes_extensions_client.py
+++ b/tempest/services/compute/json/volumes_extensions_client.py
@@ -61,7 +61,7 @@
url = "os-volumes/%s" % str(volume_id)
resp, body = self.get(url)
body = json.loads(body)
- self.validate_response(schema.get_volume, resp, body)
+ self.validate_response(schema.create_get_volume, resp, body)
return resp, body['volume']
def create_volume(self, size, **kwargs):
@@ -81,11 +81,14 @@
post_body = json.dumps({'volume': post_body})
resp, body = self.post('os-volumes', post_body)
body = json.loads(body)
+ self.validate_response(schema.create_get_volume, resp, body)
return resp, body['volume']
def delete_volume(self, volume_id):
"""Deletes the Specified Volume."""
- return self.delete("os-volumes/%s" % str(volume_id))
+ resp, body = self.delete("os-volumes/%s" % str(volume_id))
+ self.validate_response(schema.delete_volume, resp, body)
+ return resp, body
def wait_for_volume_status(self, volume_id, status):
"""Waits for a Volume to reach a given status."""