From ed86a2ca728fda54e099b310bc84c7a4ca86ae3c Mon Sep 17 00:00:00 2001 From: Brendan Reilly Date: Nov 11 2020 21:03:52 +0000 Subject: Do not add conflicts when builds are identical Fixes: #1660 --- diff --git a/module_build_service/scheduler/default_modules.py b/module_build_service/scheduler/default_modules.py index 4061201..8194006 100644 --- a/module_build_service/scheduler/default_modules.py +++ b/module_build_service/scheduler/default_modules.py @@ -275,7 +275,10 @@ def handle_collisions_with_base_module_rpms(mmd, arches): for rpm in non_bm_rpms: rpm_name = kobo.rpmlib.parse_nvra(rpm)["name"] if rpm_name in name_to_nevras: - conflicts = conflicts | name_to_nevras[rpm_name] + # Do not add conflicts for identical NEVRAs + nevras = {n for n in name_to_nevras[rpm_name] if n not in non_bm_rpms} + if nevras: + conflicts = conflicts | nevras # Add the conflicting NEVRAs to `ursine_rpms` so the Conflicts are later generated for them # in the KojiModuleBuilder. diff --git a/tests/test_scheduler/test_default_modules.py b/tests/test_scheduler/test_default_modules.py index 92fef87..90fbf78 100644 --- a/tests/test_scheduler/test_default_modules.py +++ b/tests/test_scheduler/test_default_modules.py @@ -314,6 +314,54 @@ def test_handle_collisions_with_base_module_rpms(mock_grft, mock_get_session): assert second_call[2] == ["aarch64", "x86_64"] +@patch("module_build_service.scheduler.default_modules.get_session") +@patch("module_build_service.scheduler.default_modules._get_rpms_from_tags") +def test_handle_collisions_with_same_rpms(mock_grft, mock_get_session): + """ + Test that handle_collisions_with_base_module_rpms will not add conflicts if the nevras + are the same. + """ + mmd = load_mmd(read_staged_data("formatted_testmodule.yaml")) + xmd = mmd.get_xmd() + xmd["mbs"]["buildrequires"]["platform"]["koji_tag"] = "module-el-build" + xmd["mbs"]["buildrequires"]["python"] = {"koji_tag": "module-python27"} + xmd["mbs"]["buildrequires"]["bash"] = {"koji_tag": "module-bash"} + mmd.set_xmd(xmd) + + bm_rpms = { + "bash-completion-1:2.7-5.el8.noarch", + "bash-0:4.4.19-7.el8.aarch64", + "python2-tools-0:2.7.18-1.module+el8.1.0+3568+bbd875cb.aarch64", + "python2-tools-0:2.7.18-1.module+el8.1.0+3568+bbd875cb.x86_64", + } + non_bm_rpms = { + "bash-0:4.4.20-1.el8.aarch64", + "python2-tools-0:2.7.18-1.module+el8.1.0+3568+bbd875cb.aarch64", + "python2-tools-0:2.7.18-1.module+el8.1.0+3568+bbd875cb.x86_64", + } + mock_grft.side_effect = [bm_rpms, non_bm_rpms] + + default_modules.handle_collisions_with_base_module_rpms(mmd, ["aarch64", "x86_64"]) + + mock_get_session.assert_called_once() + xmd_mbs = mmd.get_xmd()["mbs"] + assert set(xmd_mbs["ursine_rpms"]) == { + "bash-0:4.4.19-7.el8.aarch64", + } + assert mock_grft.call_count == 2 + # We can't check the calls directly because the second argument is a set converted to a list, + # so the order can't be determined ahead of time. + first_call = mock_grft.mock_calls[0][1] + assert first_call[0] == mock_get_session.return_value + assert first_call[1] == ["module-el-build"] + assert first_call[2] == ["aarch64", "x86_64"] + + second_call = mock_grft.mock_calls[1][1] + assert second_call[0] == mock_get_session.return_value + assert set(second_call[1]) == {"module-bash", "module-python27"} + assert second_call[2] == ["aarch64", "x86_64"] + + @patch("module_build_service.scheduler.default_modules.koji_retrying_multicall_map") @patch("module_build_service.scheduler.default_modules._get_rpms_in_external_repo") def test_get_rpms_from_tags(mock_grier, mock_multicall_map):