Verify the response attributes of 'list_aggregates'
This patch verifies the response attributes of list_aggregates.
The response body of v2 and v3 API has the same format:
"aggregates": [
{
"availability_zone": "nova",
"created_at": "2012-11-16T06:22:23.361359",
"deleted": false,
"deleted_at": null,
"hosts": [],
"id": 1,
"metadata": {
"availability_zone": "nova"
},
"name": "name",
"updated_at": null
}
]
Partially implements blueprint nova-api-attribute-test
Change-Id: If4c09929f3e9d3fd743aad2b727a74834fdbf8fd
diff --git a/tempest/api_schema/compute/aggregates.py b/tempest/api_schema/compute/aggregates.py
new file mode 100644
index 0000000..49793fe
--- /dev/null
+++ b/tempest/api_schema/compute/aggregates.py
@@ -0,0 +1,43 @@
+# Copyright 2014 NEC Corporation. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+list_aggregates = {
+ 'status_code': [200],
+ 'response_body': {
+ 'type': 'object',
+ 'properties': {
+ 'aggregates': {
+ 'type': 'array',
+ 'items': {
+ 'type': 'object',
+ 'properties': {
+ 'availability_zone': {'type': ['string', 'null']},
+ 'created_at': {'type': 'string'},
+ 'deleted': {'type': 'boolean'},
+ 'deleted_at': {'type': ['string', 'null']},
+ 'hosts': {'type': 'array'},
+ 'id': {'type': 'integer'},
+ 'metadata': {'type': 'object'},
+ 'name': {'type': 'string'},
+ 'updated_at': {'type': ['string', 'null']}
+ },
+ 'required': ['availability_zone', 'created_at', 'deleted',
+ 'deleted_at', 'hosts', 'id', 'metadata',
+ 'name', 'updated_at']
+ }
+ }
+ },
+ 'required': ['aggregates']
+ }
+}
diff --git a/tempest/services/compute/json/aggregates_client.py b/tempest/services/compute/json/aggregates_client.py
index 700a29b..ccb85c4 100644
--- a/tempest/services/compute/json/aggregates_client.py
+++ b/tempest/services/compute/json/aggregates_client.py
@@ -15,6 +15,7 @@
import json
+from tempest.api_schema.compute import aggregates as schema
from tempest.common import rest_client
from tempest import config
from tempest import exceptions
@@ -32,6 +33,7 @@
"""Get aggregate list."""
resp, body = self.get("os-aggregates")
body = json.loads(body)
+ self.validate_response(schema.list_aggregates, resp, body)
return resp, body['aggregates']
def get_aggregate(self, aggregate_id):
diff --git a/tempest/services/compute/v3/json/aggregates_client.py b/tempest/services/compute/v3/json/aggregates_client.py
index fddf5df..7f73622 100644
--- a/tempest/services/compute/v3/json/aggregates_client.py
+++ b/tempest/services/compute/v3/json/aggregates_client.py
@@ -15,6 +15,7 @@
import json
+from tempest.api_schema.compute import aggregates as schema
from tempest.common import rest_client
from tempest import config
from tempest import exceptions
@@ -32,6 +33,7 @@
"""Get aggregate list."""
resp, body = self.get("os-aggregates")
body = json.loads(body)
+ self.validate_response(schema.list_aggregates, resp, body)
return resp, body['aggregates']
def get_aggregate(self, aggregate_id):