From a22fe4682c088a2f4397d53dbeaa35842e45992d Mon Sep 17 00:00:00 2001 From: David Moore <109112035+damoore044@users.noreply.github.com> Date: Tue, 26 Mar 2024 12:20:21 -0400 Subject: [PATCH] ErrataManagement UI: Update show_count, and errata_tab_pagination cases (#14520) fix UI:Errata test_positive_list (#14514) (cherry picked from commit a5fa4582741e8562476aa38107ff7271c586ae38) --- tests/foreman/ui/test_errata.py | 101 +++++++++++++++++++++++--------- 1 file changed, 74 insertions(+), 27 deletions(-) diff --git a/tests/foreman/ui/test_errata.py b/tests/foreman/ui/test_errata.py index a2eb69a818c..dadcaf6bef9 100644 --- a/tests/foreman/ui/test_errata.py +++ b/tests/foreman/ui/test_errata.py @@ -234,7 +234,7 @@ def registered_contenthost( :note: rhel_contenthost will be parameterized by rhel6 to 9, also -fips for all distros. to use specific rhel version parameterized contenthost; - use pytest.mark.rhel_ver_match() to mark contenthost version(s) for tests using this fixture. + use `pytest.mark.rhel_ver_match()` to mark contenthost version(s) for tests using this fixture. :repos: pass as a parameterized request list of upstream URLs for custom repositories. @@ -654,10 +654,7 @@ def test_host_content_errata_tab_pagination( pf4_pagination = session.host_new.get_errata_pagination(_chost_name) assert (_read_page := pf4_pagination.read()) assert _read_page != _prior_pagination - # assert per_page and total_pages remained the same - assert pf4_pagination.current_per_page == 5 assert pf4_pagination.current_page == 1 - assert pf4_pagination.total_pages > 1 # total_items decreased by one item_count = pf4_pagination.total_items assert item_count == _prior_app_count - 1 @@ -1194,59 +1191,109 @@ def test_positive_content_host_search_type(session, erratatype_vm): @pytest.mark.tier3 +@pytest.mark.rhel_ver_match('8') @pytest.mark.parametrize( - 'module_repos_collection_with_setup', - [ - { - 'distro': 'rhel7', - 'SatelliteToolsRepository': {}, - 'RHELAnsibleEngineRepository': {'cdn': True}, - 'YumRepository': {'url': settings.repos.yum_9.url}, - } - ], + 'registered_contenthost', + [[CUSTOM_REPO_URL]], indirect=True, ) -def test_positive_show_count_on_content_host_page( - session, module_org_with_parameter, erratatype_vm -): - """Available errata count displayed in Content hosts page +def test_positive_show_count_on_host_pages(session, module_org, registered_contenthost): + """Available errata by type displayed in New Host>Errata page, + and expected count by type in Legacy>Content hosts page. :id: 8575e282-d56e-41dc-80dd-f5f6224417cb :Setup: - 1. Errata synced on satellite server. - 2. Some content hosts are present. + 1. Errata synced on satellite server from custom repository. + 2. Registered host, subscribed to promoted CVV, with repo synced to appliable custom packages and erratum. - :steps: Go to Hosts -> Content Hosts. + :steps: - :expectedresults: The available errata count is displayed. + 1. Go to Hosts -> All Hosts, and Legacy ContentHost -> Hosts. + 2. None of the erratum are installable. + 3. Install all outdated applicable packages via yum. + 4. Recalculate errata applicablity for host. + 5. All of the erratum are now installable, on both pages from step 1. + + :expectedresults: + The available errata count is displayed and updates. + Displayed erratum match between the two content host pages. :BZ: 1484044, 1775427 :customerscenario: true """ - vm = erratatype_vm + vm = registered_contenthost hostname = vm.hostname + assert vm.subscribed + assert vm.execute('subscription-manager repos').status == 0 + assert vm.applicable_errata_count == 0 + with session: session.location.select(loc_name=DEFAULT_LOC) + # new host UI + new_host_values = session.host_new.search(hostname) + assert new_host_values[0]['Name'] == hostname + # None of the erratum are installable + for errata_type in ('Security', 'Bugfix', 'Enhancement'): + installable_errata = None + empty_table = False + try: + # exception will be raised in case of unfound element (dropdown or dropdown entry) + # if an exception was raised, the table is missing/empty (no errata). + installable_errata = session.host_new.get_errata_by_type( + entity_name=hostname, + type=errata_type, + )['content']['errata']['table'] + except Exception: + empty_table = True + assert ( + not installable_errata + ), f'Found some installable {errata_type} errata, when none were expected.' + assert empty_table + # legacy contenthost UI content_host_values = session.contenthost.search(hostname) assert content_host_values[0]['Name'] == hostname installable_errata = content_host_values[0]['Installable Updates']['errata'] - for errata_type in ('security', 'bug_fix', 'enhancement'): - assert int(installable_errata[errata_type]) == 0 + assert ( + int(installable_errata[errata_type]) == 0 + ), f'Found some installable {errata_type} errata, when none were expected.' + # install outdated packages, recalculate errata applicability pkgs = ' '.join(FAKE_9_YUM_OUTDATED_PACKAGES) assert vm.execute(f'yum install -y {pkgs}').status == 0 - + assert vm.execute('subscription-manager repos').status == 0 + assert vm.applicable_errata_count == 5 + + # new host UI (errata tab) + new_host_values = session.host_new.search(hostname) + assert new_host_values[0]['Name'] == hostname + # erratum are installable + security_errata = session.host_new.get_errata_by_type( + entity_name=hostname, + type='Security', + )['content']['errata']['table'] + assert len(security_errata) == FAKE_9_YUM_SECURITY_ERRATUM_COUNT + for errata_type in ('Bugfix', 'Enhancement'): + installable_errata = session.host_new.get_errata_by_type( + entity_name=hostname, + type=errata_type, + )['content']['errata']['table'] + assert ( + len(installable_errata) == 1 + ), f'Expected only one {errata_type} errata to be installable.' + # legacy contenthost UI content_host_values = session.contenthost.search(hostname) assert content_host_values[0]['Name'] == hostname installable_errata = content_host_values[0]['Installable Updates']['errata'] - + # erratum are installable assert int(installable_errata['security']) == FAKE_9_YUM_SECURITY_ERRATUM_COUNT for errata_type in ('bug_fix', 'enhancement'): - assert int(installable_errata[errata_type]) == 1 + assert ( + int(installable_errata[errata_type]) == 1 + ), f'Expected only one {errata_type} errata to be installable.' @pytest.mark.tier3