From 1086e725efffde7fbfe2bf3a190f7ed6cdf8f352 Mon Sep 17 00:00:00 2001 From: Jan Kaluza Date: Mar 01 2022 06:16:20 +0000 Subject: Fix tests, do not depend on kobo.rpmlib, build unsigned compose by default. Signed-off-by: Jan Kaluza --- diff --git a/cccc/cli.py b/cccc/cli.py index a2ff8c9..c921ebb 100644 --- a/cccc/cli.py +++ b/cccc/cli.py @@ -139,6 +139,7 @@ def _merge_updated_config(conf, args, merged_dir, scratch_dir): p.set_variants_file(conf["variants_file"]) # Override prepopulate so it points to updated file. p.set_prepopulate_file(conf["prepopulate_file"]) + p.set_unsigned_compose(conf["unsigned_compose"]) p.disable_cts() # write the updated pungi config file with the file name expected by ODCS diff --git a/cccc/compose.py b/cccc/compose.py index 21e162f..578cc7a 100644 --- a/cccc/compose.py +++ b/cccc/compose.py @@ -6,7 +6,6 @@ import json import os import tempfile import shutil -import kobo.rpmlib import requests import odcs.client.odcs @@ -154,7 +153,7 @@ def print_affected_ssts(conf, diff_rpms_brief_path): srpm_names = set() for rpms in data.values(): for rpm_data in rpms.values(): - srpm_name = kobo.rpmlib.parse_nvra(rpm_data["srpm_nevra"])["name"] + srpm_name = rpm_data["srpm_nevra"].rsplit("-", 2)[0] srpm_names.add(srpm_name) bugzilla_request = { diff --git a/cccc/config.py b/cccc/config.py index 6d71d77..773fe0c 100644 --- a/cccc/config.py +++ b/cccc/config.py @@ -25,6 +25,7 @@ _DefaultConfig = { "bugzilla_api_key_file": "", "variants_file": "variants.xml", "prepopulate_file": "prepopulate.json", + "unsigned_compose": True, } _RHELConfiguration = { diff --git a/cccc/pungi.py b/cccc/pungi.py index 3b4ead7..a38d75e 100644 --- a/cccc/pungi.py +++ b/cccc/pungi.py @@ -187,3 +187,14 @@ class PungiConfig(object): :return: None """ self.conf["gather_prepopulate"] = prepopulate_file + + def set_unsigned_compose(self, unsigned_compose): + """ + Configure the compose to take unsigned version of RPMs. + + :return: None + """ + if unsigned_compose: + self.conf["sigkeys"] = [None] + self.conf["signed_packages_wait"] = 0 + self.conf["signed_packages_retries"] = 0 diff --git a/requirements.txt b/requirements.txt index 53704c7..de51f77 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,5 @@ kobo odcs[client] openidc_client -kobo koji -rpm # compose-utils diff --git a/tests/test_cli.py b/tests/test_cli.py index 9ab64b3..ef6c442 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -129,9 +129,11 @@ class TestCLI(unittest.TestCase): @patch("cccc.git.commit_all") @patch("cccc.git.new_empty_branch") @patch("cccc.git.clone_repo") + @patch("cccc.cli.time.sleep") def test_cli(self, testcase_name, pr_pungi_repo, pr_comps_repo, pr_mod_defaults_repo, tree_arches, skip_phases, + mock_sleep, mock_git_clone, mock_git_newbranch, mock_git_commit, diff --git a/tests/test_compose.py b/tests/test_compose.py index 09b7284..1f9c6cb 100644 --- a/tests/test_compose.py +++ b/tests/test_compose.py @@ -124,4 +124,4 @@ class TestCompose(unittest.TestCase): " - sst_1\n" " - sst_2" ) - self.assertEqual(expected_output, output) + self.assertTrue(expected_output in output) diff --git a/tests/test_config.py b/tests/test_config.py index e7a0228..55e0e28 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -28,7 +28,9 @@ DEFAULT_DEFAULTS = { "bugzilla_jsonrpc_url": "https://bugzilla.redhat.com/jsonrpc.cgi", "bugzilla_product": "", "bugzilla_api_key_file": "", - "variants_file": "variants.xml" + "variants_file": "variants.xml", + "prepopulate_file": "prepopulate.json", + "unsigned_compose": True, } diff --git a/tests/test_utils.py b/tests/test_utils.py index 6434145..156d92e 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -40,8 +40,13 @@ class TestUtilsExecuteCmd(unittest.TestCase): execute_cmd(["/usr/bin/printenv", "mY_RanDoM_EnV_varblE"], stdout=sys.stdout, env=dict(mY_RanDoM_EnV_varblE="RanDoM_vAl")) output = sys.stdout.getvalue() - self.assertEqual("RanDoM_vAl", output.rstrip()) + expected_output = """Executing: ['/usr/bin/printenv', 'mY_RanDoM_EnV_varblE'] +cwd: None +RanDoM_vAl +RanDoM_vAl""" + + self.assertEqual(expected_output, output.rstrip()) with self.assertRaisesRegex( RuntimeError, "Command .* returned non-zero value .*"): execute_cmd(["/usr/bin/printenv", "mY_RanDoM_EnV_varblE"])