From 67f073e2b0ef68237927143c3cfa321ba54f4220 Mon Sep 17 00:00:00 2001 From: Jan Kaluza Date: Sep 03 2019 05:06:23 +0000 Subject: Return both Koji build NVRs and SRPM NVRs in the `Errata.get_builds()`. This fixes an issue when some SRPMs are not shipped by policy. In this case, those SRPMs would be missing from the `get_builds()` list. This commit simply combines Koji build NVRs with SRPM NVRs. For normal RPMs, these two values will match. For modules, the SRPM NVRs will contain the list of SRPMs included in a module. As a side-effect, the `get_builds()` will now contain also the list of module build NVRs, but this is not wrong, since module build is also Koji build and therefore it might be returned by `get_builds()`. --- diff --git a/freshmaker/errata.py b/freshmaker/errata.py index e87c2f5..c0df41b 100644 --- a/freshmaker/errata.py +++ b/freshmaker/errata.py @@ -311,6 +311,10 @@ class Errata(object): Returns set of NVRs of builds added to the advisory. These are just brew build NVRs, not the particular RPM NVRs. + If module build is attached to advisory, also all the NVRs of builds + included in this module build are returned, together with the NVR of + the module build. + :param number errata_id: ID of advisory. :param string rhel_release_prefix: When set to non-empty string, it will be used to limit the set of builds returned by this @@ -351,7 +355,16 @@ class Errata(object): product_version, rhel_release_prefix) continue for build in builds: - nvrs.update(get_srpms_nvrs(build)) + # Add attached Koji build NVRs. + nvrs.update(set(build.keys())) + + # Add attached SRPM NVRs. For normal RPM builds, these are the + # same as Koji build NVRs, but for modules, these are SRPMs + # included in a module. + srpm_nvrs = get_srpms_nvrs(build) + if srpm_nvrs: + nvrs.update(srpm_nvrs) + return nvrs def get_pulp_repository_ids(self, errata_id): diff --git a/tests/test_errata.py b/tests/test_errata.py index ec9a214..148b723 100644 --- a/tests/test_errata.py +++ b/tests/test_errata.py @@ -324,6 +324,25 @@ class TestErrata(helpers.FreshmakerTestCase): ret = self.errata.get_builds(28484, "RHEL-7") self.assertEqual(ret, set(['libntirpc-1.4.3-4.el7rhgs'])) + @patch.object(Errata, "_errata_rest_get") + @patch.object(Errata, "_errata_http_get") + def test_get_builds_no_srpm( + self, errata_http_get, errata_rest_get): + api = MockedErrataAPI(errata_rest_get, errata_http_get) + api.builds_json = { + "PRODUCT1": [ + { + "libntirpc-1.4.3-4.el7rhgs": + { + "PRODUCT2-3.2-NFS": + {"x86_64": ["libntirpc-devel-1.4.3-4.el7rhgs.x86_64.rpm"]} + } + } + ] + } + ret = self.errata.get_builds(28484, "") + self.assertEqual(ret, set(['libntirpc-1.4.3-4.el7rhgs'])) + def test_get_docker_repo_tags(self): with patch.object(self.errata, "xmlrpc") as xmlrpc: xmlrpc.get_advisory_cdn_docker_file_list.return_value = {