From 1b41e14d03d00ef460b5ba68d179be794c9fce2f Mon Sep 17 00:00:00 2001 From: David Moore <109112035+damoore044@users.noreply.github.com> Date: Tue, 18 Feb 2025 14:37:14 -0500 Subject: [PATCH] RHEL10 Clients coverage, rhel7 & 8 hosts bumped (#17003) * rhel10 parametrized fixture chosts * Fixups, reverting some UI tests * drop RHEL6 from supported distros --- pytest_fixtures/core/contenthosts.py | 7 - robottelo/constants/__init__.py | 4 +- tests/foreman/api/test_ansible.py | 2 +- tests/foreman/api/test_capsulecontent.py | 20 +-- tests/foreman/api/test_errata.py | 145 +++++++++--------- .../destructive/test_capsule_loadbalancer.py | 2 +- tests/foreman/ui/test_activationkey.py | 2 +- tests/foreman/ui/test_reporttemplates.py | 2 +- 8 files changed, 87 insertions(+), 97 deletions(-) diff --git a/pytest_fixtures/core/contenthosts.py b/pytest_fixtures/core/contenthosts.py index b7742fdcd3b..d8b2c02f90a 100644 --- a/pytest_fixtures/core/contenthosts.py +++ b/pytest_fixtures/core/contenthosts.py @@ -94,13 +94,6 @@ def rhel8_contenthost_module(request): yield host -@pytest.fixture(params=[{'rhel_version': 6}]) -def rhel6_contenthost(request): - """A function-level fixture that provides a rhel6 content host object""" - with Broker(**host_conf(request), host_class=ContentHost) as host: - yield host - - @pytest.fixture(params=[{'rhel_version': '9'}]) def rhel9_contenthost(request): """A fixture that provides a rhel9 content host object""" diff --git a/robottelo/constants/__init__.py b/robottelo/constants/__init__.py index 6d476fb1891..4896fecec02 100644 --- a/robottelo/constants/__init__.py +++ b/robottelo/constants/__init__.py @@ -33,12 +33,12 @@ DISTRO_DEFAULT = 'rhel7' -DISTROS_SUPPORTED = ['rhel6', 'rhel7', 'rhel8', 'rhel9'] +DISTROS_SUPPORTED = ['rhel7', 'rhel8', 'rhel9', 'rhel10'] DISTROS_MAJOR_VERSION = { - 'rhel6': 6, 'rhel7': 7, 'rhel8': 8, 'rhel9': 9, + 'rhel10': 10, } MAJOR_VERSION_DISTRO = {value: key for key, value in DISTROS_MAJOR_VERSION.items()} diff --git a/tests/foreman/api/test_ansible.py b/tests/foreman/api/test_ansible.py index 36d462b8029..7e75c187a93 100644 --- a/tests/foreman/api/test_ansible.py +++ b/tests/foreman/api/test_ansible.py @@ -485,7 +485,7 @@ def test_positive_ansible_job_on_multiple_host( assert result.status_label == 'failed' @pytest.mark.no_containers - @pytest.mark.rhel_ver_match('[^6]') + @pytest.mark.rhel_ver_match(r'^(?!.*fips).*$') # all major versions, excluding fips def test_positive_ansible_localhost_job_on_host( self, target_sat, module_org, module_location, module_ak_with_synced_repo, rhel_contenthost ): diff --git a/tests/foreman/api/test_capsulecontent.py b/tests/foreman/api/test_capsulecontent.py index 32a72b48fd4..dda6c26cbb2 100644 --- a/tests/foreman/api/test_capsulecontent.py +++ b/tests/foreman/api/test_capsulecontent.py @@ -804,7 +804,7 @@ def test_flatpak_pulpcore_endpoint(self, target_sat, module_capsule_configured): @pytest.mark.e2e @pytest.mark.tier4 @pytest.mark.skip_if_not_set('capsule') - @pytest.mark.parametrize('distro', ['rhel7', 'rhel8_bos', 'rhel9_bos']) + @pytest.mark.parametrize('distro', ['rhel7', 'rhel8_bos', 'rhel9_bos', 'rhel10_bos_beta']) def test_positive_sync_kickstart_repo( self, target_sat, module_capsule_configured, function_sca_manifest_org, distro ): @@ -868,18 +868,18 @@ def test_positive_sync_kickstart_repo( module_capsule_configured.wait_for_sync(start_time=timestamp) cvv = cvv.read() assert len(cvv.environment) == 2 - # Check for kickstart content on SAT and CAPS - tail = ( - f'rhel/server/7/{REPOS["kickstart"][distro]["version"]}/x86_64/kickstart' - if distro == 'rhel7' - else f'{distro.split("_")[0]}/{REPOS["kickstart"][distro]["version"]}/x86_64/baseos/kickstart' # noqa:E501 - ) + tail = None + if distro == 'rhel7': + tail = f'rhel/server/7/{REPOS["kickstart"][distro]["version"]}/x86_64/kickstart' + elif 'beta' in distro: + tail = f'{distro.split("_")[0]}/{REPOS["kickstart"][distro]["version"]}/beta/x86_64/baseos/kickstart' + else: + tail = f'{distro.split("_")[0]}/{REPOS["kickstart"][distro]["version"]}/x86_64/baseos/kickstart' # noqa:E501 url_base = ( f'pulp/content/{function_sca_manifest_org.label}/{lce.label}/{cv.label}/' f'content/dist/{tail}' ) - # Check kickstart specific files for file in KICKSTART_CONTENT: sat_file = target_sat.checksum_by_url(f'{target_sat.url}/{url_base}/{file}') @@ -1447,13 +1447,13 @@ def test_positive_remove_capsule_orphans( 'repos_collection', [ { - 'distro': 'rhel9', + 'distro': 'rhel10', 'YumRepository': {'url': settings.repos.yum_0.url}, } ], indirect=True, ) - @pytest.mark.rhel_ver_list([settings.content_host.default_rhel_version]) + @pytest.mark.rhel_ver_match('N-0') def test_complete_sync_fixes_metadata( self, module_target_sat, diff --git a/tests/foreman/api/test_errata.py b/tests/foreman/api/test_errata.py index b7baedb7345..c43d72e762f 100644 --- a/tests/foreman/api/test_errata.py +++ b/tests/foreman/api/test_errata.py @@ -1010,7 +1010,7 @@ def test_positive_list_sorted_filtered(custom_repo, target_sat): @pytest.fixture(scope='module') -def setup_content_rhel8( +def setup_rhel_content( module_sca_manifest_org, rh_repo_module_manifest, activation_key, @@ -1019,7 +1019,7 @@ def setup_content_rhel8( module_target_sat, return_result=True, ): - """Setup content for rhel8 content host + """Setup content for rhel content host Using RH SAT-TOOLS RHEL8 for sat-tools, and FAKE_YUM_9 as custom-repo. Published to content-view and promoted to lifecycle-environment. @@ -1068,8 +1068,9 @@ def setup_content_rhel8( @pytest.mark.tier2 +@pytest.mark.rhel_ver_match('8') def test_positive_get_count_for_host( - setup_content_rhel8, activation_key, rhel8_contenthost, module_target_sat + setup_rhel_content, activation_key, rhel_contenthost, module_target_sat ): """Available errata count when retrieving Host @@ -1094,50 +1095,51 @@ def test_positive_get_count_for_host( :CaseImportance: Medium """ - org = setup_content_rhel8['organization'] - custom_repo = setup_content_rhel8['rh_repo'] - rhel8_contenthost.create_custom_repos(**{f'{custom_repo.name}': custom_repo.url}) - result = rhel8_contenthost.register( + chost = rhel_contenthost + org = setup_rhel_content['organization'] + custom_repo = setup_rhel_content['rh_repo'] + chost.create_custom_repos(**{f'{custom_repo.name}': custom_repo.url}) + result = chost.register( org=org, activation_keys=activation_key.name, target=module_target_sat, loc=None, ) - assert result.status == 0, ( - f'Failed to register the host - {rhel8_contenthost.hostname}: {result.stderr}' - ) - assert rhel8_contenthost.subscribed - rhel8_contenthost.execute(r'subscription-manager repos --enable \*') - host = rhel8_contenthost.nailgun_host.read() + assert result.status == 0, f'Failed to register the host - {chost.hostname}: {result.stderr}' + assert chost.subscribed + chost.execute(r'subscription-manager repos --enable \*') + host = chost.nailgun_host.read() + # No applicable errata to start - assert rhel8_contenthost.applicable_errata_count == 0 + assert chost.applicable_errata_count == 0 for errata in ('security', 'bugfix', 'enhancement'): _validate_errata_counts(host, errata_type=errata, expected_value=0) # One bugfix errata after installing outdated Kangaroo - result = rhel8_contenthost.execute(f'yum install -y {FAKE_9_YUM_OUTDATED_PACKAGES[7]}') + result = chost.execute(f'yum install -y {FAKE_9_YUM_OUTDATED_PACKAGES[7]}') assert result.status == 0, f'Failed to install package {FAKE_9_YUM_OUTDATED_PACKAGES[7]}' _validate_errata_counts(host, errata_type='bugfix', expected_value=1) # One enhancement errata after installing outdated Gorilla - result = rhel8_contenthost.execute(f'yum install -y {FAKE_9_YUM_OUTDATED_PACKAGES[3]}') + result = chost.execute(f'yum install -y {FAKE_9_YUM_OUTDATED_PACKAGES[3]}') assert result.status == 0, f'Failed to install package {FAKE_9_YUM_OUTDATED_PACKAGES[3]}' _validate_errata_counts(host, errata_type='enhancement', expected_value=1) # Install and check two outdated packages, with applicable security erratum # custom_repo outdated Walrus - result = rhel8_contenthost.execute(f'yum install -y {FAKE_1_CUSTOM_PACKAGE}') + result = chost.execute(f'yum install -y {FAKE_1_CUSTOM_PACKAGE}') assert result.status == 0, f'Failed to install package {FAKE_1_CUSTOM_PACKAGE}' _validate_errata_counts(host, errata_type='security', expected_value=1) # rh_repo outdated Puppet-agent - result = rhel8_contenthost.execute(f'yum install -y {REAL_RHEL8_1_PACKAGE_FILENAME}') + result = chost.execute(f'yum install -y {REAL_RHEL8_1_PACKAGE_FILENAME}') assert result.status == 0, f'Failed to install package {REAL_RHEL8_1_PACKAGE_FILENAME}' _validate_errata_counts(host, errata_type='security', expected_value=2) # All avaliable errata present - assert rhel8_contenthost.applicable_errata_count == 4 + assert chost.applicable_errata_count == 4 @pytest.mark.upgrade @pytest.mark.tier3 +@pytest.mark.rhel_ver_match('8') def test_positive_get_applicable_for_host( - setup_content_rhel8, activation_key, rhel8_contenthost, target_sat + setup_rhel_content, activation_key, rhel_contenthost, target_sat ): """Get applicable errata ids for a host @@ -1161,41 +1163,40 @@ def test_positive_get_applicable_for_host( :CaseImportance: Medium """ - org = setup_content_rhel8['organization'] - custom_repo = setup_content_rhel8['rh_repo'] + org = setup_rhel_content['organization'] + custom_repo = setup_rhel_content['rh_repo'] + chost = rhel_contenthost - rhel8_contenthost.create_custom_repos(**{f'{custom_repo.name}': custom_repo.url}) - result = rhel8_contenthost.register( + chost.create_custom_repos(**{f'{custom_repo.name}': custom_repo.url}) + result = chost.register( activation_keys=activation_key.name, target=target_sat, org=org, loc=None, ) - assert result.status == 0, ( - f'Failed to register the host - {rhel8_contenthost.hostname}: {result.stderr}' - ) - assert rhel8_contenthost.subscribed - rhel8_contenthost.execute(r'subscription-manager repos --enable \*') + assert result.status == 0, f'Failed to register the host - {chost.hostname}: {result.stderr}' + assert chost.subscribed + chost.execute(r'subscription-manager repos --enable \*') for errata in REPO_WITH_ERRATA['errata']: # Remove custom package if present, old or new. package_name = errata['package_name'] - result = rhel8_contenthost.execute(f'yum erase -y {package_name}') + result = chost.execute(f'yum erase -y {package_name}') if result.status != 0: pytest.fail(f'Failed to remove {package_name}: {result.stdout} {result.stderr}') - rhel8_contenthost.execute('subscription-manager repos') - assert rhel8_contenthost.applicable_errata_count == 0 - host = rhel8_contenthost.nailgun_host.read() + chost.execute('subscription-manager repos') + assert chost.applicable_errata_count == 0 + host = chost.nailgun_host.read() # Check no applicable errata to start erratum = _fetch_available_errata(host, expected_amount=0) assert len(erratum) == 0 # Install outdated applicable custom package - rhel8_contenthost.run(f'yum install -y {FAKE_1_CUSTOM_PACKAGE}') + chost.run(f'yum install -y {FAKE_1_CUSTOM_PACKAGE}') erratum = _fetch_available_errata(host, 1) assert len(erratum) == 1 assert CUSTOM_REPO_ERRATA_ID in [errata['errata_id'] for errata in erratum] # Install outdated applicable real package (from RH repo) - rhel8_contenthost.run(f'yum install -y {REAL_RHEL8_1_PACKAGE_FILENAME}') + chost.run(f'yum install -y {REAL_RHEL8_1_PACKAGE_FILENAME}') erratum = _fetch_available_errata(host, 2) assert len(erratum) == 2 assert REAL_RHEL8_1_ERRATA_ID in [errata['errata_id'] for errata in erratum] @@ -1256,13 +1257,14 @@ def test_positive_get_diff_for_cv_envs(target_sat): @pytest.mark.tier3 +@pytest.mark.rhel_ver_match('8') def test_positive_incremental_update_required( module_sca_manifest_org, module_lce, activation_key, module_cv, rh_repo_module_manifest, - rhel8_contenthost, + rhel_contenthost, target_sat, ): """Given a set of hosts and errata, check for content view version @@ -1293,6 +1295,7 @@ def test_positive_incremental_update_required( :BZ: 2013093 """ + chost = rhel_contenthost org = module_sca_manifest_org rh_repo = target_sat.api.Repository( id=rh_repo_module_manifest.id, @@ -1306,18 +1309,18 @@ def test_positive_incremental_update_required( _cv = cv_publish_promote(target_sat, org, module_cv, module_lce) module_cv = _cv['content-view'] - result = rhel8_contenthost.register( + result = chost.register( org=org, activation_keys=activation_key.name, target=target_sat, loc=None, ) - assert result.status == 0, f'Failed to register the host: {rhel8_contenthost.hostname}' - assert rhel8_contenthost.subscribed - rhel8_contenthost.execute(r'subscription-manager repos --enable \*') - host = rhel8_contenthost.nailgun_host.read() + assert result.status == 0, f'Failed to register the host: {chost.hostname}' + assert chost.subscribed + chost.execute(r'subscription-manager repos --enable \*') + host = chost.nailgun_host.read() # install package to create demand for an Erratum - result = rhel8_contenthost.run(f'yum install -y {REAL_RHEL8_1_PACKAGE_FILENAME}') + result = chost.run(f'yum install -y {REAL_RHEL8_1_PACKAGE_FILENAME}') assert result.status == 0, f'Failed to install package: {REAL_RHEL8_1_PACKAGE_FILENAME}' # Call nailgun to make the API POST to see if any incremental updates are required response = target_sat.api.Host().bulk_available_incremental_updates( @@ -1335,7 +1338,7 @@ def test_positive_incremental_update_required( ).create() module_cv = target_sat.api.ContentView(id=module_cv.id).read() module_cv = cv_publish_promote(target_sat, org, module_cv, module_lce)['content-view'] - rhel8_contenthost.execute('subscription-manager repos') + chost.execute('subscription-manager repos') # Call nailgun to make the API POST to ensure an incremental update is required response = target_sat.api.Host().bulk_available_incremental_updates( data={ @@ -1373,10 +1376,11 @@ def rh_repo_module_manifest(module_sca_manifest_org, module_target_sat): @pytest.mark.tier3 +@pytest.mark.rhel_ver_match('N-1') def test_positive_incremental_update_apply_to_envs_cvs( target_sat, module_sca_manifest_org, - rhel8_contenthost, + rhel_contenthost, module_product, ): """With multiple environments and content views, register a host to one, @@ -1407,6 +1411,7 @@ def test_positive_incremental_update_apply_to_envs_cvs( incremental version of the content-view. """ + chost = rhel_contenthost # any existing custom CVs in org, except Default CV prior_cv_count = ( len(target_sat.api.ContentView(organization=module_sca_manifest_org).search()) - 1 @@ -1477,21 +1482,21 @@ def test_positive_incremental_update_apply_to_envs_cvs( content_view=host_cv, ).create() # content host, global registration - result = rhel8_contenthost.register( + result = chost.register( org=module_sca_manifest_org, activation_keys=ak.name, target=target_sat, loc=None, ) - assert result.status == 0, f'Failed to register the host: {rhel8_contenthost.hostname}' - assert rhel8_contenthost.subscribed - rhel8_contenthost.execute(r'subscription-manager repos --enable \*') + assert result.status == 0, f'Failed to register the host: {chost.hostname}' + assert chost.subscribed + chost.execute(r'subscription-manager repos --enable \*') # Installing all outdated packages pkgs = ' '.join(FAKE_9_YUM_OUTDATED_PACKAGES) - assert rhel8_contenthost.execute(f'yum install -y {pkgs}').status == 0 - rhel8_contenthost.execute('subscription-manager repos') + assert chost.execute(f'yum install -y {pkgs}').status == 0 + chost.execute('subscription-manager repos') # After installing packages, check available incremental updates - host = rhel8_contenthost.nailgun_host.read() + host = chost.nailgun_host.read() response = target_sat.api.Host().bulk_available_incremental_updates( data={ 'organization_id': module_sca_manifest_org.id, @@ -1501,7 +1506,7 @@ def test_positive_incremental_update_apply_to_envs_cvs( ) # expecting no available updates before CV change assert response == [], ( - f'No incremental updates should currently be available to host: {rhel8_contenthost.hostname}.' + f'No incremental updates should currently be available to host: {chost.hostname}.' ) # New Erratum CV filter created for host view @@ -1517,11 +1522,11 @@ def test_positive_incremental_update_apply_to_envs_cvs( )['content-view-version'] # cv is not updated to host yet, applicable errata should be zero - rhel8_contenthost.execute('subscription-manager repos') - host_app_errata = rhel8_contenthost.applicable_errata_count + chost.execute('subscription-manager repos') + host_app_errata = chost.applicable_errata_count assert host_app_errata == 0 # After adding filter to cv, check available incremental updates - host_app_packages = rhel8_contenthost.applicable_package_count + host_app_packages = chost.applicable_package_count response = target_sat.api.Host().bulk_available_incremental_updates( data={ 'organization_id': module_sca_manifest_org.id, @@ -1529,12 +1534,10 @@ def test_positive_incremental_update_apply_to_envs_cvs( 'errata_ids': FAKE_9_YUM_SECURITY_ERRATUM, }, ) - assert response, ( - f'Expected one incremental update, but found none, for host: {rhel8_contenthost.hostname}.' - ) + assert response, f'Expected one incremental update, but found none, for host: {chost.hostname}.' # find that only expected CV version has incremental update available assert len(response) == 1, ( - f'Incremental update should currently be available to only one host: {rhel8_contenthost.hostname}.' + f'Incremental update should currently be available to only one host: {chost.hostname}.' ) next_version = float(response[0]['next_version']) assert float(host_cvv.version) + 0.1 == next_version # example: 2.0 > 2.1 @@ -1579,34 +1582,28 @@ def test_positive_incremental_update_apply_to_envs_cvs( assert host_version_number == next_version host_cvv = target_sat.api.ContentViewVersion(id=created_version_id).read() assert float(host_cvv.version) == next_version - rhel8_contenthost.execute('subscription-manager repos') + chost.execute('subscription-manager repos') # expected errata from FAKE_9 Security list added added_errata = response['output']['changed_content'][0]['added_units']['erratum'] assert set(added_errata) == set(FAKE_9_YUM_SECURITY_ERRATUM) # applicable errata count increased by length of security ids list - assert rhel8_contenthost.applicable_errata_count == host_app_errata + len( - FAKE_9_YUM_SECURITY_ERRATUM - ) + assert chost.applicable_errata_count == host_app_errata + len(FAKE_9_YUM_SECURITY_ERRATUM) # newly added errata from incremental version are now applicable to host - post_app_errata_ids = errata_id_set( - _fetch_available_errata_instances(target_sat, rhel8_contenthost) - ) + post_app_errata_ids = errata_id_set(_fetch_available_errata_instances(target_sat, chost)) assert set(FAKE_9_YUM_SECURITY_ERRATUM).issubset(post_app_errata_ids) # expected packages from the security erratum were added to host added_packages = response['output']['changed_content'][0]['added_units']['rpm'] assert len(added_packages) == 12 # expected that not all of the added packages will be applicable - assert 8 == host_app_packages == rhel8_contenthost.applicable_package_count + assert 8 == host_app_packages == chost.applicable_package_count # install all of the newly added packages, recalculate applicability for pkg in added_packages: - assert rhel8_contenthost.run(f'yum install -y {pkg}').status == 0 - rhel8_contenthost.execute('subscription-manager repos') + assert chost.run(f'yum install -y {pkg}').status == 0 + chost.execute('subscription-manager repos') # security errata should not be applicable after installing updated packages - post_app_errata_ids = errata_id_set( - _fetch_available_errata_instances(target_sat, rhel8_contenthost) - ) + post_app_errata_ids = errata_id_set(_fetch_available_errata_instances(target_sat, chost)) assert set(FAKE_9_YUM_SECURITY_ERRATUM).isdisjoint(post_app_errata_ids) - assert rhel8_contenthost.applicable_errata_count == 0 + assert chost.applicable_errata_count == 0 # after applying the incremental update, check for any more available response = target_sat.api.Host().bulk_available_incremental_updates( @@ -1618,7 +1615,7 @@ def test_positive_incremental_update_apply_to_envs_cvs( ) # expect no remaining updates, after applying the only one assert response == [], ( - f'No incremental updates should currently be available to host: {rhel8_contenthost.hostname}.' + f'No incremental updates should currently be available to host: {chost.hostname}.' ) diff --git a/tests/foreman/destructive/test_capsule_loadbalancer.py b/tests/foreman/destructive/test_capsule_loadbalancer.py index 0cbb40484c0..bfc0ed9b809 100644 --- a/tests/foreman/destructive/test_capsule_loadbalancer.py +++ b/tests/foreman/destructive/test_capsule_loadbalancer.py @@ -252,7 +252,7 @@ def test_loadbalancer_install_package( assert result.status == 0 -@pytest.mark.rhel_ver_match('[^6]') +@pytest.mark.rhel_ver_match('N-2') @pytest.mark.tier1 def test_client_register_through_lb( loadbalancer_setup, diff --git a/tests/foreman/ui/test_activationkey.py b/tests/foreman/ui/test_activationkey.py index 33d8b7e249b..d3f9b23fad4 100644 --- a/tests/foreman/ui/test_activationkey.py +++ b/tests/foreman/ui/test_activationkey.py @@ -960,7 +960,7 @@ def test_negative_usage_limit(session, module_org, target_sat, module_promoted_c @pytest.mark.no_containers -@pytest.mark.rhel_ver_match('^6') +@pytest.mark.rhel_ver_match(r'^(?!.*fips).*$') # all versions, excluding any 'fips' @pytest.mark.tier3 @pytest.mark.upgrade @pytest.mark.skipif((not settings.robottelo.repos_hosting_url), reason='Missing repos_hosting_url') diff --git a/tests/foreman/ui/test_reporttemplates.py b/tests/foreman/ui/test_reporttemplates.py index fbc56615183..d930a630de7 100644 --- a/tests/foreman/ui/test_reporttemplates.py +++ b/tests/foreman/ui/test_reporttemplates.py @@ -534,7 +534,7 @@ def test_positive_generate_all_installed_packages_report( @pytest.mark.tier2 @pytest.mark.no_containers -@pytest.mark.rhel_ver_match('[^6]') +@pytest.mark.rhel_ver_match(r'^(?!.*fips).*$') # all versions, excluding any 'fips' def test_positive_installable_errata_with_user( session, target_sat, function_org, function_lce, function_location, rhel_contenthost ):