2016-03-23 09:40:16 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
import mock
|
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
2017-01-13 08:57:30 +00:00
|
|
|
from kobo.shortcuts import force_list
|
|
|
|
|
2016-03-23 09:40:16 +00:00
|
|
|
from tests import helpers
|
2016-04-05 07:13:01 +00:00
|
|
|
from pungi.phases import ostree_installer as ostree
|
2018-02-20 13:29:49 +00:00
|
|
|
from six.moves import shlex_quote
|
2016-03-23 09:40:16 +00:00
|
|
|
|
|
|
|
|
2017-03-15 14:54:45 +00:00
|
|
|
LOG_PATH = 'logs/x86_64/Everything/ostree_installer-1'
|
|
|
|
|
|
|
|
|
2016-04-05 07:13:01 +00:00
|
|
|
class OstreeInstallerPhaseTest(helpers.PungiTestCase):
|
2016-03-23 09:40:16 +00:00
|
|
|
|
2016-04-05 07:13:01 +00:00
|
|
|
@mock.patch('pungi.phases.ostree_installer.ThreadPool')
|
2016-03-23 09:40:16 +00:00
|
|
|
def test_run(self, ThreadPool):
|
2017-02-22 02:48:05 +00:00
|
|
|
cfg = helpers.IterableMock()
|
2016-03-23 09:40:16 +00:00
|
|
|
compose = helpers.DummyCompose(self.topdir, {
|
2016-04-05 07:13:01 +00:00
|
|
|
'ostree_installer': [
|
2016-03-23 09:40:16 +00:00
|
|
|
('^Everything$', {'x86_64': cfg})
|
2019-03-21 09:58:13 +00:00
|
|
|
],
|
|
|
|
'runroot': True,
|
2019-08-01 14:36:54 +00:00
|
|
|
"translate_paths": [(self.topdir + "/work", "http://example.com/work")],
|
2016-03-23 09:40:16 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
pool = ThreadPool.return_value
|
|
|
|
|
2019-08-01 14:36:54 +00:00
|
|
|
phase = ostree.OstreeInstallerPhase(
|
|
|
|
compose, mock.Mock(), self._make_pkgset_phase(["p1", "p2"])
|
|
|
|
)
|
2016-03-23 09:40:16 +00:00
|
|
|
phase.run()
|
|
|
|
|
|
|
|
self.assertEqual(len(pool.add.call_args_list), 1)
|
2019-08-01 14:36:54 +00:00
|
|
|
self.assertEqual(
|
|
|
|
pool.add.call_args_list[0][0][0].baseurls,
|
|
|
|
[
|
|
|
|
"http://example.com/work/$basearch/repo/p1",
|
|
|
|
"http://example.com/work/$basearch/repo/p2",
|
|
|
|
],
|
|
|
|
)
|
2016-03-23 09:40:16 +00:00
|
|
|
self.assertEqual(pool.queue_put.call_args_list,
|
|
|
|
[mock.call((compose, compose.variants['Everything'], 'x86_64', cfg))])
|
|
|
|
|
2016-04-05 07:13:01 +00:00
|
|
|
@mock.patch('pungi.phases.ostree_installer.ThreadPool')
|
2016-03-23 09:40:16 +00:00
|
|
|
def test_skip_without_config(self, ThreadPool):
|
|
|
|
compose = helpers.DummyCompose(self.topdir, {})
|
|
|
|
compose.just_phases = None
|
|
|
|
compose.skip_phases = []
|
2018-05-07 08:47:48 +00:00
|
|
|
phase = ostree.OstreeInstallerPhase(compose, mock.Mock())
|
2016-03-23 09:40:16 +00:00
|
|
|
self.assertTrue(phase.skip())
|
|
|
|
|
2018-05-07 08:47:48 +00:00
|
|
|
def test_validate_conflict_with_buildinstall(self):
|
|
|
|
compose = helpers.DummyCompose(self.topdir, {
|
|
|
|
'ostree_installer': [
|
|
|
|
('^Server$', {'x86_64': mock.Mock()})
|
|
|
|
],
|
|
|
|
})
|
|
|
|
|
2018-05-24 11:18:57 +00:00
|
|
|
skipmock = mock.Mock()
|
|
|
|
skipmock.skip.return_value = False
|
|
|
|
phase = ostree.OstreeInstallerPhase(compose, skipmock)
|
2018-05-07 08:47:48 +00:00
|
|
|
with self.assertRaises(ValueError) as ctx:
|
|
|
|
phase.validate()
|
|
|
|
|
|
|
|
self.assertEqual(str(ctx.exception),
|
|
|
|
'Can not generate ostree installer for Server.x86_64:'
|
|
|
|
' it has buildinstall running already and the files'
|
|
|
|
' would clash.')
|
|
|
|
|
|
|
|
def test_validate_buildinstall_skipped(self):
|
|
|
|
compose = helpers.DummyCompose(self.topdir, {
|
|
|
|
'ostree_installer': [
|
|
|
|
('^Server$', {'x86_64': mock.Mock()})
|
|
|
|
],
|
|
|
|
})
|
|
|
|
|
|
|
|
phase = ostree.OstreeInstallerPhase(compose, mock.Mock(_skipped=True))
|
|
|
|
phase.validate()
|
|
|
|
|
2018-05-07 08:59:34 +00:00
|
|
|
def test_validate_overwrite_enabled(self):
|
|
|
|
compose = helpers.DummyCompose(self.topdir, {
|
|
|
|
'ostree_installer_overwrite': True,
|
|
|
|
'ostree_installer': [
|
|
|
|
('^Server$', {'x86_64': mock.Mock()})
|
|
|
|
],
|
|
|
|
})
|
|
|
|
|
|
|
|
phase = ostree.OstreeInstallerPhase(compose, mock.Mock(_skipped=False))
|
|
|
|
phase.validate()
|
|
|
|
|
2016-03-23 09:40:16 +00:00
|
|
|
|
2016-04-05 07:13:01 +00:00
|
|
|
class OstreeThreadTest(helpers.PungiTestCase):
|
2016-03-23 09:40:16 +00:00
|
|
|
|
2016-10-06 07:17:09 +00:00
|
|
|
def setUp(self):
|
|
|
|
super(OstreeThreadTest, self).setUp()
|
|
|
|
self.compose = helpers.DummyCompose(self.topdir, {
|
|
|
|
'release_name': 'Fedora',
|
|
|
|
'release_version': 'Rawhide',
|
|
|
|
'koji_profile': 'koji',
|
|
|
|
'runroot_tag': 'rrt',
|
|
|
|
'image_volid_formats': ['{release_short}-{variant}-{arch}'],
|
2018-02-20 13:29:49 +00:00
|
|
|
'translate_paths': [
|
|
|
|
(self.topdir + '/work', 'http://example.com/work')
|
|
|
|
],
|
2016-10-06 07:17:09 +00:00
|
|
|
})
|
|
|
|
|
2016-10-12 11:56:19 +00:00
|
|
|
def assertImageAdded(self, compose, ImageCls, iso):
|
2016-03-23 09:40:16 +00:00
|
|
|
image = ImageCls.return_value
|
|
|
|
self.assertEqual(image.path, 'Everything/x86_64/iso/image-name')
|
|
|
|
self.assertEqual(image.mtime, 13579)
|
|
|
|
self.assertEqual(image.size, 1024)
|
|
|
|
self.assertEqual(image.arch, 'x86_64')
|
2016-10-06 11:12:34 +00:00
|
|
|
self.assertEqual(image.type, "dvd-ostree")
|
2016-03-23 09:40:16 +00:00
|
|
|
self.assertEqual(image.format, "iso")
|
|
|
|
self.assertEqual(image.disc_number, 1)
|
|
|
|
self.assertEqual(image.disc_count, 1)
|
|
|
|
self.assertEqual(image.bootable, True)
|
2016-10-12 11:56:19 +00:00
|
|
|
self.assertEqual(image.implant_md5, iso.get_implanted_md5.return_value)
|
2016-03-23 09:40:16 +00:00
|
|
|
self.assertEqual(compose.im.add.mock_calls,
|
|
|
|
[mock.call('Everything', 'x86_64', image)])
|
|
|
|
|
2019-10-10 19:11:38 +00:00
|
|
|
def assertRunrootCall(self, koji, sources, release, isfinal=False, extra=[],
|
|
|
|
extra_pkgs=[], weight=None):
|
2017-01-13 08:57:30 +00:00
|
|
|
lorax_cmd = [
|
|
|
|
'lorax',
|
|
|
|
'--product=Fedora',
|
|
|
|
'--version=Rawhide',
|
|
|
|
'--release=%s' % release,
|
|
|
|
]
|
|
|
|
|
|
|
|
for s in force_list(sources):
|
2018-02-20 13:29:49 +00:00
|
|
|
lorax_cmd.append(shlex_quote('--source=%s' % s))
|
2017-01-13 08:57:30 +00:00
|
|
|
|
|
|
|
lorax_cmd.append('--variant=Everything')
|
|
|
|
lorax_cmd.append('--nomacboot')
|
|
|
|
|
|
|
|
if isfinal:
|
|
|
|
lorax_cmd.append('--isfinal')
|
|
|
|
|
2019-01-28 12:21:31 +00:00
|
|
|
lorax_cmd.append("--buildarch=x86_64")
|
2017-01-13 08:57:30 +00:00
|
|
|
lorax_cmd.append('--volid=test-Everything-x86_64')
|
|
|
|
|
|
|
|
if extra:
|
|
|
|
lorax_cmd.extend(extra)
|
|
|
|
|
2017-06-15 06:10:56 +00:00
|
|
|
outdir = self.topdir + '/work/x86_64/Everything/ostree_installer'
|
|
|
|
lorax_cmd.append(outdir)
|
2017-01-13 08:57:30 +00:00
|
|
|
|
2016-10-06 07:35:41 +00:00
|
|
|
self.assertEqual(koji.get_runroot_cmd.call_args_list,
|
|
|
|
[mock.call('rrt', 'x86_64',
|
2017-06-15 06:10:56 +00:00
|
|
|
'rm -rf %s && %s' % (outdir, ' '.join(lorax_cmd)),
|
2016-10-06 07:35:41 +00:00
|
|
|
channel=None, mounts=[self.topdir],
|
2019-10-10 19:11:38 +00:00
|
|
|
packages=['pungi', 'lorax', 'ostree'] + extra_pkgs,
|
2018-05-29 06:38:09 +00:00
|
|
|
task_id=True, use_shell=True, weight=weight,
|
2019-05-16 08:36:09 +00:00
|
|
|
chown_paths=[outdir])])
|
2016-10-06 07:35:41 +00:00
|
|
|
self.assertEqual(koji.run_runroot_cmd.call_args_list,
|
|
|
|
[mock.call(koji.get_runroot_cmd.return_value,
|
2019-05-16 08:36:09 +00:00
|
|
|
log_file=os.path.join(self.topdir, LOG_PATH, "runroot.log"))])
|
2016-10-06 07:35:41 +00:00
|
|
|
|
|
|
|
def assertIsoLinked(self, link, get_file_size, get_mtime, final_iso_path):
|
|
|
|
self.assertEqual(link.call_args_list,
|
|
|
|
[mock.call(self.topdir + '/work/x86_64/Everything/ostree_installer/images/boot.iso',
|
|
|
|
final_iso_path)])
|
|
|
|
self.assertEqual(get_file_size.call_args_list, [mock.call(final_iso_path)])
|
|
|
|
self.assertEqual(get_mtime.call_args_list, [mock.call(final_iso_path)])
|
|
|
|
|
2018-05-15 07:26:54 +00:00
|
|
|
def assertAllCopied(self, copy_all):
|
2016-10-06 07:35:41 +00:00
|
|
|
self.assertEqual(self.compose.get_image_name.call_args_list,
|
|
|
|
[mock.call('x86_64', self.compose.variants['Everything'], disc_type='ostree')])
|
|
|
|
self.assertTrue(os.path.isdir(self.topdir + '/work/x86_64/Everything/'))
|
|
|
|
self.assertFalse(os.path.isdir(self.topdir + '/work/x86_64/Everything/ostree_installer'))
|
2018-05-15 07:26:54 +00:00
|
|
|
self.assertEqual(copy_all.call_args_list,
|
|
|
|
[mock.call('{0}/work/x86_64/Everything/ostree_installer'.format(self.topdir),
|
|
|
|
'{0}/compose/Everything/x86_64/os'.format(self.topdir))])
|
2016-10-06 07:35:41 +00:00
|
|
|
|
2018-05-15 07:26:54 +00:00
|
|
|
@mock.patch('pungi.util.copy_all')
|
2016-03-23 09:40:16 +00:00
|
|
|
@mock.patch('productmd.images.Image')
|
|
|
|
@mock.patch('pungi.util.get_mtime')
|
|
|
|
@mock.patch('pungi.util.get_file_size')
|
2016-10-12 11:56:19 +00:00
|
|
|
@mock.patch('pungi.phases.ostree_installer.iso')
|
2016-03-23 09:40:16 +00:00
|
|
|
@mock.patch('os.link')
|
|
|
|
@mock.patch('pungi.wrappers.kojiwrapper.KojiWrapper')
|
2016-10-12 11:56:19 +00:00
|
|
|
def test_run(self, KojiWrapper, link, iso,
|
2018-05-15 07:26:54 +00:00
|
|
|
get_file_size, get_mtime, ImageCls, copy_all):
|
2016-10-06 07:17:09 +00:00
|
|
|
self.compose.supported = False
|
2016-03-23 09:40:16 +00:00
|
|
|
pool = mock.Mock()
|
|
|
|
cfg = {
|
2018-02-20 13:29:49 +00:00
|
|
|
'repo': 'Everything', # this variant-type repo is deprecated, in result will be replaced with default repo
|
2016-03-23 09:40:16 +00:00
|
|
|
'release': '20160321.n.0',
|
|
|
|
}
|
|
|
|
koji = KojiWrapper.return_value
|
|
|
|
koji.run_runroot_cmd.return_value = {
|
|
|
|
'task_id': 1234,
|
|
|
|
'retcode': 0,
|
|
|
|
'output': 'Foo bar\n',
|
|
|
|
}
|
|
|
|
get_file_size.return_value = 1024
|
|
|
|
get_mtime.return_value = 13579
|
|
|
|
final_iso_path = self.topdir + '/compose/Everything/x86_64/iso/image-name'
|
|
|
|
|
2019-08-01 14:36:54 +00:00
|
|
|
t = ostree.OstreeInstallerThread(pool, ["http://example.com/repo/1"])
|
2016-03-23 09:40:16 +00:00
|
|
|
|
2016-10-06 07:17:09 +00:00
|
|
|
t.process((self.compose, self.compose.variants['Everything'], 'x86_64', cfg), 1)
|
2016-03-23 09:40:16 +00:00
|
|
|
|
2016-10-06 07:35:41 +00:00
|
|
|
self.assertRunrootCall(koji,
|
2019-08-01 14:36:54 +00:00
|
|
|
["http://example.com/repo/1",
|
2018-04-09 13:32:33 +00:00
|
|
|
'http://example.com/work/$basearch/comps_repo_Everything'],
|
2016-11-09 08:00:33 +00:00
|
|
|
cfg['release'],
|
2017-03-15 14:54:45 +00:00
|
|
|
extra=['--logfile=%s/%s/lorax.log' % (self.topdir, LOG_PATH)])
|
2016-10-06 07:35:41 +00:00
|
|
|
self.assertIsoLinked(link, get_file_size, get_mtime, final_iso_path)
|
2016-10-12 11:56:19 +00:00
|
|
|
self.assertImageAdded(self.compose, ImageCls, iso)
|
2018-05-15 07:26:54 +00:00
|
|
|
self.assertAllCopied(copy_all)
|
2016-05-24 08:03:36 +00:00
|
|
|
|
2018-05-15 07:26:54 +00:00
|
|
|
@mock.patch('pungi.util.copy_all')
|
2016-05-24 08:03:36 +00:00
|
|
|
@mock.patch('productmd.images.Image')
|
|
|
|
@mock.patch('pungi.util.get_mtime')
|
|
|
|
@mock.patch('pungi.util.get_file_size')
|
2016-10-12 11:56:19 +00:00
|
|
|
@mock.patch('pungi.phases.ostree_installer.iso')
|
2016-05-24 08:03:36 +00:00
|
|
|
@mock.patch('os.link')
|
|
|
|
@mock.patch('pungi.wrappers.kojiwrapper.KojiWrapper')
|
2016-10-12 11:56:19 +00:00
|
|
|
def test_run_external_source(self, KojiWrapper, link, iso,
|
2018-05-15 07:26:54 +00:00
|
|
|
get_file_size, get_mtime, ImageCls, copy_all):
|
2016-05-24 08:03:36 +00:00
|
|
|
pool = mock.Mock()
|
|
|
|
cfg = {
|
2017-03-27 21:53:08 +00:00
|
|
|
'repo': 'http://example.com/repo/$arch/',
|
2016-05-24 08:03:36 +00:00
|
|
|
'release': '20160321.n.0',
|
|
|
|
}
|
|
|
|
koji = KojiWrapper.return_value
|
|
|
|
koji.run_runroot_cmd.return_value = {
|
|
|
|
'task_id': 1234,
|
|
|
|
'retcode': 0,
|
|
|
|
'output': 'Foo bar\n',
|
|
|
|
}
|
|
|
|
get_file_size.return_value = 1024
|
|
|
|
get_mtime.return_value = 13579
|
|
|
|
final_iso_path = self.topdir + '/compose/Everything/x86_64/iso/image-name'
|
|
|
|
|
2019-08-01 14:36:54 +00:00
|
|
|
t = ostree.OstreeInstallerThread(pool, ["http://example.com/repo/1"])
|
2016-05-24 08:03:36 +00:00
|
|
|
|
2016-10-06 07:17:09 +00:00
|
|
|
t.process((self.compose, self.compose.variants['Everything'], 'x86_64', cfg), 1)
|
2016-05-24 08:03:36 +00:00
|
|
|
|
2018-02-20 13:29:49 +00:00
|
|
|
self.assertRunrootCall(koji,
|
|
|
|
('http://example.com/repo/x86_64/',
|
2019-08-01 14:36:54 +00:00
|
|
|
"http://example.com/repo/1",
|
2018-04-09 13:32:33 +00:00
|
|
|
'http://example.com/work/$basearch/comps_repo_Everything'),
|
2018-02-20 13:29:49 +00:00
|
|
|
cfg['release'],
|
|
|
|
isfinal=True,
|
2017-03-15 14:54:45 +00:00
|
|
|
extra=['--logfile=%s/%s/lorax.log' % (self.topdir, LOG_PATH)])
|
2016-10-06 07:35:41 +00:00
|
|
|
self.assertIsoLinked(link, get_file_size, get_mtime, final_iso_path)
|
2016-10-12 11:56:19 +00:00
|
|
|
self.assertImageAdded(self.compose, ImageCls, iso)
|
2018-05-15 07:26:54 +00:00
|
|
|
self.assertAllCopied(copy_all)
|
2016-04-11 08:25:10 +00:00
|
|
|
|
2018-05-15 07:26:54 +00:00
|
|
|
@mock.patch('pungi.util.copy_all')
|
2017-01-13 08:57:30 +00:00
|
|
|
@mock.patch('productmd.images.Image')
|
|
|
|
@mock.patch('pungi.util.get_mtime')
|
|
|
|
@mock.patch('pungi.util.get_file_size')
|
|
|
|
@mock.patch('pungi.phases.ostree_installer.iso')
|
|
|
|
@mock.patch('os.link')
|
|
|
|
@mock.patch('pungi.wrappers.kojiwrapper.KojiWrapper')
|
|
|
|
def test_run_with_repo_key(self, KojiWrapper, link, iso,
|
2018-05-15 07:26:54 +00:00
|
|
|
get_file_size, get_mtime, ImageCls, copy_all):
|
2017-01-13 08:57:30 +00:00
|
|
|
pool = mock.Mock()
|
|
|
|
cfg = {
|
|
|
|
'release': '20160321.n.0',
|
|
|
|
'repo': [
|
2018-02-20 13:29:49 +00:00
|
|
|
'Everything', # this variant-type repo is deprecated, in result will be replaced with default repo
|
2017-01-13 08:57:30 +00:00
|
|
|
'https://example.com/extra-repo1.repo',
|
|
|
|
'https://example.com/extra-repo2.repo',
|
|
|
|
],
|
|
|
|
}
|
|
|
|
koji = KojiWrapper.return_value
|
|
|
|
koji.run_runroot_cmd.return_value = {
|
|
|
|
'task_id': 1234,
|
|
|
|
'retcode': 0,
|
|
|
|
'output': 'Foo bar\n',
|
|
|
|
}
|
|
|
|
|
2019-08-01 14:36:54 +00:00
|
|
|
t = ostree.OstreeInstallerThread(pool, ["http://example.com/repo/1"])
|
2017-01-13 08:57:30 +00:00
|
|
|
|
|
|
|
t.process((self.compose, self.compose.variants['Everything'], 'x86_64', cfg), 1)
|
|
|
|
|
|
|
|
sources = [
|
|
|
|
'https://example.com/extra-repo1.repo',
|
2018-02-20 13:29:49 +00:00
|
|
|
'https://example.com/extra-repo2.repo',
|
2019-08-01 14:36:54 +00:00
|
|
|
"http://example.com/repo/1",
|
2018-04-09 13:32:33 +00:00
|
|
|
'http://example.com/work/$basearch/comps_repo_Everything',
|
2017-01-13 08:57:30 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
self.assertRunrootCall(koji, sources, cfg['release'], isfinal=True,
|
2017-03-15 14:54:45 +00:00
|
|
|
extra=['--logfile=%s/%s/lorax.log' % (self.topdir, LOG_PATH)])
|
2017-01-13 08:57:30 +00:00
|
|
|
|
2018-05-15 07:26:54 +00:00
|
|
|
@mock.patch('pungi.util.copy_all')
|
2017-01-13 08:57:30 +00:00
|
|
|
@mock.patch('productmd.images.Image')
|
|
|
|
@mock.patch('pungi.util.get_mtime')
|
|
|
|
@mock.patch('pungi.util.get_file_size')
|
|
|
|
@mock.patch('pungi.phases.ostree_installer.iso')
|
|
|
|
@mock.patch('os.link')
|
|
|
|
@mock.patch('pungi.wrappers.kojiwrapper.KojiWrapper')
|
|
|
|
def test_run_with_multiple_variant_repos(self, KojiWrapper, link, iso,
|
2018-05-15 07:26:54 +00:00
|
|
|
get_file_size, get_mtime, ImageCls, copy_all):
|
2017-01-13 08:57:30 +00:00
|
|
|
pool = mock.Mock()
|
|
|
|
cfg = {
|
|
|
|
'release': '20160321.n.0',
|
|
|
|
'repo': [
|
2018-02-20 13:29:49 +00:00
|
|
|
'Everything', # this variant-type repo is deprecated, in result will be replaced with default repo
|
|
|
|
'Server', # this variant-type repo is deprecated, in result will be replaced with default repo
|
2017-01-13 08:57:30 +00:00
|
|
|
'https://example.com/extra-repo1.repo',
|
|
|
|
'https://example.com/extra-repo2.repo',
|
|
|
|
],
|
|
|
|
}
|
|
|
|
koji = KojiWrapper.return_value
|
|
|
|
koji.run_runroot_cmd.return_value = {
|
|
|
|
'task_id': 1234,
|
|
|
|
'retcode': 0,
|
|
|
|
'output': 'Foo bar\n',
|
|
|
|
}
|
|
|
|
|
2019-08-01 14:36:54 +00:00
|
|
|
t = ostree.OstreeInstallerThread(pool, ["http://example.com/repo/1"])
|
2017-01-13 08:57:30 +00:00
|
|
|
|
|
|
|
t.process((self.compose, self.compose.variants['Everything'], 'x86_64', cfg), 1)
|
|
|
|
|
|
|
|
sources = [
|
|
|
|
'https://example.com/extra-repo1.repo',
|
2018-02-20 13:29:49 +00:00
|
|
|
'https://example.com/extra-repo2.repo',
|
2019-08-01 14:36:54 +00:00
|
|
|
"http://example.com/repo/1",
|
2018-04-09 13:32:33 +00:00
|
|
|
'http://example.com/work/$basearch/comps_repo_Everything',
|
2017-01-13 08:57:30 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
self.assertRunrootCall(koji, sources, cfg['release'], isfinal=True,
|
2017-03-15 14:54:45 +00:00
|
|
|
extra=['--logfile=%s/%s/lorax.log' % (self.topdir, LOG_PATH)])
|
2017-01-13 08:57:30 +00:00
|
|
|
|
2018-05-15 07:26:54 +00:00
|
|
|
@mock.patch('pungi.util.copy_all')
|
2016-04-11 08:25:10 +00:00
|
|
|
@mock.patch('productmd.images.Image')
|
|
|
|
@mock.patch('pungi.util.get_mtime')
|
2018-06-06 13:44:11 +00:00
|
|
|
@mock.patch('pungi.util.get_file_size')
|
|
|
|
@mock.patch('pungi.phases.ostree_installer.iso')
|
|
|
|
@mock.patch('os.link')
|
|
|
|
@mock.patch('pungi.wrappers.kojiwrapper.KojiWrapper')
|
|
|
|
def test_run_without_comps(
|
|
|
|
self, KojiWrapper, link, iso, get_file_size, get_mtime, ImageCls, copy_all
|
|
|
|
):
|
|
|
|
self.compose.has_comps = False
|
|
|
|
pool = mock.Mock()
|
|
|
|
cfg = {
|
|
|
|
'release': '20160321.n.0',
|
|
|
|
'repo': [],
|
|
|
|
}
|
|
|
|
koji = KojiWrapper.return_value
|
|
|
|
koji.run_runroot_cmd.return_value = {
|
|
|
|
'task_id': 1234,
|
|
|
|
'retcode': 0,
|
|
|
|
'output': 'Foo bar\n',
|
|
|
|
}
|
|
|
|
|
2019-08-01 14:36:54 +00:00
|
|
|
t = ostree.OstreeInstallerThread(pool, ["http://example.com/repo/1"])
|
2018-06-06 13:44:11 +00:00
|
|
|
|
|
|
|
t.process((self.compose, self.compose.variants['Everything'], 'x86_64', cfg), 1)
|
|
|
|
|
2019-08-01 14:36:54 +00:00
|
|
|
sources = ["http://example.com/repo/1"]
|
2018-06-06 13:44:11 +00:00
|
|
|
|
|
|
|
self.assertRunrootCall(koji, sources, cfg['release'], isfinal=True,
|
|
|
|
extra=['--logfile=%s/%s/lorax.log' % (self.topdir, LOG_PATH)])
|
|
|
|
|
|
|
|
@mock.patch('pungi.util.copy_all')
|
|
|
|
@mock.patch('productmd.images.Image')
|
|
|
|
@mock.patch('pungi.util.get_mtime')
|
2016-04-11 08:25:10 +00:00
|
|
|
@mock.patch('pungi.util.get_file_size')
|
2016-10-12 11:56:19 +00:00
|
|
|
@mock.patch('pungi.wrappers.iso')
|
2016-04-11 08:25:10 +00:00
|
|
|
@mock.patch('os.link')
|
|
|
|
@mock.patch('pungi.wrappers.kojiwrapper.KojiWrapper')
|
|
|
|
def test_fail_with_relative_template_path_but_no_repo(self, KojiWrapper, link,
|
2016-10-12 11:56:19 +00:00
|
|
|
iso, get_file_size,
|
2018-05-15 07:26:54 +00:00
|
|
|
get_mtime, ImageCls, copy_all):
|
2016-04-11 08:25:10 +00:00
|
|
|
pool = mock.Mock()
|
|
|
|
cfg = {
|
2017-03-27 21:53:08 +00:00
|
|
|
'repo': 'Everything',
|
2016-04-11 08:25:10 +00:00
|
|
|
'release': '20160321.n.0',
|
|
|
|
'add_template': ['some-file.txt'],
|
|
|
|
}
|
|
|
|
koji = KojiWrapper.return_value
|
|
|
|
koji.run_runroot_cmd.return_value = {
|
|
|
|
'task_id': 1234,
|
|
|
|
'retcode': 0,
|
|
|
|
'output': 'Foo bar\n',
|
|
|
|
}
|
|
|
|
get_file_size.return_value = 1024
|
|
|
|
get_mtime.return_value = 13579
|
|
|
|
|
2019-08-01 14:36:54 +00:00
|
|
|
t = ostree.OstreeInstallerThread(pool, ["http://example.com/repo/1"])
|
2016-04-11 08:25:10 +00:00
|
|
|
|
|
|
|
with self.assertRaises(RuntimeError) as ctx:
|
2016-10-06 07:17:09 +00:00
|
|
|
t.process((self.compose, self.compose.variants['Everything'], 'x86_64', cfg), 1)
|
2016-04-11 08:25:10 +00:00
|
|
|
|
|
|
|
self.assertIn('template_repo', str(ctx.exception))
|
|
|
|
|
|
|
|
@mock.patch('pungi.wrappers.scm.get_dir_from_scm')
|
2018-05-15 07:26:54 +00:00
|
|
|
@mock.patch('pungi.util.copy_all')
|
2016-04-11 08:25:10 +00:00
|
|
|
@mock.patch('productmd.images.Image')
|
|
|
|
@mock.patch('pungi.util.get_mtime')
|
|
|
|
@mock.patch('pungi.util.get_file_size')
|
2016-10-12 11:56:19 +00:00
|
|
|
@mock.patch('pungi.phases.ostree_installer.iso')
|
2016-04-11 08:25:10 +00:00
|
|
|
@mock.patch('os.link')
|
|
|
|
@mock.patch('pungi.wrappers.kojiwrapper.KojiWrapper')
|
2016-10-12 11:56:19 +00:00
|
|
|
def test_run_clone_templates(self, KojiWrapper, link, iso,
|
2018-05-15 07:26:54 +00:00
|
|
|
get_file_size, get_mtime, ImageCls, copy_all,
|
2016-04-11 08:25:10 +00:00
|
|
|
get_dir_from_scm):
|
|
|
|
pool = mock.Mock()
|
|
|
|
cfg = {
|
2018-02-20 13:29:49 +00:00
|
|
|
'repo': 'Everything', # this variant-type repo is deprecated, in result will be replaced with default repo
|
2016-04-11 08:25:10 +00:00
|
|
|
'release': '20160321.n.0',
|
|
|
|
'add_template': ['some_file.txt'],
|
|
|
|
'add_arch_template': ['other_file.txt'],
|
|
|
|
'template_repo': 'git://example.com/templates.git',
|
|
|
|
'template_branch': 'f24',
|
2019-10-10 19:11:38 +00:00
|
|
|
'extra_runroot_pkgs': ['templatedep'],
|
2016-04-11 08:25:10 +00:00
|
|
|
}
|
|
|
|
koji = KojiWrapper.return_value
|
|
|
|
koji.run_runroot_cmd.return_value = {
|
|
|
|
'task_id': 1234,
|
|
|
|
'retcode': 0,
|
|
|
|
'output': 'Foo bar\n',
|
|
|
|
}
|
|
|
|
get_file_size.return_value = 1024
|
|
|
|
get_mtime.return_value = 13579
|
|
|
|
final_iso_path = self.topdir + '/compose/Everything/x86_64/iso/image-name'
|
|
|
|
templ_dir = self.topdir + '/work/x86_64/Everything/lorax_templates'
|
|
|
|
|
2019-08-01 14:36:54 +00:00
|
|
|
t = ostree.OstreeInstallerThread(pool, ["http://example.com/repo/1"])
|
2016-04-11 08:25:10 +00:00
|
|
|
|
2016-10-06 07:17:09 +00:00
|
|
|
t.process((self.compose, self.compose.variants['Everything'], 'x86_64', cfg), 1)
|
2016-04-11 08:25:10 +00:00
|
|
|
|
|
|
|
self.assertEqual(get_dir_from_scm.call_args_list,
|
|
|
|
[mock.call({'scm': 'git', 'repo': 'git://example.com/templates.git',
|
|
|
|
'branch': 'f24', 'dir': '.'},
|
|
|
|
templ_dir, logger=pool._logger)])
|
2016-10-06 07:35:41 +00:00
|
|
|
self.assertRunrootCall(koji,
|
2019-08-01 14:36:54 +00:00
|
|
|
["http://example.com/repo/1",
|
2018-04-09 13:32:33 +00:00
|
|
|
'http://example.com/work/$basearch/comps_repo_Everything'],
|
2016-10-06 07:35:41 +00:00
|
|
|
cfg['release'],
|
|
|
|
isfinal=True,
|
|
|
|
extra=['--add-template=%s/some_file.txt' % templ_dir,
|
2016-11-09 08:00:33 +00:00
|
|
|
'--add-arch-template=%s/other_file.txt' % templ_dir,
|
2019-10-10 19:11:38 +00:00
|
|
|
'--logfile=%s/%s/lorax.log' % (self.topdir, LOG_PATH)],
|
|
|
|
extra_pkgs=['templatedep'])
|
2016-10-06 07:35:41 +00:00
|
|
|
self.assertIsoLinked(link, get_file_size, get_mtime, final_iso_path)
|
2016-10-12 11:56:19 +00:00
|
|
|
self.assertImageAdded(self.compose, ImageCls, iso)
|
2018-05-15 07:26:54 +00:00
|
|
|
self.assertAllCopied(copy_all)
|
2016-03-23 09:40:16 +00:00
|
|
|
|
2018-05-15 07:26:54 +00:00
|
|
|
@mock.patch('pungi.util.copy_all')
|
2016-03-23 09:40:16 +00:00
|
|
|
@mock.patch('productmd.images.Image')
|
|
|
|
@mock.patch('pungi.util.get_mtime')
|
2017-04-07 13:33:43 +00:00
|
|
|
@mock.patch('pungi.util.get_file_size')
|
|
|
|
@mock.patch('pungi.phases.ostree_installer.iso')
|
|
|
|
@mock.patch('os.link')
|
|
|
|
@mock.patch('pungi.wrappers.kojiwrapper.KojiWrapper')
|
|
|
|
def test_run_with_explicitly_generated_release(self, KojiWrapper, link, iso,
|
2018-05-15 07:26:54 +00:00
|
|
|
get_file_size, get_mtime, ImageCls, copy_all):
|
2017-04-07 13:33:43 +00:00
|
|
|
pool = mock.Mock()
|
|
|
|
cfg = {
|
2018-02-20 13:29:49 +00:00
|
|
|
'repo': 'Everything', # this variant-type repo is deprecated, in result will be replaced with default repo
|
2017-04-07 13:33:43 +00:00
|
|
|
'release': '!RELEASE_FROM_LABEL_DATE_TYPE_RESPIN',
|
|
|
|
"installpkgs": ["fedora-productimg-atomic"],
|
|
|
|
"add_template": ["/spin-kickstarts/atomic-installer/lorax-configure-repo.tmpl"],
|
|
|
|
"add_template_var": [
|
|
|
|
"ostree_osname=fedora-atomic",
|
|
|
|
"ostree_ref=fedora-atomic/Rawhide/x86_64/docker-host",
|
|
|
|
],
|
|
|
|
"add_arch_template": ["/spin-kickstarts/atomic-installer/lorax-embed-repo.tmpl"],
|
|
|
|
"add_arch_template_var": [
|
|
|
|
"ostree_repo=https://kojipkgs.fedoraproject.org/compose/atomic/Rawhide/",
|
|
|
|
"ostree_osname=fedora-atomic",
|
|
|
|
"ostree_ref=fedora-atomic/Rawhide/x86_64/docker-host",
|
|
|
|
],
|
|
|
|
}
|
|
|
|
self.compose.conf['runroot_weights'] = {'ostree_installer': 123}
|
|
|
|
koji = KojiWrapper.return_value
|
|
|
|
koji.run_runroot_cmd.return_value = {
|
|
|
|
'task_id': 1234,
|
|
|
|
'retcode': 0,
|
|
|
|
'output': 'Foo bar\n',
|
|
|
|
}
|
|
|
|
get_file_size.return_value = 1024
|
|
|
|
get_mtime.return_value = 13579
|
|
|
|
final_iso_path = self.topdir + '/compose/Everything/x86_64/iso/image-name'
|
|
|
|
|
2019-08-01 14:36:54 +00:00
|
|
|
t = ostree.OstreeInstallerThread(pool, ["http://example.com/repo/1"])
|
2017-04-07 13:33:43 +00:00
|
|
|
|
|
|
|
t.process((self.compose, self.compose.variants['Everything'], 'x86_64', cfg), 1)
|
|
|
|
|
|
|
|
self.assertRunrootCall(
|
|
|
|
koji,
|
2019-08-01 14:36:54 +00:00
|
|
|
["http://example.com/repo/1",
|
2018-04-09 13:32:33 +00:00
|
|
|
'http://example.com/work/$basearch/comps_repo_Everything'],
|
2017-04-07 13:33:43 +00:00
|
|
|
'20151203.t.0',
|
|
|
|
isfinal=True,
|
|
|
|
extra=['--installpkgs=fedora-productimg-atomic',
|
|
|
|
'--add-template=/spin-kickstarts/atomic-installer/lorax-configure-repo.tmpl',
|
|
|
|
'--add-arch-template=/spin-kickstarts/atomic-installer/lorax-embed-repo.tmpl',
|
|
|
|
'--add-template-var=ostree_osname=fedora-atomic',
|
|
|
|
'--add-template-var=ostree_ref=fedora-atomic/Rawhide/x86_64/docker-host',
|
|
|
|
'--add-arch-template-var=ostree_repo=https://kojipkgs.fedoraproject.org/compose/atomic/Rawhide/',
|
|
|
|
'--add-arch-template-var=ostree_osname=fedora-atomic',
|
|
|
|
'--add-arch-template-var=ostree_ref=fedora-atomic/Rawhide/x86_64/docker-host',
|
|
|
|
'--logfile=%s/%s/lorax.log' % (self.topdir, LOG_PATH)],
|
|
|
|
weight=123,
|
|
|
|
)
|
|
|
|
self.assertIsoLinked(link, get_file_size, get_mtime, final_iso_path)
|
|
|
|
self.assertImageAdded(self.compose, ImageCls, iso)
|
2018-05-15 07:26:54 +00:00
|
|
|
self.assertAllCopied(copy_all)
|
2017-04-07 13:33:43 +00:00
|
|
|
|
2018-05-15 07:26:54 +00:00
|
|
|
@mock.patch('pungi.util.copy_all')
|
2017-04-07 13:33:43 +00:00
|
|
|
@mock.patch('productmd.images.Image')
|
|
|
|
@mock.patch('pungi.util.get_mtime')
|
2016-03-23 09:40:16 +00:00
|
|
|
@mock.patch('pungi.util.get_file_size')
|
2016-10-12 11:56:19 +00:00
|
|
|
@mock.patch('pungi.phases.ostree_installer.iso')
|
2016-03-23 09:40:16 +00:00
|
|
|
@mock.patch('os.link')
|
|
|
|
@mock.patch('pungi.wrappers.kojiwrapper.KojiWrapper')
|
2016-10-12 11:56:19 +00:00
|
|
|
def test_run_with_implicit_release(self, KojiWrapper, link, iso,
|
2018-05-15 07:26:54 +00:00
|
|
|
get_file_size, get_mtime, ImageCls, copy_all):
|
2016-03-23 09:40:16 +00:00
|
|
|
pool = mock.Mock()
|
|
|
|
cfg = {
|
2018-02-20 13:29:49 +00:00
|
|
|
'repo': 'Everything', # this variant-type repo is deprecated, in result will be replaced with default repo
|
2016-03-23 09:40:16 +00:00
|
|
|
'release': None,
|
|
|
|
"installpkgs": ["fedora-productimg-atomic"],
|
|
|
|
"add_template": ["/spin-kickstarts/atomic-installer/lorax-configure-repo.tmpl"],
|
|
|
|
"add_template_var": [
|
|
|
|
"ostree_osname=fedora-atomic",
|
|
|
|
"ostree_ref=fedora-atomic/Rawhide/x86_64/docker-host",
|
|
|
|
],
|
|
|
|
"add_arch_template": ["/spin-kickstarts/atomic-installer/lorax-embed-repo.tmpl"],
|
|
|
|
"add_arch_template_var": [
|
|
|
|
"ostree_repo=https://kojipkgs.fedoraproject.org/compose/atomic/Rawhide/",
|
|
|
|
"ostree_osname=fedora-atomic",
|
|
|
|
"ostree_ref=fedora-atomic/Rawhide/x86_64/docker-host",
|
|
|
|
],
|
|
|
|
}
|
2017-02-23 09:28:49 +00:00
|
|
|
self.compose.conf['runroot_weights'] = {'ostree_installer': 123}
|
2016-03-23 09:40:16 +00:00
|
|
|
koji = KojiWrapper.return_value
|
|
|
|
koji.run_runroot_cmd.return_value = {
|
|
|
|
'task_id': 1234,
|
|
|
|
'retcode': 0,
|
|
|
|
'output': 'Foo bar\n',
|
|
|
|
}
|
|
|
|
get_file_size.return_value = 1024
|
|
|
|
get_mtime.return_value = 13579
|
|
|
|
final_iso_path = self.topdir + '/compose/Everything/x86_64/iso/image-name'
|
|
|
|
|
2019-08-01 14:36:54 +00:00
|
|
|
t = ostree.OstreeInstallerThread(pool, ["http://example.com/repo/1"])
|
2016-03-23 09:40:16 +00:00
|
|
|
|
2016-10-06 07:17:09 +00:00
|
|
|
t.process((self.compose, self.compose.variants['Everything'], 'x86_64', cfg), 1)
|
2016-03-23 09:40:16 +00:00
|
|
|
|
2016-10-06 07:35:41 +00:00
|
|
|
self.assertRunrootCall(
|
|
|
|
koji,
|
2019-08-01 14:36:54 +00:00
|
|
|
["http://example.com/repo/1",
|
2018-04-09 13:32:33 +00:00
|
|
|
'http://example.com/work/$basearch/comps_repo_Everything'],
|
2016-10-06 07:35:41 +00:00
|
|
|
'20151203.t.0',
|
|
|
|
isfinal=True,
|
|
|
|
extra=['--installpkgs=fedora-productimg-atomic',
|
|
|
|
'--add-template=/spin-kickstarts/atomic-installer/lorax-configure-repo.tmpl',
|
|
|
|
'--add-arch-template=/spin-kickstarts/atomic-installer/lorax-embed-repo.tmpl',
|
|
|
|
'--add-template-var=ostree_osname=fedora-atomic',
|
|
|
|
'--add-template-var=ostree_ref=fedora-atomic/Rawhide/x86_64/docker-host',
|
|
|
|
'--add-arch-template-var=ostree_repo=https://kojipkgs.fedoraproject.org/compose/atomic/Rawhide/',
|
|
|
|
'--add-arch-template-var=ostree_osname=fedora-atomic',
|
2016-11-09 08:00:33 +00:00
|
|
|
'--add-arch-template-var=ostree_ref=fedora-atomic/Rawhide/x86_64/docker-host',
|
2017-03-15 14:54:45 +00:00
|
|
|
'--logfile=%s/%s/lorax.log' % (self.topdir, LOG_PATH)],
|
2017-02-23 09:28:49 +00:00
|
|
|
weight=123,
|
2016-10-06 07:35:41 +00:00
|
|
|
)
|
|
|
|
self.assertIsoLinked(link, get_file_size, get_mtime, final_iso_path)
|
2016-10-12 11:56:19 +00:00
|
|
|
self.assertImageAdded(self.compose, ImageCls, iso)
|
2018-05-15 07:26:54 +00:00
|
|
|
self.assertAllCopied(copy_all)
|
2016-03-23 09:40:16 +00:00
|
|
|
|
2018-05-15 07:26:54 +00:00
|
|
|
@mock.patch('pungi.util.copy_all')
|
2016-03-23 09:40:16 +00:00
|
|
|
@mock.patch('productmd.images.Image')
|
|
|
|
@mock.patch('pungi.util.get_mtime')
|
|
|
|
@mock.patch('pungi.util.get_file_size')
|
2016-10-12 11:56:19 +00:00
|
|
|
@mock.patch('pungi.phases.ostree_installer.iso')
|
2016-03-23 09:40:16 +00:00
|
|
|
@mock.patch('os.link')
|
|
|
|
@mock.patch('pungi.wrappers.kojiwrapper.KojiWrapper')
|
2016-10-12 11:56:19 +00:00
|
|
|
def test_fail_crash(self, KojiWrapper, link, iso, get_file_size,
|
2018-05-15 07:26:54 +00:00
|
|
|
get_mtime, ImageCls, copy_all):
|
2016-03-23 09:40:16 +00:00
|
|
|
pool = mock.Mock()
|
|
|
|
cfg = {
|
2017-03-27 21:53:08 +00:00
|
|
|
'repo': 'Everything',
|
2016-03-23 09:40:16 +00:00
|
|
|
'release': None,
|
2016-06-24 07:44:40 +00:00
|
|
|
'failable': ['x86_64']
|
2016-03-23 09:40:16 +00:00
|
|
|
}
|
|
|
|
koji = KojiWrapper.return_value
|
|
|
|
koji.run_runroot_cmd.side_effect = helpers.boom
|
|
|
|
|
2019-08-01 14:36:54 +00:00
|
|
|
t = ostree.OstreeInstallerThread(pool, ["http://example.com/repo/1"])
|
2016-03-23 09:40:16 +00:00
|
|
|
|
2016-10-06 07:17:09 +00:00
|
|
|
t.process((self.compose, self.compose.variants['Everything'], 'x86_64', cfg), 1)
|
2018-07-11 13:37:21 +00:00
|
|
|
pool._logger.error.assert_has_calls([
|
2016-04-05 07:13:01 +00:00
|
|
|
mock.call('[FAIL] Ostree installer (variant Everything, arch x86_64) failed, but going on anyway.'),
|
2016-03-24 09:12:20 +00:00
|
|
|
mock.call('BOOM')
|
2016-03-23 09:40:16 +00:00
|
|
|
])
|
|
|
|
|
2018-05-15 07:26:54 +00:00
|
|
|
@mock.patch('pungi.util.copy_all')
|
2016-03-23 09:40:16 +00:00
|
|
|
@mock.patch('productmd.images.Image')
|
|
|
|
@mock.patch('pungi.util.get_mtime')
|
|
|
|
@mock.patch('pungi.util.get_file_size')
|
2016-10-12 11:56:19 +00:00
|
|
|
@mock.patch('pungi.phases.ostree_installer.iso')
|
2016-03-23 09:40:16 +00:00
|
|
|
@mock.patch('os.link')
|
|
|
|
@mock.patch('pungi.wrappers.kojiwrapper.KojiWrapper')
|
2016-10-12 11:56:19 +00:00
|
|
|
def test_fail_runroot_fail(self, KojiWrapper, link, iso,
|
2018-05-15 07:26:54 +00:00
|
|
|
get_file_size, get_mtime, ImageCls, copy_all):
|
2016-03-23 09:40:16 +00:00
|
|
|
pool = mock.Mock()
|
|
|
|
cfg = {
|
2017-03-27 21:53:08 +00:00
|
|
|
'repo': 'Everything',
|
2016-03-23 09:40:16 +00:00
|
|
|
'release': None,
|
2016-06-24 07:44:40 +00:00
|
|
|
'failable': ['*'],
|
2016-03-23 09:40:16 +00:00
|
|
|
}
|
|
|
|
koji = KojiWrapper.return_value
|
|
|
|
koji.run_runroot_cmd.return_value = {
|
|
|
|
'output': 'Failed',
|
|
|
|
'task_id': 1234,
|
|
|
|
'retcode': 1,
|
|
|
|
}
|
|
|
|
|
2019-08-01 14:36:54 +00:00
|
|
|
t = ostree.OstreeInstallerThread(pool, ["http://example.com/repo/1"])
|
2016-03-23 09:40:16 +00:00
|
|
|
|
2016-10-06 07:17:09 +00:00
|
|
|
t.process((self.compose, self.compose.variants['Everything'], 'x86_64', cfg), 1)
|
2018-07-11 13:37:21 +00:00
|
|
|
pool._logger.error.assert_has_calls([
|
2016-04-05 07:13:01 +00:00
|
|
|
mock.call('[FAIL] Ostree installer (variant Everything, arch x86_64) failed, but going on anyway.'),
|
2017-03-15 14:54:45 +00:00
|
|
|
mock.call('Runroot task failed: 1234. See %s/%s/runroot.log for more details.'
|
|
|
|
% (self.topdir, LOG_PATH))
|
2016-03-23 09:40:16 +00:00
|
|
|
])
|