Add compute microversion 2.54 schema in servers_client

Compute microversion 2.54 adds 'key_name' in rebuild servers
APIs response.
This commit fill the schema gap for that.

Change-Id: I6c46319a873a34d74e8ed1a32ffc0b32c4d04ab2
This commit is contained in:
ghanshyam 2018-04-24 11:09:25 +03:00 committed by Ken'ichi Ohmichi
parent e4f4d8bee1
commit 85a4b0a314
5 changed files with 107 additions and 1 deletions

View File

@ -354,6 +354,10 @@ Microversion tests implemented in Tempest
.. _2.48: https://docs.openstack.org/nova/latest/reference/api-microversion-history.html#id43
* `2.54`_
.. _2.54: https://docs.openstack.org/nova/latest/reference/api-microversion-history.html#id4
* `2.55`_
.. _2.55: https://docs.openstack.org/nova/latest/reference/api-microversion-history.html#id49

View File

@ -0,0 +1,51 @@
# Copyright 2018 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.
from tempest.api.compute import base
from tempest.common import waiters
from tempest.lib.common.utils import data_utils
from tempest.lib import decorators
# NOTE(gmann): This file is to write the tests which mainly
# tests newly added microversion schema related to servers APIs.
# As per (https://docs.openstack.org/tempest/latest/microversion_testing.
# html#tempest-scope-for-microversion-testing),
# we need to fill the API response schema gaps which gets modified
# during microversion change. To cover the testing of such schema
# we need to have operation schema test which just test
# the microversion schemas.
# If you are adding server APIs microversion schema file without
# their integration tests, you can add tests to cover those schema
# in this file.
class ServerShowV254Test(base.BaseV2ComputeTest):
min_microversion = '2.54'
max_microversion = 'latest'
@decorators.idempotent_id('09170a98-4940-4637-add7-1a35121f1a5a')
def test_rebuild_server(self):
server = self.create_test_server(wait_until='ACTIVE')
keypair_name = data_utils.rand_name(
self.__class__.__name__ + '-keypair')
kwargs = {'name': keypair_name}
self.keypairs_client.create_keypair(**kwargs)
self.addCleanup(self.keypairs_client.delete_keypair,
keypair_name)
# Checking rebuild API response schema
self.servers_client.rebuild_server(server['id'], self.image_ref_alt,
key_name=keypair_name)
waiters.wait_for_server_status(self.servers_client,
server['id'], 'ACTIVE')

View File

@ -0,0 +1,49 @@
# 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_47 import servers as servers247
# ****** Schemas changed in microversion 2.54 *****************
# Note(gmann): This is schema for microversion 2.54 which includes the
# 'key_name' in the Response body of the following APIs:
# - ``POST '/servers/{server_id}/action (rebuild)``
key_name = {
'oneOf': [
{'type': 'string', 'minLength': 1, 'maxLength': 255},
{'type': 'null'},
]
}
rebuild_server = copy.deepcopy(servers247.rebuild_server)
rebuild_server['response_body']['properties']['server'][
'properties'].update({'key_name': key_name})
rebuild_server['response_body']['properties']['server'][
'required'].append('key_name')
rebuild_server_with_admin_pass = copy.deepcopy(
servers247.rebuild_server_with_admin_pass)
rebuild_server_with_admin_pass['response_body']['properties']['server'][
'properties'].update({'key_name': key_name})
rebuild_server_with_admin_pass['response_body']['properties']['server'][
'required'].append('key_name')
# ****** Schemas unchanged in microversion 2.54 since microversion 2.47 ***
# NOTE(gmann): 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.
get_server = copy.deepcopy(servers247.get_server)
list_servers_detail = copy.deepcopy(servers247.list_servers_detail)
update_server = copy.deepcopy(servers247.update_server)

View File

@ -29,6 +29,7 @@ from tempest.lib.api_schema.response.compute.v2_26 import servers as schemav226
from tempest.lib.api_schema.response.compute.v2_3 import servers as schemav23
from tempest.lib.api_schema.response.compute.v2_47 import servers as schemav247
from tempest.lib.api_schema.response.compute.v2_48 import servers as schemav248
from tempest.lib.api_schema.response.compute.v2_54 import servers as schemav254
from tempest.lib.api_schema.response.compute.v2_6 import servers as schemav26
from tempest.lib.api_schema.response.compute.v2_9 import servers as schemav29
from tempest.lib.common import rest_client
@ -47,7 +48,8 @@ class ServersClient(base_compute_client.BaseComputeClient):
{'min': '2.19', 'max': '2.25', 'schema': schemav219},
{'min': '2.26', 'max': '2.46', 'schema': schemav226},
{'min': '2.47', 'max': '2.47', 'schema': schemav247},
{'min': '2.48', 'max': None, 'schema': schemav248}]
{'min': '2.48', 'max': '2.53', 'schema': schemav248},
{'min': '2.54', 'max': None, 'schema': schemav254}]
def __init__(self, auth_provider, service, region,
enable_instance_password=True, **kwargs):