From 3a363d8abb95d63bdae0857b45b762996a7a8792 Mon Sep 17 00:00:00 2001 From: David Moore Date: Thu, 12 Oct 2023 13:40:11 -0400 Subject: [PATCH] Testing stream fixes for errata:cli --- tests/foreman/cli/test_errata.py | 37 +++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/tests/foreman/cli/test_errata.py b/tests/foreman/cli/test_errata.py index 13e0502ac31..245fd3b01b0 100644 --- a/tests/foreman/cli/test_errata.py +++ b/tests/foreman/cli/test_errata.py @@ -194,22 +194,39 @@ def hosts(request): @pytest.fixture(scope='module') def register_hosts( hosts, - module_entitlement_manifest_org, - module_ak_cv_lce, + module_org, + module_lce, + module_ak, rh_repo, custom_repo, module_target_sat, ): """Register hosts to Satellite""" for host in hosts: - host.install_katello_ca(module_target_sat) - host.register_contenthost(module_entitlement_manifest_org.name, module_ak_cv_lce.name) - host.enable_repo(REPOS['rhst7']['id']) + # host.install_katello_ca(module_target_sat) + # host.register_contenthost(module_entitlement_manifest_org.name, module_ak_cv_lce.name) + # host.enable_repo(REPOS['rhst7']['id']) + module_target_sat.cli_factory.setup_org_for_a_custom_repo( + { + 'url': REPO_WITH_ERRATA['url'], + 'organization-id': module_org.id, + 'lifecycle-environment-id': module_lce.id, + 'activationkey-id': module_ak.id, + } + ) + host.register( + activation_keys=module_ak.name, + target=module_target_sat, + org=module_org, + loc=None, + ) + assert host.subscribed + return hosts @pytest.fixture -def errata_hosts(register_hosts): +def errata_hosts(register_hosts, module_target_sat, module_org, module_lce, module_ak): """Ensure that rpm is installed on host.""" for host in register_hosts: # Remove all packages. @@ -225,6 +242,7 @@ def errata_hosts(register_hosts): result = host.execute(f'yum install -y {old_package}') if result.status != 0: pytest.fail(f'Failed to install {old_package}: {result.stdout} {result.stderr}') + host.execute('subscription-manager repos') return register_hosts @@ -667,7 +685,7 @@ def test_install_errata_to_one_host( @pytest.mark.tier3 @pytest.mark.e2e def test_positive_list_affected_chosts_by_erratum_restrict_flag( - request, module_entitlement_manifest_org, module_cv, module_lce, errata_hosts + target_sat, request, module_entitlement_manifest_org, module_cv, module_lce, errata_hosts ): """View a list of affected content hosts for an erratum filtered with restrict flags. Applicability is calculated using the Library, @@ -699,16 +717,14 @@ def test_positive_list_affected_chosts_by_erratum_restrict_flag( :CaseAutomation: Automated """ - # Uninstall package so that only the first errata applies. for host in errata_hosts: host.execute(f'yum erase -y {REPO_WITH_ERRATA["errata"][1]["package_name"]}') - + host.execute('subscription-manager repos') # Create list of uninstallable errata. errata = REPO_WITH_ERRATA['errata'][0] uninstallable = REPO_WITH_ERRATA['errata_ids'].copy() uninstallable.remove(errata['id']) - # Check search for only installable errata param = { 'errata-restrict-installable': 1, @@ -729,6 +745,7 @@ def test_positive_list_affected_chosts_by_erratum_restrict_flag( 'organization-id': module_entitlement_manifest_org.id, 'per-page': PER_PAGE_LARGE, } + errata_ids = get_errata_ids(param) assert set(REPO_WITH_ERRATA['errata_ids']).issubset( errata_ids