diff --git a/tests/foreman/ui/test_contenthost.py b/tests/foreman/ui/test_contenthost.py index 01e5d7db5cf..9fe08e90b80 100644 --- a/tests/foreman/ui/test_contenthost.py +++ b/tests/foreman/ui/test_contenthost.py @@ -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( @@ -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. @@ -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(