Merge #257 `[ostree] Enable marking ostree phase as failable`

This commit is contained in:
Dennis Gilmore 2016-04-06 18:36:31 +00:00
commit 5f12c8c9ce
3 changed files with 67 additions and 0 deletions

View File

@ -142,6 +142,7 @@ Options
* live
* image-build
* live-media
* ostree
* ostree-installer
.. note::

View File

@ -38,7 +38,10 @@ class OSTreeThread(WorkerThread):
def process(self, item, num):
compose, variant, arch, config = item
self.num = num
with util.failable(compose, variant, arch, 'ostree'):
self.worker(compose, variant, arch, config)
def worker(self, compose, variant, arch, config):
msg = 'OSTree phase for variant %s, arch %s' % (variant.uid, arch)
self.pool.log_info('[BEGIN] %s' % msg)
self.logdir = compose.paths.log.topdir('{}/ostree'.format(arch))

View File

@ -116,6 +116,69 @@ class OSTreeThreadTest(helpers.PungiTestCase):
[mock.call(koji.get_runroot_cmd.return_value,
log_file=self.topdir + '/logs/x86_64/ostree/runroot.log')])
@mock.patch('pungi.wrappers.kojiwrapper.KojiWrapper')
def test_run_fail(self, KojiWrapper):
compose = helpers.DummyCompose(self.topdir, {
'koji_profile': 'koji',
'runroot_tag': 'rrt',
'failable_deliverables': [
('^.*$', {'*': ['ostree']})
]
})
pool = mock.Mock()
cfg = {
'source_repo_from': 'Everything',
'config_url': 'https://git.fedorahosted.org/git/fedora-atomic.git',
'config_branch': 'f24',
'treefile': 'fedora-atomic-docker-host.json',
'ostree_repo': '/other/place/for/atomic'
}
koji = KojiWrapper.return_value
koji.run_runroot_cmd.return_value = {
'task_id': 1234,
'retcode': 1,
'output': 'Foo bar\n',
}
t = ostree.OSTreeThread(pool)
t.process((compose, compose.variants['Everything'], 'x86_64', cfg), 1)
compose.log_info.assert_has_calls([
mock.call('[FAIL] Ostree (variant Everything, arch x86_64) failed, but going on anyway.'),
mock.call('Runroot task failed: 1234. See {} for more details.'.format(
self.topdir + '/logs/x86_64/ostree/runroot.log'))
])
@mock.patch('pungi.wrappers.kojiwrapper.KojiWrapper')
def test_run_handle_exception(self, KojiWrapper):
compose = helpers.DummyCompose(self.topdir, {
'koji_profile': 'koji',
'runroot_tag': 'rrt',
'failable_deliverables': [
('^.*$', {'*': ['ostree']})
]
})
pool = mock.Mock()
cfg = {
'source_repo_from': 'Everything',
'config_url': 'https://git.fedorahosted.org/git/fedora-atomic.git',
'config_branch': 'f24',
'treefile': 'fedora-atomic-docker-host.json',
'ostree_repo': '/other/place/for/atomic'
}
koji = KojiWrapper.return_value
koji.run_runroot_cmd.side_effect = helpers.boom
t = ostree.OSTreeThread(pool)
t.process((compose, compose.variants['Everything'], 'x86_64', cfg), 1)
compose.log_info.assert_has_calls([
mock.call('[FAIL] Ostree (variant Everything, arch x86_64) failed, but going on anyway.'),
mock.call('BOOM')
])
if __name__ == '__main__':
unittest.main()