Check create/get/delete V2 server_group attributes
This patch adds the JSON schema for Nova V2 create, get & delete
server_group 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 server_group V2 APIs is same and given
below:
{
"server_group": {
"id": "5bbcc3c4-1da2-4437-a48a-66f15b1b13f9",
"name": "test",
"policies": ["anti-affinity"],
"members": [],
"metadata": {}
}
}
Delete server_group API only return 204 response code.
Partially implements blueprint nova-api-attribute-test
Change-Id: I0447292553394877493fc264451559d9df14242f
diff --git a/tempest/api_schema/compute/v2/servers.py b/tempest/api_schema/compute/v2/servers.py
index 981d8f7..f7ed94e 100644
--- a/tempest/api_schema/compute/v2/servers.py
+++ b/tempest/api_schema/compute/v2/servers.py
@@ -142,3 +142,38 @@
'required': ['addresses']
}
}
+
+common_server_group = {
+ 'type': 'object',
+ 'properties': {
+ 'id': {'type': 'string'},
+ 'name': {'type': 'string'},
+ 'policies': {
+ 'type': 'array',
+ 'items': {'type': 'string'}
+ },
+ # 'members' attribute contains the array of instance's UUID of
+ # instances present in server group
+ 'members': {
+ 'type': 'array',
+ 'items': {'type': 'string'}
+ },
+ 'metadata': {'type': 'object'}
+ },
+ 'required': ['id', 'name', 'policies', 'members', 'metadata']
+}
+
+create_get_server_group = {
+ 'status_code': [200],
+ 'response_body': {
+ 'type': 'object',
+ 'properties': {
+ 'server_group': common_server_group
+ },
+ 'required': ['server_group']
+ }
+}
+
+delete_server_group = {
+ 'status_code': [204]
+}
diff --git a/tempest/services/compute/json/servers_client.py b/tempest/services/compute/json/servers_client.py
index 70123fe..0f91a6e 100644
--- a/tempest/services/compute/json/servers_client.py
+++ b/tempest/services/compute/json/servers_client.py
@@ -506,11 +506,14 @@
resp, body = self.post('os-server-groups', post_body)
body = json.loads(body)
+ self.validate_response(schema.create_get_server_group, resp, body)
return resp, body['server_group']
def delete_server_group(self, server_group_id):
"""Delete the given server-group."""
- return self.delete("os-server-groups/%s" % str(server_group_id))
+ resp, body = self.delete("os-server-groups/%s" % str(server_group_id))
+ self.validate_response(schema.delete_server_group, resp, body)
+ return resp, body
def list_server_groups(self):
"""List the server-groups."""
@@ -522,4 +525,5 @@
"""Get the details of given server_group."""
resp, body = self.get("os-server-groups/%s" % str(server_group_id))
body = json.loads(body)
+ self.validate_response(schema.create_get_server_group, resp, body)
return resp, body['server_group']