diff --git a/pungi/phases/buildinstall.py b/pungi/phases/buildinstall.py index c3ffdedb..9c1b3ff9 100644 --- a/pungi/phases/buildinstall.py +++ b/pungi/phases/buildinstall.py @@ -191,8 +191,19 @@ class BuildinstallPhase(PhaseBase): # TODO: label is not used label = "" volid = get_volid(self.compose, arch, variant, escape_spaces=False, disc_type=disc_type) - tweak_buildinstall(buildinstall_dir, os_tree, arch, variant.uid, label, volid, kickstart_file) - link_boot_iso(self.compose, arch, variant) + try: + tweak_buildinstall(buildinstall_dir, os_tree, arch, variant.uid, label, volid, kickstart_file) + link_boot_iso(self.compose, arch, variant) + except Exception as exc: + if not self.compose.can_fail(variant, arch, 'buildinstall'): + raise + else: + tb = traceback.format_exc() + self.pool.log_info( + '[FAIL] Copying results of buildinstall for variant %s arch %s failed, ' + 'but going on anyway.\n%s' + % (variant.uid, arch, exc)) + self.pool.log_debug(tb) def get_kickstart_file(compose): diff --git a/tests/test_buildinstall.py b/tests/test_buildinstall.py index 560adf4e..97b4d4ba 100755 --- a/tests/test_buildinstall.py +++ b/tests/test_buildinstall.py @@ -11,7 +11,7 @@ import sys sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) from pungi.phases.buildinstall import BuildinstallPhase, BuildinstallThread, link_boot_iso -from tests.helpers import DummyCompose, PungiTestCase, touch +from tests.helpers import DummyCompose, PungiTestCase, touch, boom class BuildInstallCompose(DummyCompose): @@ -398,6 +398,48 @@ class TestCopyFiles(PungiTestCase): mock.call(compose, 'amd64', compose.variants['Client']), mock.call(compose, 'amd64', compose.variants['Server'])]) + @mock.patch('pungi.phases.buildinstall.link_boot_iso') + @mock.patch('pungi.phases.buildinstall.tweak_buildinstall') + @mock.patch('pungi.phases.buildinstall.get_volid') + @mock.patch('os.listdir') + @mock.patch('os.path.isdir') + @mock.patch('pungi.phases.buildinstall.get_kickstart_file') + def test_copy_fail(self, get_kickstart_file, isdir, listdir, + get_volid, tweak_buildinstall, link_boot_iso): + compose = BuildInstallCompose(self.topdir, { + 'buildinstall_method': 'lorax', + 'failable_deliverables': [ + ('^.+$', {'*': ['buildinstall']}) + ], + }) + + get_volid.side_effect = ( + lambda compose, arch, variant, escape_spaces, disc_type: "%s.%s" % (variant.uid, arch) + ) + get_kickstart_file.return_value = 'kickstart' + tweak_buildinstall.side_effect = boom + + phase = BuildinstallPhase(compose) + phase.copy_files() + + self.assertItemsEqual( + get_volid.mock_calls, + [mock.call(compose, 'x86_64', compose.variants['Server'], escape_spaces=False, disc_type='dvd'), + mock.call(compose, 'amd64', compose.variants['Client'], escape_spaces=False, disc_type='dvd'), + mock.call(compose, 'amd64', compose.variants['Server'], escape_spaces=False, disc_type='dvd')]) + self.assertItemsEqual( + tweak_buildinstall.mock_calls, + [mock.call(self.topdir + '/work/x86_64/buildinstall/Server', + self.topdir + '/compose/Server/x86_64/os', + 'x86_64', 'Server', '', 'Server.x86_64', 'kickstart'), + mock.call(self.topdir + '/work/amd64/buildinstall/Server', + self.topdir + '/compose/Server/amd64/os', + 'amd64', 'Server', '', 'Server.amd64', 'kickstart'), + mock.call(self.topdir + '/work/amd64/buildinstall/Client', + self.topdir + '/compose/Client/amd64/os', + 'amd64', 'Client', '', 'Client.amd64', 'kickstart')]) + self.assertItemsEqual(link_boot_iso.mock_calls, []) + class BuildinstallThreadTestCase(PungiTestCase):