[ostree] Enable marking ostree phase as failable
Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
3e1a6edecc
commit
ed12a64a84
@ -142,6 +142,7 @@ Options
|
|||||||
* live
|
* live
|
||||||
* image-build
|
* image-build
|
||||||
* live-media
|
* live-media
|
||||||
|
* ostree
|
||||||
* ostree-installer
|
* ostree-installer
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
@ -38,7 +38,10 @@ class OSTreeThread(WorkerThread):
|
|||||||
def process(self, item, num):
|
def process(self, item, num):
|
||||||
compose, variant, arch, config = item
|
compose, variant, arch, config = item
|
||||||
self.num = num
|
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)
|
msg = 'OSTree phase for variant %s, arch %s' % (variant.uid, arch)
|
||||||
self.pool.log_info('[BEGIN] %s' % msg)
|
self.pool.log_info('[BEGIN] %s' % msg)
|
||||||
self.logdir = compose.paths.log.topdir('{}/ostree'.format(arch))
|
self.logdir = compose.paths.log.topdir('{}/ostree'.format(arch))
|
||||||
|
@ -116,6 +116,69 @@ class OSTreeThreadTest(helpers.PungiTestCase):
|
|||||||
[mock.call(koji.get_runroot_cmd.return_value,
|
[mock.call(koji.get_runroot_cmd.return_value,
|
||||||
log_file=self.topdir + '/logs/x86_64/ostree/runroot.log')])
|
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__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Loading…
Reference in New Issue
Block a user