diff --git a/doc/configuration.rst b/doc/configuration.rst index 36b332a7..ff26b444 100644 --- a/doc/configuration.rst +++ b/doc/configuration.rst @@ -142,6 +142,7 @@ Options * live * image-build * live-media + * ostree * ostree-installer .. note:: diff --git a/pungi/phases/ostree.py b/pungi/phases/ostree.py index 77e4838f..e0827e5c 100644 --- a/pungi/phases/ostree.py +++ b/pungi/phases/ostree.py @@ -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)) diff --git a/tests/test_ostree_phase.py b/tests/test_ostree_phase.py index 7617ddef..debae88d 100755 --- a/tests/test_ostree_phase.py +++ b/tests/test_ostree_phase.py @@ -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()