Merge "Add tag in compute interfaces schema for microversion 2.70"

This commit is contained in:
Zuul 2020-12-04 07:19:23 +00:00 committed by Gerrit Code Review
commit 32e71b0620
3 changed files with 76 additions and 0 deletions

View File

@ -427,3 +427,33 @@ class AttachInterfacesUnderV243Test(AttachInterfacesTestBase):
CONF.compute.build_interval, original_ip_count):
raise lib_exc.TimeoutException(
'Timed out while waiting for IP count to decrease.')
class AttachInterfacesV270Test(AttachInterfacesTestBase):
"""Test interface API with microversion greater than 2.69"""
min_microversion = '2.70'
@decorators.idempotent_id('2853f095-8277-4067-92bd-9f10bd4f8e0c')
@utils.services('network')
def test_create_get_list_interfaces(self):
"""Test interface API with microversion greater than 2.69
Checking create, get, list interface APIs response schema.
"""
server = self.create_test_server(wait_until='ACTIVE')
try:
iface = self.interfaces_client.create_interface(server['id'])[
'interfaceAttachment']
iface = waiters.wait_for_interface_status(
self.interfaces_client, server['id'], iface['port_id'],
'ACTIVE')
except lib_exc.BadRequest as e:
msg = ('Multiple possible networks found, use a Network ID to be '
'more specific.')
if not CONF.compute.fixed_network_name and six.text_type(e) == msg:
raise
else:
# just to check the response schema
self.interfaces_client.show_interface(
server['id'], iface['port_id'])
self.interfaces_client.list_interfaces(server['id'])

View File

@ -0,0 +1,37 @@
# 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.
import copy
from tempest.lib.api_schema.response.compute.v2_1 import interfaces
# ****** Schemas changed in microversion 2.70 *****************
#
# 1. add optional field 'tag' in the Response body of the following APIs:
# - GET /servers/{server_id}/os-interface
# - POST /servers/{server_id}/os-interface
# - GET /servers/{server_id}/os-interface/{port_id}
get_create_interfaces = copy.deepcopy(interfaces.get_create_interfaces)
get_create_interfaces['response_body']['properties']['interfaceAttachment'][
'properties'].update({'tag': {'type': ['string', 'null']}})
list_interfaces = copy.deepcopy(interfaces.list_interfaces)
list_interfaces['response_body']['properties']['interfaceAttachments'][
'items']['properties'].update({'tag': {'type': ['string', 'null']}})
# 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 ***
delete_interface = copy.deepcopy(interfaces.delete_interface)

View File

@ -16,15 +16,22 @@
from oslo_serialization import jsonutils as json
from tempest.lib.api_schema.response.compute.v2_1 import interfaces as schema
from tempest.lib.api_schema.response.compute.v2_70 import interfaces as \
schemav270
from tempest.lib.common import rest_client
from tempest.lib.services.compute import base_compute_client
class InterfacesClient(base_compute_client.BaseComputeClient):
schema_versions_info = [
{'min': None, 'max': '2.69', 'schema': schema},
{'min': '2.70', 'max': None, 'schema': schemav270}]
def list_interfaces(self, server_id):
resp, body = self.get('servers/%s/os-interface' % server_id)
body = json.loads(body)
schema = self.get_schema(self.schema_versions_info)
self.validate_response(schema.list_interfaces, resp, body)
return rest_client.ResponseBody(resp, body)
@ -40,6 +47,7 @@ class InterfacesClient(base_compute_client.BaseComputeClient):
resp, body = self.post('servers/%s/os-interface' % server_id,
body=post_body)
body = json.loads(body)
schema = self.get_schema(self.schema_versions_info)
self.validate_response(schema.get_create_interfaces, resp, body)
return rest_client.ResponseBody(resp, body)
@ -47,6 +55,7 @@ class InterfacesClient(base_compute_client.BaseComputeClient):
resp, body = self.get('servers/%s/os-interface/%s' % (server_id,
port_id))
body = json.loads(body)
schema = self.get_schema(self.schema_versions_info)
self.validate_response(schema.get_create_interfaces, resp, body)
return rest_client.ResponseBody(resp, body)