Skip to content

Commit

Permalink
Helpers for rhel version support
Browse files Browse the repository at this point in the history
  • Loading branch information
damoore044 committed Dec 11, 2023
1 parent abcfc49 commit b79a4fb
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 17 deletions.
20 changes: 18 additions & 2 deletions tests/foreman/api/test_errata.py
Original file line number Diff line number Diff line change
Expand Up @@ -824,17 +824,33 @@ def test_apply_modular_errata_using_default_content_view(
stream = '0'
version = '20180704244205'

rhel8_contenthost.install_katello_ca(target_sat)
"""rhel8_contenthost.install_katello_ca(target_sat)
rhel8_contenthost.register_contenthost(
module_entitlement_manifest_org.label, rhel8_module_ak.name
)"""

# Associate custom repos with org, lce, ak:
target_sat.cli_factory.setup_org_for_a_custom_repo(
{
'organization-id': module_entitlement_manifest_org.id,
'lifecycle-environment-id': default_lce.id,
'activationkey-id': rhel8_module_ak.id,
'content-view-id': rhel8_custom_repo_cv.id,
}
)
rhel8_contenthost.register(
activation_keys=rhel8_module_ak.name,
target=target_sat,
org=module_entitlement_manifest_org,
loc=None,
)
assert rhel8_contenthost.subscribed
host = rhel8_contenthost.nailgun_host
host = host.read()
# Assert no errata on host, no packages applicable or installable
errata = _fetch_available_errata(module_entitlement_manifest_org, host, expected_amount=0)
assert len(errata) == 0
rhel8_contenthost.install_katello_host_tools()
# rhel8_contenthost.install_katello_host_tools()
# Install older version of module stream to generate the errata
result = rhel8_contenthost.execute(
f'yum -y module install {module_name}:{stream}:{version}',
Expand Down
29 changes: 14 additions & 15 deletions tests/foreman/ui/test_contenthost.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,35 +103,37 @@ def run_remote_command_on_content_host(command, vm_module_streams):


def get_supported_rhel_versions():
"""Helper to get supported rhel versions for contenthost.
return: a list of integers"""
"""Helper to get the supported base rhel versions for contenthost.
return: a list of integers
"""
return [
ver for ver in settings.supportability.content_hosts.rhel.versions if isinstance(ver, int)
]


def get_rhel_lifecycle_support(current_version):
def get_rhel_lifecycle_support(rhel_version):
"""Helper to get what the Lifecycle Support Status should be,
based on provided rhel version.
:param current_version: integer of the current base rhel version
:return: the expected status of rhel version support, string"""

:param rhel_version: integer of the current base rhel version
:return: string with the expected status of rhel version support
"""
rhels = get_supported_rhel_versions()
rhel_lifecycle_status = 'Unknown'
if current_version not in rhels:
if rhel_version not in rhels:
return rhel_lifecycle_status
elif (len(rhels) - 1) - rhels.index(current_version) <= 1:
elif (len(rhels) - 1) - rhels.index(rhel_version) <= 1:
rhel_lifecycle_status = 'Full support'
elif (len(rhels) - 1) - rhels.index(current_version) == 2:
elif (len(rhels) - 1) - rhels.index(rhel_version) == 2:
rhel_lifecycle_status = 'Approaching end of maintenance support'
elif (len(rhels) - 1) - rhels.index(current_version) >= 3:
elif (len(rhels) - 1) - rhels.index(rhel_version) >= 3:
rhel_lifecycle_status = 'End of maintenance support'

return rhel_lifecycle_status


@pytest.mark.e2e
@pytest.mark.tier3
@pytest.mark.parametrize('setting_update', ['new_hosts_page'], indirect=True)
@pytest.mark.parametrize(
'module_repos_collection_with_manifest',
[
Expand All @@ -147,7 +149,6 @@ def get_rhel_lifecycle_support(current_version):
],
indirect=True,
)
@pytest.mark.parametrize('setting_update', ['new_hosts_page'], indirect=True)
@pytest.mark.no_containers
def test_positive_end_to_end(
vm,
Expand Down Expand Up @@ -176,7 +177,6 @@ def test_positive_end_to_end(
host_rhel_version = None
if _distro.startswith('rhel'):
host_rhel_version = int(_distro[4:])

rhel_status = get_rhel_lifecycle_support(host_rhel_version if not None else 0)

result = vm.run(f'yum -y install {FAKE_1_CUSTOM_PACKAGE}')
Expand All @@ -186,14 +186,13 @@ def test_positive_end_to_end(
session.settings.update(f'name = {property_name}', 'Yes')
session.location.select(default_location.name)
session.organization.select(module_org.name)
# Use new_host UI, only check the details and host status
# Use new hosts UI, only check the details and host status
host_details = session.host.get_details(vm.hostname, widget_names='properties')
host_status = session.host_new.get_host_statuses(vm.hostname)
# Use old hosts UI for remainder
session.settings.update(f'name = {property_name}', 'No')

assert rhel_status in host_status['RHEL lifecycle']['Status']
assert rhel_status in host_details['properties']['properties_table']['RHEL lifecycle']
# TODO: Use UI in old 'All Hosts' page, add 'RHEL Lifecycle status' column, assert the status.
# Ensure content host is searchable
assert session.contenthost.search(vm.hostname)[0]['Name'] == vm.hostname
chost = session.contenthost.read(
Expand Down

0 comments on commit b79a4fb

Please sign in to comment.