Skip to content

Commit

Permalink
Check RHEL Lifecycle status in ContentHost UI
Browse files Browse the repository at this point in the history
  • Loading branch information
damoore044 committed Dec 1, 2023
1 parent 7a3acb4 commit abcfc49
Showing 1 changed file with 55 additions and 1 deletion.
56 changes: 55 additions & 1 deletion tests/foreman/ui/test_contenthost.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,34 @@ def run_remote_command_on_content_host(command, vm_module_streams):
return result


def get_supported_rhel_versions():
"""Helper to get supported 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):
"""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"""

rhels = get_supported_rhel_versions()
rhel_lifecycle_status = 'Unknown'
if current_version not in rhels:
return rhel_lifecycle_status
elif (len(rhels) - 1) - rhels.index(current_version) <= 1:
rhel_lifecycle_status = 'Full support'
elif (len(rhels) - 1) - rhels.index(current_version) == 2:
rhel_lifecycle_status = 'Approaching end of maintenance support'
elif (len(rhels) - 1) - rhels.index(current_version) >= 3:
rhel_lifecycle_status = 'End of maintenance support'

return rhel_lifecycle_status


@pytest.mark.e2e
@pytest.mark.tier3
@pytest.mark.parametrize(
Expand All @@ -119,8 +147,16 @@ def run_remote_command_on_content_host(command, vm_module_streams):
],
indirect=True,
)
@pytest.mark.parametrize('setting_update', ['new_hosts_page'], indirect=True)
@pytest.mark.no_containers
def test_positive_end_to_end(session, default_location, module_repos_collection_with_manifest, vm):
def test_positive_end_to_end(
vm,
session,
module_org,
setting_update,
default_location,
module_repos_collection_with_manifest,
):
"""Create all entities required for content host, set up host, register it
as a content host, read content host details, install package and errata.
Expand All @@ -135,11 +171,29 @@ def test_positive_end_to_end(session, default_location, module_repos_collection_
:CaseImportance: Critical
"""
property_name = setting_update.name
_distro = module_repos_collection_with_manifest.distro
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}')
assert result.status == 0
startdate = datetime.utcnow().strftime('%m/%d/%Y')
with session:
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
host_details = session.host.get_details(vm.hostname, widget_names='properties')
host_status = session.host_new.get_host_statuses(vm.hostname)
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 abcfc49

Please sign in to comment.