Verify create/get flavor attributes of Nova APIs
This patch adds the JSON schema for Nova V2/V3 create & get flavor
APIs response and validate the response with added JSON schema to
block the backward incompatibility change in the future.
The response body of V2 create & get flavor API is below:
{
"flavor": {
"name": "m1.tiny",
"links": [
{
"href": "http://openstack.example.com/
v2/openstack/flavors/1",
"rel": "self"
},
{
"href": "http://openstack.example.com/
openstack/flavors/1",
"rel": "bookmark"
}
],
"ram": 512,
"vcpus": 1,
"swap": "",
"disk": 1,
"id": "1",
"OS-FLV-DISABLED:disabled": false,
"os-flavor-access:is_public": true,
"rxtx_factor": 1.0,
"OS-FLV-EXT-DATA:ephemeral": 0
}
}
The response body of V3 create & get flavor API is below:
{
"flavor": {
"name": "m1.tiny",
"links": [
{
"href": "http://openstack.example.com/
v3/openstack/flavors/1",
"rel": "self"
},
{
"href": "http://openstack.example.com/
openstack/flavors/1",
"rel": "bookmark"
}
],
"ram": 512,
"vcpus": 1,
"swap": 0,
"disk": 1,
"id": "1",
"disabled": false,
"ephemeral": 0,
"flavor-access:is_public": true,
"os-flavor-rxtx:rxtx_factor": 1.0
}
}
Partially implements blueprint nova-api-attribute-test
Change-Id: I57569e315aebd5b712b8635b1f5ad8a768d77592
diff --git a/tempest/services/compute/json/flavors_client.py b/tempest/services/compute/json/flavors_client.py
index 65d2657..89cbe1d 100644
--- a/tempest/services/compute/json/flavors_client.py
+++ b/tempest/services/compute/json/flavors_client.py
@@ -56,6 +56,7 @@
def get_flavor_details(self, flavor_id):
resp, body = self.get("flavors/%s" % str(flavor_id))
body = json.loads(body)
+ self.validate_response(v2schema.create_get_flavor_details, resp, body)
return resp, body['flavor']
def create_flavor(self, name, ram, vcpus, disk, flavor_id, **kwargs):
@@ -79,11 +80,14 @@
resp, body = self.post('flavors', post_body)
body = json.loads(body)
+ self.validate_response(v2schema.create_get_flavor_details, resp, body)
return resp, body['flavor']
def delete_flavor(self, flavor_id):
"""Deletes the given flavor."""
- return self.delete("flavors/%s" % str(flavor_id))
+ resp, body = self.delete("flavors/{0}".format(flavor_id))
+ self.validate_response(v2schema.delete_flavor, resp, body)
+ return resp, body
def is_resource_deleted(self, id):
# Did not use get_flavor_details(id) for verification as it gives