Merge "Verify list agents attributes of V2/V3 APIs"

This commit is contained in:
Jenkins
2014-04-25 03:18:31 +00:00
committed by Gerrit Code Review
3 changed files with 48 additions and 2 deletions

View File

@@ -0,0 +1,40 @@
# 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_agents = {
'status_code': [200],
'response_body': {
'type': 'object',
'properties': {
'agents': {
'type': 'array',
'items': {
'type': 'object',
'properties': {
'agent_id': {'type': ['integer', 'string']},
'hypervisor': {'type': 'string'},
'os': {'type': 'string'},
'architecture': {'type': 'string'},
'version': {'type': 'string'},
'url': {'type': 'string', 'format': 'uri'},
'md5hash': {'type': 'string'}
},
'required': ['agent_id', 'hypervisor', 'os',
'architecture', 'version', 'url', 'md5hash']
}
}
},
'required': ['agents']
}
}

View File

@@ -15,6 +15,7 @@
import json
import urllib
from tempest.api_schema.compute import agents as common_schema
from tempest.api_schema.compute.v2 import agents as schema
from tempest.common import rest_client
from tempest import config
@@ -37,7 +38,9 @@ class AgentsClientJSON(rest_client.RestClient):
if params:
url += '?%s' % urllib.urlencode(params)
resp, body = self.get(url)
return resp, json.loads(body).get('agents')
body = json.loads(body)
self.validate_response(common_schema.list_agents, resp, body)
return resp, body['agents']
def create_agent(self, **kwargs):
"""Create an agent build."""

View File

@@ -15,6 +15,7 @@
import json
import urllib
from tempest.api_schema.compute import agents as common_schema
from tempest.api_schema.compute.v3 import agents as schema
from tempest.common import rest_client
from tempest import config
@@ -34,7 +35,9 @@ class AgentsV3ClientJSON(rest_client.RestClient):
if params:
url += '?%s' % urllib.urlencode(params)
resp, body = self.get(url)
return resp, self._parse_resp(body)
body = json.loads(body)
self.validate_response(common_schema.list_agents, resp, body)
return resp, body['agents']
def create_agent(self, **kwargs):
"""Create an agent build."""