robottelo
robottelo copied to clipboard
RFE: Dynamic generation of RHEL versions to lessen hardcoding
Problem statement
A lot of tests hardcode RHEL versions in the test body. With every RHEL release all tests that work with multiple RHEL versions should be updated in order to use/test all supported RHEL versions. Maintenance of these hardcoded versions is complex.
Solution
Use settings.supportability.content_hosts.rhel.versions
where possible. For cases that do not aim to use *_fips
RHELs, there should be a helper function that would return only RHEL versions of Integer type - 6, 7, 8, 9.
Example
Instead of using
search_string = 'name="RedHat" AND (major="6" OR major="7" OR major="8" OR major="9")'
we should use something like
# the following could be some kind of robottelo helper function
supported_rhel_vers = [ver for ver in settings.supportability.content_hosts.rhel.versions if isinstance(ver, int)]
search_string = 'name="RedHat" AND (' + ' OR '.join(map(lambda x: f'major="{x}"', supported_rhel_vers)) + ')'
Links
Link to the PR review where the change was proposed: https://github.com/SatelliteQE/robottelo/pull/10390#pullrequestreview-1233681142
We already have one supporting function implemented: https://github.com/SatelliteQE/robottelo/blob/e6ece85607eb1c8a8808431eca7e255f60ec1e05/conf/dynaconf_hooks.py#L93-L96
We talked about this today and decided to try to incorporate the query string as a generated constant. The exact content of the constant are dependant on the most common uses in the framework.