diff --git a/backend/copr-backend.spec b/backend/copr-backend.spec index a75ba78f6..0379ea647 100644 --- a/backend/copr-backend.spec +++ b/backend/copr-backend.spec @@ -56,6 +56,7 @@ BuildRequires: python3-retask BuildRequires: python3-setproctitle BuildRequires: python3-sphinx BuildRequires: python3-tabulate +BuildRequires: python3-zstandard BuildRequires: modulemd-tools >= 0.6 BuildRequires: prunerepo >= %prunerepo_version BuildRequires: dnf diff --git a/backend/tests/test_modifyrepo.py b/backend/tests/test_modifyrepo.py index b6215aaca..16e50b0e9 100644 --- a/backend/tests/test_modifyrepo.py +++ b/backend/tests/test_modifyrepo.py @@ -547,7 +547,11 @@ def test_comps_present(self, f_third_build): pass assert call_copr_repo(chrootdir) - name = glob.glob(os.path.join(chrootdir, "repodata", "*-comps.xml.gz")) + + f39 = distro.id() == "fedora" and int(distro.version()) >= 39 + compression = "zst" if f39 else "gz" + pattern = "*-comps.xml.{0}".format(compression) + name = glob.glob(os.path.join(chrootdir, "repodata", pattern)) assert os.path.exists(name[0]) diff --git a/backend/tests/testlib/repodata.py b/backend/tests/testlib/repodata.py index b150d7a66..4adbce07e 100644 --- a/backend/tests/testlib/repodata.py +++ b/backend/tests/testlib/repodata.py @@ -6,6 +6,7 @@ import glob import gzip from xml.dom import minidom +from zstandard import ZstdDecompressor def load_primary_xml(dirname): ''' @@ -16,8 +17,7 @@ def load_primary_xml(dirname): hrefs = set() names = set() primary = glob.glob(os.path.join(dirname, '*primary*xml*'))[0] - with gzip.open(primary) as fprimary: - xml_content = fprimary.read() + xml_content = extract(primary) dom = minidom.parseString(xml_content) @@ -36,3 +36,14 @@ def load_primary_xml(dirname): 'hrefs': hrefs, 'names': names, } + +def extract(path): + if path.endswith(".zst"): + with open(path, "rb") as fp: + decompressor = ZstdDecompressor() + return decompressor.stream_reader(fp).read() + + if path.endswith(".gz"): + with gzip.open(path) as fp: + return fp.read() + raise ValueError("Unexpected extension: {0}".format(path))