2016-02-29 08:21:49 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2016-05-25 11:39:02 +00:00
|
|
|
try:
|
|
|
|
import unittest2 as unittest
|
|
|
|
except ImportError:
|
|
|
|
import unittest
|
2016-02-29 08:21:49 +00:00
|
|
|
|
2016-11-23 08:54:34 +00:00
|
|
|
import glob
|
2016-02-29 08:21:49 +00:00
|
|
|
import os
|
2021-08-30 07:41:37 +00:00
|
|
|
|
|
|
|
import mock
|
2019-10-04 12:45:03 +00:00
|
|
|
import six
|
2016-02-29 08:21:49 +00:00
|
|
|
|
2021-08-30 07:41:37 +00:00
|
|
|
from pungi.module_util import Modulemd
|
2020-01-22 10:02:22 +00:00
|
|
|
from pungi.phases.createrepo import (
|
|
|
|
CreaterepoPhase,
|
2021-08-30 07:41:37 +00:00
|
|
|
ModulesMetadata,
|
2020-01-22 10:02:22 +00:00
|
|
|
create_variant_repo,
|
|
|
|
get_productids_from_scm,
|
|
|
|
)
|
2016-02-29 11:58:21 +00:00
|
|
|
from tests.helpers import DummyCompose, PungiTestCase, copy_fixture, touch
|
2018-03-15 12:31:58 +00:00
|
|
|
|
2016-02-29 08:21:49 +00:00
|
|
|
|
|
|
|
class TestCreaterepoPhase(PungiTestCase):
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.phases.createrepo.ThreadPool")
|
2017-08-29 12:26:57 +00:00
|
|
|
def test_validates_without_option(self, ThreadPoolCls):
|
2020-01-22 10:02:22 +00:00
|
|
|
compose = DummyCompose(self.topdir, {"createrepo_checksum": "sha256"})
|
2017-08-29 12:26:57 +00:00
|
|
|
|
|
|
|
phase = CreaterepoPhase(compose)
|
|
|
|
try:
|
|
|
|
phase.validate()
|
|
|
|
except ValueError:
|
2020-01-22 10:02:22 +00:00
|
|
|
self.fail("Missing delta config should not fail validation")
|
2017-08-29 12:26:57 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.phases.createrepo.ThreadPool")
|
2016-02-29 11:58:21 +00:00
|
|
|
def test_fails_deltas_without_old_compose(self, ThreadPoolCls):
|
2020-01-22 10:02:22 +00:00
|
|
|
compose = DummyCompose(
|
|
|
|
self.topdir, {"createrepo_checksum": "sha256", "createrepo_deltas": True}
|
|
|
|
)
|
2016-02-29 11:58:21 +00:00
|
|
|
|
|
|
|
phase = CreaterepoPhase(compose)
|
|
|
|
with self.assertRaises(ValueError) as ctx:
|
|
|
|
phase.validate()
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertIn("deltas", str(ctx.exception))
|
2016-02-29 08:21:49 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.phases.createrepo.ThreadPool")
|
2017-08-29 12:26:57 +00:00
|
|
|
def test_fails_deltas_without_old_compose_granular_config(self, ThreadPoolCls):
|
2020-01-22 10:02:22 +00:00
|
|
|
compose = DummyCompose(
|
|
|
|
self.topdir,
|
|
|
|
{
|
|
|
|
"createrepo_checksum": "sha256",
|
|
|
|
"createrepo_deltas": [("^Everything$", {"*": True})],
|
|
|
|
},
|
|
|
|
)
|
2017-08-29 12:26:57 +00:00
|
|
|
|
|
|
|
phase = CreaterepoPhase(compose)
|
|
|
|
with self.assertRaises(ValueError) as ctx:
|
|
|
|
phase.validate()
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertIn("deltas", str(ctx.exception))
|
2017-08-29 12:26:57 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.checks.get_num_cpus")
|
|
|
|
@mock.patch("pungi.phases.createrepo.ThreadPool")
|
2017-10-03 13:09:53 +00:00
|
|
|
def test_starts_jobs(self, ThreadPoolCls, get_num_cpus):
|
|
|
|
get_num_cpus.return_value = 5
|
2016-02-29 08:21:49 +00:00
|
|
|
compose = DummyCompose(self.topdir, {})
|
|
|
|
|
|
|
|
pool = ThreadPoolCls.return_value
|
|
|
|
|
|
|
|
phase = CreaterepoPhase(compose)
|
|
|
|
phase.run()
|
|
|
|
|
2019-08-01 10:51:52 +00:00
|
|
|
server = compose.variants["Server"]
|
|
|
|
everything = compose.variants["Everything"]
|
|
|
|
client = compose.variants["Client"]
|
2017-10-03 13:09:53 +00:00
|
|
|
self.assertEqual(len(pool.add.mock_calls), 5)
|
2019-10-04 12:45:03 +00:00
|
|
|
six.assertCountEqual(
|
|
|
|
self,
|
2016-02-29 08:21:49 +00:00
|
|
|
pool.queue_put.mock_calls,
|
2019-08-01 10:51:52 +00:00
|
|
|
[
|
|
|
|
mock.call((compose, "x86_64", server, "rpm")),
|
|
|
|
mock.call((compose, "x86_64", server, "debuginfo")),
|
|
|
|
mock.call((compose, "amd64", server, "rpm")),
|
|
|
|
mock.call((compose, "amd64", server, "debuginfo")),
|
|
|
|
mock.call((compose, None, server, "srpm")),
|
|
|
|
mock.call((compose, "x86_64", everything, "rpm")),
|
|
|
|
mock.call((compose, "x86_64", everything, "debuginfo")),
|
|
|
|
mock.call((compose, "amd64", everything, "rpm")),
|
|
|
|
mock.call((compose, "amd64", everything, "debuginfo")),
|
|
|
|
mock.call((compose, None, everything, "srpm")),
|
|
|
|
mock.call((compose, "amd64", client, "rpm")),
|
|
|
|
mock.call((compose, "amd64", client, "debuginfo")),
|
|
|
|
mock.call((compose, None, client, "srpm")),
|
|
|
|
],
|
|
|
|
)
|
2016-02-29 08:21:49 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.checks.get_num_cpus")
|
|
|
|
@mock.patch("pungi.phases.createrepo.ThreadPool")
|
2017-10-03 13:09:53 +00:00
|
|
|
def test_skips_empty_variants(self, ThreadPoolCls, get_num_cpus):
|
|
|
|
get_num_cpus.return_value = 5
|
2016-02-29 08:21:49 +00:00
|
|
|
compose = DummyCompose(self.topdir, {})
|
2020-01-22 10:02:22 +00:00
|
|
|
compose.variants["Client"].is_empty = True
|
2016-02-29 08:21:49 +00:00
|
|
|
|
|
|
|
pool = ThreadPoolCls.return_value
|
|
|
|
|
|
|
|
phase = CreaterepoPhase(compose)
|
|
|
|
phase.run()
|
|
|
|
self.maxDiff = None
|
|
|
|
|
2019-08-01 10:51:52 +00:00
|
|
|
server = compose.variants["Server"]
|
|
|
|
everything = compose.variants["Everything"]
|
2017-10-03 13:09:53 +00:00
|
|
|
self.assertEqual(len(pool.add.mock_calls), 5)
|
2019-10-04 12:45:03 +00:00
|
|
|
six.assertCountEqual(
|
|
|
|
self,
|
2016-02-29 08:21:49 +00:00
|
|
|
pool.queue_put.mock_calls,
|
2019-08-01 10:51:52 +00:00
|
|
|
[
|
|
|
|
mock.call((compose, "x86_64", server, "rpm")),
|
|
|
|
mock.call((compose, "x86_64", server, "debuginfo")),
|
|
|
|
mock.call((compose, "amd64", server, "rpm")),
|
|
|
|
mock.call((compose, "amd64", server, "debuginfo")),
|
|
|
|
mock.call((compose, None, server, "srpm")),
|
|
|
|
mock.call((compose, "x86_64", everything, "rpm")),
|
|
|
|
mock.call((compose, "x86_64", everything, "debuginfo")),
|
|
|
|
mock.call((compose, "amd64", everything, "rpm")),
|
|
|
|
mock.call((compose, "amd64", everything, "debuginfo")),
|
|
|
|
mock.call((compose, None, everything, "srpm")),
|
|
|
|
],
|
|
|
|
)
|
2016-02-29 08:21:49 +00:00
|
|
|
|
2020-06-08 12:52:57 +00:00
|
|
|
@mock.patch("pungi.phases.createrepo.get_dir_from_scm")
|
|
|
|
@mock.patch("pungi.phases.createrepo.ThreadPool")
|
|
|
|
def test_clones_extra_modulemd(self, ThreadPoolCls, get_dir_from_scm):
|
|
|
|
scm = mock.Mock()
|
|
|
|
compose = DummyCompose(
|
|
|
|
self.topdir, {"createrepo_extra_modulemd": {"Server": scm}}
|
|
|
|
)
|
|
|
|
|
|
|
|
phase = CreaterepoPhase(compose)
|
|
|
|
phase.run()
|
|
|
|
|
|
|
|
self.assertEqual(
|
|
|
|
get_dir_from_scm.call_args_list,
|
|
|
|
[mock.call(scm, os.path.join(compose.topdir, "work/global/tmp-Server"))],
|
|
|
|
)
|
|
|
|
|
2016-02-29 08:21:49 +00:00
|
|
|
|
2019-07-01 10:11:39 +00:00
|
|
|
def make_mocked_modifyrepo_cmd(tc, module_artifacts):
|
|
|
|
def mocked_modifyrepo_cmd(repodir, mmd_path, **kwargs):
|
|
|
|
mod_index = Modulemd.ModuleIndex.new()
|
|
|
|
mod_index.update_from_file(mmd_path, strict=True)
|
|
|
|
|
|
|
|
tc.assertEqual(len(mod_index.get_module_names()), 1)
|
|
|
|
|
|
|
|
module = mod_index.get_module("test")
|
|
|
|
module_streams = module.get_all_streams()
|
|
|
|
tc.assertEqual(len(module_streams), len(module_artifacts))
|
|
|
|
for ms in module_streams:
|
|
|
|
tc.assertIn(ms.get_stream_name(), module_artifacts)
|
2019-10-04 12:45:03 +00:00
|
|
|
six.assertCountEqual(
|
2021-03-02 10:19:05 +00:00
|
|
|
tc,
|
|
|
|
ms.get_rpm_artifacts(),
|
|
|
|
module_artifacts[ms.get_stream_name()],
|
2019-07-01 10:11:39 +00:00
|
|
|
)
|
2020-01-22 10:02:22 +00:00
|
|
|
|
2019-07-01 10:11:39 +00:00
|
|
|
return mocked_modifyrepo_cmd
|
|
|
|
|
|
|
|
|
2016-11-23 09:23:30 +00:00
|
|
|
class TestCreateVariantRepo(PungiTestCase):
|
2019-08-01 10:51:52 +00:00
|
|
|
def setUp(self):
|
|
|
|
super(TestCreateVariantRepo, self).setUp()
|
|
|
|
self.pkgset = mock.Mock(
|
|
|
|
paths={"x86_64": "/repo/x86_64", "global": "/repo/global"}
|
|
|
|
)
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.phases.createrepo.run")
|
|
|
|
@mock.patch("pungi.phases.createrepo.CreaterepoWrapper")
|
2016-02-29 08:21:49 +00:00
|
|
|
def test_variant_repo_rpms(self, CreaterepoWrapperCls, run):
|
2021-07-21 10:16:03 +00:00
|
|
|
compose = DummyCompose(
|
|
|
|
self.topdir,
|
|
|
|
{"createrepo_checksum": "sha256"},
|
|
|
|
)
|
2016-02-29 08:21:49 +00:00
|
|
|
compose.has_comps = False
|
|
|
|
|
|
|
|
repo = CreaterepoWrapperCls.return_value
|
2020-01-22 10:02:22 +00:00
|
|
|
copy_fixture("server-rpms.json", compose.paths.compose.metadata("rpms.json"))
|
2016-02-29 08:21:49 +00:00
|
|
|
|
2021-08-30 07:41:37 +00:00
|
|
|
with mock.patch("pungi.phases.createrepo.CACHE_TOPDIR", self.topdir):
|
|
|
|
create_variant_repo(
|
|
|
|
compose, "x86_64", compose.variants["Server"], "rpm", self.pkgset
|
|
|
|
)
|
2016-02-29 08:21:49 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
list_file = (
|
|
|
|
self.topdir + "/work/x86_64/repo_package_list/Server.x86_64.rpm.conf"
|
|
|
|
)
|
2021-08-30 07:41:37 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertEqual(
|
|
|
|
CreaterepoWrapperCls.mock_calls[0], mock.call(createrepo_c=True)
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(
|
2016-02-29 08:21:49 +00:00
|
|
|
repo.get_createrepo_cmd.mock_calls,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
self.topdir + "/compose/Server/x86_64/os",
|
|
|
|
checksum="sha256",
|
|
|
|
database=True,
|
|
|
|
groupfile=None,
|
|
|
|
workers=3,
|
|
|
|
outputdir=self.topdir + "/compose/Server/x86_64/os",
|
|
|
|
pkglist=list_file,
|
|
|
|
skip_stat=True,
|
|
|
|
update=True,
|
|
|
|
update_md_path="/repo/x86_64",
|
|
|
|
deltas=False,
|
|
|
|
oldpackagedirs=None,
|
|
|
|
use_xz=False,
|
|
|
|
extra_args=[],
|
2021-07-21 10:16:03 +00:00
|
|
|
cachedir=os.path.join(
|
2021-08-30 07:41:37 +00:00
|
|
|
self.topdir,
|
2021-07-21 10:16:03 +00:00
|
|
|
"%s-%s" % (compose.conf["release_short"], os.getuid()),
|
|
|
|
),
|
2020-01-22 10:02:22 +00:00
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(repo.get_modifyrepo_cmd.mock_calls, [])
|
2019-10-04 13:10:14 +00:00
|
|
|
self.assertFileContent(list_file, "Packages/b/bash-4.3.30-2.fc21.x86_64.rpm\n")
|
2016-02-29 08:21:49 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.phases.createrepo.run")
|
|
|
|
@mock.patch("pungi.phases.createrepo.CreaterepoWrapper")
|
2018-05-18 08:17:41 +00:00
|
|
|
def test_variant_repo_rpms_without_database(self, CreaterepoWrapperCls, run):
|
2021-07-21 10:16:03 +00:00
|
|
|
compose = DummyCompose(
|
|
|
|
self.topdir,
|
|
|
|
{"createrepo_checksum": "sha256", "createrepo_enable_cache": False},
|
|
|
|
)
|
2018-05-18 08:17:41 +00:00
|
|
|
compose.should_create_yum_database = False
|
|
|
|
compose.has_comps = False
|
|
|
|
|
|
|
|
repo = CreaterepoWrapperCls.return_value
|
2020-01-22 10:02:22 +00:00
|
|
|
copy_fixture("server-rpms.json", compose.paths.compose.metadata("rpms.json"))
|
2018-05-18 08:17:41 +00:00
|
|
|
|
2019-08-01 10:51:52 +00:00
|
|
|
create_variant_repo(
|
|
|
|
compose, "x86_64", compose.variants["Server"], "rpm", self.pkgset
|
|
|
|
)
|
2018-05-18 08:17:41 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
list_file = (
|
|
|
|
self.topdir + "/work/x86_64/repo_package_list/Server.x86_64.rpm.conf"
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
CreaterepoWrapperCls.mock_calls[0], mock.call(createrepo_c=True)
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(
|
2018-05-18 08:17:41 +00:00
|
|
|
repo.get_createrepo_cmd.mock_calls,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
self.topdir + "/compose/Server/x86_64/os",
|
|
|
|
checksum="sha256",
|
|
|
|
database=False,
|
|
|
|
groupfile=None,
|
|
|
|
workers=3,
|
|
|
|
outputdir=self.topdir + "/compose/Server/x86_64/os",
|
|
|
|
pkglist=list_file,
|
|
|
|
skip_stat=True,
|
|
|
|
update=True,
|
|
|
|
update_md_path="/repo/x86_64",
|
|
|
|
deltas=False,
|
|
|
|
oldpackagedirs=None,
|
|
|
|
use_xz=False,
|
|
|
|
extra_args=[],
|
2021-07-21 10:16:03 +00:00
|
|
|
cachedir=None,
|
2020-01-22 10:02:22 +00:00
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(repo.get_modifyrepo_cmd.mock_calls, [])
|
2019-10-04 13:10:14 +00:00
|
|
|
self.assertFileContent(list_file, "Packages/b/bash-4.3.30-2.fc21.x86_64.rpm\n")
|
2018-05-18 08:17:41 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.phases.createrepo.run")
|
|
|
|
@mock.patch("pungi.phases.createrepo.CreaterepoWrapper")
|
2016-02-29 08:21:49 +00:00
|
|
|
def test_variant_repo_source(self, CreaterepoWrapperCls, run):
|
2021-07-21 10:16:03 +00:00
|
|
|
compose = DummyCompose(
|
|
|
|
self.topdir,
|
|
|
|
{"createrepo_checksum": "sha256", "createrepo_enable_cache": False},
|
|
|
|
)
|
2016-02-29 08:21:49 +00:00
|
|
|
compose.has_comps = False
|
|
|
|
|
|
|
|
repo = CreaterepoWrapperCls.return_value
|
2020-01-22 10:02:22 +00:00
|
|
|
copy_fixture("server-rpms.json", compose.paths.compose.metadata("rpms.json"))
|
2016-02-29 08:21:49 +00:00
|
|
|
|
2019-08-01 10:51:52 +00:00
|
|
|
create_variant_repo(
|
|
|
|
compose, None, compose.variants["Server"], "srpm", self.pkgset
|
|
|
|
)
|
2016-02-29 08:21:49 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
list_file = self.topdir + "/work/global/repo_package_list/Server.None.srpm.conf"
|
|
|
|
self.assertEqual(
|
|
|
|
CreaterepoWrapperCls.mock_calls[0], mock.call(createrepo_c=True)
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(
|
2016-02-29 08:21:49 +00:00
|
|
|
repo.get_createrepo_cmd.mock_calls,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
self.topdir + "/compose/Server/source/tree",
|
|
|
|
checksum="sha256",
|
|
|
|
database=True,
|
|
|
|
groupfile=None,
|
|
|
|
workers=3,
|
|
|
|
outputdir=self.topdir + "/compose/Server/source/tree",
|
|
|
|
pkglist=list_file,
|
|
|
|
skip_stat=True,
|
|
|
|
update=True,
|
|
|
|
update_md_path="/repo/global",
|
|
|
|
deltas=False,
|
|
|
|
oldpackagedirs=None,
|
|
|
|
use_xz=False,
|
|
|
|
extra_args=[],
|
2021-07-21 10:16:03 +00:00
|
|
|
cachedir=None,
|
2020-01-22 10:02:22 +00:00
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(repo.get_modifyrepo_cmd.mock_calls, [])
|
2019-10-04 13:10:14 +00:00
|
|
|
self.assertFileContent(list_file, "Packages/b/bash-4.3.30-2.fc21.src.rpm\n")
|
2016-02-29 08:21:49 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.phases.createrepo.run")
|
|
|
|
@mock.patch("pungi.phases.createrepo.CreaterepoWrapper")
|
2016-02-29 08:21:49 +00:00
|
|
|
def test_variant_repo_debug(self, CreaterepoWrapperCls, run):
|
2021-07-21 10:16:03 +00:00
|
|
|
compose = DummyCompose(
|
|
|
|
self.topdir,
|
|
|
|
{"createrepo_checksum": "sha256", "createrepo_enable_cache": False},
|
|
|
|
)
|
2016-02-29 08:21:49 +00:00
|
|
|
compose.has_comps = False
|
|
|
|
|
|
|
|
repo = CreaterepoWrapperCls.return_value
|
2020-01-22 10:02:22 +00:00
|
|
|
copy_fixture("server-rpms.json", compose.paths.compose.metadata("rpms.json"))
|
2016-02-29 08:21:49 +00:00
|
|
|
|
2019-08-01 10:51:52 +00:00
|
|
|
create_variant_repo(
|
|
|
|
compose, "x86_64", compose.variants["Server"], "debuginfo", self.pkgset
|
|
|
|
)
|
2016-02-29 08:21:49 +00:00
|
|
|
self.maxDiff = None
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
list_file = (
|
|
|
|
self.topdir + "/work/x86_64/repo_package_list/Server.x86_64.debuginfo.conf"
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
CreaterepoWrapperCls.mock_calls[0], mock.call(createrepo_c=True)
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(
|
2016-02-29 08:21:49 +00:00
|
|
|
repo.get_createrepo_cmd.mock_calls,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
self.topdir + "/compose/Server/x86_64/debug/tree",
|
|
|
|
checksum="sha256",
|
|
|
|
database=True,
|
|
|
|
groupfile=None,
|
|
|
|
workers=3,
|
|
|
|
outputdir=self.topdir + "/compose/Server/x86_64/debug/tree",
|
|
|
|
pkglist=list_file,
|
|
|
|
skip_stat=True,
|
|
|
|
update=True,
|
|
|
|
update_md_path="/repo/x86_64",
|
|
|
|
deltas=False,
|
|
|
|
oldpackagedirs=None,
|
|
|
|
use_xz=False,
|
|
|
|
extra_args=[],
|
2021-07-21 10:16:03 +00:00
|
|
|
cachedir=None,
|
2020-01-22 10:02:22 +00:00
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(repo.get_modifyrepo_cmd.mock_calls, [])
|
2019-10-04 13:10:14 +00:00
|
|
|
self.assertFileContent(
|
2020-01-22 10:02:22 +00:00
|
|
|
list_file, "Packages/b/bash-debuginfo-4.3.30-2.fc21.x86_64.rpm\n"
|
2019-10-04 13:10:14 +00:00
|
|
|
)
|
2016-02-29 08:21:49 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.phases.createrepo.run")
|
|
|
|
@mock.patch("pungi.phases.createrepo.CreaterepoWrapper")
|
2016-02-29 08:21:49 +00:00
|
|
|
def test_variant_repo_no_createrepo_c(self, CreaterepoWrapperCls, run):
|
2020-01-22 10:02:22 +00:00
|
|
|
compose = DummyCompose(
|
2021-07-21 10:16:03 +00:00
|
|
|
self.topdir,
|
|
|
|
{
|
|
|
|
"createrepo_c": False,
|
|
|
|
"createrepo_enable_cache": False,
|
|
|
|
"createrepo_checksum": "sha256",
|
|
|
|
},
|
2020-01-22 10:02:22 +00:00
|
|
|
)
|
2016-02-29 08:21:49 +00:00
|
|
|
compose.has_comps = False
|
|
|
|
|
|
|
|
repo = CreaterepoWrapperCls.return_value
|
2020-01-22 10:02:22 +00:00
|
|
|
copy_fixture("server-rpms.json", compose.paths.compose.metadata("rpms.json"))
|
2016-02-29 08:21:49 +00:00
|
|
|
|
2019-08-01 10:51:52 +00:00
|
|
|
create_variant_repo(
|
|
|
|
compose, "x86_64", compose.variants["Server"], "rpm", self.pkgset
|
|
|
|
)
|
2016-02-29 08:21:49 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
list_file = (
|
|
|
|
self.topdir + "/work/x86_64/repo_package_list/Server.x86_64.rpm.conf"
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
CreaterepoWrapperCls.mock_calls[0], mock.call(createrepo_c=False)
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(
|
2016-02-29 08:21:49 +00:00
|
|
|
repo.get_createrepo_cmd.mock_calls,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
self.topdir + "/compose/Server/x86_64/os",
|
|
|
|
checksum="sha256",
|
|
|
|
database=True,
|
|
|
|
groupfile=None,
|
|
|
|
workers=3,
|
|
|
|
outputdir=self.topdir + "/compose/Server/x86_64/os",
|
|
|
|
pkglist=list_file,
|
|
|
|
skip_stat=True,
|
|
|
|
update=True,
|
|
|
|
update_md_path="/repo/x86_64",
|
|
|
|
deltas=False,
|
|
|
|
oldpackagedirs=None,
|
|
|
|
use_xz=False,
|
|
|
|
extra_args=[],
|
2021-07-21 10:16:03 +00:00
|
|
|
cachedir=None,
|
2020-01-22 10:02:22 +00:00
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(repo.get_modifyrepo_cmd.mock_calls, [])
|
2019-10-04 13:10:14 +00:00
|
|
|
self.assertFileContent(list_file, "Packages/b/bash-4.3.30-2.fc21.x86_64.rpm\n")
|
2016-02-29 08:21:49 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.phases.createrepo.run")
|
|
|
|
@mock.patch("pungi.phases.createrepo.CreaterepoWrapper")
|
2016-02-29 08:21:49 +00:00
|
|
|
def test_variant_repo_is_idepotent(self, CreaterepoWrapperCls, run):
|
2020-01-22 10:02:22 +00:00
|
|
|
compose = DummyCompose(
|
|
|
|
self.topdir,
|
2021-07-21 10:16:03 +00:00
|
|
|
{
|
|
|
|
"createrepo_checksum": "sha256",
|
|
|
|
"createrepo_enable_cache": False,
|
|
|
|
"createrepo_num_workers": 10,
|
|
|
|
},
|
2020-01-22 10:02:22 +00:00
|
|
|
)
|
2016-02-29 08:21:49 +00:00
|
|
|
compose.has_comps = False
|
|
|
|
|
|
|
|
repo = CreaterepoWrapperCls.return_value
|
2020-01-22 10:02:22 +00:00
|
|
|
copy_fixture("server-rpms.json", compose.paths.compose.metadata("rpms.json"))
|
2016-02-29 08:21:49 +00:00
|
|
|
|
|
|
|
# Running the same thing twice only creates repo once.
|
2019-08-01 10:51:52 +00:00
|
|
|
create_variant_repo(
|
|
|
|
compose, "x86_64", compose.variants["Server"], "rpm", self.pkgset
|
|
|
|
)
|
|
|
|
create_variant_repo(
|
|
|
|
compose, "x86_64", compose.variants["Server"], "rpm", self.pkgset
|
|
|
|
)
|
2016-02-29 08:21:49 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
list_file = (
|
|
|
|
self.topdir + "/work/x86_64/repo_package_list/Server.x86_64.rpm.conf"
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
CreaterepoWrapperCls.mock_calls[0], mock.call(createrepo_c=True)
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(
|
2016-02-29 08:21:49 +00:00
|
|
|
repo.get_createrepo_cmd.mock_calls,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
self.topdir + "/compose/Server/x86_64/os",
|
|
|
|
checksum="sha256",
|
|
|
|
database=True,
|
|
|
|
groupfile=None,
|
|
|
|
workers=10,
|
|
|
|
outputdir=self.topdir + "/compose/Server/x86_64/os",
|
|
|
|
pkglist=list_file,
|
|
|
|
skip_stat=True,
|
|
|
|
update=True,
|
|
|
|
update_md_path="/repo/x86_64",
|
|
|
|
deltas=False,
|
|
|
|
oldpackagedirs=None,
|
|
|
|
use_xz=False,
|
|
|
|
extra_args=[],
|
2021-07-21 10:16:03 +00:00
|
|
|
cachedir=None,
|
2020-01-22 10:02:22 +00:00
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(repo.get_modifyrepo_cmd.mock_calls, [])
|
2019-10-04 13:10:14 +00:00
|
|
|
self.assertFileContent(list_file, "Packages/b/bash-4.3.30-2.fc21.x86_64.rpm\n")
|
2016-09-12 09:01:45 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.phases.createrepo.run")
|
|
|
|
@mock.patch("pungi.phases.createrepo.CreaterepoWrapper")
|
2016-09-12 09:01:45 +00:00
|
|
|
def test_variant_repo_rpms_with_xz(self, CreaterepoWrapperCls, run):
|
2020-01-22 10:02:22 +00:00
|
|
|
compose = DummyCompose(
|
2021-07-21 10:16:03 +00:00
|
|
|
self.topdir,
|
|
|
|
{
|
|
|
|
"createrepo_checksum": "sha256",
|
|
|
|
"createrepo_enable_cache": False,
|
|
|
|
"createrepo_use_xz": True,
|
|
|
|
},
|
2020-01-22 10:02:22 +00:00
|
|
|
)
|
2016-09-12 09:01:45 +00:00
|
|
|
compose.has_comps = False
|
|
|
|
|
|
|
|
repo = CreaterepoWrapperCls.return_value
|
2020-01-22 10:02:22 +00:00
|
|
|
copy_fixture("server-rpms.json", compose.paths.compose.metadata("rpms.json"))
|
2016-09-12 09:01:45 +00:00
|
|
|
|
2019-08-01 10:51:52 +00:00
|
|
|
create_variant_repo(
|
|
|
|
compose, "x86_64", compose.variants["Server"], "rpm", self.pkgset
|
|
|
|
)
|
2016-09-12 09:01:45 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
list_file = (
|
|
|
|
self.topdir + "/work/x86_64/repo_package_list/Server.x86_64.rpm.conf"
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
CreaterepoWrapperCls.mock_calls[0], mock.call(createrepo_c=True)
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(
|
2016-09-12 09:01:45 +00:00
|
|
|
repo.get_createrepo_cmd.mock_calls,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
self.topdir + "/compose/Server/x86_64/os",
|
|
|
|
checksum="sha256",
|
|
|
|
database=True,
|
|
|
|
groupfile=None,
|
|
|
|
workers=3,
|
|
|
|
outputdir=self.topdir + "/compose/Server/x86_64/os",
|
|
|
|
pkglist=list_file,
|
|
|
|
skip_stat=True,
|
|
|
|
update=True,
|
|
|
|
update_md_path="/repo/x86_64",
|
|
|
|
deltas=False,
|
|
|
|
oldpackagedirs=None,
|
|
|
|
use_xz=True,
|
|
|
|
extra_args=[],
|
2021-07-21 10:16:03 +00:00
|
|
|
cachedir=None,
|
2020-01-22 10:02:22 +00:00
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(repo.get_modifyrepo_cmd.mock_calls, [])
|
2019-10-04 13:10:14 +00:00
|
|
|
self.assertFileContent(list_file, "Packages/b/bash-4.3.30-2.fc21.x86_64.rpm\n")
|
2016-02-29 11:58:21 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.phases.createrepo.run")
|
|
|
|
@mock.patch("pungi.phases.createrepo.CreaterepoWrapper")
|
2016-02-29 11:58:21 +00:00
|
|
|
def test_variant_repo_rpms_with_deltas(self, CreaterepoWrapperCls, run):
|
2020-01-22 10:02:22 +00:00
|
|
|
compose = DummyCompose(
|
2021-07-21 10:16:03 +00:00
|
|
|
self.topdir,
|
|
|
|
{
|
|
|
|
"createrepo_checksum": "sha256",
|
|
|
|
"createrepo_deltas": True,
|
|
|
|
"createrepo_enable_cache": False,
|
|
|
|
},
|
2020-01-22 10:02:22 +00:00
|
|
|
)
|
2016-02-29 11:58:21 +00:00
|
|
|
compose.has_comps = False
|
2020-01-22 10:02:22 +00:00
|
|
|
compose.old_composes = [self.topdir + "/old"]
|
|
|
|
touch(
|
|
|
|
os.path.join(self.topdir, "old", "test-1.0-20151203.0", "STATUS"),
|
|
|
|
"FINISHED",
|
|
|
|
)
|
2016-02-29 11:58:21 +00:00
|
|
|
|
|
|
|
repo = CreaterepoWrapperCls.return_value
|
2020-01-22 10:02:22 +00:00
|
|
|
copy_fixture("server-rpms.json", compose.paths.compose.metadata("rpms.json"))
|
2016-02-29 11:58:21 +00:00
|
|
|
|
2020-03-06 13:53:52 +00:00
|
|
|
os.makedirs(
|
|
|
|
self.topdir + "/old/test-1.0-20151203.0/compose/Server/x86_64/os/Packages"
|
|
|
|
)
|
|
|
|
|
2019-08-01 10:51:52 +00:00
|
|
|
create_variant_repo(
|
|
|
|
compose, "x86_64", compose.variants["Server"], "rpm", self.pkgset
|
|
|
|
)
|
2016-02-29 11:58:21 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
list_file = (
|
|
|
|
self.topdir + "/work/x86_64/repo_package_list/Server.x86_64.rpm.conf"
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
CreaterepoWrapperCls.mock_calls[0], mock.call(createrepo_c=True)
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(
|
2016-02-29 11:58:21 +00:00
|
|
|
repo.get_createrepo_cmd.mock_calls,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
self.topdir + "/compose/Server/x86_64/os",
|
|
|
|
checksum="sha256",
|
|
|
|
database=True,
|
|
|
|
groupfile=None,
|
|
|
|
workers=3,
|
|
|
|
outputdir=self.topdir + "/compose/Server/x86_64/os",
|
|
|
|
pkglist=list_file,
|
|
|
|
skip_stat=True,
|
|
|
|
update=True,
|
|
|
|
update_md_path=None,
|
|
|
|
deltas=True,
|
|
|
|
oldpackagedirs=self.topdir
|
|
|
|
+ "/old/test-1.0-20151203.0/compose/Server/x86_64/os/Packages",
|
|
|
|
use_xz=False,
|
|
|
|
extra_args=[],
|
2021-07-21 10:16:03 +00:00
|
|
|
cachedir=None,
|
2020-01-22 10:02:22 +00:00
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(repo.get_modifyrepo_cmd.mock_calls, [])
|
2019-10-04 13:10:14 +00:00
|
|
|
self.assertFileContent(list_file, "Packages/b/bash-4.3.30-2.fc21.x86_64.rpm\n")
|
2017-07-14 08:39:47 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.phases.createrepo.run")
|
|
|
|
@mock.patch("pungi.phases.createrepo.CreaterepoWrapper")
|
|
|
|
def test_variant_repo_rpms_with_deltas_granular_config(
|
|
|
|
self, CreaterepoWrapperCls, run
|
|
|
|
):
|
|
|
|
compose = DummyCompose(
|
|
|
|
self.topdir,
|
|
|
|
{
|
|
|
|
"createrepo_checksum": "sha256",
|
|
|
|
"createrepo_deltas": [("^Server$", {"*": True})],
|
2021-07-21 10:16:03 +00:00
|
|
|
"createrepo_enable_cache": False,
|
2020-01-22 10:02:22 +00:00
|
|
|
},
|
|
|
|
)
|
2017-08-29 12:26:57 +00:00
|
|
|
compose.has_comps = False
|
2020-01-22 10:02:22 +00:00
|
|
|
compose.old_composes = [self.topdir + "/old"]
|
|
|
|
touch(
|
|
|
|
os.path.join(self.topdir, "old", "test-1.0-20151203.0", "STATUS"),
|
|
|
|
"FINISHED",
|
|
|
|
)
|
2020-03-06 13:53:52 +00:00
|
|
|
os.makedirs(
|
|
|
|
self.topdir + "/old/test-1.0-20151203.0/compose/Server/x86_64/os/Packages"
|
|
|
|
)
|
2017-08-29 12:26:57 +00:00
|
|
|
|
|
|
|
repo = CreaterepoWrapperCls.return_value
|
2020-01-22 10:02:22 +00:00
|
|
|
copy_fixture("server-rpms.json", compose.paths.compose.metadata("rpms.json"))
|
2017-08-29 12:26:57 +00:00
|
|
|
|
2019-08-01 10:51:52 +00:00
|
|
|
create_variant_repo(
|
|
|
|
compose, "x86_64", compose.variants["Server"], "rpm", self.pkgset
|
|
|
|
)
|
2017-08-29 12:26:57 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
list_file = (
|
|
|
|
self.topdir + "/work/x86_64/repo_package_list/Server.x86_64.rpm.conf"
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
CreaterepoWrapperCls.mock_calls[0], mock.call(createrepo_c=True)
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(
|
2017-08-29 12:26:57 +00:00
|
|
|
repo.get_createrepo_cmd.mock_calls,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
self.topdir + "/compose/Server/x86_64/os",
|
|
|
|
checksum="sha256",
|
|
|
|
database=True,
|
|
|
|
groupfile=None,
|
|
|
|
workers=3,
|
|
|
|
outputdir=self.topdir + "/compose/Server/x86_64/os",
|
|
|
|
pkglist=list_file,
|
|
|
|
skip_stat=True,
|
|
|
|
update=True,
|
|
|
|
update_md_path=None,
|
|
|
|
deltas=True,
|
|
|
|
oldpackagedirs=self.topdir
|
|
|
|
+ "/old/test-1.0-20151203.0/compose/Server/x86_64/os/Packages",
|
|
|
|
use_xz=False,
|
|
|
|
extra_args=[],
|
2021-07-21 10:16:03 +00:00
|
|
|
cachedir=None,
|
2020-01-22 10:02:22 +00:00
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(repo.get_modifyrepo_cmd.mock_calls, [])
|
2019-10-04 13:10:14 +00:00
|
|
|
self.assertFileContent(list_file, "Packages/b/bash-4.3.30-2.fc21.x86_64.rpm\n")
|
2017-08-29 12:26:57 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.phases.createrepo.run")
|
|
|
|
@mock.patch("pungi.phases.createrepo.CreaterepoWrapper")
|
|
|
|
def test_variant_repo_rpms_with_deltas_granular_config_no_match(
|
|
|
|
self, CreaterepoWrapperCls, run
|
|
|
|
):
|
|
|
|
compose = DummyCompose(
|
|
|
|
self.topdir,
|
|
|
|
{
|
|
|
|
"createrepo_checksum": "sha256",
|
|
|
|
"createrepo_deltas": [("^Everything$", {"x86_64": True})],
|
2021-07-21 10:16:03 +00:00
|
|
|
"createrepo_enable_cache": False,
|
2020-01-22 10:02:22 +00:00
|
|
|
},
|
|
|
|
)
|
2017-08-29 12:26:57 +00:00
|
|
|
compose.has_comps = False
|
2020-01-22 10:02:22 +00:00
|
|
|
compose.old_composes = [self.topdir + "/old"]
|
|
|
|
touch(
|
|
|
|
os.path.join(self.topdir, "old", "test-1.0-20151203.0", "STATUS"),
|
|
|
|
"FINISHED",
|
|
|
|
)
|
2017-08-29 12:26:57 +00:00
|
|
|
|
|
|
|
repo = CreaterepoWrapperCls.return_value
|
2020-01-22 10:02:22 +00:00
|
|
|
copy_fixture("server-rpms.json", compose.paths.compose.metadata("rpms.json"))
|
2017-08-29 12:26:57 +00:00
|
|
|
|
2019-08-01 10:51:52 +00:00
|
|
|
create_variant_repo(
|
|
|
|
compose, "x86_64", compose.variants["Server"], "rpm", self.pkgset
|
|
|
|
)
|
2017-08-29 12:26:57 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
list_file = (
|
|
|
|
self.topdir + "/work/x86_64/repo_package_list/Server.x86_64.rpm.conf"
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
CreaterepoWrapperCls.mock_calls[0], mock.call(createrepo_c=True)
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(
|
2017-08-29 12:26:57 +00:00
|
|
|
repo.get_createrepo_cmd.mock_calls,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
self.topdir + "/compose/Server/x86_64/os",
|
|
|
|
checksum="sha256",
|
|
|
|
database=True,
|
|
|
|
groupfile=None,
|
|
|
|
workers=3,
|
|
|
|
outputdir=self.topdir + "/compose/Server/x86_64/os",
|
|
|
|
pkglist=list_file,
|
|
|
|
skip_stat=True,
|
|
|
|
update=True,
|
|
|
|
update_md_path="/repo/x86_64",
|
|
|
|
deltas=False,
|
|
|
|
oldpackagedirs=None,
|
|
|
|
use_xz=False,
|
|
|
|
extra_args=[],
|
2021-07-21 10:16:03 +00:00
|
|
|
cachedir=None,
|
2020-01-22 10:02:22 +00:00
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(repo.get_modifyrepo_cmd.mock_calls, [])
|
2019-10-04 13:10:14 +00:00
|
|
|
self.assertFileContent(list_file, "Packages/b/bash-4.3.30-2.fc21.x86_64.rpm\n")
|
2017-08-29 12:26:57 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.phases.createrepo.run")
|
|
|
|
@mock.patch("pungi.phases.createrepo.CreaterepoWrapper")
|
2017-08-29 12:26:57 +00:00
|
|
|
def test_variant_repo_rpms_with_deltas_granular_config_no_match_on_arch(
|
2020-01-22 10:02:22 +00:00
|
|
|
self, CreaterepoWrapperCls, run
|
|
|
|
):
|
|
|
|
compose = DummyCompose(
|
|
|
|
self.topdir,
|
|
|
|
{
|
|
|
|
"createrepo_checksum": "sha256",
|
|
|
|
"createrepo_deltas": [("^Server$", {"s390x": True})],
|
2021-07-21 10:16:03 +00:00
|
|
|
"createrepo_enable_cache": False,
|
2020-01-22 10:02:22 +00:00
|
|
|
},
|
|
|
|
)
|
2017-08-29 12:26:57 +00:00
|
|
|
compose.has_comps = False
|
2020-01-22 10:02:22 +00:00
|
|
|
compose.old_composes = [self.topdir + "/old"]
|
|
|
|
touch(
|
|
|
|
os.path.join(self.topdir, "old", "test-1.0-20151203.0", "STATUS"),
|
|
|
|
"FINISHED",
|
|
|
|
)
|
2017-08-29 12:26:57 +00:00
|
|
|
|
|
|
|
repo = CreaterepoWrapperCls.return_value
|
2020-01-22 10:02:22 +00:00
|
|
|
copy_fixture("server-rpms.json", compose.paths.compose.metadata("rpms.json"))
|
2017-08-29 12:26:57 +00:00
|
|
|
|
2019-08-01 10:51:52 +00:00
|
|
|
create_variant_repo(
|
|
|
|
compose, "x86_64", compose.variants["Server"], "rpm", self.pkgset
|
|
|
|
)
|
2017-08-29 12:26:57 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
list_file = (
|
|
|
|
self.topdir + "/work/x86_64/repo_package_list/Server.x86_64.rpm.conf"
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
CreaterepoWrapperCls.mock_calls[0], mock.call(createrepo_c=True)
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(
|
2017-08-29 12:26:57 +00:00
|
|
|
repo.get_createrepo_cmd.mock_calls,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
self.topdir + "/compose/Server/x86_64/os",
|
|
|
|
checksum="sha256",
|
|
|
|
database=True,
|
|
|
|
groupfile=None,
|
|
|
|
workers=3,
|
|
|
|
outputdir=self.topdir + "/compose/Server/x86_64/os",
|
|
|
|
pkglist=list_file,
|
|
|
|
skip_stat=True,
|
|
|
|
update=True,
|
|
|
|
update_md_path="/repo/x86_64",
|
|
|
|
deltas=False,
|
|
|
|
oldpackagedirs=None,
|
|
|
|
use_xz=False,
|
|
|
|
extra_args=[],
|
2021-07-21 10:16:03 +00:00
|
|
|
cachedir=None,
|
2020-01-22 10:02:22 +00:00
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(repo.get_modifyrepo_cmd.mock_calls, [])
|
2019-10-04 13:10:14 +00:00
|
|
|
self.assertFileContent(list_file, "Packages/b/bash-4.3.30-2.fc21.x86_64.rpm\n")
|
2017-08-29 12:26:57 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.phases.createrepo.run")
|
|
|
|
@mock.patch("pungi.phases.createrepo.CreaterepoWrapper")
|
2017-07-14 08:39:47 +00:00
|
|
|
def test_variant_repo_rpms_with_deltas_hashed_dirs(self, CreaterepoWrapperCls, run):
|
2020-01-22 10:02:22 +00:00
|
|
|
compose = DummyCompose(
|
|
|
|
self.topdir,
|
|
|
|
{
|
|
|
|
"createrepo_checksum": "sha256",
|
|
|
|
"createrepo_deltas": True,
|
2021-07-21 10:16:03 +00:00
|
|
|
"createrepo_enable_cache": False,
|
2020-01-22 10:02:22 +00:00
|
|
|
"hashed_directories": True,
|
|
|
|
},
|
|
|
|
)
|
2017-07-14 08:39:47 +00:00
|
|
|
compose.has_comps = False
|
2020-01-22 10:02:22 +00:00
|
|
|
compose.old_composes = [self.topdir + "/old"]
|
|
|
|
touch(
|
|
|
|
os.path.join(self.topdir, "old", "test-1.0-20151203.0", "STATUS"),
|
|
|
|
"FINISHED",
|
|
|
|
)
|
2017-07-14 08:39:47 +00:00
|
|
|
self.maxDiff = None
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
for f in ["a/a.rpm", "b/b.rpm", "foo"]:
|
|
|
|
touch(
|
|
|
|
self.topdir
|
|
|
|
+ "/old/test-1.0-20151203.0/compose/Server/x86_64/os/Packages/"
|
|
|
|
+ f
|
|
|
|
)
|
2017-07-14 08:39:47 +00:00
|
|
|
|
|
|
|
repo = CreaterepoWrapperCls.return_value
|
2020-01-22 10:02:22 +00:00
|
|
|
copy_fixture("server-rpms.json", compose.paths.compose.metadata("rpms.json"))
|
2017-07-14 08:39:47 +00:00
|
|
|
|
2019-08-01 10:51:52 +00:00
|
|
|
create_variant_repo(
|
|
|
|
compose, "x86_64", compose.variants["Server"], "rpm", self.pkgset
|
|
|
|
)
|
2017-07-14 08:39:47 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
list_file = (
|
|
|
|
self.topdir + "/work/x86_64/repo_package_list/Server.x86_64.rpm.conf"
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
CreaterepoWrapperCls.mock_calls[0], mock.call(createrepo_c=True)
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(
|
2017-07-14 08:39:47 +00:00
|
|
|
repo.get_createrepo_cmd.mock_calls,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
self.topdir + "/compose/Server/x86_64/os",
|
|
|
|
checksum="sha256",
|
|
|
|
database=True,
|
|
|
|
groupfile=None,
|
|
|
|
workers=3,
|
|
|
|
outputdir=self.topdir + "/compose/Server/x86_64/os",
|
|
|
|
pkglist=list_file,
|
|
|
|
skip_stat=True,
|
|
|
|
update=True,
|
|
|
|
update_md_path=None,
|
|
|
|
deltas=True,
|
|
|
|
oldpackagedirs=[
|
|
|
|
self.topdir
|
2020-02-06 07:09:32 +00:00
|
|
|
+ "/old/test-1.0-20151203.0/compose/Server/x86_64/os/Packages/a", # noqa: E501
|
2020-01-22 10:02:22 +00:00
|
|
|
self.topdir
|
2020-02-06 07:09:32 +00:00
|
|
|
+ "/old/test-1.0-20151203.0/compose/Server/x86_64/os/Packages/b", # noqa: E501
|
2020-01-22 10:02:22 +00:00
|
|
|
],
|
|
|
|
use_xz=False,
|
|
|
|
extra_args=[],
|
2021-07-21 10:16:03 +00:00
|
|
|
cachedir=None,
|
2020-01-22 10:02:22 +00:00
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(repo.get_modifyrepo_cmd.mock_calls, [])
|
2019-10-04 13:10:14 +00:00
|
|
|
self.assertFileContent(list_file, "Packages/b/bash-4.3.30-2.fc21.x86_64.rpm\n")
|
2017-07-14 08:39:47 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.phases.createrepo.run")
|
|
|
|
@mock.patch("pungi.phases.createrepo.CreaterepoWrapper")
|
|
|
|
def test_variant_repo_rpms_with_deltas_hashed_dirs_but_old_doesnt_exist(
|
|
|
|
self, CreaterepoWrapperCls, run
|
|
|
|
):
|
|
|
|
compose = DummyCompose(
|
|
|
|
self.topdir,
|
|
|
|
{
|
|
|
|
"createrepo_checksum": "sha256",
|
|
|
|
"createrepo_deltas": True,
|
2021-07-21 10:16:03 +00:00
|
|
|
"createrepo_enable_cache": False,
|
2020-01-22 10:02:22 +00:00
|
|
|
"hashed_directories": True,
|
|
|
|
},
|
|
|
|
)
|
2017-07-14 08:39:47 +00:00
|
|
|
compose.has_comps = False
|
2020-01-22 10:02:22 +00:00
|
|
|
compose.old_composes = [self.topdir + "/old"]
|
|
|
|
touch(
|
|
|
|
os.path.join(self.topdir, "old", "test-1.0-20151203.0", "STATUS"),
|
|
|
|
"FINISHED",
|
|
|
|
)
|
2017-07-14 08:39:47 +00:00
|
|
|
self.maxDiff = None
|
|
|
|
|
|
|
|
repo = CreaterepoWrapperCls.return_value
|
2020-01-22 10:02:22 +00:00
|
|
|
copy_fixture("server-rpms.json", compose.paths.compose.metadata("rpms.json"))
|
2017-07-14 08:39:47 +00:00
|
|
|
|
2019-08-01 10:51:52 +00:00
|
|
|
create_variant_repo(
|
|
|
|
compose, "x86_64", compose.variants["Server"], "rpm", self.pkgset
|
|
|
|
)
|
2017-07-14 08:39:47 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
list_file = (
|
|
|
|
self.topdir + "/work/x86_64/repo_package_list/Server.x86_64.rpm.conf"
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
CreaterepoWrapperCls.mock_calls[0], mock.call(createrepo_c=True)
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(
|
2017-07-14 08:39:47 +00:00
|
|
|
repo.get_createrepo_cmd.mock_calls,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
self.topdir + "/compose/Server/x86_64/os",
|
|
|
|
checksum="sha256",
|
|
|
|
database=True,
|
|
|
|
groupfile=None,
|
|
|
|
workers=3,
|
|
|
|
outputdir=self.topdir + "/compose/Server/x86_64/os",
|
|
|
|
pkglist=list_file,
|
|
|
|
skip_stat=True,
|
|
|
|
update=True,
|
|
|
|
update_md_path="/repo/x86_64",
|
|
|
|
deltas=True,
|
2020-03-06 13:53:52 +00:00
|
|
|
oldpackagedirs=None,
|
2020-01-22 10:02:22 +00:00
|
|
|
use_xz=False,
|
|
|
|
extra_args=[],
|
2021-07-21 10:16:03 +00:00
|
|
|
cachedir=None,
|
2020-01-22 10:02:22 +00:00
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(repo.get_modifyrepo_cmd.mock_calls, [])
|
2019-10-04 13:10:14 +00:00
|
|
|
self.assertFileContent(list_file, "Packages/b/bash-4.3.30-2.fc21.x86_64.rpm\n")
|
2016-02-29 08:21:49 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.phases.createrepo.run")
|
|
|
|
@mock.patch("pungi.phases.createrepo.CreaterepoWrapper")
|
2016-02-29 11:58:21 +00:00
|
|
|
def test_variant_repo_source_with_deltas(self, CreaterepoWrapperCls, run):
|
2017-08-29 12:02:55 +00:00
|
|
|
# This should not actually create deltas, only binary repos do.
|
2020-01-22 10:02:22 +00:00
|
|
|
compose = DummyCompose(
|
2021-07-21 10:16:03 +00:00
|
|
|
self.topdir,
|
|
|
|
{
|
|
|
|
"createrepo_checksum": "sha256",
|
|
|
|
"createrepo_enable_cache": False,
|
|
|
|
"createrepo_deltas": True,
|
|
|
|
},
|
2020-01-22 10:02:22 +00:00
|
|
|
)
|
2016-02-29 11:58:21 +00:00
|
|
|
compose.has_comps = False
|
2020-01-22 10:02:22 +00:00
|
|
|
compose.old_composes = [self.topdir + "/old"]
|
|
|
|
touch(
|
|
|
|
os.path.join(self.topdir, "old", "test-1.0-20151203.0", "STATUS"),
|
|
|
|
"FINISHED",
|
|
|
|
)
|
2016-02-29 11:58:21 +00:00
|
|
|
|
|
|
|
repo = CreaterepoWrapperCls.return_value
|
2020-01-22 10:02:22 +00:00
|
|
|
copy_fixture("server-rpms.json", compose.paths.compose.metadata("rpms.json"))
|
2016-02-29 11:58:21 +00:00
|
|
|
|
2019-08-01 10:51:52 +00:00
|
|
|
create_variant_repo(
|
|
|
|
compose, None, compose.variants["Server"], "srpm", self.pkgset
|
|
|
|
)
|
2016-02-29 11:58:21 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
list_file = self.topdir + "/work/global/repo_package_list/Server.None.srpm.conf"
|
|
|
|
self.assertEqual(
|
|
|
|
CreaterepoWrapperCls.mock_calls[0], mock.call(createrepo_c=True)
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(
|
2016-02-29 11:58:21 +00:00
|
|
|
repo.get_createrepo_cmd.mock_calls,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
self.topdir + "/compose/Server/source/tree",
|
|
|
|
checksum="sha256",
|
|
|
|
database=True,
|
|
|
|
groupfile=None,
|
|
|
|
workers=3,
|
|
|
|
outputdir=self.topdir + "/compose/Server/source/tree",
|
|
|
|
pkglist=list_file,
|
|
|
|
skip_stat=True,
|
|
|
|
update=True,
|
|
|
|
update_md_path="/repo/global",
|
|
|
|
deltas=False,
|
|
|
|
oldpackagedirs=None,
|
|
|
|
use_xz=False,
|
|
|
|
extra_args=[],
|
2021-07-21 10:16:03 +00:00
|
|
|
cachedir=None,
|
2020-01-22 10:02:22 +00:00
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(repo.get_modifyrepo_cmd.mock_calls, [])
|
2019-10-04 13:10:14 +00:00
|
|
|
self.assertFileContent(list_file, "Packages/b/bash-4.3.30-2.fc21.src.rpm\n")
|
2016-02-29 11:58:21 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.phases.createrepo.run")
|
|
|
|
@mock.patch("pungi.phases.createrepo.CreaterepoWrapper")
|
2016-02-29 11:58:21 +00:00
|
|
|
def test_variant_repo_debug_with_deltas(self, CreaterepoWrapperCls, run):
|
2017-08-29 12:02:55 +00:00
|
|
|
# This should not actually create deltas, only binary repos do.
|
2020-01-22 10:02:22 +00:00
|
|
|
compose = DummyCompose(
|
2021-07-21 10:16:03 +00:00
|
|
|
self.topdir,
|
|
|
|
{
|
|
|
|
"createrepo_checksum": "sha256",
|
|
|
|
"createrepo_deltas": True,
|
|
|
|
"createrepo_enable_cache": False,
|
|
|
|
},
|
2020-01-22 10:02:22 +00:00
|
|
|
)
|
2016-02-29 11:58:21 +00:00
|
|
|
compose.has_comps = False
|
2020-01-22 10:02:22 +00:00
|
|
|
compose.old_composes = [self.topdir + "/old"]
|
|
|
|
touch(
|
|
|
|
os.path.join(self.topdir, "old", "test-1.0-20151203.0", "STATUS"),
|
|
|
|
"FINISHED",
|
|
|
|
)
|
2016-02-29 11:58:21 +00:00
|
|
|
|
|
|
|
repo = CreaterepoWrapperCls.return_value
|
2020-01-22 10:02:22 +00:00
|
|
|
copy_fixture("server-rpms.json", compose.paths.compose.metadata("rpms.json"))
|
2016-02-29 11:58:21 +00:00
|
|
|
|
2019-08-01 10:51:52 +00:00
|
|
|
create_variant_repo(
|
|
|
|
compose, "x86_64", compose.variants["Server"], "debuginfo", self.pkgset
|
|
|
|
)
|
2016-02-29 11:58:21 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
list_file = (
|
|
|
|
self.topdir + "/work/x86_64/repo_package_list/Server.x86_64.debuginfo.conf"
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
CreaterepoWrapperCls.mock_calls[0], mock.call(createrepo_c=True)
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(
|
2016-02-29 11:58:21 +00:00
|
|
|
repo.get_createrepo_cmd.mock_calls,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
self.topdir + "/compose/Server/x86_64/debug/tree",
|
|
|
|
checksum="sha256",
|
|
|
|
database=True,
|
|
|
|
groupfile=None,
|
|
|
|
workers=3,
|
|
|
|
outputdir=self.topdir + "/compose/Server/x86_64/debug/tree",
|
|
|
|
pkglist=list_file,
|
|
|
|
skip_stat=True,
|
|
|
|
update=True,
|
|
|
|
update_md_path="/repo/x86_64",
|
|
|
|
deltas=False,
|
|
|
|
oldpackagedirs=None,
|
|
|
|
use_xz=False,
|
|
|
|
extra_args=[],
|
2021-07-21 10:16:03 +00:00
|
|
|
cachedir=None,
|
2020-01-22 10:02:22 +00:00
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(repo.get_modifyrepo_cmd.mock_calls, [])
|
2019-10-04 13:10:14 +00:00
|
|
|
self.assertFileContent(
|
|
|
|
list_file, "Packages/b/bash-debuginfo-4.3.30-2.fc21.x86_64.rpm\n"
|
|
|
|
)
|
2016-11-23 09:23:30 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.phases.createrepo.run")
|
|
|
|
@mock.patch("pungi.phases.createrepo.CreaterepoWrapper")
|
2016-11-23 09:23:30 +00:00
|
|
|
def test_variant_repo_rpms_with_productid(self, CreaterepoWrapperCls, run):
|
2020-01-22 10:02:22 +00:00
|
|
|
compose = DummyCompose(
|
|
|
|
self.topdir,
|
|
|
|
{
|
|
|
|
"createrepo_checksum": "sha256",
|
2021-07-21 10:16:03 +00:00
|
|
|
"createrepo_enable_cache": False,
|
2020-01-22 10:02:22 +00:00
|
|
|
"product_id": "yes", # Truthy value is enough for this test
|
|
|
|
},
|
|
|
|
)
|
2016-11-23 09:23:30 +00:00
|
|
|
compose.has_comps = False
|
2020-01-22 10:02:22 +00:00
|
|
|
product_id = compose.paths.work.product_id("x86_64", compose.variants["Server"])
|
2016-11-23 09:23:30 +00:00
|
|
|
repodata_dir = os.path.join(
|
2020-01-22 10:02:22 +00:00
|
|
|
compose.paths.compose.os_tree("x86_64", compose.variants["Server"]),
|
|
|
|
"repodata",
|
|
|
|
)
|
2016-11-23 09:23:30 +00:00
|
|
|
touch(product_id)
|
|
|
|
os.mkdir(repodata_dir)
|
|
|
|
|
|
|
|
repo = CreaterepoWrapperCls.return_value
|
2020-01-22 10:02:22 +00:00
|
|
|
copy_fixture("server-rpms.json", compose.paths.compose.metadata("rpms.json"))
|
2016-11-23 09:23:30 +00:00
|
|
|
|
2019-08-01 10:51:52 +00:00
|
|
|
create_variant_repo(
|
|
|
|
compose, "x86_64", compose.variants["Server"], "rpm", self.pkgset
|
|
|
|
)
|
2016-11-23 09:23:30 +00:00
|
|
|
|
|
|
|
self.maxDiff = None
|
2020-01-22 10:02:22 +00:00
|
|
|
list_file = (
|
|
|
|
self.topdir + "/work/x86_64/repo_package_list/Server.x86_64.rpm.conf"
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
CreaterepoWrapperCls.mock_calls[0], mock.call(createrepo_c=True)
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(
|
2016-11-23 09:23:30 +00:00
|
|
|
repo.get_createrepo_cmd.mock_calls,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
self.topdir + "/compose/Server/x86_64/os",
|
|
|
|
checksum="sha256",
|
|
|
|
database=True,
|
|
|
|
groupfile=None,
|
|
|
|
workers=3,
|
|
|
|
outputdir=self.topdir + "/compose/Server/x86_64/os",
|
|
|
|
pkglist=list_file,
|
|
|
|
skip_stat=True,
|
|
|
|
update=True,
|
|
|
|
update_md_path="/repo/x86_64",
|
|
|
|
deltas=False,
|
|
|
|
oldpackagedirs=None,
|
|
|
|
use_xz=False,
|
|
|
|
extra_args=[],
|
2021-07-21 10:16:03 +00:00
|
|
|
cachedir=None,
|
2020-01-22 10:02:22 +00:00
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(
|
2016-11-23 09:23:30 +00:00
|
|
|
repo.get_modifyrepo_cmd.mock_calls,
|
2020-01-22 10:02:22 +00:00
|
|
|
[mock.call(repodata_dir, product_id, compress_type="gz")],
|
2019-10-04 12:45:03 +00:00
|
|
|
)
|
2019-10-04 13:10:14 +00:00
|
|
|
self.assertFileContent(list_file, "Packages/b/bash-4.3.30-2.fc21.x86_64.rpm\n")
|
2016-11-23 09:23:30 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.phases.createrepo.run")
|
|
|
|
@mock.patch("pungi.phases.createrepo.CreaterepoWrapper")
|
2016-11-23 09:23:30 +00:00
|
|
|
def test_variant_repo_debug_with_productid(self, CreaterepoWrapperCls, run):
|
2020-01-22 10:02:22 +00:00
|
|
|
compose = DummyCompose(
|
|
|
|
self.topdir,
|
|
|
|
{
|
|
|
|
"createrepo_checksum": "sha256",
|
2021-07-21 10:16:03 +00:00
|
|
|
"createrepo_enable_cache": False,
|
2020-01-22 10:02:22 +00:00
|
|
|
"product_id": "yes", # Truthy value is enough for this test
|
|
|
|
},
|
|
|
|
)
|
2016-11-23 09:23:30 +00:00
|
|
|
compose.has_comps = False
|
|
|
|
|
|
|
|
repo = CreaterepoWrapperCls.return_value
|
2020-01-22 10:02:22 +00:00
|
|
|
copy_fixture("server-rpms.json", compose.paths.compose.metadata("rpms.json"))
|
2016-11-23 09:23:30 +00:00
|
|
|
|
2019-08-01 10:51:52 +00:00
|
|
|
create_variant_repo(
|
|
|
|
compose, "x86_64", compose.variants["Server"], "debuginfo", self.pkgset
|
|
|
|
)
|
2016-11-23 09:23:30 +00:00
|
|
|
|
|
|
|
self.maxDiff = None
|
2020-01-22 10:02:22 +00:00
|
|
|
list_file = (
|
|
|
|
self.topdir + "/work/x86_64/repo_package_list/Server.x86_64.debuginfo.conf"
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
CreaterepoWrapperCls.mock_calls[0], mock.call(createrepo_c=True)
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(
|
2016-11-23 09:23:30 +00:00
|
|
|
repo.get_createrepo_cmd.mock_calls,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
self.topdir + "/compose/Server/x86_64/debug/tree",
|
|
|
|
checksum="sha256",
|
|
|
|
database=True,
|
|
|
|
groupfile=None,
|
|
|
|
workers=3,
|
|
|
|
outputdir=self.topdir + "/compose/Server/x86_64/debug/tree",
|
|
|
|
pkglist=list_file,
|
|
|
|
skip_stat=True,
|
|
|
|
update=True,
|
|
|
|
update_md_path="/repo/x86_64",
|
|
|
|
deltas=False,
|
|
|
|
oldpackagedirs=None,
|
|
|
|
use_xz=False,
|
|
|
|
extra_args=[],
|
2021-07-21 10:16:03 +00:00
|
|
|
cachedir=None,
|
2020-01-22 10:02:22 +00:00
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(repo.get_modifyrepo_cmd.mock_calls, [])
|
2019-10-04 13:10:14 +00:00
|
|
|
self.assertFileContent(
|
|
|
|
list_file, "Packages/b/bash-debuginfo-4.3.30-2.fc21.x86_64.rpm\n"
|
|
|
|
)
|
2016-02-29 11:58:21 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.phases.createrepo.run")
|
|
|
|
@mock.patch("pungi.phases.createrepo.CreaterepoWrapper")
|
2016-11-23 09:23:30 +00:00
|
|
|
def test_variant_repo_source_with_productid(self, CreaterepoWrapperCls, run):
|
2020-01-22 10:02:22 +00:00
|
|
|
compose = DummyCompose(
|
|
|
|
self.topdir,
|
|
|
|
{
|
|
|
|
"createrepo_checksum": "sha256",
|
2021-07-21 10:16:03 +00:00
|
|
|
"createrepo_enable_cache": False,
|
2020-01-22 10:02:22 +00:00
|
|
|
"product_id": "yes", # Truthy value is enough for this test
|
|
|
|
},
|
|
|
|
)
|
2016-11-23 09:23:30 +00:00
|
|
|
compose.has_comps = False
|
|
|
|
|
|
|
|
repo = CreaterepoWrapperCls.return_value
|
2020-01-22 10:02:22 +00:00
|
|
|
copy_fixture("server-rpms.json", compose.paths.compose.metadata("rpms.json"))
|
2016-11-23 09:23:30 +00:00
|
|
|
|
2019-08-01 10:51:52 +00:00
|
|
|
create_variant_repo(
|
|
|
|
compose, None, compose.variants["Server"], "srpm", self.pkgset
|
|
|
|
)
|
2016-11-23 09:23:30 +00:00
|
|
|
|
|
|
|
self.maxDiff = None
|
2020-01-22 10:02:22 +00:00
|
|
|
list_file = self.topdir + "/work/global/repo_package_list/Server.None.srpm.conf"
|
|
|
|
self.assertEqual(
|
|
|
|
CreaterepoWrapperCls.mock_calls[0], mock.call(createrepo_c=True)
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(
|
2016-11-23 09:23:30 +00:00
|
|
|
repo.get_createrepo_cmd.mock_calls,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
self.topdir + "/compose/Server/source/tree",
|
|
|
|
checksum="sha256",
|
|
|
|
database=True,
|
|
|
|
groupfile=None,
|
|
|
|
workers=3,
|
|
|
|
outputdir=self.topdir + "/compose/Server/source/tree",
|
|
|
|
pkglist=list_file,
|
|
|
|
skip_stat=True,
|
|
|
|
update=True,
|
|
|
|
update_md_path="/repo/global",
|
|
|
|
deltas=False,
|
|
|
|
oldpackagedirs=None,
|
|
|
|
use_xz=False,
|
|
|
|
extra_args=[],
|
2021-07-21 10:16:03 +00:00
|
|
|
cachedir=None,
|
2020-01-22 10:02:22 +00:00
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(repo.get_modifyrepo_cmd.mock_calls, [])
|
2019-10-04 13:10:14 +00:00
|
|
|
self.assertFileContent(list_file, "Packages/b/bash-4.3.30-2.fc21.src.rpm\n")
|
2016-11-23 09:23:30 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@unittest.skipUnless(Modulemd is not None, "Skipped test, no module support.")
|
|
|
|
@mock.patch("pungi.phases.createrepo.find_file_in_repodata")
|
|
|
|
@mock.patch("pungi.phases.createrepo.run")
|
|
|
|
@mock.patch("pungi.phases.createrepo.CreaterepoWrapper")
|
2018-03-15 12:31:58 +00:00
|
|
|
def test_variant_repo_modules_artifacts_not_in_compose(
|
2020-01-22 10:02:22 +00:00
|
|
|
self, CreaterepoWrapperCls, run, modulemd_filename
|
2018-06-22 09:22:54 +00:00
|
|
|
):
|
2020-01-22 10:02:22 +00:00
|
|
|
compose = DummyCompose(self.topdir, {"createrepo_checksum": "sha256"})
|
2018-03-15 12:31:58 +00:00
|
|
|
compose.has_comps = False
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
variant = compose.variants["Server"]
|
2018-03-15 12:31:58 +00:00
|
|
|
variant.arch_mmds["x86_64"] = {}
|
2018-10-02 09:09:12 +00:00
|
|
|
variant.arch_mmds["x86_64"]["test:f27:1:2017"] = variant.add_fake_module(
|
2020-01-22 10:02:22 +00:00
|
|
|
"test:f27:1:2017", rpm_nvrs=["pkg-0:1.0.0-1.x86_64"]
|
|
|
|
)
|
2018-10-02 09:09:12 +00:00
|
|
|
variant.arch_mmds["x86_64"]["test:f28:1:2017"] = variant.add_fake_module(
|
2020-01-22 10:02:22 +00:00
|
|
|
"test:f28:1:2017", rpm_nvrs=["pkg-0:2.0.0-1.x86_64"]
|
|
|
|
)
|
2018-03-15 12:31:58 +00:00
|
|
|
|
|
|
|
repo = CreaterepoWrapperCls.return_value
|
2019-07-01 10:11:39 +00:00
|
|
|
repo.get_modifyrepo_cmd.side_effect = make_mocked_modifyrepo_cmd(
|
|
|
|
self, {"f27": [], "f28": []}
|
|
|
|
)
|
2020-01-22 10:02:22 +00:00
|
|
|
copy_fixture("server-rpms.json", compose.paths.compose.metadata("rpms.json"))
|
2018-03-15 12:31:58 +00:00
|
|
|
|
|
|
|
repodata_dir = os.path.join(
|
2020-01-22 10:02:22 +00:00
|
|
|
compose.paths.compose.os_tree("x86_64", compose.variants["Server"]),
|
|
|
|
"repodata",
|
|
|
|
)
|
|
|
|
modulemd_filename.return_value = (
|
|
|
|
"Server/x86_64/os/repodata/3511d16a7-modules.yaml.gz"
|
|
|
|
)
|
2018-06-22 09:22:54 +00:00
|
|
|
modules_metadata = mock.Mock()
|
2018-03-15 12:31:58 +00:00
|
|
|
|
2019-08-01 10:51:52 +00:00
|
|
|
create_variant_repo(
|
2020-01-22 10:02:22 +00:00
|
|
|
compose,
|
|
|
|
"x86_64",
|
|
|
|
compose.variants["Server"],
|
|
|
|
"rpm",
|
|
|
|
self.pkgset,
|
|
|
|
modules_metadata,
|
2019-08-01 10:51:52 +00:00
|
|
|
)
|
2018-03-15 12:31:58 +00:00
|
|
|
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(
|
2018-03-15 12:31:58 +00:00
|
|
|
repo.get_modifyrepo_cmd.mock_calls,
|
2019-10-04 13:00:05 +00:00
|
|
|
[mock.call(repodata_dir, mock.ANY, compress_type="gz", mdtype="modules")],
|
2019-10-04 12:45:03 +00:00
|
|
|
)
|
2018-03-15 12:31:58 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@unittest.skipUnless(Modulemd is not None, "Skipped test, no module support.")
|
|
|
|
@mock.patch("pungi.phases.createrepo.find_file_in_repodata")
|
|
|
|
@mock.patch("pungi.phases.createrepo.run")
|
|
|
|
@mock.patch("pungi.phases.createrepo.CreaterepoWrapper")
|
2018-03-15 12:31:58 +00:00
|
|
|
def test_variant_repo_modules_artifacts(
|
2020-01-22 10:02:22 +00:00
|
|
|
self, CreaterepoWrapperCls, run, modulemd_filename
|
|
|
|
):
|
|
|
|
compose = DummyCompose(self.topdir, {"createrepo_checksum": "sha256"})
|
2018-03-15 12:31:58 +00:00
|
|
|
compose.has_comps = False
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
variant = compose.variants["Server"]
|
2018-09-05 06:51:38 +00:00
|
|
|
variant.arch_mmds["x86_64"] = {
|
|
|
|
"test:f27:2018:cafe": variant.add_fake_module(
|
2018-10-02 09:09:12 +00:00
|
|
|
"test:f27:2018:cafe",
|
2018-10-02 09:00:18 +00:00
|
|
|
rpm_nvrs=["bash-0:4.3.30-2.fc21.x86_64"],
|
|
|
|
with_artifacts=True,
|
2018-09-05 06:51:38 +00:00
|
|
|
),
|
|
|
|
"test:f28:2018:beef": variant.add_fake_module(
|
2018-10-02 09:09:12 +00:00
|
|
|
"test:f28:2018:beef",
|
2018-10-02 09:00:18 +00:00
|
|
|
rpm_nvrs=["pkg-0:2.0.0-1.x86_64"],
|
|
|
|
with_artifacts=True,
|
2018-09-05 06:51:38 +00:00
|
|
|
),
|
|
|
|
}
|
|
|
|
variant.module_uid_to_koji_tag = {
|
|
|
|
"test:f28:2018:beef": "tag-1",
|
|
|
|
"test:f27:2018:cafe": "tag-2",
|
|
|
|
}
|
2018-03-15 12:31:58 +00:00
|
|
|
|
|
|
|
repo = CreaterepoWrapperCls.return_value
|
2019-07-01 10:11:39 +00:00
|
|
|
repo.get_modifyrepo_cmd.side_effect = make_mocked_modifyrepo_cmd(
|
|
|
|
self,
|
|
|
|
{"f27": ["bash-0:4.3.30-2.fc21.x86_64"], "f28": ["pkg-0:2.0.0-1.x86_64"]},
|
|
|
|
)
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
copy_fixture("server-rpms.json", compose.paths.compose.metadata("rpms.json"))
|
2018-03-15 12:31:58 +00:00
|
|
|
|
|
|
|
repodata_dir = os.path.join(
|
2020-01-22 10:02:22 +00:00
|
|
|
compose.paths.compose.os_tree("x86_64", compose.variants["Server"]),
|
|
|
|
"repodata",
|
|
|
|
)
|
2018-03-15 12:31:58 +00:00
|
|
|
|
2018-03-20 07:52:49 +00:00
|
|
|
modules_metadata = ModulesMetadata(compose)
|
|
|
|
|
2020-02-06 07:09:32 +00:00
|
|
|
modulemd_filename.return_value = "Server/x86_64/os/repodata/3511d16a723e1bd69826e591508f07e377d2212769b59178a9-modules.yaml.gz" # noqa: E501
|
2019-08-01 10:51:52 +00:00
|
|
|
create_variant_repo(
|
2020-01-22 10:02:22 +00:00
|
|
|
compose,
|
|
|
|
"x86_64",
|
|
|
|
compose.variants["Server"],
|
|
|
|
"rpm",
|
|
|
|
self.pkgset,
|
|
|
|
modules_metadata,
|
2019-08-01 10:51:52 +00:00
|
|
|
)
|
2018-03-15 12:31:58 +00:00
|
|
|
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(
|
2018-03-15 12:31:58 +00:00
|
|
|
repo.get_modifyrepo_cmd.mock_calls,
|
2019-10-04 13:00:05 +00:00
|
|
|
[mock.call(repodata_dir, mock.ANY, compress_type="gz", mdtype="modules")],
|
2019-10-04 12:45:03 +00:00
|
|
|
)
|
2018-03-15 12:31:58 +00:00
|
|
|
|
2020-06-08 12:52:57 +00:00
|
|
|
@unittest.skipUnless(Modulemd is not None, "Skipped test, no module support.")
|
|
|
|
@mock.patch("pungi.phases.createrepo.find_file_in_repodata")
|
|
|
|
@mock.patch("pungi.phases.createrepo.run")
|
|
|
|
@mock.patch("pungi.phases.createrepo.CreaterepoWrapper")
|
|
|
|
def test_variant_repo_extra_modulemd(
|
|
|
|
self, CreaterepoWrapperCls, run, modulemd_filename
|
|
|
|
):
|
|
|
|
compose = DummyCompose(
|
|
|
|
self.topdir, {"createrepo_extra_modulemd": {"Server": mock.Mock()}}
|
|
|
|
)
|
|
|
|
compose.has_comps = False
|
|
|
|
|
|
|
|
variant = compose.variants["Server"]
|
|
|
|
variant.arch_mmds["x86_64"] = {}
|
|
|
|
variant.module_uid_to_koji_tag = {}
|
|
|
|
|
|
|
|
repo = CreaterepoWrapperCls.return_value
|
|
|
|
|
|
|
|
copy_fixture("server-rpms.json", compose.paths.compose.metadata("rpms.json"))
|
|
|
|
copy_fixture(
|
|
|
|
"fake-modulemd.yaml",
|
|
|
|
os.path.join(compose.topdir, "work/global/tmp-Server/x86_64/*.yaml"),
|
|
|
|
)
|
|
|
|
|
|
|
|
repodata_dir = os.path.join(
|
|
|
|
compose.paths.compose.os_tree("x86_64", compose.variants["Server"]),
|
|
|
|
"repodata",
|
|
|
|
)
|
|
|
|
|
|
|
|
modules_metadata = ModulesMetadata(compose)
|
|
|
|
|
|
|
|
modulemd_filename.return_value = "Server/x86_64/os/repodata/3511d16a723e1bd69826e591508f07e377d2212769b59178a9-modules.yaml.gz" # noqa: E501
|
|
|
|
create_variant_repo(
|
|
|
|
compose,
|
|
|
|
"x86_64",
|
|
|
|
compose.variants["Server"],
|
|
|
|
"rpm",
|
|
|
|
self.pkgset,
|
|
|
|
modules_metadata,
|
|
|
|
)
|
|
|
|
|
|
|
|
self.assertEqual(
|
|
|
|
repo.get_modifyrepo_cmd.mock_calls,
|
|
|
|
[mock.call(repodata_dir, mock.ANY, compress_type="gz", mdtype="modules")],
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
list(modules_metadata.productmd_modules_metadata["Server"]["x86_64"]),
|
|
|
|
["mymodule:master:1:cafe"],
|
|
|
|
)
|
|
|
|
|
2016-02-29 08:21:49 +00:00
|
|
|
|
2016-11-23 08:54:34 +00:00
|
|
|
class TestGetProductIds(PungiTestCase):
|
|
|
|
def mock_get(self, filenames):
|
|
|
|
def _mock_get(scm, dest):
|
|
|
|
for filename in filenames:
|
|
|
|
touch(os.path.join(dest, filename))
|
2020-01-22 10:02:22 +00:00
|
|
|
|
2016-11-23 08:54:34 +00:00
|
|
|
return _mock_get
|
|
|
|
|
|
|
|
def assertProductIds(self, mapping):
|
2020-01-22 10:02:22 +00:00
|
|
|
pids = glob.glob(self.compose.paths.work.product_id("*", "*"))
|
2016-11-23 08:54:34 +00:00
|
|
|
expected = set()
|
2017-09-05 08:01:21 +00:00
|
|
|
for variant, arches in mapping.items():
|
2016-11-23 08:54:34 +00:00
|
|
|
for arch in arches:
|
2020-01-22 10:02:22 +00:00
|
|
|
expected.add(
|
|
|
|
os.path.join(
|
|
|
|
self.topdir,
|
|
|
|
"work",
|
|
|
|
arch,
|
|
|
|
"product_id",
|
|
|
|
"%s.%s.pem" % (variant, arch),
|
|
|
|
"productid",
|
|
|
|
)
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
six.assertCountEqual(self, pids, expected)
|
2016-11-23 08:54:34 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.phases.createrepo.get_dir_from_scm")
|
2016-11-23 08:54:34 +00:00
|
|
|
def test_not_configured(self, get_dir_from_scm):
|
|
|
|
self.compose = DummyCompose(self.topdir, {})
|
|
|
|
get_productids_from_scm(self.compose)
|
|
|
|
self.assertEqual(get_dir_from_scm.call_args_list, [])
|
|
|
|
self.assertProductIds({})
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.phases.createrepo.get_dir_from_scm")
|
2016-11-23 08:54:34 +00:00
|
|
|
def test_correct(self, get_dir_from_scm):
|
|
|
|
cfg = mock.Mock()
|
2020-01-22 10:02:22 +00:00
|
|
|
self.compose = DummyCompose(self.topdir, {"product_id": cfg})
|
|
|
|
get_dir_from_scm.side_effect = self.mock_get(
|
|
|
|
[
|
|
|
|
"Client-amd64-cert.pem",
|
|
|
|
"Everything-amd64-cert.pem",
|
|
|
|
"Server-amd64-cert.pem",
|
|
|
|
"Everything-x86_64-cert.pem",
|
|
|
|
"Server-x86_64-cert.pem",
|
|
|
|
]
|
|
|
|
)
|
2016-11-23 08:54:34 +00:00
|
|
|
|
|
|
|
get_productids_from_scm(self.compose)
|
|
|
|
|
2019-10-04 13:00:05 +00:00
|
|
|
self.assertEqual(get_dir_from_scm.call_args_list, [mock.call(cfg, mock.ANY)])
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertProductIds(
|
|
|
|
{
|
|
|
|
"Client": ["amd64"],
|
|
|
|
"Everything": ["amd64", "x86_64"],
|
|
|
|
"Server": ["amd64", "x86_64"],
|
|
|
|
}
|
|
|
|
)
|
2016-11-23 08:54:34 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.phases.createrepo.get_dir_from_scm")
|
2016-11-23 08:54:34 +00:00
|
|
|
def test_allow_missing(self, get_dir_from_scm):
|
|
|
|
cfg = mock.Mock()
|
2020-01-22 10:02:22 +00:00
|
|
|
self.compose = DummyCompose(
|
|
|
|
self.topdir, {"product_id": cfg, "product_id_allow_missing": True}
|
|
|
|
)
|
|
|
|
get_dir_from_scm.side_effect = self.mock_get(
|
|
|
|
["Server-amd64-cert.pem", "Server-x86_64-cert.pem"]
|
|
|
|
)
|
2016-11-23 08:54:34 +00:00
|
|
|
|
|
|
|
get_productids_from_scm(self.compose)
|
|
|
|
|
2019-10-04 13:00:05 +00:00
|
|
|
self.assertEqual(get_dir_from_scm.call_args_list, [mock.call(cfg, mock.ANY)])
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertProductIds({"Server": ["amd64", "x86_64"]})
|
2016-11-23 08:54:34 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.phases.createrepo.get_dir_from_scm")
|
2016-11-23 08:54:34 +00:00
|
|
|
def test_missing_fails(self, get_dir_from_scm):
|
|
|
|
cfg = mock.Mock()
|
2020-01-22 10:02:22 +00:00
|
|
|
self.compose = DummyCompose(self.topdir, {"product_id": cfg})
|
|
|
|
get_dir_from_scm.side_effect = self.mock_get(
|
|
|
|
["Server-amd64-cert.pem", "Server-x86_64-cert.pem"]
|
|
|
|
)
|
2016-11-23 08:54:34 +00:00
|
|
|
|
|
|
|
with self.assertRaises(RuntimeError) as ctx:
|
|
|
|
get_productids_from_scm(self.compose)
|
|
|
|
|
2019-10-04 13:00:05 +00:00
|
|
|
self.assertEqual(get_dir_from_scm.call_args_list, [mock.call(cfg, mock.ANY)])
|
2020-07-28 01:23:53 +00:00
|
|
|
self.assertRegex(
|
2017-10-30 08:16:18 +00:00
|
|
|
str(ctx.exception),
|
2020-02-06 07:09:32 +00:00
|
|
|
r"No product certificate found \(arch: amd64, variant: (Everything|Client)\)", # noqa: E501
|
2020-01-22 10:02:22 +00:00
|
|
|
)
|
2016-11-23 08:54:34 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.phases.createrepo.get_dir_from_scm")
|
2016-11-23 08:54:34 +00:00
|
|
|
def test_multiple_matching(self, get_dir_from_scm):
|
|
|
|
cfg = mock.Mock()
|
2020-01-22 10:02:22 +00:00
|
|
|
self.compose = DummyCompose(self.topdir, {"product_id": cfg})
|
|
|
|
get_dir_from_scm.side_effect = self.mock_get(
|
|
|
|
[
|
|
|
|
"Client-amd64-cert.pem",
|
|
|
|
"Client-amd64-cert-duplicate.pem",
|
|
|
|
"Everything-amd64-cert.pem",
|
|
|
|
"Server-amd64-cert.pem",
|
|
|
|
"Everything-x86_64-cert.pem",
|
|
|
|
"Server-x86_64-cert.pem",
|
|
|
|
]
|
|
|
|
)
|
2016-11-23 08:54:34 +00:00
|
|
|
|
|
|
|
with self.assertRaises(RuntimeError) as ctx:
|
|
|
|
get_productids_from_scm(self.compose)
|
|
|
|
|
2019-10-04 13:00:05 +00:00
|
|
|
self.assertEqual(get_dir_from_scm.call_args_list, [mock.call(cfg, mock.ANY)])
|
2020-07-28 01:23:53 +00:00
|
|
|
self.assertRegex(str(ctx.exception), "Multiple product certificates found.+")
|