Work around missing microversion headers on /

In get_min_max_api_microversions, we issue a request against the root
endpoint / to get the available microversions. This endpoint does return
them in the body but due to an issue in Ironic does not return the
microversion headers. Unfortunately, our implementation of request()
makes Tempest expected these headers and fail if they're absent.

Until Ironic is fixed, use /v1 to get the required information.

Change-Id: I7003e0c90ce764c903d870d739786a8a97d5f0af
Related-Bug: #2079023
This commit is contained in:
Dmitry Tantsur
2024-09-05 09:57:52 +02:00
parent b294d966d1
commit 7faed25a84

View File

@@ -79,8 +79,18 @@ class BaremetalClient(rest_client.RestClient):
def get_min_max_api_microversions(self):
"""Returns a tuple of minimum and remote microversions."""
_, resp_body = self._show_request(None, uri='/')
version = resp_body.get('default_version', {})
if '/v1' in self.base_url:
root_uri = '/'
else:
# NOTE(dtantsur): we should just use / here but due to a bug in
# Ironic, / does not contain the microversion headers. See
# https://bugs.launchpad.net/ironic/+bug/2079023
root_uri = '/v1'
_, resp_body = self._show_request(None, uri=root_uri)
try:
version = resp_body['default_version']
except KeyError:
version = resp_body['version']
api_min = version.get('min_version')
api_max = version.get('version')
return (api_min, api_max)