Verify the response attributes of 'list_hosts'
This patch verifies the response attributes of list_hosts.
The response body of v2 and v3 API are in the same format:
"hosts": [
{
"host_name": "b6e4adbc193d428ea923899d07fb001e",
"service": "conductor",
"zone": "internal"
}
]
Partially implements blueprint nova-api-attribute-test
Change-Id: Ia26d14e6fcec0e8f76224669ebde57ff8840605c
diff --git a/tempest/api_schema/compute/hosts.py b/tempest/api_schema/compute/hosts.py
new file mode 100644
index 0000000..b9a3db9
--- /dev/null
+++ b/tempest/api_schema/compute/hosts.py
@@ -0,0 +1,35 @@
+# 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_hosts = {
+ 'status_code': [200],
+ 'response_body': {
+ 'type': 'object',
+ 'properties': {
+ 'hosts': {
+ 'type': 'array',
+ 'items': {
+ 'type': 'object',
+ 'properties': {
+ 'host_name': {'type': 'string'},
+ 'service': {'type': 'string'},
+ 'zone': {'type': 'string'}
+ },
+ 'required': ['host_name', 'service', 'zone']
+ }
+ }
+ },
+ 'required': ['hosts']
+ }
+}
diff --git a/tempest/services/compute/json/hosts_client.py b/tempest/services/compute/json/hosts_client.py
index fb45997..0130f27 100644
--- a/tempest/services/compute/json/hosts_client.py
+++ b/tempest/services/compute/json/hosts_client.py
@@ -15,6 +15,7 @@
import json
import urllib
+from tempest.api_schema.compute import hosts as schema
from tempest.common import rest_client
from tempest import config
@@ -36,6 +37,7 @@
resp, body = self.get(url)
body = json.loads(body)
+ self.validate_response(schema.list_hosts, resp, body)
return resp, body['hosts']
def show_host_detail(self, hostname):
diff --git a/tempest/services/compute/v3/json/hosts_client.py b/tempest/services/compute/v3/json/hosts_client.py
index e27c7c6..bcb9d36 100644
--- a/tempest/services/compute/v3/json/hosts_client.py
+++ b/tempest/services/compute/v3/json/hosts_client.py
@@ -15,6 +15,7 @@
import json
import urllib
+from tempest.api_schema.compute import hosts as schema
from tempest.common import rest_client
from tempest import config
@@ -36,6 +37,7 @@
resp, body = self.get(url)
body = json.loads(body)
+ self.validate_response(schema.list_hosts, resp, body)
return resp, body['hosts']
def show_host_detail(self, hostname):