From fdfaae8b711f3861f8139070a3d4537643c03157 Mon Sep 17 00:00:00 2001 From: Jan Kaluza Date: Mon, 6 Apr 2020 09:43:16 +0200 Subject: [PATCH] Allow gather phase reuse on `product_id` change. I've analysed multiple nigthly composes and often the only difference in the configuration between two nightly composes is different `product_id` commit hash. The `product_id` is used in later `createrepo` phase and does not influence the gather phase at all. I therefore think it can be whitelisted in gather phase reuse code. Signed-off-by: Jan Kaluza --- pungi/phases/gather/__init__.py | 7 +++++++ tests/test_gather_phase.py | 22 ++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/pungi/phases/gather/__init__.py b/pungi/phases/gather/__init__.py index f4baa5fd..348cee7e 100644 --- a/pungi/phases/gather/__init__.py +++ b/pungi/phases/gather/__init__.py @@ -251,6 +251,13 @@ def reuse_old_gather_packages(compose, arch, variant, package_sets): ) return continue + + # Skip checking for frequently changing configuration options which do *not* + # influence Gather phase. + config_whitelist = ["product_id"] + if opt in config_whitelist: + continue + if opt not in config or config[opt] != value: compose.log_info( log_msg % ("compose configuration option %s changed." % opt) diff --git a/tests/test_gather_phase.py b/tests/test_gather_phase.py index 2df55bce..4029fe84 100644 --- a/tests/test_gather_phase.py +++ b/tests/test_gather_phase.py @@ -1173,6 +1173,28 @@ class TestReuseOldGatherPackages(helpers.PungiTestCase): ) self.assertEqual(result, None) + @mock.patch("pungi.phases.gather.load_old_gather_result") + @mock.patch("pungi.phases.gather.load_old_compose_config") + def test_reuse_compose_config_different_whitelist( + self, load_old_compose_config, load_old_gather_result + ): + for whitelist_opt in ["product_id"]: + load_old_gather_result.return_value = { + "rpm": [{"path": "/build/bash-1.0.0-1.x86_64.rpm"}], + "srpm": [], + "debuginfo": [], + } + + compose = helpers.DummyCompose(self.topdir, {"gather_allow_reuse": True}) + compose_conf_copy = dict(compose.conf) + compose_conf_copy[whitelist_opt] = "different" + load_old_compose_config.return_value = compose_conf_copy + + result = gather.reuse_old_gather_packages( + compose, "x86_64", compose.variants["Server"], [] + ) + self.assertEqual(result, {"rpm": [], "srpm": [], "debuginfo": []}) + def _prepare_package_sets( self, load_old_gather_result, extra_global_pkgs=None, **kwargs ):