ostree: Remove arch_repo path usage

Pass all pkgset repos as input to the task.

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2019-08-01 16:17:39 +02:00
parent ab9122be2a
commit 26ddd46acb
5 changed files with 59 additions and 35 deletions

View File

@ -293,7 +293,7 @@ def run_compose(compose, create_latest_link=True, latest_link_status=None):
extrafiles_phase = pungi.phases.ExtraFilesPhase(compose, pkgset_phase)
createrepo_phase = pungi.phases.CreaterepoPhase(compose, pkgset_phase)
ostree_installer_phase = pungi.phases.OstreeInstallerPhase(compose, buildinstall_phase)
ostree_phase = pungi.phases.OSTreePhase(compose)
ostree_phase = pungi.phases.OSTreePhase(compose, pkgset_phase)
productimg_phase = pungi.phases.ProductimgPhase(compose, pkgset_phase)
createiso_phase = pungi.phases.CreateisoPhase(compose, buildinstall_phase)
extra_isos_phase = pungi.phases.ExtraIsosPhase(compose)

View File

@ -18,12 +18,22 @@ from ..wrappers import scm
class OSTreePhase(ConfigGuardedPhase):
name = 'ostree'
def __init__(self, compose):
def __init__(self, compose, pkgset_phase=None):
super(OSTreePhase, self).__init__(compose)
self.pool = ThreadPool(logger=self.compose._logger)
self.pkgset_phase = pkgset_phase
def get_repos(self):
return [
translate_path(
self.compose,
self.compose.paths.work.pkgset_repo(pkgset.name, "$basearch"),
)
for pkgset in self.pkgset_phase.package_sets
]
def _enqueue(self, variant, arch, conf):
self.pool.add(OSTreeThread(self.pool))
self.pool.add(OSTreeThread(self.pool, self.get_repos()))
self.pool.queue_put((self.compose, variant, arch, conf))
def run(self):
@ -43,6 +53,10 @@ class OSTreePhase(ConfigGuardedPhase):
class OSTreeThread(WorkerThread):
def __init__(self, pool, repos):
super(OSTreeThread, self).__init__(pool)
self.repos = repos
def process(self, item, num):
compose, variant, arch, config = item
self.num = num
@ -60,9 +74,8 @@ class OSTreeThread(WorkerThread):
repodir = os.path.join(workdir, 'config_repo')
self._clone_repo(repodir, config['config_url'], config.get('config_branch', 'master'))
repo_baseurl = compose.paths.work.arch_repo('$basearch', create_dir=False)
comps_repo = compose.paths.work.comps_repo('$basearch', variant=variant, create_dir=False)
repos = shortcuts.force_list(config['repo']) + [translate_path(compose, repo_baseurl)]
repos = shortcuts.force_list(config['repo']) + self.repos
if compose.has_comps:
repos.append(translate_path(compose, comps_repo))
repos = get_repo_dicts(repos, logger=self.pool)

View File

@ -55,6 +55,18 @@ class PungiTestCase(BaseTestCase):
def assertValidConfig(self, conf):
self.assertEqual(checks.validate(conf, offline=True), ([], []))
def _make_pkgset_phase(self, names):
pkgsets = []
for name in names:
pkgset = mock.Mock(paths={})
pkgset.name = name
for arch in ("x86_64", "amd64"):
pkgset.paths[arch] = os.path.join(
self.topdir, "work", arch, "repo", name
)
pkgsets.append(pkgset)
return mock.Mock(package_sets=pkgsets)
class MockVariant(mock.Mock):
def __init__(self, is_empty=False, name=None, *args, **kwargs):

View File

@ -406,17 +406,6 @@ class TestBuildinstallPhase(PungiTestCase):
mock.call(compose, 'amd64', variant=compose.variants['Client'], disc_type='dvd'),
mock.call(compose, 'amd64', variant=compose.variants['Server'], disc_type='dvd')])
def _make_pkgset_phase(self, names):
pkgsets = []
for name in names:
pkgset = mock.Mock(paths={})
for arch in ("x86_64", "amd64"):
pkgset.paths[arch] = os.path.join(
self.topdir, "work", arch, "repo", name
)
pkgsets.append(pkgset)
return mock.Mock(package_sets=pkgsets)
@mock.patch('pungi.phases.buildinstall.ThreadPool')
@mock.patch('pungi.phases.buildinstall.LoraxWrapper')
@mock.patch('pungi.phases.buildinstall.get_volid')

