Check attach-detach FIP & get FIP pool attributes
This patch adds the JSON schema for get Floating IPs pools
and attach & detach Floating IP APIs response and validate
the response with added JSON schema to block the backward
incompatibility change in the future.
attch, detach & delete Floating IPs does not return any
response body. So only response code is being validated.
The response body of get Floating IP pools API is below:
{
"floating_ip_pools": [
{
"name": "pool1"
}
]
}
Partially implements blueprint nova-api-attribute-test
Change-Id: I540b6c72fdcb6b568adbef72f5b2423a038bac7a
diff --git a/tempest/api_schema/compute/v2/floating_ips.py b/tempest/api_schema/compute/v2/floating_ips.py
index 648d0bf..3ea6320 100644
--- a/tempest/api_schema/compute/v2/floating_ips.py
+++ b/tempest/api_schema/compute/v2/floating_ips.py
@@ -74,3 +74,27 @@
'required': ['floating_ip']
}
}
+
+floating_ip_pools = {
+ 'status_code': [200],
+ 'response_body': {
+ 'type': 'object',
+ 'properties': {
+ 'floating_ip_pools': {
+ 'type': 'array',
+ 'items': {
+ 'type': 'object',
+ 'properties': {
+ 'name': {'type': 'string'}
+ },
+ 'required': ['name']
+ }
+ }
+ },
+ 'required': ['floating_ip_pools']
+ }
+}
+
+add_remove_floating_ip = {
+ 'status_code': [202]
+}
diff --git a/tempest/services/compute/json/floating_ips_client.py b/tempest/services/compute/json/floating_ips_client.py
index 273ada6..e2e12d5 100644
--- a/tempest/services/compute/json/floating_ips_client.py
+++ b/tempest/services/compute/json/floating_ips_client.py
@@ -64,6 +64,7 @@
"""Deletes the provided floating IP from the project."""
url = "os-floating-ips/%s" % str(floating_ip_id)
resp, body = self.delete(url)
+ self.validate_response(schema.add_remove_floating_ip, resp, body)
return resp, body
def associate_floating_ip_to_server(self, floating_ip, server_id):
@@ -77,6 +78,7 @@
post_body = json.dumps(post_body)
resp, body = self.post(url, post_body)
+ self.validate_response(schema.add_remove_floating_ip, resp, body)
return resp, body
def disassociate_floating_ip_from_server(self, floating_ip, server_id):
@@ -90,6 +92,7 @@
post_body = json.dumps(post_body)
resp, body = self.post(url, post_body)
+ self.validate_response(schema.add_remove_floating_ip, resp, body)
return resp, body
def is_resource_deleted(self, id):
@@ -107,4 +110,5 @@
resp, body = self.get(url)
body = json.loads(body)
+ self.validate_response(schema.floating_ip_pools, resp, body)
return resp, body['floating_ip_pools']