Add compute tests for microversion 2.100
Compute's new API microversion 2.100 now returns server's
associated scheduler_hints information in both
``GET /servers/{server_id}``, ``GET /servers/detail``,
``PUT /servers/{server_id}`` and ``POST /server/{server_id}/action``
(rebuild) responses.
Depends-On: https://review.opendev.org/c/openstack/nova/+/938604
Change-Id: I91038e3f6801e7f47106f0b320b71cd0cfef6d7c
diff --git a/doc/source/microversion_testing.rst b/doc/source/microversion_testing.rst
index 9701cbc..e58753b 100644
--- a/doc/source/microversion_testing.rst
+++ b/doc/source/microversion_testing.rst
@@ -462,6 +462,10 @@
.. _2.98: https://docs.openstack.org/nova/latest/reference/api-microversion-history.html#microversion-2-98
+ * `2.100`_
+
+ .. _2.100: https://docs.openstack.org/nova/latest/reference/api-microversion-history.html#microversion-2-100
+
* Volume
* `3.3`_
diff --git a/tempest/api/compute/servers/test_servers.py b/tempest/api/compute/servers/test_servers.py
index 76cf01d..ea3a710 100644
--- a/tempest/api/compute/servers/test_servers.py
+++ b/tempest/api/compute/servers/test_servers.py
@@ -309,3 +309,30 @@
self.servers_client.rebuild_server(server['id'], self.image_ref_alt)
waiters.wait_for_server_status(self.servers_client,
server['id'], 'ACTIVE')
+
+
+class ServersListShow2100Test(base.BaseV2ComputeTest):
+ """Test compute server with microversion >= than 2.100
+
+ This test tests the Server APIs response schema for 2.100 microversion.
+ No specific assert or behaviour verification is needed.
+ """
+
+ min_microversion = '2.100'
+ max_microversion = 'latest'
+
+ @decorators.idempotent_id('2c3a8270-e6f7-4400-af0f-db003c117e48')
+ def test_list_show_rebuild_update_server_2100(self):
+ server = self.create_test_server(wait_until='ACTIVE')
+ # Checking list API response schema.
+ self.servers_client.list_servers(detail=True)
+ # Checking show API response schema
+ self.servers_client.show_server(server['id'])
+ # Checking update API response schema
+ self.servers_client.update_server(server['id'])
+ waiters.wait_for_server_status(self.servers_client,
+ server['id'], 'ACTIVE')
+ # Check rebuild API response schema
+ self.servers_client.rebuild_server(server['id'], self.image_ref_alt)
+ waiters.wait_for_server_status(self.servers_client,
+ server['id'], 'ACTIVE')
diff --git a/tempest/lib/api_schema/response/compute/v2_1/parameter_types.py b/tempest/lib/api_schema/response/compute/v2_1/parameter_types.py
index b36c9d6..d5c9b95 100644
--- a/tempest/lib/api_schema/response/compute/v2_1/parameter_types.py
+++ b/tempest/lib/api_schema/response/compute/v2_1/parameter_types.py
@@ -127,3 +127,16 @@
{'type': 'null'}
]
}
+
+server_id = {
+ 'type': 'string', 'format': 'uuid'
+}
+
+name = {
+ # NOTE: Nova v2.1 API contains some 'name' parameters such
+ # as server, flavor, aggregate and so on. They are
+ # stored in the DB and Nova specific parameters.
+ # This definition is used for all their parameters.
+ 'type': 'string', 'minLength': 1, 'maxLength': 255,
+ 'format': 'name'
+}
diff --git a/tempest/lib/api_schema/response/compute/v2_100/__init__.py b/tempest/lib/api_schema/response/compute/v2_100/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/lib/api_schema/response/compute/v2_100/__init__.py
diff --git a/tempest/lib/api_schema/response/compute/v2_100/servers.py b/tempest/lib/api_schema/response/compute/v2_100/servers.py
new file mode 100644
index 0000000..8721387
--- /dev/null
+++ b/tempest/lib/api_schema/response/compute/v2_100/servers.py
@@ -0,0 +1,129 @@
+# 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 parameter_types
+from tempest.lib.api_schema.response.compute.v2_99 import servers as servers299
+
+###########################################################################
+#
+# 2.100:
+#
+# The scheduler_hints parameter is now returned in the response body
+# of the following calls:
+# - GET /servers/detail
+# - GET /servers/{server_id}
+# - POST /server/{server_id}/action (rebuild)
+# - PUT /servers/{server_id}
+#
+###########################################################################
+
+_hints = {
+ 'type': 'object',
+ 'properties': {
+ 'group': {
+ 'type': 'string',
+ 'format': 'uuid'
+ },
+ 'different_host': {
+ # NOTE: The value of 'different_host' is the set of server
+ # uuids where a new server is scheduled on a different host.
+ # A user can specify one server as string parameter and should
+ # specify multiple servers as array parameter instead.
+ 'oneOf': [
+ {
+ 'type': 'string',
+ 'format': 'uuid'
+ },
+ {
+ 'type': 'array',
+ 'items': parameter_types.server_id
+ }
+ ]
+ },
+ 'same_host': {
+ # NOTE: The value of 'same_host' is the set of server
+ # uuids where a new server is scheduled on the same host.
+ 'type': ['string', 'array'],
+ 'items': parameter_types.server_id
+ },
+ 'query': {
+ # NOTE: The value of 'query' is converted to dict data with
+ # jsonutils.loads() and used for filtering hosts.
+ 'type': ['string', 'object'],
+ },
+ # NOTE: The value of 'target_cell' is the cell name what cell
+ # a new server is scheduled on.
+ 'target_cell': parameter_types.name,
+ 'different_cell': {
+ 'type': ['string', 'array'],
+ 'items': {
+ 'type': 'string'
+ }
+ },
+ 'build_near_host_ip': parameter_types.ip_address,
+ 'cidr': {
+ 'type': 'string',
+ 'pattern': '^/[0-9a-f.:]+$'
+ },
+ },
+ # NOTE: As this Mail:
+ # http://lists.openstack.org/pipermail/openstack-dev/2015-June/067996.html
+ # pointed out the limit the scheduler-hints in the API is problematic. So
+ # relax it.
+ 'additionalProperties': True
+}
+
+get_server = copy.deepcopy(servers299.get_server)
+get_server['response_body']['properties']['server'][
+ 'properties'].update({'scheduler_hints': _hints})
+get_server['response_body']['properties']['server'][
+ 'required'].append('scheduler_hints')
+
+list_servers_detail = copy.deepcopy(servers299.list_servers_detail)
+list_servers_detail['response_body']['properties']['servers']['items'][
+ 'properties'].update({'scheduler_hints': _hints})
+list_servers_detail['response_body']['properties']['servers']['items'][
+ 'required'].append('scheduler_hints')
+
+rebuild_server = copy.deepcopy(servers299.rebuild_server)
+rebuild_server['response_body']['properties']['server'][
+ 'properties'].update({'scheduler_hints': _hints})
+rebuild_server['response_body']['properties']['server'][
+ 'required'].append('scheduler_hints')
+
+rebuild_server_with_admin_pass = copy.deepcopy(
+ servers299.rebuild_server_with_admin_pass)
+rebuild_server_with_admin_pass['response_body']['properties']['server'][
+ 'properties'].update({'scheduler_hints': _hints})
+rebuild_server_with_admin_pass['response_body']['properties']['server'][
+ 'required'].append('scheduler_hints')
+
+update_server = copy.deepcopy(servers299.update_server)
+update_server['response_body']['properties']['server'][
+ 'properties'].update({'scheduler_hints': _hints})
+update_server['response_body']['properties']['server'][
+ 'required'].append('scheduler_hints')
+
+# 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.99***
+attach_volume = copy.deepcopy(servers299.attach_volume)
+show_volume_attachment = copy.deepcopy(servers299.show_volume_attachment)
+list_volume_attachments = copy.deepcopy(servers299.list_volume_attachments)
+list_servers = copy.deepcopy(servers299.list_servers)
+show_server_diagnostics = copy.deepcopy(servers299.show_server_diagnostics)
+get_remote_consoles = copy.deepcopy(servers299.get_remote_consoles)
+show_instance_action = copy.deepcopy(servers299.show_instance_action)
+create_backup = copy.deepcopy(servers299.create_backup)
diff --git a/tempest/lib/services/compute/servers_client.py b/tempest/lib/services/compute/servers_client.py
index dffafef..4a607a3 100644
--- a/tempest/lib/services/compute/servers_client.py
+++ b/tempest/lib/services/compute/servers_client.py
@@ -48,6 +48,8 @@
from tempest.lib.api_schema.response.compute.v2_96 import servers as schemav296
from tempest.lib.api_schema.response.compute.v2_98 import servers as schemav298
from tempest.lib.api_schema.response.compute.v2_99 import servers as schemav299
+from tempest.lib.api_schema.response.compute.v2_100 import \
+ servers as schemav2100 # noqa: H306
from tempest.lib.common import rest_client
from tempest.lib.services.compute import base_compute_client
@@ -81,7 +83,8 @@
{'min': '2.89', 'max': '2.95', 'schema': schemav289},
{'min': '2.96', 'max': '2.97', 'schema': schemav296},
{'min': '2.98', 'max': '2.98', 'schema': schemav298},
- {'min': '2.99', 'max': None, 'schema': schemav299},
+ {'min': '2.99', 'max': '2.99', 'schema': schemav299},
+ {'min': '2.100', 'max': None, 'schema': schemav2100},
]
def __init__(self, auth_provider, service, region,