API Microversion Testing Support in Tempest

API Microversion Testing Support in Tempest

Framework to support API Microversion testing

Many of the OpenStack components have implemented API microversions. It is important to test those microversions in Tempest or external plugins. Tempest now provides stable interfaces to support to test the API microversions. Based on the microversion range coming from the combination of both configuration and each test case, APIs request will be made with selected microversion.

This document explains the interfaces needed for microversion testing.

The api_version_request module

class APIVersionRequest(version_string=None)[source]

This class represents an API Version Request.

This class provides convenience methods for manipulation and comparison of version numbers that we need to do to implement microversions.

Parameters:version_string -- String representation of APIVersionRequest. Correct format is 'X.Y', where 'X' and 'Y' are int values. None value should be used to create Null APIVersionRequest, which is equal to 0.0
get_string()[source]

Version string representation.

Converts object to string representation which if used to create an APIVersionRequest object results in the same version request.

is_null()[source]

Checks whether version is null.

Return True if version object is null otherwise False.

Returns:boolean
matches(min_version, max_version)[source]

Matches the version object.

Returns whether the version object represents a version greater than or equal to the minimum version and less than or equal to the maximum version.

Parameters:
  • min_version -- Minimum acceptable version.
  • max_version -- Maximum acceptable version.
Returns:

boolean

If min_version is null then there is no minimum limit. If max_version is null then there is no maximum limit. If self is null then raise ValueError

The api_version_utils module

class BaseMicroversionTest[source]

Mixin class for API microversion test class.

assert_version_header_matches_request(api_microversion_header_name, api_microversion, response_header)[source]

Checks API microversion in response header

Verify whether microversion is present in response header and with specified 'api_microversion' value.

Parameters:
  • api_microversion_header_name -- Microversion header name Example- "X-OpenStack-Nova-API-Version"
  • api_microversion -- Microversion number like "2.10"
  • response_header -- Response header where microversion is expected to be present.
check_skip_with_microversion(test_min_version, test_max_version, cfg_min_version, cfg_max_version)[source]

Checks API microversions range and returns whether test needs to be skip

Compare the test and configured microversion range and returns whether test microversion range is out of configured one. This method can be used to skip the test based on configured and test microversion range.

Parameters:
  • test_min_version -- Test Minimum Microversion
  • test_max_version -- Test Maximum Microversion
  • cfg_min_version -- Configured Minimum Microversion
  • cfg_max_version -- Configured Maximum Microversion
Returns:

boolean

select_request_microversion(test_min_version, cfg_min_version)[source]

Select microversion from test and configuration min version.

Compare requested microversion and return the maximum microversion out of those.

Parameters:
  • test_min_version -- Test Minimum Microversion
  • cfg_min_version -- Configured Minimum Microversion
Returns:

Selected microversion string

Creative Commons Attribution 3.0 License

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.