diff --git a/pungi/phases/buildinstall.py b/pungi/phases/buildinstall.py index c06be91a..00c14fa7 100644 --- a/pungi/phases/buildinstall.py +++ b/pungi/phases/buildinstall.py @@ -130,6 +130,8 @@ class BuildinstallPhase(PhaseBase): if buildinstall_method == "lorax": for variant in self.compose.get_variants(arch=arch, types=['variant']): + if variant.is_empty: + continue volid = get_volid(self.compose, arch, variant=variant, disc_type="boot") commands.append( (variant, diff --git a/tests/test_buildinstall.py b/tests/test_buildinstall.py index 5755b992..1b95f4b8 100755 --- a/tests/test_buildinstall.py +++ b/tests/test_buildinstall.py @@ -35,9 +35,9 @@ class _DummyCompose(object): self.log_debug = mock.Mock() self.supported = True self.variants = { - 'x86_64': [mock.Mock(uid='Server', buildinstallpackages=['bash', 'vim'])], - 'amd64': [mock.Mock(uid='Client', buildinstallpackages=[]), - mock.Mock(uid='Server', buildinstallpackages=['bash', 'vim'])], + 'x86_64': [mock.Mock(uid='Server', buildinstallpackages=['bash', 'vim'], is_empty=False)], + 'amd64': [mock.Mock(uid='Client', buildinstallpackages=[], is_empty=False), + mock.Mock(uid='Server', buildinstallpackages=['bash', 'vim'], is_empty=False)], } def get_arches(self): @@ -112,6 +112,39 @@ class TestBuildinstallPhase(unittest.TestCase): bugurl=None)], any_order=True) + @mock.patch('pungi.phases.buildinstall.ThreadPool') + @mock.patch('pungi.phases.buildinstall.LoraxWrapper') + @mock.patch('pungi.phases.buildinstall.get_volid') + def test_lorax_skips_empty_variants(self, get_volid, loraxCls, poolCls): + compose = _DummyCompose({ + 'bootable': True, + 'release_name': 'Test', + 'release_short': 't', + 'release_version': '1', + 'release_is_layered': False, + 'buildinstall_method': 'lorax' + }) + compose.variants['amd64'][0].is_empty = True + compose.variants['amd64'][1].is_empty = True + + get_volid.return_value = 'vol_id' + + phase = BuildinstallPhase(compose) + + phase.run() + + pool = poolCls.return_value + self.assertEqual(1, len(pool.queue_put.mock_calls)) + + # Obtained correct lorax command. + lorax = loraxCls.return_value + lorax.get_lorax_cmd.assert_has_calls( + [mock.call('Test', '1', '1', 'file:///a/b/', '/buildinstall_dir/x86_64/Server', + buildarch='x86_64', is_final=True, nomacboot=True, noupgrade=True, + volid='vol_id', variant='Server', buildinstallpackages=['bash', 'vim'], + bugurl=None)], + any_order=True) + @mock.patch('pungi.phases.buildinstall.ThreadPool') @mock.patch('pungi.phases.buildinstall.LoraxWrapper') @mock.patch('pungi.phases.buildinstall.get_volid')