2016-03-23 09:38:34 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
|
2016-10-25 10:13:16 +00:00
|
|
|
import json
|
2022-11-07 18:10:33 +00:00
|
|
|
from unittest import mock
|
2016-03-23 09:38:34 +00:00
|
|
|
|
|
|
|
import os
|
|
|
|
|
|
|
|
from tests import helpers
|
|
|
|
from pungi.phases import ostree
|
|
|
|
|
|
|
|
|
|
|
|
class OSTreePhaseTest(helpers.PungiTestCase):
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.phases.ostree.ThreadPool")
|
2016-03-23 09:38:34 +00:00
|
|
|
def test_run(self, ThreadPool):
|
2017-02-22 02:48:05 +00:00
|
|
|
cfg = helpers.IterableMock()
|
2020-01-22 10:02:22 +00:00
|
|
|
compose = helpers.DummyCompose(
|
|
|
|
self.topdir,
|
|
|
|
{
|
|
|
|
"ostree": [("^Everything$", {"x86_64": cfg})],
|
|
|
|
"runroot": True,
|
|
|
|
"translate_paths": [(self.topdir, "http://example.com")],
|
|
|
|
},
|
|
|
|
)
|
2016-03-23 09:38:34 +00:00
|
|
|
|
|
|
|
pool = ThreadPool.return_value
|
|
|
|
|
2019-08-01 14:17:39 +00:00
|
|
|
phase = ostree.OSTreePhase(compose, self._make_pkgset_phase(["p1", "p2"]))
|
2016-03-23 09:38:34 +00:00
|
|
|
phase.run()
|
|
|
|
|
|
|
|
self.assertEqual(len(pool.add.call_args_list), 1)
|
2019-08-01 14:17:39 +00:00
|
|
|
self.assertEqual(
|
|
|
|
pool.add.call_args_list[0][0][0].repos,
|
|
|
|
[
|
|
|
|
"http://example.com/work/$basearch/repo/p1",
|
|
|
|
"http://example.com/work/$basearch/repo/p2",
|
|
|
|
],
|
|
|
|
)
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertEqual(
|
|
|
|
pool.queue_put.call_args_list,
|
|
|
|
[mock.call((compose, compose.variants["Everything"], "x86_64", cfg))],
|
|
|
|
)
|
2016-03-23 09:38:34 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.phases.ostree.ThreadPool")
|
2016-03-23 09:38:34 +00:00
|
|
|
def test_skip_without_config(self, ThreadPool):
|
|
|
|
compose = helpers.DummyCompose(self.topdir, {})
|
|
|
|
compose.just_phases = None
|
|
|
|
compose.skip_phases = []
|
|
|
|
phase = ostree.OSTreePhase(compose)
|
|
|
|
self.assertTrue(phase.skip())
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.phases.ostree.ThreadPool")
|
2017-08-03 13:26:34 +00:00
|
|
|
def test_run_with_simple_config(self, ThreadPool):
|
|
|
|
cfg = helpers.IterableMock(get=lambda x, y: None)
|
2020-01-22 10:02:22 +00:00
|
|
|
compose = helpers.DummyCompose(self.topdir, {"ostree": {"^Everything$": cfg}})
|
2017-08-03 13:26:34 +00:00
|
|
|
|
|
|
|
pool = ThreadPool.return_value
|
|
|
|
|
2019-08-01 14:17:39 +00:00
|
|
|
phase = ostree.OSTreePhase(compose, self._make_pkgset_phase(["p1"]))
|
2017-08-03 13:26:34 +00:00
|
|
|
phase.run()
|
|
|
|
|
|
|
|
self.assertEqual(len(pool.add.call_args_list), 2)
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertEqual(
|
|
|
|
pool.queue_put.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call((compose, compose.variants["Everything"], "x86_64", cfg)),
|
|
|
|
mock.call((compose, compose.variants["Everything"], "amd64", cfg)),
|
|
|
|
],
|
|
|
|
)
|
2017-08-03 13:26:34 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.phases.ostree.ThreadPool")
|
2017-08-03 13:26:34 +00:00
|
|
|
def test_run_with_simple_config_limit_arches(self, ThreadPool):
|
2020-01-22 10:02:22 +00:00
|
|
|
cfg = helpers.IterableMock(get=lambda x, y: ["x86_64"])
|
|
|
|
compose = helpers.DummyCompose(self.topdir, {"ostree": {"^Everything$": cfg}})
|
2017-08-03 13:26:34 +00:00
|
|
|
|
|
|
|
pool = ThreadPool.return_value
|
|
|
|
|
2019-08-01 14:17:39 +00:00
|
|
|
phase = ostree.OSTreePhase(compose, self._make_pkgset_phase(["p1"]))
|
2017-08-03 13:26:34 +00:00
|
|
|
phase.run()
|
|
|
|
|
|
|
|
self.assertEqual(len(pool.add.call_args_list), 1)
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertEqual(
|
|
|
|
pool.queue_put.call_args_list,
|
|
|
|
[mock.call((compose, compose.variants["Everything"], "x86_64", cfg))],
|
|
|
|
)
|
2017-08-03 13:26:34 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.phases.ostree.ThreadPool")
|
2017-08-03 13:26:34 +00:00
|
|
|
def test_run_with_simple_config_limit_arches_two_blocks(self, ThreadPool):
|
2020-01-22 10:02:22 +00:00
|
|
|
cfg1 = helpers.IterableMock(get=lambda x, y: ["x86_64"])
|
|
|
|
cfg2 = helpers.IterableMock(get=lambda x, y: ["s390x"])
|
|
|
|
compose = helpers.DummyCompose(
|
|
|
|
self.topdir, {"ostree": {"^Everything$": [cfg1, cfg2]}}
|
|
|
|
)
|
2017-08-03 13:26:34 +00:00
|
|
|
|
|
|
|
pool = ThreadPool.return_value
|
|
|
|
|
2019-08-01 14:17:39 +00:00
|
|
|
phase = ostree.OSTreePhase(compose, self._make_pkgset_phase(["p1"]))
|
2017-08-03 13:26:34 +00:00
|
|
|
phase.run()
|
|
|
|
|
|
|
|
self.assertEqual(len(pool.add.call_args_list), 2)
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertEqual(
|
|
|
|
pool.queue_put.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call((compose, compose.variants["Everything"], "x86_64", cfg1)),
|
|
|
|
mock.call((compose, compose.variants["Everything"], "s390x", cfg2)),
|
|
|
|
],
|
|
|
|
)
|
2017-08-03 13:26:34 +00:00
|
|
|
|
2016-03-23 09:38:34 +00:00
|
|
|
|
|
|
|
class OSTreeThreadTest(helpers.PungiTestCase):
|
2016-05-09 13:59:02 +00:00
|
|
|
def setUp(self):
|
|
|
|
super(OSTreeThreadTest, self).setUp()
|
2020-01-22 10:02:22 +00:00
|
|
|
self.repo = os.path.join(self.topdir, "place/for/atomic")
|
|
|
|
os.makedirs(os.path.join(self.repo, "refs", "heads"))
|
2016-09-15 12:20:26 +00:00
|
|
|
self.cfg = {
|
2020-01-22 10:02:22 +00:00
|
|
|
"repo": "Everything",
|
|
|
|
"config_url": "https://git.fedorahosted.org/git/fedora-atomic.git",
|
|
|
|
"config_branch": "f24",
|
|
|
|
"treefile": "fedora-atomic-docker-host.json",
|
|
|
|
"ostree_repo": self.repo,
|
2016-09-15 12:20:26 +00:00
|
|
|
}
|
2020-01-22 10:02:22 +00:00
|
|
|
self.compose = helpers.DummyCompose(
|
|
|
|
self.topdir,
|
|
|
|
{
|
|
|
|
"koji_profile": "koji",
|
|
|
|
"runroot_tag": "rrt",
|
|
|
|
"translate_paths": [(self.topdir, "http://example.com")],
|
|
|
|
},
|
|
|
|
)
|
2016-09-15 12:20:26 +00:00
|
|
|
self.pool = mock.Mock()
|
2016-05-09 13:59:02 +00:00
|
|
|
|
2020-01-02 02:16:50 +00:00
|
|
|
def _dummy_config_repo(self, scm_dict, target, compose=None):
|
2016-10-25 10:13:16 +00:00
|
|
|
os.makedirs(target)
|
2020-01-22 10:02:22 +00:00
|
|
|
helpers.touch(
|
|
|
|
os.path.join(target, "fedora-atomic-docker-host.json"),
|
|
|
|
json.dumps(
|
|
|
|
{
|
|
|
|
"ref": "fedora-atomic/25/x86_64",
|
|
|
|
"repos": ["fedora-rawhide", "fedora-24", "fedora-23"],
|
|
|
|
}
|
|
|
|
),
|
|
|
|
)
|
|
|
|
helpers.touch(
|
|
|
|
os.path.join(target, "fedora-rawhide.repo"),
|
|
|
|
"[fedora-rawhide]\nmirrorlist=mirror-mirror-on-the-wall",
|
|
|
|
)
|
|
|
|
helpers.touch(
|
|
|
|
os.path.join(target, "fedora-24.repo"),
|
|
|
|
"[fedora-24]\nmetalink=who-is-the-fairest-of-them-all",
|
|
|
|
)
|
|
|
|
helpers.touch(
|
|
|
|
os.path.join(target, "fedora-23.repo"),
|
|
|
|
"[fedora-23]\nbaseurl=why-not-zoidberg?",
|
|
|
|
)
|
2016-04-07 12:33:37 +00:00
|
|
|
|
2016-10-25 10:13:16 +00:00
|
|
|
def _mock_runroot(self, retcode, writefiles=None):
|
|
|
|
"""Pretend to run a task in runroot, creating a log file with given line
|
|
|
|
|
|
|
|
Also allows for writing other files of requested"""
|
2020-01-22 10:02:22 +00:00
|
|
|
|
2016-09-15 12:20:26 +00:00
|
|
|
def fake_runroot(self, log_file, **kwargs):
|
2016-10-25 10:13:16 +00:00
|
|
|
if writefiles:
|
2016-09-15 12:20:26 +00:00
|
|
|
logdir = os.path.dirname(log_file)
|
2016-10-25 10:13:16 +00:00
|
|
|
for filename in writefiles:
|
2020-01-22 10:02:22 +00:00
|
|
|
helpers.touch(
|
|
|
|
os.path.join(logdir, filename), "\n".join(writefiles[filename])
|
|
|
|
)
|
2018-09-13 13:50:22 +00:00
|
|
|
helpers.touch(os.path.join(logdir, filename + ".stamp"))
|
2020-01-22 10:02:22 +00:00
|
|
|
return {"task_id": 1234, "retcode": retcode, "output": "Foo bar\n"}
|
|
|
|
|
2016-09-15 12:20:26 +00:00
|
|
|
return fake_runroot
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.wrappers.scm.get_dir_from_scm")
|
|
|
|
@mock.patch("pungi.wrappers.kojiwrapper.KojiWrapper")
|
2018-02-06 21:29:22 +00:00
|
|
|
def test_extra_config_content(self, KojiWrapper, get_dir_from_scm):
|
|
|
|
get_dir_from_scm.side_effect = self._dummy_config_repo
|
2020-01-22 10:02:22 +00:00
|
|
|
self.compose.conf["runroot_weights"] = {"ostree": 123}
|
2018-02-06 21:29:22 +00:00
|
|
|
|
|
|
|
koji = KojiWrapper.return_value
|
|
|
|
koji.run_runroot_cmd.side_effect = self._mock_runroot(0)
|
|
|
|
|
2019-08-01 14:17:39 +00:00
|
|
|
t = ostree.OSTreeThread(self.pool, ["http://example.com/repo/1"])
|
2018-02-06 21:29:22 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
extra_config_file = os.path.join(self.topdir, "work/ostree-1/extra_config.json")
|
2018-02-06 21:29:22 +00:00
|
|
|
self.assertFalse(os.path.isfile(extra_config_file))
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
t.process(
|
|
|
|
(self.compose, self.compose.variants["Everything"], "x86_64", self.cfg), 1
|
|
|
|
)
|
2018-02-06 21:29:22 +00:00
|
|
|
|
|
|
|
self.assertTrue(os.path.isfile(extra_config_file))
|
2020-01-22 10:02:22 +00:00
|
|
|
with open(extra_config_file, "r") as f:
|
2018-02-06 21:29:22 +00:00
|
|
|
extraconf_content = json.load(f)
|
2018-04-09 13:32:33 +00:00
|
|
|
|
|
|
|
proper_extraconf_content = {
|
|
|
|
"repo": [
|
2020-01-22 10:02:22 +00:00
|
|
|
{
|
|
|
|
"name": "http:__example.com_repo_1",
|
|
|
|
"baseurl": "http://example.com/repo/1",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "http:__example.com_work__basearch_comps_repo_Everything",
|
2020-02-06 07:09:32 +00:00
|
|
|
"baseurl": "http://example.com/work/$basearch/comps_repo_Everything", # noqa: E501
|
2020-01-22 10:02:22 +00:00
|
|
|
},
|
2018-04-09 13:32:33 +00:00
|
|
|
]
|
|
|
|
}
|
2018-02-06 21:29:22 +00:00
|
|
|
self.assertEqual(proper_extraconf_content, extraconf_content)
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.wrappers.scm.get_dir_from_scm")
|
|
|
|
@mock.patch("pungi.wrappers.kojiwrapper.KojiWrapper")
|
2016-04-07 12:33:37 +00:00
|
|
|
def test_run(self, KojiWrapper, get_dir_from_scm):
|
|
|
|
get_dir_from_scm.side_effect = self._dummy_config_repo
|
2020-01-22 10:02:22 +00:00
|
|
|
self.compose.conf["runroot_weights"] = {"ostree": 123}
|
2016-04-07 12:33:37 +00:00
|
|
|
|
2016-03-23 09:38:34 +00:00
|
|
|
koji = KojiWrapper.return_value
|
2016-09-15 12:20:26 +00:00
|
|
|
koji.run_runroot_cmd.side_effect = self._mock_runroot(0)
|
2016-03-23 09:38:34 +00:00
|
|
|
|
2019-08-01 14:17:39 +00:00
|
|
|
t = ostree.OSTreeThread(self.pool, ["http://example.com/repo/1"])
|
2016-03-23 09:38:34 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
t.process(
|
|
|
|
(self.compose, self.compose.variants["Everything"], "x86_64", self.cfg), 1
|
|
|
|
)
|
|
|
|
|
|
|
|
self.assertEqual(
|
|
|
|
get_dir_from_scm.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
{
|
|
|
|
"scm": "git",
|
|
|
|
"repo": "https://git.fedorahosted.org/git/fedora-atomic.git",
|
|
|
|
"branch": "f24",
|
|
|
|
"dir": ".",
|
|
|
|
},
|
|
|
|
self.topdir + "/work/ostree-1/config_repo",
|
|
|
|
compose=self.compose,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
koji.get_runroot_cmd.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
"rrt",
|
|
|
|
"x86_64",
|
|
|
|
[
|
|
|
|
"pungi-make-ostree",
|
|
|
|
"tree",
|
|
|
|
"--repo=%s" % self.repo,
|
|
|
|
"--log-dir=%s/logs/x86_64/Everything/ostree-1" % self.topdir,
|
|
|
|
"--treefile=%s/fedora-atomic-docker-host.json"
|
|
|
|
% (self.topdir + "/work/ostree-1/config_repo"),
|
|
|
|
"--extra-config=%s/extra_config.json"
|
|
|
|
% (self.topdir + "/work/ostree-1"),
|
|
|
|
],
|
|
|
|
channel=None,
|
|
|
|
mounts=[self.topdir, self.repo],
|
|
|
|
packages=["pungi", "ostree", "rpm-ostree"],
|
|
|
|
use_shell=True,
|
|
|
|
new_chroot=True,
|
|
|
|
weight=123,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
koji.run_runroot_cmd.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
koji.get_runroot_cmd.return_value,
|
|
|
|
log_file=self.topdir
|
|
|
|
+ "/logs/x86_64/Everything/ostree-1/runroot.log",
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
self.assertTrue(
|
|
|
|
os.path.isfile(os.path.join(self.topdir, "work/ostree-1/extra_config.json"))
|
|
|
|
)
|
2016-05-09 13:59:02 +00:00
|
|
|
self.assertTrue(os.path.isdir(self.repo))
|
2016-04-07 13:42:20 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.wrappers.scm.get_dir_from_scm")
|
2020-05-13 05:58:07 +00:00
|
|
|
@mock.patch("pungi.wrappers.kojiwrapper.KojiWrapper")
|
|
|
|
def test_run_use_koji_plugin(self, KojiWrapper, get_dir_from_scm):
|
|
|
|
get_dir_from_scm.side_effect = self._dummy_config_repo
|
|
|
|
self.compose.conf["runroot_weights"] = {"ostree": 123}
|
|
|
|
self.compose.conf["ostree_use_koji_plugin"] = True
|
|
|
|
|
|
|
|
koji = KojiWrapper.return_value
|
|
|
|
koji.run_runroot_cmd.side_effect = self._mock_runroot(0)
|
|
|
|
|
|
|
|
t = ostree.OSTreeThread(self.pool, ["http://example.com/repo/1"])
|
|
|
|
|
|
|
|
t.process(
|
|
|
|
(self.compose, self.compose.variants["Everything"], "x86_64", self.cfg), 1
|
|
|
|
)
|
|
|
|
|
|
|
|
self.assertEqual(
|
|
|
|
get_dir_from_scm.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
{
|
|
|
|
"scm": "git",
|
|
|
|
"repo": "https://git.fedorahosted.org/git/fedora-atomic.git",
|
|
|
|
"branch": "f24",
|
|
|
|
"dir": ".",
|
|
|
|
},
|
|
|
|
self.topdir + "/work/ostree-1/config_repo",
|
|
|
|
compose=self.compose,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
koji.get_pungi_ostree_cmd.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
"rrt",
|
|
|
|
"x86_64",
|
|
|
|
{
|
|
|
|
"repo": self.repo,
|
|
|
|
"log-dir": "%s/logs/x86_64/Everything/ostree-1" % self.topdir,
|
|
|
|
"treefile": "%s/fedora-atomic-docker-host.json"
|
|
|
|
% (self.topdir + "/work/ostree-1/config_repo"),
|
|
|
|
"extra-config": "%s/extra_config.json"
|
|
|
|
% (self.topdir + "/work/ostree-1"),
|
|
|
|
"update-summary": False,
|
|
|
|
"ostree-ref": None,
|
|
|
|
"force-new-commit": False,
|
|
|
|
"version": None,
|
|
|
|
},
|
|
|
|
channel=None,
|
|
|
|
mounts=[self.topdir, self.repo],
|
|
|
|
packages=["pungi", "ostree", "rpm-ostree"],
|
|
|
|
weight=123,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
koji.run_runroot_cmd.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
koji.get_pungi_ostree_cmd.return_value,
|
|
|
|
log_file=self.topdir
|
|
|
|
+ "/logs/x86_64/Everything/ostree-1/runroot.log",
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
self.assertTrue(
|
|
|
|
os.path.isfile(os.path.join(self.topdir, "work/ostree-1/extra_config.json"))
|
|
|
|
)
|
|
|
|
self.assertTrue(os.path.isdir(self.repo))
|
|
|
|
|
|
|
|
@mock.patch("pungi.wrappers.scm.get_dir_from_scm")
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.wrappers.kojiwrapper.KojiWrapper")
|
2016-04-07 12:33:37 +00:00
|
|
|
def test_run_fail(self, KojiWrapper, get_dir_from_scm):
|
|
|
|
get_dir_from_scm.side_effect = self._dummy_config_repo
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
self.cfg["failable"] = ["*"]
|
2016-04-06 12:57:12 +00:00
|
|
|
koji = KojiWrapper.return_value
|
2016-09-15 12:20:26 +00:00
|
|
|
koji.run_runroot_cmd.side_effect = self._mock_runroot(1)
|
2016-04-06 12:57:12 +00:00
|
|
|
|
2019-08-01 14:17:39 +00:00
|
|
|
t = ostree.OSTreeThread(self.pool, ["http://example.com/repo/1"])
|
2016-04-06 12:57:12 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
t.process(
|
|
|
|
(self.compose, self.compose.variants["Everything"], "x86_64", self.cfg), 1
|
|
|
|
)
|
2016-04-06 12:57:12 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
self.compose._logger.error.assert_has_calls(
|
|
|
|
[
|
|
|
|
mock.call(
|
2020-02-06 07:09:32 +00:00
|
|
|
"[FAIL] Ostree (variant Everything, arch x86_64) failed, but going on anyway." # noqa: E501
|
2020-01-22 10:02:22 +00:00
|
|
|
),
|
|
|
|
mock.call(
|
|
|
|
"Runroot task failed: 1234. See %s for more details."
|
|
|
|
% (self.topdir + "/logs/x86_64/Everything/ostree-1/runroot.log")
|
|
|
|
),
|
|
|
|
]
|
|
|
|
)
|
2016-04-06 12:57:12 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.wrappers.scm.get_dir_from_scm")
|
|
|
|
@mock.patch("pungi.wrappers.kojiwrapper.KojiWrapper")
|
2016-04-07 12:33:37 +00:00
|
|
|
def test_run_handle_exception(self, KojiWrapper, get_dir_from_scm):
|
|
|
|
get_dir_from_scm.side_effect = self._dummy_config_repo
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
self.cfg["failable"] = ["*"]
|
2016-04-06 12:57:12 +00:00
|
|
|
koji = KojiWrapper.return_value
|
|
|
|
koji.run_runroot_cmd.side_effect = helpers.boom
|
|
|
|
|
2019-08-01 14:17:39 +00:00
|
|
|
t = ostree.OSTreeThread(self.pool, ["http://example.com/repo/1"])
|
2016-04-06 12:57:12 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
t.process(
|
|
|
|
(self.compose, self.compose.variants["Everything"], "x86_64", self.cfg), 1
|
|
|
|
)
|
2016-04-06 12:57:12 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
self.compose._logger.error.assert_has_calls(
|
|
|
|
[
|
|
|
|
mock.call(
|
2020-02-06 07:09:32 +00:00
|
|
|
"[FAIL] Ostree (variant Everything, arch x86_64) failed, but going on anyway." # noqa: E501
|
2020-01-22 10:02:22 +00:00
|
|
|
),
|
|
|
|
mock.call("BOOM"),
|
|
|
|
]
|
|
|
|
)
|
2016-04-06 12:57:12 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.wrappers.scm.get_dir_from_scm")
|
|
|
|
@mock.patch("pungi.wrappers.kojiwrapper.KojiWrapper")
|
2016-09-15 12:20:26 +00:00
|
|
|
def test_run_send_message(self, KojiWrapper, get_dir_from_scm):
|
|
|
|
get_dir_from_scm.side_effect = self._dummy_config_repo
|
|
|
|
|
|
|
|
self.compose.notifier = mock.Mock()
|
2020-01-22 10:02:22 +00:00
|
|
|
self.compose.conf["translate_paths"] = [(self.topdir, "http://example.com/")]
|
2016-09-15 12:20:26 +00:00
|
|
|
|
|
|
|
koji = KojiWrapper.return_value
|
|
|
|
koji.run_runroot_cmd.side_effect = self._mock_runroot(
|
2016-10-25 10:13:16 +00:00
|
|
|
0,
|
2020-01-22 10:02:22 +00:00
|
|
|
{
|
|
|
|
"commitid.log": "fca3465861a",
|
|
|
|
"create-ostree-repo.log": [
|
|
|
|
"Doing work",
|
|
|
|
"fedora-atomic/25/x86_64 -> fca3465861a",
|
|
|
|
],
|
|
|
|
},
|
|
|
|
)
|
2019-08-01 14:17:39 +00:00
|
|
|
t = ostree.OSTreeThread(self.pool, ["http://example.com/repo/1"])
|
2016-09-15 12:20:26 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
t.process(
|
|
|
|
(self.compose, self.compose.variants["Everything"], "x86_64", self.cfg), 1
|
|
|
|
)
|
2016-09-15 12:20:26 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertEqual(
|
|
|
|
self.compose.notifier.send.mock_calls,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
"ostree",
|
|
|
|
variant="Everything",
|
|
|
|
arch="x86_64",
|
|
|
|
ref="fedora-atomic/25/x86_64",
|
|
|
|
commitid="fca3465861a",
|
|
|
|
repo_path="http://example.com/place/for/atomic",
|
|
|
|
local_repo_path=self.repo,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
2016-09-15 12:20:26 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.wrappers.scm.get_dir_from_scm")
|
|
|
|
@mock.patch("pungi.wrappers.kojiwrapper.KojiWrapper")
|
2019-01-10 06:53:46 +00:00
|
|
|
def test_run_send_message_custom_ref(self, KojiWrapper, get_dir_from_scm):
|
|
|
|
get_dir_from_scm.side_effect = self._dummy_config_repo
|
|
|
|
self.cfg["ostree_ref"] = "my/${basearch}"
|
|
|
|
|
|
|
|
self.compose.notifier = mock.Mock()
|
2020-01-22 10:02:22 +00:00
|
|
|
self.compose.conf["translate_paths"] = [(self.topdir, "http://example.com/")]
|
2019-01-10 06:53:46 +00:00
|
|
|
|
|
|
|
koji = KojiWrapper.return_value
|
|
|
|
koji.run_runroot_cmd.side_effect = self._mock_runroot(
|
|
|
|
0,
|
2020-01-22 10:02:22 +00:00
|
|
|
{
|
|
|
|
"commitid.log": "fca3465861a",
|
|
|
|
"create-ostree-repo.log": [
|
|
|
|
"Doing work",
|
|
|
|
"fedora-atomic/25/x86_64 -> fca3465861a",
|
|
|
|
],
|
|
|
|
},
|
|
|
|
)
|
2019-08-01 14:17:39 +00:00
|
|
|
t = ostree.OSTreeThread(self.pool, ["http://example.com/repo/1"])
|
2019-01-10 06:53:46 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
t.process(
|
|
|
|
(self.compose, self.compose.variants["Everything"], "x86_64", self.cfg), 1
|
|
|
|
)
|
2019-01-10 06:53:46 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertEqual(
|
|
|
|
self.compose.notifier.send.mock_calls,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
"ostree",
|
|
|
|
variant="Everything",
|
|
|
|
arch="x86_64",
|
|
|
|
ref="my/x86_64",
|
|
|
|
commitid="fca3465861a",
|
|
|
|
repo_path="http://example.com/place/for/atomic",
|
|
|
|
local_repo_path=self.repo,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
2019-01-10 06:53:46 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.wrappers.scm.get_dir_from_scm")
|
|
|
|
@mock.patch("pungi.wrappers.kojiwrapper.KojiWrapper")
|
2016-09-15 12:20:26 +00:00
|
|
|
def test_run_send_message_without_commit_id(self, KojiWrapper, get_dir_from_scm):
|
|
|
|
get_dir_from_scm.side_effect = self._dummy_config_repo
|
|
|
|
|
|
|
|
self.compose.notifier = mock.Mock()
|
|
|
|
|
|
|
|
koji = KojiWrapper.return_value
|
2016-10-25 10:13:16 +00:00
|
|
|
koji.run_runroot_cmd.side_effect = self._mock_runroot(
|
2020-01-22 10:02:22 +00:00
|
|
|
0, {"create-ostree-repo.log": ["Doing work", "Weird output"]}
|
|
|
|
)
|
2019-08-01 14:17:39 +00:00
|
|
|
t = ostree.OSTreeThread(self.pool, ["http://example.com/repo/1"])
|
2016-09-15 12:20:26 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
t.process(
|
|
|
|
(self.compose, self.compose.variants["Everything"], "x86_64", self.cfg), 1
|
|
|
|
)
|
2016-09-15 12:20:26 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertEqual(
|
|
|
|
self.compose.notifier.send.mock_calls,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
"ostree",
|
|
|
|
variant="Everything",
|
|
|
|
arch="x86_64",
|
|
|
|
ref="fedora-atomic/25/x86_64",
|
|
|
|
commitid=None,
|
|
|
|
repo_path="http://example.com/place/for/atomic",
|
|
|
|
local_repo_path=self.repo,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
2016-09-15 12:20:26 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.wrappers.scm.get_dir_from_scm")
|
|
|
|
@mock.patch("pungi.wrappers.kojiwrapper.KojiWrapper")
|
2016-09-15 12:20:26 +00:00
|
|
|
def test_run_send_no_message_on_failure(self, KojiWrapper, get_dir_from_scm):
|
|
|
|
get_dir_from_scm.side_effect = self._dummy_config_repo
|
|
|
|
|
|
|
|
self.compose.notifier = mock.Mock()
|
|
|
|
|
|
|
|
koji = KojiWrapper.return_value
|
|
|
|
koji.run_runroot_cmd.side_effect = self._mock_runroot(1)
|
2019-08-01 14:17:39 +00:00
|
|
|
t = ostree.OSTreeThread(self.pool, ["http://example.com/repo/1"])
|
2016-09-15 12:20:26 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertRaises(
|
|
|
|
RuntimeError,
|
|
|
|
t.process,
|
|
|
|
(self.compose, self.compose.variants["Everything"], "x86_64", self.cfg),
|
|
|
|
1,
|
|
|
|
)
|
2016-09-15 12:20:26 +00:00
|
|
|
self.assertEqual(self.compose.notifier.send.mock_calls, [])
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.wrappers.scm.get_dir_from_scm")
|
|
|
|
@mock.patch("pungi.wrappers.kojiwrapper.KojiWrapper")
|
2016-11-03 12:59:00 +00:00
|
|
|
def test_run_with_update_summary(self, KojiWrapper, get_dir_from_scm):
|
2020-01-22 10:02:22 +00:00
|
|
|
self.cfg["update_summary"] = True
|
2016-11-03 12:59:00 +00:00
|
|
|
|
|
|
|
get_dir_from_scm.side_effect = self._dummy_config_repo
|
|
|
|
|
|
|
|
koji = KojiWrapper.return_value
|
|
|
|
koji.run_runroot_cmd.side_effect = self._mock_runroot(0)
|
|
|
|
|
2019-08-01 14:17:39 +00:00
|
|
|
t = ostree.OSTreeThread(self.pool, ["http://example.com/repo/1"])
|
2016-11-03 12:59:00 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
t.process(
|
|
|
|
(self.compose, self.compose.variants["Everything"], "x86_64", self.cfg), 1
|
|
|
|
)
|
|
|
|
|
|
|
|
self.assertEqual(
|
|
|
|
get_dir_from_scm.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
{
|
|
|
|
"scm": "git",
|
|
|
|
"repo": "https://git.fedorahosted.org/git/fedora-atomic.git",
|
|
|
|
"branch": "f24",
|
|
|
|
"dir": ".",
|
|
|
|
},
|
|
|
|
self.topdir + "/work/ostree-1/config_repo",
|
|
|
|
compose=self.compose,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
koji.get_runroot_cmd.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
"rrt",
|
|
|
|
"x86_64",
|
|
|
|
[
|
|
|
|
"pungi-make-ostree",
|
|
|
|
"tree",
|
|
|
|
"--repo=%s" % self.repo,
|
|
|
|
"--log-dir=%s/logs/x86_64/Everything/ostree-1" % self.topdir,
|
|
|
|
"--treefile=%s/fedora-atomic-docker-host.json"
|
|
|
|
% (self.topdir + "/work/ostree-1/config_repo"),
|
|
|
|
"--extra-config=%s/work/ostree-1/extra_config.json"
|
|
|
|
% self.topdir,
|
|
|
|
"--update-summary",
|
|
|
|
],
|
|
|
|
channel=None,
|
|
|
|
mounts=[self.topdir, self.repo],
|
|
|
|
packages=["pungi", "ostree", "rpm-ostree"],
|
|
|
|
use_shell=True,
|
|
|
|
new_chroot=True,
|
|
|
|
weight=None,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
koji.run_runroot_cmd.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
koji.get_runroot_cmd.return_value,
|
|
|
|
log_file=self.topdir
|
|
|
|
+ "/logs/x86_64/Everything/ostree-1/runroot.log",
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
@mock.patch("pungi.wrappers.scm.get_dir_from_scm")
|
|
|
|
@mock.patch("pungi.wrappers.kojiwrapper.KojiWrapper")
|
2016-11-04 08:07:26 +00:00
|
|
|
def test_run_with_versioning_metadata(self, KojiWrapper, get_dir_from_scm):
|
2020-01-22 10:02:22 +00:00
|
|
|
self.cfg["version"] = "24"
|
2016-11-04 08:07:26 +00:00
|
|
|
|
|
|
|
get_dir_from_scm.side_effect = self._dummy_config_repo
|
|
|
|
|
|
|
|
koji = KojiWrapper.return_value
|
|
|
|
koji.run_runroot_cmd.side_effect = self._mock_runroot(0)
|
|
|
|
|
2019-08-01 14:17:39 +00:00
|
|
|
t = ostree.OSTreeThread(self.pool, ["http://example.com/repo/1"])
|
2016-11-04 08:07:26 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
t.process(
|
|
|
|
(self.compose, self.compose.variants["Everything"], "x86_64", self.cfg), 1
|
|
|
|
)
|
|
|
|
|
|
|
|
self.assertEqual(
|
|
|
|
get_dir_from_scm.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
{
|
|
|
|
"scm": "git",
|
|
|
|
"repo": "https://git.fedorahosted.org/git/fedora-atomic.git",
|
|
|
|
"branch": "f24",
|
|
|
|
"dir": ".",
|
|
|
|
},
|
|
|
|
self.topdir + "/work/ostree-1/config_repo",
|
|
|
|
compose=self.compose,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
koji.get_runroot_cmd.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
"rrt",
|
|
|
|
"x86_64",
|
|
|
|
[
|
|
|
|
"pungi-make-ostree",
|
|
|
|
"tree",
|
|
|
|
"--repo=%s" % self.repo,
|
|
|
|
"--log-dir=%s/logs/x86_64/Everything/ostree-1" % self.topdir,
|
|
|
|
"--treefile=%s/fedora-atomic-docker-host.json"
|
|
|
|
% (self.topdir + "/work/ostree-1/config_repo"),
|
|
|
|
"--version=24",
|
|
|
|
"--extra-config=%s/work/ostree-1/extra_config.json"
|
|
|
|
% self.topdir,
|
|
|
|
],
|
|
|
|
channel=None,
|
|
|
|
mounts=[self.topdir, self.repo],
|
|
|
|
packages=["pungi", "ostree", "rpm-ostree"],
|
|
|
|
use_shell=True,
|
|
|
|
new_chroot=True,
|
|
|
|
weight=None,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
koji.run_runroot_cmd.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
koji.get_runroot_cmd.return_value,
|
|
|
|
log_file=self.topdir
|
|
|
|
+ "/logs/x86_64/Everything/ostree-1/runroot.log",
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
@mock.patch("pungi.wrappers.scm.get_dir_from_scm")
|
|
|
|
@mock.patch("pungi.wrappers.kojiwrapper.KojiWrapper")
|
|
|
|
def test_run_with_generated_versioning_metadata(
|
|
|
|
self, KojiWrapper, get_dir_from_scm
|
|
|
|
):
|
|
|
|
self.cfg["version"] = "!OSTREE_VERSION_FROM_LABEL_DATE_TYPE_RESPIN"
|
2017-03-29 13:49:21 +00:00
|
|
|
|
|
|
|
get_dir_from_scm.side_effect = self._dummy_config_repo
|
|
|
|
|
|
|
|
koji = KojiWrapper.return_value
|
|
|
|
koji.run_runroot_cmd.side_effect = self._mock_runroot(0)
|
|
|
|
|
2019-08-01 14:17:39 +00:00
|
|
|
t = ostree.OSTreeThread(self.pool, ["http://example.com/repo/1"])
|
2017-03-29 13:49:21 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
t.process(
|
|
|
|
(self.compose, self.compose.variants["Everything"], "x86_64", self.cfg), 1
|
|
|
|
)
|
|
|
|
|
|
|
|
self.assertEqual(
|
|
|
|
get_dir_from_scm.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
{
|
|
|
|
"scm": "git",
|
|
|
|
"repo": "https://git.fedorahosted.org/git/fedora-atomic.git",
|
|
|
|
"branch": "f24",
|
|
|
|
"dir": ".",
|
|
|
|
},
|
|
|
|
self.topdir + "/work/ostree-1/config_repo",
|
|
|
|
compose=self.compose,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
koji.get_runroot_cmd.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
"rrt",
|
|
|
|
"x86_64",
|
|
|
|
[
|
|
|
|
"pungi-make-ostree",
|
|
|
|
"tree",
|
|
|
|
"--repo=%s" % self.repo,
|
|
|
|
"--log-dir=%s/logs/x86_64/Everything/ostree-1" % self.topdir,
|
|
|
|
"--treefile=%s/fedora-atomic-docker-host.json"
|
|
|
|
% (self.topdir + "/work/ostree-1/config_repo"),
|
|
|
|
"--version=25.20151203.t.0",
|
|
|
|
"--extra-config=%s/work/ostree-1/extra_config.json"
|
|
|
|
% self.topdir,
|
|
|
|
],
|
|
|
|
channel=None,
|
|
|
|
mounts=[self.topdir, self.repo],
|
|
|
|
packages=["pungi", "ostree", "rpm-ostree"],
|
|
|
|
use_shell=True,
|
|
|
|
new_chroot=True,
|
|
|
|
weight=None,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
koji.run_runroot_cmd.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
koji.get_runroot_cmd.return_value,
|
|
|
|
log_file=self.topdir
|
|
|
|
+ "/logs/x86_64/Everything/ostree-1/runroot.log",
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
@mock.patch("pungi.wrappers.scm.get_dir_from_scm")
|
|
|
|
@mock.patch("pungi.wrappers.kojiwrapper.KojiWrapper")
|
[ostree] Add 'tree' sub-command to pungi-make-ostree script
Update pungi-make-ostree to supourt sub-command 'tree', which is just
as the original feature of pungi-make-ostree to compose OSTree tree.
With the change we can add other sub commands later to build other
OSTree artifacts, like the installer image.
Inaddtional to the change, now the the 'tree' command can accept an
optional '--extra-config' parameter to update the original tree
configuration with extra configurations specified in a json file
before composing the OSTree tree.
Example:
pungi-make-ostree tree --repo=/ostree --treefile=/path/to/treefile \
--log-dir=/path/to/log --extra-config=/path/to/extra-config.json
The extra-config file can contains the same configuration as OSTree
phase, the difference is it doesn't understand variant UID as source
repo since it's not ran in the chain of phases. A valid configuration
can be like:
{
"source_repo_from": "http://example.com/repo/x86_64/Server",
"extra_source_repos": [
{
"name": "optional",
"baseurl": "http://example.com/repo/x86_64/optional",
"exclude": "systemd-container",
"gpgcheck": False
},
{
"name": "extra",
"baseurl": "http://example.com/repo/x86_64/extra",
}
],
"keep_original_sources": True
}
The OSTree phase is updated to move out the task of updating treefile,
instead of that, it writes the extra configurations to a json file,
then 'pungi-make-ostree tree' will take it by option '--extra-config'.
Signed-off-by: Qixiang Wan <qwan@redhat.com>
2016-12-02 12:11:09 +00:00
|
|
|
def test_write_extra_config_file(self, KojiWrapper, get_dir_from_scm):
|
2016-11-07 05:23:13 +00:00
|
|
|
get_dir_from_scm.side_effect = self._dummy_config_repo
|
|
|
|
|
|
|
|
koji = KojiWrapper.return_value
|
|
|
|
koji.run_runroot_cmd.side_effect = self._mock_runroot(0)
|
|
|
|
|
|
|
|
cfg = {
|
2020-02-06 07:09:32 +00:00
|
|
|
"repo": [ # Variant type repos will not be included into extra_config. This part of the config is deprecated # noqa: E501
|
2020-01-22 10:02:22 +00:00
|
|
|
"Everything", # do not include
|
2016-11-07 05:23:13 +00:00
|
|
|
{
|
2020-01-22 10:02:22 +00:00
|
|
|
"name": "repo_a",
|
|
|
|
"baseurl": "http://url/to/repo/a",
|
|
|
|
"exclude": "systemd-container",
|
2016-11-07 05:23:13 +00:00
|
|
|
},
|
2018-02-06 21:29:22 +00:00
|
|
|
{ # do not include
|
2020-01-22 10:02:22 +00:00
|
|
|
"name": "Server",
|
|
|
|
"baseurl": "Server",
|
|
|
|
"exclude": "systemd-container",
|
|
|
|
},
|
2016-11-07 05:23:13 +00:00
|
|
|
],
|
2020-01-22 10:02:22 +00:00
|
|
|
"keep_original_sources": True,
|
|
|
|
"config_url": "https://git.fedorahosted.org/git/fedora-atomic.git",
|
|
|
|
"config_branch": "f24",
|
|
|
|
"treefile": "fedora-atomic-docker-host.json",
|
|
|
|
"ostree_repo": self.repo,
|
2016-11-07 05:23:13 +00:00
|
|
|
}
|
|
|
|
|
2019-08-01 14:17:39 +00:00
|
|
|
t = ostree.OSTreeThread(self.pool, ["http://example.com/repo/1"])
|
2016-11-07 05:23:13 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
t.process((self.compose, self.compose.variants["Everything"], "x86_64", cfg), 1)
|
2016-11-07 05:23:13 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
extra_config_file = os.path.join(self.topdir, "work/ostree-1/extra_config.json")
|
[ostree] Add 'tree' sub-command to pungi-make-ostree script
Update pungi-make-ostree to supourt sub-command 'tree', which is just
as the original feature of pungi-make-ostree to compose OSTree tree.
With the change we can add other sub commands later to build other
OSTree artifacts, like the installer image.
Inaddtional to the change, now the the 'tree' command can accept an
optional '--extra-config' parameter to update the original tree
configuration with extra configurations specified in a json file
before composing the OSTree tree.
Example:
pungi-make-ostree tree --repo=/ostree --treefile=/path/to/treefile \
--log-dir=/path/to/log --extra-config=/path/to/extra-config.json
The extra-config file can contains the same configuration as OSTree
phase, the difference is it doesn't understand variant UID as source
repo since it's not ran in the chain of phases. A valid configuration
can be like:
{
"source_repo_from": "http://example.com/repo/x86_64/Server",
"extra_source_repos": [
{
"name": "optional",
"baseurl": "http://example.com/repo/x86_64/optional",
"exclude": "systemd-container",
"gpgcheck": False
},
{
"name": "extra",
"baseurl": "http://example.com/repo/x86_64/extra",
}
],
"keep_original_sources": True
}
The OSTree phase is updated to move out the task of updating treefile,
instead of that, it writes the extra configurations to a json file,
then 'pungi-make-ostree tree' will take it by option '--extra-config'.
Signed-off-by: Qixiang Wan <qwan@redhat.com>
2016-12-02 12:11:09 +00:00
|
|
|
self.assertTrue(os.path.isfile(extra_config_file))
|
2020-01-22 10:02:22 +00:00
|
|
|
with open(extra_config_file, "r") as extra_config_fd:
|
2018-02-06 21:29:22 +00:00
|
|
|
extra_config = json.load(extra_config_fd)
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertTrue(extra_config.get("keep_original_sources", False))
|
2020-02-06 07:09:32 +00:00
|
|
|
# should equal to number of valid repositories in cfg['repo'] + default repository + comps repository # noqa: E501
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertEqual(len(extra_config.get("repo", [])), 3)
|
|
|
|
self.assertEqual(
|
|
|
|
extra_config.get("repo").pop()["baseurl"],
|
|
|
|
"http://example.com/work/$basearch/comps_repo_Everything",
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
extra_config.get("repo").pop()["baseurl"], "http://example.com/repo/1"
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
extra_config.get("repo").pop()["baseurl"], "http://url/to/repo/a"
|
|
|
|
)
|