From 000c5f6558e788842fbf95d2fdb0014d18285c15 Mon Sep 17 00:00:00 2001 From: Matej Matuska Date: Thu, 21 Aug 2025 15:10:58 +0200 Subject: [PATCH 47/55] repositoriesblacklist: Remove the rhel7-optional unsupported PESID Update tests to assume 8->9 upgrade path. --- .../libraries/repositoriesblacklist.py | 4 +- .../tests/test_repositoriesblacklist.py | 48 ++++++++++--------- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/repos/system_upgrade/common/actors/repositoriesblacklist/libraries/repositoriesblacklist.py b/repos/system_upgrade/common/actors/repositoriesblacklist/libraries/repositoriesblacklist.py index e22fbee0..5059f619 100644 --- a/repos/system_upgrade/common/actors/repositoriesblacklist/libraries/repositoriesblacklist.py +++ b/repos/system_upgrade/common/actors/repositoriesblacklist/libraries/repositoriesblacklist.py @@ -6,7 +6,6 @@ from leapp.models import CustomTargetRepository, RepositoriesBlacklisted, Reposi # {OS_MAJOR_VERSION: PESID} UNSUPPORTED_PESIDS = { - "7": "rhel7-optional", "8": "rhel8-CRB", "9": "rhel9-CRB", "10": "rhel10-CRB" @@ -28,9 +27,8 @@ def _report_using_unsupported_repos(repos): def _report_excluded_repos(repos): - optional_repository_name = 'optional' if get_source_major_version() == '7' else 'CRB' api.current_logger().info( - "The {0} repository is not enabled. Excluding {1} from the upgrade".format(optional_repository_name, repos) + "The CRB repository is not enabled. Excluding {} from the upgrade".format(repos) ) report = [ diff --git a/repos/system_upgrade/common/actors/repositoriesblacklist/tests/test_repositoriesblacklist.py b/repos/system_upgrade/common/actors/repositoriesblacklist/tests/test_repositoriesblacklist.py index c4f9a36e..945007c6 100644 --- a/repos/system_upgrade/common/actors/repositoriesblacklist/tests/test_repositoriesblacklist.py +++ b/repos/system_upgrade/common/actors/repositoriesblacklist/tests/test_repositoriesblacklist.py @@ -20,8 +20,8 @@ from leapp.models import ( def repofacts_opts_disabled(): repos_data = [ RepositoryData( - repoid="rhel-7-server-optional-rpms", - name="RHEL 7 Server", + repoid="codeready-builder-for-rhel-8-x86_64-rpms", + name="RHEL 8 CRB", enabled=False, ) ] @@ -32,11 +32,11 @@ def repofacts_opts_disabled(): @pytest.fixture -def rhel7_optional_pesidrepo(): +def rhel8_crb_pesidrepo(): return PESIDRepositoryEntry( - pesid='rhel7-optional', - major_version='7', - repoid='rhel-7-server-optional-rpms', + pesid='rhel8-CRB', + major_version='8', + repoid='codeready-builder-for-rhel-8-x86_64-rpms', rhui='', arch='x86_64', channel='ga', @@ -46,11 +46,11 @@ def rhel7_optional_pesidrepo(): @pytest.fixture -def rhel8_crb_pesidrepo(): +def rhel9_crb_pesidrepo(): return PESIDRepositoryEntry( - pesid='rhel8-CRB', - major_version='8', - repoid='codeready-builder-for-rhel-8-x86_64-rpms', + pesid='rhel9-CRB', + major_version='9', + repoid='codeready-builder-for-rhel-9-x86_64-rpms', rhui='', arch='x86_64', channel='ga', @@ -60,10 +60,10 @@ def rhel8_crb_pesidrepo(): @pytest.fixture -def repomap_opts_only(rhel7_optional_pesidrepo, rhel8_crb_pesidrepo): +def repomap_opts_only(rhel8_crb_pesidrepo, rhel9_crb_pesidrepo): return RepositoriesMapping( - mapping=[RepoMapEntry(source='rhel7-optional', target=['rhel8-CRB'])], - repositories=[rhel7_optional_pesidrepo, rhel8_crb_pesidrepo] + mapping=[RepoMapEntry(source='rhel8-CRB', target=['rhel9-CRB'])], + repositories=[rhel8_crb_pesidrepo, rhel9_crb_pesidrepo] ) @@ -75,8 +75,8 @@ def test_all_target_optionals_blacklisted_when_no_optional_on_source(monkeypatch repos_data = [ RepositoryData( - repoid="rhel-7-server-rpms", - name="RHEL 7 Server", + repoid="rhel-8-server-rpms", + name="RHEL 8 Server", enabled=True, ) ] @@ -92,7 +92,7 @@ def test_all_target_optionals_blacklisted_when_no_optional_on_source(monkeypatch repositoriesblacklist.process() assert api.produce.called - assert 'codeready-builder-for-rhel-8-x86_64-rpms' in api.produce.model_instances[0].repoids + assert 'codeready-builder-for-rhel-9-x86_64-rpms' in api.produce.model_instances[0].repoids def test_with_no_mapping_for_optional_repos(monkeypatch, repomap_opts_only, repofacts_opts_disabled): @@ -115,7 +115,11 @@ def test_blacklist_produced_when_optional_repo_disabled(monkeypatch, repofacts_o Tests whether a correct blacklist is generated when there is disabled optional repo on the system. """ - monkeypatch.setattr(api, 'current_actor', CurrentActorMocked(msgs=[repofacts_opts_disabled, repomap_opts_only])) + monkeypatch.setattr( + api, + "current_actor", + CurrentActorMocked(msgs=[repofacts_opts_disabled, repomap_opts_only]), + ) monkeypatch.setattr(api, "produce", produce_mocked()) monkeypatch.setattr(reporting, "create_report", produce_mocked()) @@ -123,7 +127,7 @@ def test_blacklist_produced_when_optional_repo_disabled(monkeypatch, repofacts_o assert api.produce.model_instances, 'A blacklist should get generated.' - expected_blacklisted_repoid = 'codeready-builder-for-rhel-8-x86_64-rpms' + expected_blacklisted_repoid = 'codeready-builder-for-rhel-9-x86_64-rpms' err_msg = 'Blacklist does not contain expected repoid.' assert expected_blacklisted_repoid in api.produce.model_instances[0].repoids, err_msg @@ -166,8 +170,8 @@ def test_repositoriesblacklist_not_empty(monkeypatch, repofacts_opts_disabled, r def test_repositoriesblacklist_empty(monkeypatch, repofacts_opts_disabled, repomap_opts_only): """ - Tests whether nothing is produced if there are some disabled optional repos, but an empty blacklist is determined - from the repo mapping data. + Tests whether nothing is produced if there are some disabled optional + repos, but an empty blacklist is determined from the repo mapping data. """ msgs_to_feed = [repofacts_opts_disabled, repomap_opts_only] @@ -177,7 +181,7 @@ def test_repositoriesblacklist_empty(monkeypatch, repofacts_opts_disabled, repom repositoriesblacklist, "_get_repoids_to_exclude", lambda dummy_mapping: set() - ) # pylint:disable=W0108 + ) monkeypatch.setattr(api, "produce", produce_mocked()) repositoriesblacklist.process() @@ -187,7 +191,7 @@ def test_repositoriesblacklist_empty(monkeypatch, repofacts_opts_disabled, repom @pytest.mark.parametrize( ("enabled_repo", "exp_report_title", "message_produced"), [ - ("codeready-builder-for-rhel-8-x86_64-rpms", "Using repository not supported by Red Hat", False), + ("codeready-builder-for-rhel-9-x86_64-rpms", "Using repository not supported by Red Hat", False), ("some_other_enabled_repo", "Excluded target system repositories", True), (None, "Excluded target system repositories", True), ], -- 2.51.1