View File

@ -25,14 +25,24 @@ class OSTreePhaseTest(helpers.PungiTestCase):
('^Everything$', {'x86_64': cfg})
],
'runroot': True,
"translate_paths": [
(self.topdir, "http://example.com")
],
})
pool = ThreadPool.return_value
phase = ostree.OSTreePhase(compose)
phase = ostree.OSTreePhase(compose, self._make_pkgset_phase(["p1", "p2"]))
phase.run()
self.assertEqual(len(pool.add.call_args_list), 1)
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",
],
)
self.assertEqual(pool.queue_put.call_args_list,
[mock.call((compose, compose.variants['Everything'], 'x86_64', cfg))])
@ -55,7 +65,7 @@ class OSTreePhaseTest(helpers.PungiTestCase):
pool = ThreadPool.return_value
phase = ostree.OSTreePhase(compose)
phase = ostree.OSTreePhase(compose, self._make_pkgset_phase(["p1"]))
phase.run()
self.assertEqual(len(pool.add.call_args_list), 2)
@ -74,7 +84,7 @@ class OSTreePhaseTest(helpers.PungiTestCase):
pool = ThreadPool.return_value
phase = ostree.OSTreePhase(compose)
phase = ostree.OSTreePhase(compose, self._make_pkgset_phase(["p1"]))
phase.run()
self.assertEqual(len(pool.add.call_args_list), 1)
@ -93,7 +103,7 @@ class OSTreePhaseTest(helpers.PungiTestCase):
pool = ThreadPool.return_value
phase = ostree.OSTreePhase(compose)
phase = ostree.OSTreePhase(compose, self._make_pkgset_phase(["p1"]))
phase.run()
self.assertEqual(len(pool.add.call_args_list), 2)
@ -159,7 +169,7 @@ class OSTreeThreadTest(helpers.PungiTestCase):
koji = KojiWrapper.return_value
koji.run_runroot_cmd.side_effect = self._mock_runroot(0)
t = ostree.OSTreeThread(self.pool)
t = ostree.OSTreeThread(self.pool, ["http://example.com/repo/1"])
extra_config_file = os.path.join(self.topdir, 'work/ostree-1/extra_config.json')
self.assertFalse(os.path.isfile(extra_config_file))
@ -172,8 +182,8 @@ class OSTreeThreadTest(helpers.PungiTestCase):
proper_extraconf_content = {
"repo": [
{"name": "http:__example.com_work__basearch_repo",
"baseurl": "http://example.com/work/$basearch/repo"},
{"name": "http:__example.com_repo_1",
"baseurl": "http://example.com/repo/1"},
{"name": "http:__example.com_work__basearch_comps_repo_Everything",
"baseurl": "http://example.com/work/$basearch/comps_repo_Everything"}
]
@ -189,7 +199,7 @@ class OSTreeThreadTest(helpers.PungiTestCase):
koji = KojiWrapper.return_value
koji.run_runroot_cmd.side_effect = self._mock_runroot(0)
t = ostree.OSTreeThread(self.pool)
t = ostree.OSTreeThread(self.pool, ["http://example.com/repo/1"])
t.process((self.compose, self.compose.variants['Everything'], 'x86_64', self.cfg), 1)
@ -225,7 +235,7 @@ class OSTreeThreadTest(helpers.PungiTestCase):
koji = KojiWrapper.return_value
koji.run_runroot_cmd.side_effect = self._mock_runroot(1)
t = ostree.OSTreeThread(self.pool)
t = ostree.OSTreeThread(self.pool, ["http://example.com/repo/1"])
t.process((self.compose, self.compose.variants['Everything'], 'x86_64', self.cfg), 1)
@ -244,7 +254,7 @@ class OSTreeThreadTest(helpers.PungiTestCase):
koji = KojiWrapper.return_value
koji.run_runroot_cmd.side_effect = helpers.boom
t = ostree.OSTreeThread(self.pool)
t = ostree.OSTreeThread(self.pool, ["http://example.com/repo/1"])
t.process((self.compose, self.compose.variants['Everything'], 'x86_64', self.cfg), 1)
@ -267,7 +277,7 @@ class OSTreeThreadTest(helpers.PungiTestCase):
{'commitid.log': 'fca3465861a',
'create-ostree-repo.log':
['Doing work', 'fedora-atomic/25/x86_64 -> fca3465861a']})
t = ostree.OSTreeThread(self.pool)
t = ostree.OSTreeThread(self.pool, ["http://example.com/repo/1"])
t.process((self.compose, self.compose.variants['Everything'], 'x86_64', self.cfg), 1)
@ -295,7 +305,7 @@ class OSTreeThreadTest(helpers.PungiTestCase):
{'commitid.log': 'fca3465861a',
'create-ostree-repo.log':
['Doing work', 'fedora-atomic/25/x86_64 -> fca3465861a']})
t = ostree.OSTreeThread(self.pool)
t = ostree.OSTreeThread(self.pool, ["http://example.com/repo/1"])
t.process((self.compose, self.compose.variants['Everything'], 'x86_64', self.cfg), 1)
@ -319,7 +329,7 @@ class OSTreeThreadTest(helpers.PungiTestCase):
koji.run_runroot_cmd.side_effect = self._mock_runroot(
0,
{'create-ostree-repo.log': ['Doing work', 'Weird output']})
t = ostree.OSTreeThread(self.pool)
t = ostree.OSTreeThread(self.pool, ["http://example.com/repo/1"])
t.process((self.compose, self.compose.variants['Everything'], 'x86_64', self.cfg), 1)
@ -341,7 +351,7 @@ class OSTreeThreadTest(helpers.PungiTestCase):
koji = KojiWrapper.return_value
koji.run_runroot_cmd.side_effect = self._mock_runroot(1)
t = ostree.OSTreeThread(self.pool)
t = ostree.OSTreeThread(self.pool, ["http://example.com/repo/1"])
self.assertRaises(RuntimeError, t.process,
(self.compose, self.compose.variants['Everything'], 'x86_64', self.cfg),
@ -358,7 +368,7 @@ class OSTreeThreadTest(helpers.PungiTestCase):
koji = KojiWrapper.return_value
koji.run_runroot_cmd.side_effect = self._mock_runroot(0)
t = ostree.OSTreeThread(self.pool)
t = ostree.OSTreeThread(self.pool, ["http://example.com/repo/1"])
t.process((self.compose, self.compose.variants['Everything'], 'x86_64', self.cfg), 1)
@ -393,7 +403,7 @@ class OSTreeThreadTest(helpers.PungiTestCase):
koji = KojiWrapper.return_value
koji.run_runroot_cmd.side_effect = self._mock_runroot(0)
t = ostree.OSTreeThread(self.pool)
t = ostree.OSTreeThread(self.pool, ["http://example.com/repo/1"])
t.process((self.compose, self.compose.variants['Everything'], 'x86_64', self.cfg), 1)
@ -428,7 +438,7 @@ class OSTreeThreadTest(helpers.PungiTestCase):
koji = KojiWrapper.return_value
koji.run_runroot_cmd.side_effect = self._mock_runroot(0)
t = ostree.OSTreeThread(self.pool)
t = ostree.OSTreeThread(self.pool, ["http://example.com/repo/1"])
t.process((self.compose, self.compose.variants['Everything'], 'x86_64', self.cfg), 1)
@ -482,7 +492,7 @@ class OSTreeThreadTest(helpers.PungiTestCase):
'ostree_repo': self.repo
}
t = ostree.OSTreeThread(self.pool)
t = ostree.OSTreeThread(self.pool, ["http://example.com/repo/1"])
t.process((self.compose, self.compose.variants['Everything'], 'x86_64', cfg), 1)
@ -495,7 +505,7 @@ class OSTreeThreadTest(helpers.PungiTestCase):
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/work/$basearch/repo')
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')