diff --git a/tests/foreman/ui/test_errata.py b/tests/foreman/ui/test_errata.py index ab6eb81ce9d..8e54976628a 100644 --- a/tests/foreman/ui/test_errata.py +++ b/tests/foreman/ui/test_errata.py @@ -330,7 +330,7 @@ def registered_contenthost( # found index (repo) with matching name, grab sub-manager repo-id: assert repo.name in repo_ids_names['names'] sub_man_repo_id = repo_ids_names['ids'][repo_ids_names['names'].index(repo.name)] - # repo present, and can be enabled without error + # repo can be enabled by id without error enable_repo = client.execute(f'subscription-manager repos --enable {sub_man_repo_id}') assert enable_repo.status == 0, ( f'Failed to enable a repository with subscription-manager, on client: {client.hostname}.' @@ -357,6 +357,7 @@ def cleanup(): @pytest.mark.e2e @pytest.mark.tier3 @pytest.mark.rhel_ver_match('[^6]') +@pytest.mark.parametrize('registered_contenthost', [[CUSTOM_REPO_URL]], indirect=True) @pytest.mark.no_containers def test_end_to_end( registered_contenthost, @@ -366,7 +367,7 @@ def test_end_to_end( module_cv, session, ): - """Create all entities required for errata, set up applicable host, + """Create all entities required for errata, register an applicable host, read errata details and apply it to host. :id: a26182fc-f31a-493f-b094-3f5f8d2ece47 @@ -408,21 +409,7 @@ def test_end_to_end( client = registered_contenthost hostname = client.hostname assert client.subscribed - # create new custom repo, sync, add to content view - custom_repo = module_target_sat.api.Repository( - url=CUSTOM_REPO_URL, product=module_product - ).create() - custom_repo.sync() - module_cv.repository = [custom_repo] - module_cv.update(['repository']) - # publish new version with the newly added content, promote. - # once promoted, the new version with content - # will be available to host. - module_cv.read().publish() - module_cv = module_cv.read() - module_cv.version.sort(key=lambda version: version.id) - content_view_version = module_cv.version[-1].read() - content_view_version.promote(data={'environment_ids': module_lce.id}) + custom_repo = module_cv.read().repository[0].read() # nothing applicable to start result = client.execute('subscription-manager repos') assert ( @@ -569,7 +556,7 @@ def test_end_to_end( @pytest.mark.tier2 @pytest.mark.no_containers -@pytest.mark.rhel_ver_match('8') +@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') def test_host_content_errata_tab_pagination( @@ -579,6 +566,7 @@ def test_host_content_errata_tab_pagination( module_sca_manifest_org, module_lce, module_cv, + module_ak, ): """ # Test per-page pagination for BZ#1662254 @@ -621,7 +609,7 @@ def test_host_content_errata_tab_pagination( # custom_repo was created & added to cv, in registered_contenthost fixture # search for the instance custom_repo = [repo for repo in all_repos if repo.url == CUSTOM_REPO_3_URL] - assert len(custom_repo) == 1 + assert len(custom_repo) > 0 custom_repo = custom_repo[0].read() custom_repo.sync() # Set up rh_repo @@ -972,15 +960,17 @@ def test_positive_apply_for_all_hosts( :expectedresults: Check that the erratum is applied in all the content hosts. """ + num_hosts = 4 + distro = 'rhel9' # one custom repo on satellite, for all hosts to use custom_repo = target_sat.api.Repository(url=CUSTOM_REPO_URL, product=module_product).create() custom_repo.sync() module_cv.repository = [custom_repo] module_cv.update(['repository']) with Broker( - nick='rhel9', workflow='deploy-rhel', host_class=ContentHost, _count=4, + nick=distro, workflow='deploy-rhel', host_class=ContentHost, _count=num_hosts, ) as hosts: - if not isinstance(hosts, list) or len(hosts) != 4: + if not isinstance(hosts, list) or len(hosts) != num_hosts: pytest.fail('Failed to provision the expected number of hosts.') for client in hosts: # setup/register all hosts to same ak, content-view, and the one custom repo @@ -995,21 +985,35 @@ def test_positive_apply_for_all_hosts( assert setup['result'] != 'error', f'{setup["message"]}' assert (client := setup['client']) assert client.subscribed - assert client.execute(f'yum install -y {FAKE_1_CUSTOM_PACKAGE}').status == 0 + pkgs = ' '.join(FAKE_9_YUM_OUTDATED_PACKAGES) + assert client.execute(f'yum install -y {pkgs}').status == 0 assert client.execute('subscription-manager repos').status == 0 with session: session.location.select(loc_name=DEFAULT_LOC) + # for first errata, install in each chost and check, one at a time for client in hosts: status = session.contenthost.install_errata( client.hostname, CUSTOM_REPO_ERRATA_ID, install_via='rex' ) assert status['overview']['job_status'] == 'Success' assert status['overview']['job_status_progress'] == '100%' + # check updated package in chost details + assert client.execute('subscription-manager repos').status == 0 packages_rows = session.contenthost.search_package( client.hostname, FAKE_2_CUSTOM_PACKAGE ) assert packages_rows[0]['Installed Package'] == FAKE_2_CUSTOM_PACKAGE + # for second errata, install into all chosts at once + # from Content > Errata > info > ContentHosts tab + errata_id = settings.repos.yum_9.errata[4] # RHBA-2012:1030 + session.errata.install( + entity_name=errata_id, + host_names="All", + ) + # bulk action task for expected hosts + + # check each task status and package version, for each chost @pytest.mark.tier2 @@ -1267,6 +1271,7 @@ def test_positive_host_content_library( assert client.applicable_errata_count == 0 assert client.execute(f'yum install -y {FAKE_1_CUSTOM_PACKAGE}').status == 0 + assert client.execute(f'subscription-manager repos').status == 0 assert client.applicable_errata_count == 1 assert client.applicable_package_count == 1 @@ -1587,12 +1592,14 @@ def test_positive_filtered_errata_status_installable_param( """ client = registered_contenthost assert client.execute(f'yum install -y {FAKE_1_CUSTOM_PACKAGE}').status == 0 + assert client.execute(f'subscription-manager repos').status == 0 # Adding content view filter and content view filter rule to exclude errata, # for the installed package above. cv_filter = target_sat.api.ErratumContentViewFilter( content_view=module_cv, inclusion=False ).create() module_cv = module_cv.read() + module_cv.version.sort(key=lambda version: version.id) errata = target_sat.api.Errata(content_view_version=module_cv.version[-1]).search( query={'search': f'errata_id="{CUSTOM_REPO_ERRATA_ID}"'} )[0] @@ -1644,12 +1651,12 @@ def test_positive_filtered_errata_status_installable_param( @pytest.mark.tier3 def test_content_host_errata_search_commands( - session, - target_sat, module_product, + target_sat, module_org, module_ak, module_cv, + session, ): """View a list of affected content hosts for security (RHSA) and bugfix (RHBA) errata, filtered with errata status and applicable flags. Applicability is calculated using the @@ -1699,8 +1706,10 @@ def test_content_host_errata_search_commands( assert client.subscribed # Install pkg walrus-0.71-1.noarch to create need for RHSA on client 1 assert clients[0].execute(f'yum install -y {FAKE_1_CUSTOM_PACKAGE}').status == 0 + assert clients[0].execute('subscription-manager repos').status == 0 # Install pkg kangaroo-0.1-1.noarch to create need for RHBA on client 2 assert clients[1].execute(f'yum install -y {FAKE_4_CUSTOM_PACKAGE}').status == 0 + assert clients[1].execute('subscription-manager repos').status == 0 with session: session.location.select(loc_name=DEFAULT_LOC)