Verify Nova create & get Floating IP attributes
This patch adds the JSON schema for Nova create & get Floating IP
APIs response and validate the response with added JSON schema
to block the backward incompatibility change in the future.
The response body of create & get Floating IP APIs is below:
{
"floating_ip": {
"id": 1,
"pool": "nova",
"instance_id": null,
"ip": "10.10.10.1",
"fixed_ip": null,
}
}
Partially implements blueprint nova-api-attribute-test
Change-Id: Ia1c2f856511e62d7a0da01ac78bd37383596198f
diff --git a/tempest/api_schema/compute/v2/floating_ips.py b/tempest/api_schema/compute/v2/floating_ips.py
index 61582ec..648d0bf 100644
--- a/tempest/api_schema/compute/v2/floating_ips.py
+++ b/tempest/api_schema/compute/v2/floating_ips.py
@@ -44,3 +44,33 @@
'required': ['floating_ips']
}
}
+
+floating_ip = {
+ 'status_code': [200],
+ 'response_body': {
+ 'type': 'object',
+ 'properties': {
+ 'floating_ip': {
+ 'type': 'object',
+ 'properties': {
+ # NOTE: Now the type of 'id' is integer, but here allows
+ # 'string' also because we will be able to change it to
+ # 'uuid' in the future.
+ 'id': {'type': ['integer', 'string']},
+ 'pool': {'type': ['string', 'null']},
+ 'instance_id': {'type': ['integer', 'string', 'null']},
+ 'ip': {
+ 'type': 'string',
+ 'format': 'ip-address'
+ },
+ 'fixed_ip': {
+ 'type': ['string', 'null'],
+ 'format': 'ip-address'
+ }
+ },
+ 'required': ['id', 'pool', 'instance_id', 'ip', 'fixed_ip']
+ }
+ },
+ 'required': ['floating_ip']
+ }
+}
diff --git a/tempest/services/compute/json/floating_ips_client.py b/tempest/services/compute/json/floating_ips_client.py
index 2a7e25a..273ada6 100644
--- a/tempest/services/compute/json/floating_ips_client.py
+++ b/tempest/services/compute/json/floating_ips_client.py
@@ -47,6 +47,7 @@
body = json.loads(body)
if resp.status == 404:
raise exceptions.NotFound(body)
+ self.validate_response(schema.floating_ip, resp, body)
return resp, body['floating_ip']
def create_floating_ip(self, pool_name=None):
@@ -56,6 +57,7 @@
post_body = json.dumps(post_body)
resp, body = self.post(url, post_body)
body = json.loads(body)
+ self.validate_response(schema.floating_ip, resp, body)
return resp, body['floating_ip']
def delete_floating_ip(self, floating_ip_id):