From 087636e0635d90cbc397bcc8cc58958d955c4459 Mon Sep 17 00:00:00 2001 From: David Moore Date: Thu, 18 Jan 2024 06:52:24 -0500 Subject: [PATCH] method filling searchbar will leave it filled --- tests/foreman/ui/test_errata.py | 151 ++++++++++++++++++++++++-------- 1 file changed, 116 insertions(+), 35 deletions(-) diff --git a/tests/foreman/ui/test_errata.py b/tests/foreman/ui/test_errata.py index b02dc447995..349f5e4bbd6 100644 --- a/tests/foreman/ui/test_errata.py +++ b/tests/foreman/ui/test_errata.py @@ -237,6 +237,11 @@ def registered_contenthost( :repos: pass as a parameterized request list of upstream URLs for custom repositories. default: None; when None set to [CUSTOM_REPO_URL,] + example: + @pytest.mark.parametrize("registered_contenthost", + [[repo1_url, repo2_url,]], + indirect=True, + ) """ # read indirect parameterization request, could be None try: @@ -474,6 +479,7 @@ def test_end_to_end( @pytest.mark.tier2 +@pytest.mark.no_containers @pytest.mark.rhel_ver_match('8') @pytest.mark.parametrize("registered_contenthost", [[CUSTOM_REPO_3_URL]], indirect=True) @pytest.mark.skipif((not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url') @@ -490,23 +496,32 @@ def test_host_content_errata_tab_pagination( # Test per-page pagination for BZ#1662254 # Test apply by REX using Select All for BZ#1846670 + :setup: + 1. rhel8 registered contentehost with custom repos enabled + 2. enable and sync rh repository + 3. add rh repo to cv for registered host and publish/promote. + :id: 6363eda7-a162-4a4a-b70f-75decbd8202e :steps: 1. Install more than 20 packages that need errata 2. View Content Host's Errata page 3. Assert total_pages > 1 - 4. Change per-page setting to 100 + 4. Change per-page setting to 50 5. Assert table has more than 20 errata - 6. Use the selection box on the left to select all on the page. + 6. Select one avaliable errata and install it + 7. Assert total items in table is one less + 8. Assert per page count and total pages has not changed + 9. Use the selection box on the left to select all on the page. The following is displayed at the top of the table: - All 20 items on this page are selected. Select all YYY. + All 20 items on this page, max of 50, are selected. Select all YYY. - 7. Click the "Select all" text and assert more than 20 results are selected. - 8. Click the drop down arrow to the right of "Apply Selected", and select + 10. Click the "Select all" text and assert more than 20 results are selected. + 11. Click the drop down arrow to the right of "Apply Selected", and select "via remote execution" - 9. Click Submit - 10. Assert Errata are applied as expected. + 12. Click Submit + 13. Assert Errata are applied as expected + 14. Assert no pagination on new host UI>content>errata :expectedresults: More than page of errata can be selected and applied using REX while changing per-page settings. @@ -532,7 +547,6 @@ def test_host_content_errata_tab_pagination( reposet=REPOSET['rhst8'], releasever='None', ) - # Sync step because repo is not synced by default rh_repo = module_target_sat.api.Repository(id=rh_repo_id).read() rh_repo.sync() # add rh_repo to cv, publish version and promote w/ the repository @@ -552,43 +566,110 @@ def test_host_content_errata_tab_pagination( ) assert registered_contenthost.subscribed registered_contenthost.add_rex_key(satellite=module_target_sat) - # Enable repos and install packages that need errata assert registered_contenthost.execute(r'subscription-manager repos --enable \*').status == 0 + # Install all YUM 3 packages pkgs = ' '.join(FAKE_3_YUM_OUTDATED_PACKAGES) assert registered_contenthost.execute(f'yum install -y {pkgs}').status == 0 + with session: # Go to new host's page UI, Content>Errata tab, - # read the page's pagination widgets + # read the view's pagination entitity session.organization.select(org_name=org.name) session.location.select(loc_name=DEFAULT_LOC) - page_values = session.host_new.get_errata_pagination(registered_contenthost.hostname) - pagination = page_values['content']['errata']['pagination'] - assert int(pagination['per_page']) == 20 + # There are two pagination objects on errata tab, we read the top one + pf4_pagination = session.host_new.get_errata_pagination(registered_contenthost.hostname) + assert pf4_pagination.current_per_page == 20 # assert total_pages > 1 with default page settings - assert int(pagination['pages']) > 1 + assert pf4_pagination.total_pages > 1 + # Change per-page setting to 50 and assert there is now only one page + pf4_pagination.set_per_page(50) + pf4_pagination = session.host_new.get_errata_pagination(registered_contenthost.hostname) + assert pf4_pagination.current_per_page == 50 + assert pf4_pagination.total_pages == 1 + # assert at least the 28 errata from fake repo are present + assert pf4_pagination.total_items >= 28 + _prior_app_count = pf4_pagination.total_items - view = session.host_new.navigate_to( - session.contenthost, 'Edit', entity_name=registered_contenthost.hostname + # Install one avaliable errata from UI with REX as default + errata_id = CUSTOM_REPO_3_ERRATA[1] + session.host_new.apply_erratas( + registered_contenthost.hostname, f'errata_id = "{errata_id}"' ) - per_page_value = view.errata.pagination.per_page - # Change per-page setting to 100 and assert there is now only one page - assert per_page_value.fill('100') - page_values = session.host_new.get_errata_pagination(registered_contenthost.hostname) - pagination = page_values['content']['errata']['pagination'] - assert int(pagination['per_page']) == 100 - assert int(pagination['pages']) == 1 - # assert at least the 28 errata from fake repo are present - assert int(pagination['total_items']) >= 28 - - # install all errata with REX by default - status = session.host_new.apply_erratas(registered_contenthost.hostname, 'All') - # assert errata are listed on job invocation page - assert status['overview']['job_status'] == 'Success' - assert status['overview']['job_status_progress'] == '100%' - # check that there are no applicable errata left on the CHost's errata page - page_values = session.host_new.get_errata_pagination(registered_contenthost.hostname) - pagination = page_values['content']['errata']['pagination'] - assert int(pagination['total_items']) == 0 + # find host errata install job and status, timeout is 120s + # may take some time, wait for any not pending + status = module_target_sat.wait_for_tasks( + search_query=( + f'Remote action: Install errata on {registered_contenthost.hostname}' + ' and result != pending' + ), + search_rate=2, + max_tries=60, + ) + assert len(status) >= 1 + task = status[0] + assert task.result == 'success' + assert 'host' in task.input + assert registered_contenthost.nailgun_host.id == task.input['host']['id'] + # find bulk applicability task and status + status = module_target_sat.wait_for_tasks( + search_query=( + f'Bulk generate applicability for host {registered_contenthost.hostname}' + ' and result != pending' + ), + search_rate=2, + max_tries=60, + ) + assert len(status) >= 1 + task = status[0] + assert task.result == 'success' + assert 'host_ids' in task.input + assert registered_contenthost.nailgun_host.id in task.input['host_ids'] + # read pagination after installing one errata + assert registered_contenthost.applicable_errata_count == _prior_app_count - 1 + pf4_pagination = session.host_new.get_errata_pagination(registered_contenthost.hostname) + # per_page and total_pages remained the same + assert pf4_pagination.current_per_page == 50 + assert pf4_pagination.total_pages == 1 + # assert total_items decreased by one + item_count = pf4_pagination.total_items + assert item_count == _prior_app_count - 1 + + # Install all avaliable errata from UI, we pass a blank ' ' search, + # so that all errata are displayed and selected + session.host_new.apply_erratas(registered_contenthost.hostname, ' ') + # find host errata install job and status, timeout is 120s + status = module_target_sat.wait_for_tasks( + search_query=( + f'Remote action: Install errata on {registered_contenthost.hostname}' + ' and result != pending' + ), + search_rate=2, + max_tries=60, + ) + assert len(status) >= 1 + task = status[0] + assert task.result == 'success' + assert 'host' in task.input + assert registered_contenthost.nailgun_host.id == task.input['host']['id'] + # find bulk applicability task and status + status = module_target_sat.wait_for_tasks( + search_query=( + f'Bulk generate applicability for host {registered_contenthost.hostname}' + ' and result != pending' + ), + search_rate=2, + max_tries=60, + ) + assert len(status) >= 1 + task = status[0] + assert task.result == 'success' + assert 'host_ids' in task.input + assert registered_contenthost.nailgun_host.id in task.input['host_ids'] + # check that there are no applicable errata left for Chost or in errata tab + assert registered_contenthost.applicable_errata_count == 0 + pf4_pagination = session.host_new.get_errata_pagination(registered_contenthost.hostname) + # the errata table is not present when empty, not paginated + assert not pf4_pagination.read() @pytest.mark.tier2