9ff5c280ab
The motivation for this commit is that some API responses like backing up a server image return the location of the image_id in either the response body or the response header depending on the microversion, e.g. [0]. In the case of server backup action, image_id is added to response body in microversion 2.45. Add `compare_version_header_to_request` to `api_version_utils` to accept a new kwarg called `operation`. At run time, 'eq' is translated to the __eq__ attribute of `APIVersionRequest`. The other operations include le, lt, gt, ge, and ne. This makes it possible to do for example: if api_version_utils.compare_version_header_to_response( "X-OpenStack-Nova-API-Version", "2.45", resp, "lt"): image1_id = resp['image_id'] else: image1_id = data_utils.parse_image_id(resp['location']) Which means that if "2.45" < "microversion in resp" then we can grab the image_id from the response body -- else we have to grab it from resp.response['location']. This commit: - adds compare_version_header_to_response to api_version_utils allowing to compare the request's header microversion to an expected microversion - modifies test_server_actions to use the new function in tests that always assume that the image_id attribute is in the resp header (not true across all microversions) -- this can be done to other tests in follow-up patch - adds related unit tests for all scenarios [0] https://developer.openstack.org/api-ref/compute/#create-server-back-up-createbackup-action Change-Id: Ib97e65cca468a09bbeaf68fcfe0e8192674a481e
16 lines
673 B
YAML
16 lines
673 B
YAML
---
|
|
features:
|
|
- |
|
|
Add a new function called ``compare_version_header_to_response`` to
|
|
``tempest.lib.common.api_version_utils``, which compares the API
|
|
micoversion in the response header to another microversion using the
|
|
comparators defined in
|
|
``tempest.lib.common.api_version_request.APIVersionRequest``.
|
|
|
|
It is now possible to determine how to retrieve an attribute from a
|
|
response body of an API call, depending on the returned microversion.
|
|
|
|
Add a new exception type called ``InvalidParam`` to
|
|
``tempest.lib.exceptions``, allowing the possibility of raising an
|
|
exception if an invalid parameter is passed to a library function.
|