From 20c2e59218a87f1dfe8496334352b47e4c0eec39 Mon Sep 17 00:00:00 2001 From: Haibo Lin Date: Fri, 26 Nov 2021 12:03:03 +0800 Subject: [PATCH] Pass compose parameter for debugging git issue With this param, get_dir_from_scm will try to copy the tmp git dir to compose target dir when error occurs. This does not fix the issue but it would be helpful for debugging when it occurs again. JIRA: RHELCMP-7244 Signed-off-by: Haibo Lin --- pungi/phases/createrepo.py | 3 ++- tests/test_createrepophase.py | 30 ++++++++++++++++++++++++------ 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/pungi/phases/createrepo.py b/pungi/phases/createrepo.py index c299169f..3df030a4 100644 --- a/pungi/phases/createrepo.py +++ b/pungi/phases/createrepo.py @@ -81,6 +81,7 @@ class CreaterepoPhase(PhaseBase): get_dir_from_scm( self.compose.conf["createrepo_extra_modulemd"][variant.uid], self.compose.paths.work.tmp_dir(variant=variant, create_dir=False), + compose=self.compose, ) self.pool.queue_put((self.compose, None, variant, "srpm")) @@ -363,7 +364,7 @@ def get_productids_from_scm(compose): tmp_dir = compose.mkdtemp(prefix="pungi_") try: - get_dir_from_scm(product_id, tmp_dir) + get_dir_from_scm(product_id, tmp_dir, compose=compose) except OSError as e: if e.errno == errno.ENOENT and product_id_allow_missing: compose.log_warning("No product IDs in %s" % product_id) diff --git a/tests/test_createrepophase.py b/tests/test_createrepophase.py index 45c2c25c..aecff998 100644 --- a/tests/test_createrepophase.py +++ b/tests/test_createrepophase.py @@ -141,7 +141,13 @@ class TestCreaterepoPhase(PungiTestCase): self.assertEqual( get_dir_from_scm.call_args_list, - [mock.call(scm, os.path.join(compose.topdir, "work/global/tmp-Server"))], + [ + mock.call( + scm, + os.path.join(compose.topdir, "work/global/tmp-Server"), + compose=compose, + ) + ], ) @@ -1333,7 +1339,7 @@ class TestCreateVariantRepo(PungiTestCase): class TestGetProductIds(PungiTestCase): def mock_get(self, filenames): - def _mock_get(scm, dest): + def _mock_get(scm, dest, compose=None): for filename in filenames: touch(os.path.join(dest, filename)) @@ -1379,7 +1385,10 @@ class TestGetProductIds(PungiTestCase): get_productids_from_scm(self.compose) - self.assertEqual(get_dir_from_scm.call_args_list, [mock.call(cfg, mock.ANY)]) + self.assertEqual( + get_dir_from_scm.call_args_list, + [mock.call(cfg, mock.ANY, compose=self.compose)], + ) self.assertProductIds( { "Client": ["amd64"], @@ -1400,7 +1409,10 @@ class TestGetProductIds(PungiTestCase): get_productids_from_scm(self.compose) - self.assertEqual(get_dir_from_scm.call_args_list, [mock.call(cfg, mock.ANY)]) + self.assertEqual( + get_dir_from_scm.call_args_list, + [mock.call(cfg, mock.ANY, compose=self.compose)], + ) self.assertProductIds({"Server": ["amd64", "x86_64"]}) @mock.patch("pungi.phases.createrepo.get_dir_from_scm") @@ -1414,7 +1426,10 @@ class TestGetProductIds(PungiTestCase): with self.assertRaises(RuntimeError) as ctx: get_productids_from_scm(self.compose) - self.assertEqual(get_dir_from_scm.call_args_list, [mock.call(cfg, mock.ANY)]) + self.assertEqual( + get_dir_from_scm.call_args_list, + [mock.call(cfg, mock.ANY, compose=self.compose)], + ) self.assertRegex( str(ctx.exception), r"No product certificate found \(arch: amd64, variant: (Everything|Client)\)", # noqa: E501 @@ -1438,5 +1453,8 @@ class TestGetProductIds(PungiTestCase): with self.assertRaises(RuntimeError) as ctx: get_productids_from_scm(self.compose) - self.assertEqual(get_dir_from_scm.call_args_list, [mock.call(cfg, mock.ANY)]) + self.assertEqual( + get_dir_from_scm.call_args_list, + [mock.call(cfg, mock.ANY, compose=self.compose)], + ) self.assertRegex(str(ctx.exception), "Multiple product certificates found.+")