Verify server list_addresses V2/V3 APIs attributes
This patch adds the JSON schema for Nova V2 & V3 server list_addresses
APIs response and validate the response with added
JSON schema to block the backward incompatibility change in the future.
The response body of server list_addresses V2 API is below:
{
"addresses": {
"private": [
{
"version": 4,
"addr": "192.168.0.3"
}
]
}
}
The response body of server list_addresses V3 API is below:
{
"addresses": {
"private": [
{
"version": 4,
"addr": "192.168.0.3",
"type": "fixed",
"mac_addr": "aa:bb:cc:dd:ee:ff"
}
]
}
}
Partially implements blueprint nova-api-attribute-test
Change-Id: I21392dfb8141d0cf98bf2dcbcb3fd49e75f9cbd8
diff --git a/tempest/api_schema/compute/v2/servers.py b/tempest/api_schema/compute/v2/servers.py
index 3da3276..981d8f7 100644
--- a/tempest/api_schema/compute/v2/servers.py
+++ b/tempest/api_schema/compute/v2/servers.py
@@ -131,3 +131,14 @@
server_actions_confirm_resize = copy.deepcopy(
servers.server_actions_delete_password)
+
+list_addresses = {
+ 'status_code': [200],
+ 'response_body': {
+ 'type': 'object',
+ 'properties': {
+ 'addresses': parameter_types.addresses
+ },
+ 'required': ['addresses']
+ }
+}
diff --git a/tempest/api_schema/compute/v3/servers.py b/tempest/api_schema/compute/v3/servers.py
index 8f694f7..682021f 100644
--- a/tempest/api_schema/compute/v3/servers.py
+++ b/tempest/api_schema/compute/v3/servers.py
@@ -84,3 +84,14 @@
server_actions_change_password = copy.deepcopy(
servers.server_actions_delete_password)
+
+list_addresses = {
+ 'status_code': [200],
+ 'response_body': {
+ 'type': 'object',
+ 'properties': {
+ 'addresses': addresses_v3
+ },
+ 'required': ['addresses']
+ }
+}
diff --git a/tempest/services/compute/json/servers_client.py b/tempest/services/compute/json/servers_client.py
index 9c7eec6..c266d15 100644
--- a/tempest/services/compute/json/servers_client.py
+++ b/tempest/services/compute/json/servers_client.py
@@ -193,6 +193,7 @@
"""Lists all addresses for a server."""
resp, body = self.get("servers/%s/ips" % str(server_id))
body = json.loads(body)
+ self.validate_response(schema.list_addresses, resp, body)
return resp, body['addresses']
def list_addresses_by_network(self, server_id, network_id):
diff --git a/tempest/services/compute/v3/json/servers_client.py b/tempest/services/compute/v3/json/servers_client.py
index caa0a1d..004e149 100644
--- a/tempest/services/compute/v3/json/servers_client.py
+++ b/tempest/services/compute/v3/json/servers_client.py
@@ -193,6 +193,7 @@
"""Lists all addresses for a server."""
resp, body = self.get("servers/%s/ips" % str(server_id))
body = json.loads(body)
+ self.validate_response(schema.list_addresses, resp, body)
return resp, body['addresses']
def list_addresses_by_network(self, server_id, network_id):