From f30174d9ba28454f0babd711db37972e84ddb57f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hozza?= Date: Mon, 19 May 2025 13:05:45 +0200 Subject: [PATCH] Test/stages/rpm: add compatibility with RPM 6.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RPM 6.0 (landed in F43, current rawhide), no longer uses short key ID for the 'gpg-pubkey' pseudo-package, but to prevent any collision, it uses full key ID. This means that we can't consistently just compare the pipeline rpm stage metadata from the test data with what we get from building the test manifest. The reason is that we need to keep running the unit test in upstream and downstream CI pipelines for OSes, which may ship RPM 6.0, but also older RPM version. Extend the test case to do a special case check for any 'gpg-pubkey' package in the metadata if the package version length differs between the test data and data got from building the manifest. Signed-off-by: Tomáš Hozza --- test/run/test_stages.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/test/run/test_stages.py b/test/run/test_stages.py index 7950313b..9b82b38f 100644 --- a/test/run/test_stages.py +++ b/test/run/test_stages.py @@ -246,6 +246,35 @@ class TestStages(test.TestBase): with open(md_path, "r", encoding="utf8") as f: metadata = json.load(f) + # NB: RPM 6.0 (on F43+) no longer uses short key ids to identify imported GPG keys. + # This means that the gpg-pubkey pseudo-package version differs with RPM 6 vs. older RPM version. + # https://fedoraproject.org/wiki/Changes/RPM-6.0 + for pipeline in metadata: + self.assertIn(pipeline, res["metadata"]) + test_rpm_pkgs_md = metadata[pipeline]["org.osbuild.rpm"]["packages"] + got_rpm_pkgs_md = res["metadata"][pipeline]["org.osbuild.rpm"]["packages"] + + # Iterate over the metadata and do a special check of the 'gpg-pubkey' package + # if it is present and the version is has different length (short key id vs. full key id) + for test_pkg, got_pkg in zip(test_rpm_pkgs_md, got_rpm_pkgs_md): + self.assertEqual(test_pkg["name"], got_pkg["name"]) + if test_pkg["name"] != "gpg-pubkey": + continue + if len(test_pkg["version"]) == len(got_pkg["version"]): + continue + + test_pkg_version = test_pkg.pop("version") + got_pkg_version = got_pkg.pop("version") + # Ensure that the remaining fields are equal + self.assertEqual(test_pkg, got_pkg) + # Check that the shorter version (the short key id) is a suffix of the longer version. + # Check both ways, since we may eventually use the full key id in the test data, while + # still running the test with an older RPM version (i.e. on RHEL). + if len(test_pkg_version) > len(got_pkg_version): + assert test_pkg_version.endswith(got_pkg_version) + else: + assert got_pkg_version.endswith(test_pkg_version) + self.assertEqual(metadata, res["metadata"]) # cache the downloaded data for the sources by copying