Merge "Change schema hypervisor.cpu_info from string to object in 2.28"

This commit is contained in:
Zuul 2018-08-20 15:19:27 +00:00 committed by Gerrit Code Review
commit 114214cab6
5 changed files with 71 additions and 1 deletions

View File

@ -334,6 +334,10 @@ Microversion tests implemented in Tempest
.. _2.26: https://docs.openstack.org/nova/latest/reference/api-microversion-history.html#id23
* `2.28`_
.. _2.28: https://docs.openstack.org/nova/latest/reference/api-microversion-history.html#id25
* `2.32`_
.. _2.32: https://docs.openstack.org/nova/latest/reference/api-microversion-history.html#id29

View File

@ -104,6 +104,19 @@ class HypervisorAdminTestJSON(HypervisorAdminTestBase):
"None of the hypervisors had a valid uptime: %s" % hypers)
class HypervisorAdminV228Test(HypervisorAdminTestBase):
min_microversion = '2.28'
@decorators.idempotent_id('d46bab64-0fbe-4eb8-9133-e6ee56188cc5')
def test_get_list_hypervisor_details(self):
# NOTE(zhufl): This test tests the hypervisor APIs response schema
# for 2.28 microversion. No specific assert or behaviour verification
# is needed.
hypers = self._list_hypervisors()
self.assertNotEmpty(hypers, "No hypervisors found.")
self.client.show_hypervisor(hypers[0]['id'])
class HypervisorAdminUnderV252Test(HypervisorAdminTestBase):
max_microversion = '2.52'

View File

@ -0,0 +1,40 @@
# Copyright 2018 ZTE 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.
import copy
from tempest.lib.api_schema.response.compute.v2_1 \
import hypervisors as hypervisorsv21
# hypervisor.cpu_info change from string to JSON object.
hypervisor_detail = copy.deepcopy(hypervisorsv21.hypervisor_detail)
hypervisor_detail['properties'].update({'cpu_info': {'type': 'object'}})
list_hypervisors_detail = copy.deepcopy(hypervisorsv21.list_hypervisors_detail)
list_hypervisors_detail['response_body']['properties']['hypervisors'].update(
{'items': hypervisor_detail})
get_hypervisor = copy.deepcopy(hypervisorsv21.get_hypervisor)
get_hypervisor['response_body']['properties'].update(
{'hypervisor': hypervisor_detail})
# NOTE(zhufl): Below are the unchanged schema in this microversion. We need
# to keep this schema in this file to have the generic way to select the
# right schema based on self.schema_versions_info mapping in service client.
# ****** Schemas unchanged since microversion 2.1 ***
get_hypervisor_statistics = \
copy.deepcopy(hypervisorsv21.get_hypervisor_statistics)
list_search_hypervisors = copy.deepcopy(hypervisorsv21.list_search_hypervisors)
get_hypervisor_uptime = copy.deepcopy(hypervisorsv21.get_hypervisor_uptime)
get_hypervisors_servers = copy.deepcopy(hypervisorsv21.get_hypervisors_servers)

View File

@ -15,16 +15,24 @@
from oslo_serialization import jsonutils as json
from tempest.lib.api_schema.response.compute.v2_1 import hypervisors as schema
from tempest.lib.api_schema.response.compute.v2_1 \
import hypervisors as schemav21
from tempest.lib.api_schema.response.compute.v2_28 \
import hypervisors as schemav228
from tempest.lib.common import rest_client
from tempest.lib.services.compute import base_compute_client
class HypervisorClient(base_compute_client.BaseComputeClient):
schema_versions_info = [
{'min': None, 'max': '2.27', 'schema': schemav21},
{'min': '2.28', 'max': None, 'schema': schemav228}]
def list_hypervisors(self, detail=False):
"""List hypervisors information."""
url = 'os-hypervisors'
schema = self.get_schema(self.schema_versions_info)
_schema = schema.list_search_hypervisors
if detail:
url += '/detail'
@ -39,6 +47,7 @@ class HypervisorClient(base_compute_client.BaseComputeClient):
"""Display the details of the specified hypervisor."""
resp, body = self.get('os-hypervisors/%s' % hypervisor_id)
body = json.loads(body)
schema = self.get_schema(self.schema_versions_info)
self.validate_response(schema.get_hypervisor, resp, body)
return rest_client.ResponseBody(resp, body)
@ -46,6 +55,7 @@ class HypervisorClient(base_compute_client.BaseComputeClient):
"""List instances belonging to the specified hypervisor."""
resp, body = self.get('os-hypervisors/%s/servers' % hypervisor_name)
body = json.loads(body)
schema = self.get_schema(self.schema_versions_info)
self.validate_response(schema.get_hypervisors_servers, resp, body)
return rest_client.ResponseBody(resp, body)
@ -53,6 +63,7 @@ class HypervisorClient(base_compute_client.BaseComputeClient):
"""Get hypervisor statistics over all compute nodes."""
resp, body = self.get('os-hypervisors/statistics')
body = json.loads(body)
schema = self.get_schema(self.schema_versions_info)
self.validate_response(schema.get_hypervisor_statistics, resp, body)
return rest_client.ResponseBody(resp, body)
@ -60,6 +71,7 @@ class HypervisorClient(base_compute_client.BaseComputeClient):
"""Display the uptime of the specified hypervisor."""
resp, body = self.get('os-hypervisors/%s/uptime' % hypervisor_id)
body = json.loads(body)
schema = self.get_schema(self.schema_versions_info)
self.validate_response(schema.get_hypervisor_uptime, resp, body)
return rest_client.ResponseBody(resp, body)
@ -69,5 +81,6 @@ class HypervisorClient(base_compute_client.BaseComputeClient):
"""Search specified hypervisor."""
resp, body = self.get('os-hypervisors/%s/search' % hypervisor_name)
body = json.loads(body)
schema = self.get_schema(self.schema_versions_info)
self.validate_response(schema.list_search_hypervisors, resp, body)
return rest_client.ResponseBody(resp, body)