[buildinstall] Don't run lorax for empty variants

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2016-02-18 16:12:23 +01:00
parent 71369c7690
commit 1b6688d22c
2 changed files with 38 additions and 3 deletions

View File

@ -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,

View File

@ -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')