2015-12-02 14:55:53 +00:00
|
|
|
#!/usr/bin/env python2
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
|
2016-05-25 11:39:02 +00:00
|
|
|
try:
|
|
|
|
import unittest2 as unittest
|
|
|
|
except ImportError:
|
|
|
|
import unittest
|
2015-12-02 14:55:53 +00:00
|
|
|
import mock
|
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
|
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
|
|
|
|
|
2016-03-08 10:26:14 +00:00
|
|
|
from pungi.phases.buildinstall import BuildinstallPhase, BuildinstallThread, link_boot_iso
|
2016-03-24 07:56:39 +00:00
|
|
|
from tests.helpers import DummyCompose, PungiTestCase, touch, boom
|
2015-12-02 14:55:53 +00:00
|
|
|
|
|
|
|
|
2016-02-22 14:58:34 +00:00
|
|
|
class BuildInstallCompose(DummyCompose):
|
2016-02-11 15:45:56 +00:00
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(BuildInstallCompose, self).__init__(*args, **kwargs)
|
|
|
|
self.variants = {
|
|
|
|
'Server': mock.Mock(uid='Server', arches=['x86_64', 'amd64'],
|
|
|
|
type='variant', buildinstallpackages=['bash', 'vim'],
|
|
|
|
is_empty=False),
|
|
|
|
'Client': mock.Mock(uid='Client', arches=['amd64'],
|
|
|
|
type='variant', buildinstallpackages=[],
|
|
|
|
is_empty=False),
|
|
|
|
}
|
2016-11-09 12:39:01 +00:00
|
|
|
self.all_variants = self.variants.copy()
|
2016-02-08 11:13:56 +00:00
|
|
|
|
2015-12-02 14:55:53 +00:00
|
|
|
|
2016-02-11 15:45:56 +00:00
|
|
|
class TestBuildinstallPhase(PungiTestCase):
|
2015-12-02 14:55:53 +00:00
|
|
|
|
|
|
|
def test_config_skip_unless_bootable(self):
|
2016-02-11 15:45:56 +00:00
|
|
|
compose = BuildInstallCompose(self.topdir, {})
|
2015-12-02 14:55:53 +00:00
|
|
|
compose.just_phases = None
|
|
|
|
compose.skip_phases = []
|
|
|
|
|
|
|
|
phase = BuildinstallPhase(compose)
|
|
|
|
|
|
|
|
self.assertTrue(phase.skip())
|
|
|
|
|
|
|
|
def test_does_not_skip_on_bootable(self):
|
2016-02-11 15:45:56 +00:00
|
|
|
compose = BuildInstallCompose(self.topdir, {'bootable': True})
|
2015-12-02 14:55:53 +00:00
|
|
|
compose.just_phases = None
|
|
|
|
compose.skip_phases = []
|
|
|
|
|
|
|
|
phase = BuildinstallPhase(compose)
|
|
|
|
|
|
|
|
self.assertFalse(phase.skip())
|
|
|
|
|
|
|
|
@mock.patch('pungi.phases.buildinstall.ThreadPool')
|
|
|
|
@mock.patch('pungi.phases.buildinstall.LoraxWrapper')
|
|
|
|
@mock.patch('pungi.phases.buildinstall.get_volid')
|
|
|
|
def test_starts_threads_for_each_cmd_with_lorax(self, get_volid, loraxCls, poolCls):
|
2016-02-11 15:45:56 +00:00
|
|
|
compose = BuildInstallCompose(self.topdir, {
|
2015-12-02 14:55:53 +00:00
|
|
|
'bootable': True,
|
|
|
|
'release_name': 'Test',
|
|
|
|
'release_short': 't',
|
|
|
|
'release_version': '1',
|
|
|
|
'release_is_layered': False,
|
2016-03-14 07:20:43 +00:00
|
|
|
'buildinstall_method': 'lorax',
|
|
|
|
'disc_types': {'dvd': 'DVD'},
|
2015-12-02 14:55:53 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
get_volid.return_value = 'vol_id'
|
2016-08-17 10:30:42 +00:00
|
|
|
loraxCls.return_value.get_lorax_cmd.return_value = ['lorax', '...']
|
2015-12-02 14:55:53 +00:00
|
|
|
|
|
|
|
phase = BuildinstallPhase(compose)
|
|
|
|
|
|
|
|
phase.run()
|
|
|
|
|
2015-12-02 13:46:39 +00:00
|
|
|
# Three items added for processing in total.
|
|
|
|
# Server.x86_64, Client.amd64, Server.x86_64
|
2015-12-02 14:55:53 +00:00
|
|
|
pool = poolCls.return_value
|
2015-12-02 13:46:39 +00:00
|
|
|
self.assertEqual(3, len(pool.queue_put.mock_calls))
|
2016-08-17 10:30:42 +00:00
|
|
|
self.assertItemsEqual(
|
|
|
|
[call[0][0][3] for call in pool.queue_put.call_args_list],
|
|
|
|
['rm -rf %s/work/amd64/buildinstall/Client && lorax ...' % self.topdir,
|
|
|
|
'rm -rf %s/work/amd64/buildinstall/Server && lorax ...' % self.topdir,
|
|
|
|
'rm -rf %s/work/x86_64/buildinstall/Server && lorax ...' % self.topdir])
|
2015-12-02 14:55:53 +00:00
|
|
|
|
|
|
|
# Obtained correct lorax commands.
|
2016-02-11 15:45:56 +00:00
|
|
|
self.assertItemsEqual(
|
|
|
|
loraxCls.return_value.get_lorax_cmd.mock_calls,
|
|
|
|
[mock.call('Test', '1', '1', self.topdir + '/work/x86_64/repo',
|
|
|
|
self.topdir + '/work/x86_64/buildinstall/Server',
|
2015-12-02 13:46:39 +00:00
|
|
|
buildarch='x86_64', is_final=True, nomacboot=True, noupgrade=True,
|
2015-12-08 08:29:24 +00:00
|
|
|
volid='vol_id', variant='Server', buildinstallpackages=['bash', 'vim'],
|
2016-11-09 07:50:37 +00:00
|
|
|
bugurl=None,
|
|
|
|
log_dir=self.topdir + '/logs/x86_64/buildinstall-Server-logs'),
|
2016-02-11 15:45:56 +00:00
|
|
|
mock.call('Test', '1', '1', self.topdir + '/work/amd64/repo',
|
|
|
|
self.topdir + '/work/amd64/buildinstall/Server',
|
2015-12-02 13:46:39 +00:00
|
|
|
buildarch='amd64', is_final=True, nomacboot=True, noupgrade=True,
|
2015-12-08 08:29:24 +00:00
|
|
|
volid='vol_id', variant='Server', buildinstallpackages=['bash', 'vim'],
|
2016-11-09 07:50:37 +00:00
|
|
|
bugurl=None,
|
|
|
|
log_dir=self.topdir + '/logs/amd64/buildinstall-Server-logs'),
|
2016-02-11 15:45:56 +00:00
|
|
|
mock.call('Test', '1', '1', self.topdir + '/work/amd64/repo',
|
|
|
|
self.topdir + '/work/amd64/buildinstall/Client',
|
2015-12-02 13:46:39 +00:00
|
|
|
buildarch='amd64', is_final=True, nomacboot=True, noupgrade=True,
|
2015-12-08 08:29:24 +00:00
|
|
|
volid='vol_id', variant='Client', buildinstallpackages=[],
|
2016-11-09 07:50:37 +00:00
|
|
|
bugurl=None,
|
|
|
|
log_dir=self.topdir + '/logs/amd64/buildinstall-Client-logs')])
|
2016-02-26 10:30:37 +00:00
|
|
|
self.assertItemsEqual(
|
|
|
|
get_volid.mock_calls,
|
2016-03-14 07:20:43 +00:00
|
|
|
[mock.call(compose, 'x86_64', variant=compose.variants['Server'], disc_type='DVD'),
|
|
|
|
mock.call(compose, 'amd64', variant=compose.variants['Client'], disc_type='DVD'),
|
|
|
|
mock.call(compose, 'amd64', variant=compose.variants['Server'], disc_type='DVD')])
|
2015-12-02 14:55:53 +00:00
|
|
|
|
2016-02-18 15:12:23 +00:00
|
|
|
@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):
|
2016-02-11 15:45:56 +00:00
|
|
|
compose = BuildInstallCompose(self.topdir, {
|
2016-02-18 15:12:23 +00:00
|
|
|
'bootable': True,
|
|
|
|
'release_name': 'Test',
|
|
|
|
'release_short': 't',
|
|
|
|
'release_version': '1',
|
|
|
|
'release_is_layered': False,
|
|
|
|
'buildinstall_method': 'lorax'
|
|
|
|
})
|
|
|
|
|
|
|
|
get_volid.return_value = 'vol_id'
|
2016-02-11 15:45:56 +00:00
|
|
|
compose.variants['Server'].is_empty = True
|
2016-08-17 10:30:42 +00:00
|
|
|
loraxCls.return_value.get_lorax_cmd.return_value = ['lorax', '...']
|
2016-02-18 15:12:23 +00:00
|
|
|
|
|
|
|
phase = BuildinstallPhase(compose)
|
|
|
|
|
|
|
|
phase.run()
|
|
|
|
|
|
|
|
pool = poolCls.return_value
|
|
|
|
self.assertEqual(1, len(pool.queue_put.mock_calls))
|
2016-08-17 10:30:42 +00:00
|
|
|
self.assertItemsEqual(
|
|
|
|
[call[0][0][3] for call in pool.queue_put.call_args_list],
|
|
|
|
['rm -rf %s/work/amd64/buildinstall/Client && lorax ...' % self.topdir])
|
2016-02-18 15:12:23 +00:00
|
|
|
|
|
|
|
# Obtained correct lorax command.
|
|
|
|
lorax = loraxCls.return_value
|
|
|
|
lorax.get_lorax_cmd.assert_has_calls(
|
2016-02-11 15:45:56 +00:00
|
|
|
[mock.call('Test', '1', '1', self.topdir + '/work/amd64/repo',
|
|
|
|
self.topdir + '/work/amd64/buildinstall/Client',
|
|
|
|
buildarch='amd64', is_final=True, nomacboot=True, noupgrade=True,
|
|
|
|
volid='vol_id', variant='Client', buildinstallpackages=[],
|
2016-11-09 07:50:37 +00:00
|
|
|
bugurl=None,
|
|
|
|
log_dir=self.topdir + '/logs/amd64/buildinstall-Client-logs')],
|
2016-02-18 15:12:23 +00:00
|
|
|
any_order=True)
|
2016-02-26 10:30:37 +00:00
|
|
|
self.assertItemsEqual(
|
|
|
|
get_volid.mock_calls,
|
|
|
|
[mock.call(compose, 'amd64', variant=compose.variants['Client'], disc_type='dvd')])
|
2016-02-18 15:12:23 +00:00
|
|
|
|
2015-12-02 14:55:53 +00:00
|
|
|
@mock.patch('pungi.phases.buildinstall.ThreadPool')
|
|
|
|
@mock.patch('pungi.phases.buildinstall.LoraxWrapper')
|
|
|
|
@mock.patch('pungi.phases.buildinstall.get_volid')
|
|
|
|
def test_starts_threads_for_each_cmd_with_buildinstall(self, get_volid, loraxCls, poolCls):
|
2016-02-11 15:45:56 +00:00
|
|
|
compose = BuildInstallCompose(self.topdir, {
|
2015-12-02 14:55:53 +00:00
|
|
|
'bootable': True,
|
|
|
|
'release_name': 'Test',
|
|
|
|
'release_short': 't',
|
|
|
|
'release_version': '1',
|
|
|
|
'release_is_layered': False,
|
2016-03-14 07:20:43 +00:00
|
|
|
'buildinstall_method': 'buildinstall',
|
|
|
|
'disc_types': {'dvd': 'DVD'},
|
2015-12-02 14:55:53 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
get_volid.return_value = 'vol_id'
|
|
|
|
|
|
|
|
phase = BuildinstallPhase(compose)
|
|
|
|
|
|
|
|
phase.run()
|
|
|
|
|
|
|
|
# Two items added for processing in total.
|
|
|
|
pool = poolCls.return_value
|
|
|
|
self.assertEqual(2, len(pool.queue_put.mock_calls))
|
|
|
|
|
|
|
|
# Obtained correct lorax commands.
|
2016-02-11 15:45:56 +00:00
|
|
|
self.assertItemsEqual(
|
|
|
|
loraxCls.return_value.get_buildinstall_cmd.mock_calls,
|
|
|
|
[mock.call('Test', '1', '1', self.topdir + '/work/x86_64/repo',
|
|
|
|
self.topdir + '/work/x86_64/buildinstall',
|
2015-12-02 14:55:53 +00:00
|
|
|
buildarch='x86_64', is_final=True, volid='vol_id'),
|
2016-02-11 15:45:56 +00:00
|
|
|
mock.call('Test', '1', '1', self.topdir + '/work/amd64/repo',
|
|
|
|
self.topdir + '/work/amd64/buildinstall',
|
|
|
|
buildarch='amd64', is_final=True, volid='vol_id')])
|
2016-02-26 10:30:37 +00:00
|
|
|
self.assertItemsEqual(
|
|
|
|
get_volid.mock_calls,
|
2016-03-14 07:20:43 +00:00
|
|
|
[mock.call(compose, 'x86_64', disc_type='DVD'),
|
|
|
|
mock.call(compose, 'amd64', disc_type='DVD')])
|
2015-12-08 08:29:24 +00:00
|
|
|
|
|
|
|
@mock.patch('pungi.phases.buildinstall.ThreadPool')
|
|
|
|
@mock.patch('pungi.phases.buildinstall.LoraxWrapper')
|
|
|
|
@mock.patch('pungi.phases.buildinstall.get_volid')
|
|
|
|
def test_uses_lorax_options(self, get_volid, loraxCls, poolCls):
|
2016-02-11 15:45:56 +00:00
|
|
|
compose = BuildInstallCompose(self.topdir, {
|
2015-12-08 08:29:24 +00:00
|
|
|
'bootable': True,
|
|
|
|
'release_name': 'Test',
|
|
|
|
'release_short': 't',
|
|
|
|
'release_version': '1',
|
|
|
|
'release_is_layered': False,
|
|
|
|
'buildinstall_method': 'lorax',
|
|
|
|
'lorax_options': [
|
|
|
|
('^Server$', {
|
|
|
|
'x86_64': {'bugurl': 'http://example.com'},
|
|
|
|
'amd64': {'noupgrade': False}
|
|
|
|
}),
|
|
|
|
('^Client$', {
|
|
|
|
'*': {'nomacboot': False}
|
|
|
|
}),
|
|
|
|
]
|
|
|
|
})
|
|
|
|
|
|
|
|
get_volid.return_value = 'vol_id'
|
2016-08-17 10:30:42 +00:00
|
|
|
loraxCls.return_value.get_lorax_cmd.return_value = ['lorax', '...']
|
2015-12-08 08:29:24 +00:00
|
|
|
|
|
|
|
phase = BuildinstallPhase(compose)
|
|
|
|
|
|
|
|
phase.run()
|
|
|
|
|
|
|
|
# Three items added for processing in total.
|
|
|
|
# Server.x86_64, Client.amd64, Server.x86_64
|
|
|
|
pool = poolCls.return_value
|
|
|
|
self.assertEqual(3, len(pool.queue_put.mock_calls))
|
2016-08-17 10:30:42 +00:00
|
|
|
self.assertItemsEqual(
|
|
|
|
[call[0][0][3] for call in pool.queue_put.call_args_list],
|
|
|
|
['rm -rf %s/work/amd64/buildinstall/Client && lorax ...' % self.topdir,
|
|
|
|
'rm -rf %s/work/amd64/buildinstall/Server && lorax ...' % self.topdir,
|
|
|
|
'rm -rf %s/work/x86_64/buildinstall/Server && lorax ...' % self.topdir])
|
2015-12-08 08:29:24 +00:00
|
|
|
|
|
|
|
# Obtained correct lorax commands.
|
2016-02-11 15:45:56 +00:00
|
|
|
self.assertItemsEqual(
|
|
|
|
loraxCls.return_value.get_lorax_cmd.mock_calls,
|
|
|
|
[mock.call('Test', '1', '1', self.topdir + '/work/x86_64/repo',
|
|
|
|
self.topdir + '/work/x86_64/buildinstall/Server',
|
2015-12-08 08:29:24 +00:00
|
|
|
buildarch='x86_64', is_final=True, nomacboot=True, noupgrade=True,
|
|
|
|
volid='vol_id', variant='Server', buildinstallpackages=['bash', 'vim'],
|
2016-11-09 07:50:37 +00:00
|
|
|
bugurl='http://example.com',
|
|
|
|
log_dir=self.topdir + '/logs/x86_64/buildinstall-Server-logs'),
|
2016-02-11 15:45:56 +00:00
|
|
|
mock.call('Test', '1', '1', self.topdir + '/work/amd64/repo',
|
|
|
|
self.topdir + '/work/amd64/buildinstall/Server',
|
2015-12-08 08:29:24 +00:00
|
|
|
buildarch='amd64', is_final=True, nomacboot=True, noupgrade=False,
|
|
|
|
volid='vol_id', variant='Server', buildinstallpackages=['bash', 'vim'],
|
2016-11-09 07:50:37 +00:00
|
|
|
bugurl=None,
|
|
|
|
log_dir=self.topdir + '/logs/amd64/buildinstall-Server-logs'),
|
2016-02-11 15:45:56 +00:00
|
|
|
mock.call('Test', '1', '1', self.topdir + '/work/amd64/repo',
|
|
|
|
self.topdir + '/work/amd64/buildinstall/Client',
|
2015-12-08 08:29:24 +00:00
|
|
|
buildarch='amd64', is_final=True, nomacboot=False, noupgrade=True,
|
|
|
|
volid='vol_id', variant='Client', buildinstallpackages=[],
|
2016-11-09 07:50:37 +00:00
|
|
|
bugurl=None,
|
|
|
|
log_dir=self.topdir + '/logs/amd64/buildinstall-Client-logs')])
|
2016-02-26 10:30:37 +00:00
|
|
|
self.assertItemsEqual(
|
|
|
|
get_volid.mock_calls,
|
|
|
|
[mock.call(compose, 'x86_64', variant=compose.variants['Server'], disc_type='dvd'),
|
|
|
|
mock.call(compose, 'amd64', variant=compose.variants['Client'], disc_type='dvd'),
|
|
|
|
mock.call(compose, 'amd64', variant=compose.variants['Server'], disc_type='dvd')])
|
2015-12-08 08:29:24 +00:00
|
|
|
|
|
|
|
@mock.patch('pungi.phases.buildinstall.ThreadPool')
|
|
|
|
@mock.patch('pungi.phases.buildinstall.LoraxWrapper')
|
|
|
|
@mock.patch('pungi.phases.buildinstall.get_volid')
|
|
|
|
def test_multiple_lorax_options(self, get_volid, loraxCls, poolCls):
|
2016-02-11 15:45:56 +00:00
|
|
|
compose = BuildInstallCompose(self.topdir, {
|
2015-12-08 08:29:24 +00:00
|
|
|
'bootable': True,
|
|
|
|
'release_name': 'Test',
|
|
|
|
'release_short': 't',
|
|
|
|
'release_version': '1',
|
|
|
|
'release_is_layered': False,
|
|
|
|
'buildinstall_method': 'lorax',
|
|
|
|
'lorax_options': [
|
|
|
|
('^.*$', {
|
|
|
|
'x86_64': {'nomacboot': False},
|
|
|
|
'*': {'noupgrade': False}
|
|
|
|
}),
|
|
|
|
]
|
|
|
|
})
|
|
|
|
|
|
|
|
get_volid.return_value = 'vol_id'
|
2016-08-17 10:30:42 +00:00
|
|
|
loraxCls.return_value.get_lorax_cmd.return_value = ['lorax', '...']
|
2015-12-08 08:29:24 +00:00
|
|
|
|
|
|
|
phase = BuildinstallPhase(compose)
|
|
|
|
|
|
|
|
phase.run()
|
|
|
|
|
|
|
|
# Three items added for processing in total.
|
|
|
|
# Server.x86_64, Client.amd64, Server.x86_64
|
|
|
|
pool = poolCls.return_value
|
|
|
|
self.assertEqual(3, len(pool.queue_put.mock_calls))
|
2016-08-17 10:30:42 +00:00
|
|
|
self.assertItemsEqual(
|
|
|
|
[call[0][0][3] for call in pool.queue_put.call_args_list],
|
|
|
|
['rm -rf %s/work/amd64/buildinstall/Client && lorax ...' % self.topdir,
|
|
|
|
'rm -rf %s/work/amd64/buildinstall/Server && lorax ...' % self.topdir,
|
|
|
|
'rm -rf %s/work/x86_64/buildinstall/Server && lorax ...' % self.topdir])
|
2015-12-08 08:29:24 +00:00
|
|
|
|
|
|
|
# Obtained correct lorax commands.
|
2016-02-11 15:45:56 +00:00
|
|
|
self.assertItemsEqual(
|
|
|
|
loraxCls.return_value.get_lorax_cmd.mock_calls,
|
|
|
|
[mock.call('Test', '1', '1', self.topdir + '/work/x86_64/repo',
|
|
|
|
self.topdir + '/work/x86_64/buildinstall/Server',
|
2015-12-08 08:29:24 +00:00
|
|
|
buildarch='x86_64', is_final=True, nomacboot=False, noupgrade=False,
|
|
|
|
volid='vol_id', variant='Server', buildinstallpackages=['bash', 'vim'],
|
2016-11-09 07:50:37 +00:00
|
|
|
bugurl=None,
|
|
|
|
log_dir=self.topdir + '/logs/x86_64/buildinstall-Server-logs'),
|
2016-02-11 15:45:56 +00:00
|
|
|
mock.call('Test', '1', '1', self.topdir + '/work/amd64/repo',
|
|
|
|
self.topdir + '/work/amd64/buildinstall/Server',
|
2015-12-08 08:29:24 +00:00
|
|
|
buildarch='amd64', is_final=True, nomacboot=True, noupgrade=False,
|
|
|
|
volid='vol_id', variant='Server', buildinstallpackages=['bash', 'vim'],
|
2016-11-09 07:50:37 +00:00
|
|
|
bugurl=None,
|
|
|
|
log_dir=self.topdir + '/logs/amd64/buildinstall-Server-logs'),
|
2016-02-11 15:45:56 +00:00
|
|
|
mock.call('Test', '1', '1', self.topdir + '/work/amd64/repo',
|
|
|
|
self.topdir + '/work/amd64/buildinstall/Client',
|
2015-12-08 08:29:24 +00:00
|
|
|
buildarch='amd64', is_final=True, nomacboot=True, noupgrade=False,
|
|
|
|
volid='vol_id', variant='Client', buildinstallpackages=[],
|
2016-11-09 07:50:37 +00:00
|
|
|
bugurl=None,
|
|
|
|
log_dir=self.topdir + '/logs/amd64/buildinstall-Client-logs')])
|
2016-02-26 10:30:37 +00:00
|
|
|
self.assertItemsEqual(
|
|
|
|
get_volid.mock_calls,
|
|
|
|
[mock.call(compose, 'x86_64', variant=compose.variants['Server'], disc_type='dvd'),
|
|
|
|
mock.call(compose, 'amd64', variant=compose.variants['Client'], disc_type='dvd'),
|
|
|
|
mock.call(compose, 'amd64', variant=compose.variants['Server'], disc_type='dvd')])
|
2015-12-02 14:55:53 +00:00
|
|
|
|
|
|
|
|
2016-02-11 15:45:56 +00:00
|
|
|
class TestCopyFiles(PungiTestCase):
|
2015-12-07 07:43:00 +00:00
|
|
|
|
2016-03-08 10:26:14 +00:00
|
|
|
@mock.patch('pungi.phases.buildinstall.link_boot_iso')
|
2015-12-07 07:43:00 +00:00
|
|
|
@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_files_buildinstall(self, get_kickstart_file, isdir, listdir,
|
2016-03-08 10:26:14 +00:00
|
|
|
get_volid, tweak_buildinstall, link_boot_iso):
|
2016-02-11 15:45:56 +00:00
|
|
|
compose = BuildInstallCompose(self.topdir, {
|
2015-12-07 07:43:00 +00:00
|
|
|
'buildinstall_method': 'buildinstall'
|
|
|
|
})
|
|
|
|
|
2015-12-10 11:51:18 +00:00
|
|
|
get_volid.side_effect = (
|
|
|
|
lambda compose, arch, variant, escape_spaces, disc_type: "%s.%s" % (variant.uid, arch)
|
|
|
|
)
|
2015-12-07 07:43:00 +00:00
|
|
|
get_kickstart_file.return_value = 'kickstart'
|
|
|
|
|
|
|
|
phase = BuildinstallPhase(compose)
|
|
|
|
phase.copy_files()
|
|
|
|
|
2016-02-11 15:45:56 +00:00
|
|
|
self.assertItemsEqual(
|
|
|
|
get_volid.mock_calls,
|
2016-02-26 10:30:37 +00:00
|
|
|
[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')])
|
2016-02-11 15:45:56 +00:00
|
|
|
self.assertItemsEqual(
|
|
|
|
tweak_buildinstall.mock_calls,
|
|
|
|
[mock.call(self.topdir + '/work/x86_64/buildinstall',
|
|
|
|
self.topdir + '/compose/Server/x86_64/os',
|
|
|
|
'x86_64', 'Server', '', 'Server.x86_64', 'kickstart'),
|
|
|
|
mock.call(self.topdir + '/work/amd64/buildinstall',
|
|
|
|
self.topdir + '/compose/Server/amd64/os',
|
|
|
|
'amd64', 'Server', '', 'Server.amd64', 'kickstart'),
|
|
|
|
mock.call(self.topdir + '/work/amd64/buildinstall',
|
|
|
|
self.topdir + '/compose/Client/amd64/os',
|
|
|
|
'amd64', 'Client', '', 'Client.amd64', 'kickstart')])
|
|
|
|
self.assertItemsEqual(
|
2016-03-08 10:26:14 +00:00
|
|
|
link_boot_iso.mock_calls,
|
2016-06-24 07:44:40 +00:00
|
|
|
[mock.call(compose, 'x86_64', compose.variants['Server'], False),
|
|
|
|
mock.call(compose, 'amd64', compose.variants['Client'], False),
|
|
|
|
mock.call(compose, 'amd64', compose.variants['Server'], False)])
|
2015-12-07 07:43:00 +00:00
|
|
|
|
2016-03-08 10:26:14 +00:00
|
|
|
@mock.patch('pungi.phases.buildinstall.link_boot_iso')
|
2015-12-07 07:43:00 +00:00
|
|
|
@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_files_lorax(self, get_kickstart_file, isdir, listdir,
|
2016-03-08 10:26:14 +00:00
|
|
|
get_volid, tweak_buildinstall, link_boot_iso):
|
2016-02-11 15:45:56 +00:00
|
|
|
compose = BuildInstallCompose(self.topdir, {
|
2015-12-07 07:43:00 +00:00
|
|
|
'buildinstall_method': 'lorax'
|
|
|
|
})
|
|
|
|
|
2015-12-10 11:51:18 +00:00
|
|
|
get_volid.side_effect = (
|
|
|
|
lambda compose, arch, variant, escape_spaces, disc_type: "%s.%s" % (variant.uid, arch)
|
|
|
|
)
|
2015-12-07 07:43:00 +00:00
|
|
|
get_kickstart_file.return_value = 'kickstart'
|
|
|
|
|
|
|
|
phase = BuildinstallPhase(compose)
|
|
|
|
phase.copy_files()
|
|
|
|
|
2016-02-11 15:45:56 +00:00
|
|
|
self.assertItemsEqual(
|
|
|
|
get_volid.mock_calls,
|
2016-02-26 10:30:37 +00:00
|
|
|
[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')])
|
2016-02-11 15:45:56 +00:00
|
|
|
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(
|
2016-03-08 10:26:14 +00:00
|
|
|
link_boot_iso.mock_calls,
|
2016-06-24 07:44:40 +00:00
|
|
|
[mock.call(compose, 'x86_64', compose.variants['Server'], False),
|
|
|
|
mock.call(compose, 'amd64', compose.variants['Client'], False),
|
|
|
|
mock.call(compose, 'amd64', compose.variants['Server'], False)])
|
2016-02-11 15:45:56 +00:00
|
|
|
|
2016-03-24 07:56:39 +00:00
|
|
|
@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, [])
|
|
|
|
|
2016-02-11 15:45:56 +00:00
|
|
|
|
|
|
|
class BuildinstallThreadTestCase(PungiTestCase):
|
2016-02-08 11:13:56 +00:00
|
|
|
|
|
|
|
@mock.patch('pungi.phases.buildinstall.KojiWrapper')
|
|
|
|
@mock.patch('pungi.phases.buildinstall.get_buildroot_rpms')
|
|
|
|
@mock.patch('pungi.phases.buildinstall.run')
|
2016-02-23 14:26:28 +00:00
|
|
|
def test_buildinstall_thread_with_lorax_in_runroot(self, run, get_buildroot_rpms, KojiWrapperMock):
|
2016-02-11 15:45:56 +00:00
|
|
|
compose = BuildInstallCompose(self.topdir, {
|
2016-02-08 11:13:56 +00:00
|
|
|
'buildinstall_method': 'lorax',
|
|
|
|
'runroot': True,
|
|
|
|
'runroot_tag': 'rrt',
|
|
|
|
'koji_profile': 'koji',
|
|
|
|
})
|
|
|
|
|
|
|
|
get_buildroot_rpms.return_value = ['bash', 'zsh']
|
|
|
|
pool = mock.Mock()
|
|
|
|
cmd = mock.Mock()
|
|
|
|
|
|
|
|
get_runroot_cmd = KojiWrapperMock.return_value.get_runroot_cmd
|
|
|
|
|
|
|
|
run_runroot_cmd = KojiWrapperMock.return_value.run_runroot_cmd
|
|
|
|
run_runroot_cmd.return_value = {
|
|
|
|
'output': 'Foo bar baz',
|
|
|
|
'retcode': 0,
|
|
|
|
'task_id': 1234,
|
|
|
|
}
|
|
|
|
|
|
|
|
t = BuildinstallThread(pool)
|
|
|
|
|
|
|
|
with mock.patch('time.sleep'):
|
2016-02-11 15:45:56 +00:00
|
|
|
t.process((compose, 'x86_64', compose.variants['Server'], cmd), 0)
|
2016-02-08 11:13:56 +00:00
|
|
|
|
2016-02-11 15:45:56 +00:00
|
|
|
self.assertItemsEqual(
|
|
|
|
get_runroot_cmd.mock_calls,
|
|
|
|
[mock.call('rrt', 'x86_64', cmd, channel=None,
|
|
|
|
use_shell=True, task_id=True,
|
|
|
|
packages=['strace', 'lorax'], mounts=[self.topdir])])
|
2016-02-23 14:29:33 +00:00
|
|
|
self.assertItemsEqual(
|
|
|
|
run_runroot_cmd.mock_calls,
|
|
|
|
[mock.call(get_runroot_cmd.return_value,
|
|
|
|
log_file=self.topdir + '/logs/x86_64/buildinstall-Server.x86_64.log')])
|
2016-02-23 14:26:28 +00:00
|
|
|
with open(self.topdir + '/logs/x86_64/buildinstall-Server-RPMs.x86_64.log') as f:
|
|
|
|
rpms = f.read().strip().split('\n')
|
|
|
|
self.assertItemsEqual(rpms, ['bash', 'zsh'])
|
2016-02-08 11:13:56 +00:00
|
|
|
|
|
|
|
@mock.patch('pungi.phases.buildinstall.KojiWrapper')
|
|
|
|
@mock.patch('pungi.phases.buildinstall.get_buildroot_rpms')
|
|
|
|
@mock.patch('pungi.phases.buildinstall.run')
|
2016-02-23 14:26:28 +00:00
|
|
|
def test_buildinstall_thread_with_buildinstall_in_runroot(self, run, get_buildroot_rpms, KojiWrapperMock):
|
2016-02-11 15:45:56 +00:00
|
|
|
compose = BuildInstallCompose(self.topdir, {
|
2016-02-08 11:13:56 +00:00
|
|
|
'buildinstall_method': 'buildinstall',
|
|
|
|
'runroot': True,
|
|
|
|
'runroot_tag': 'rrt',
|
|
|
|
'koji_profile': 'koji',
|
|
|
|
})
|
|
|
|
|
|
|
|
get_buildroot_rpms.return_value = ['bash', 'zsh']
|
|
|
|
pool = mock.Mock()
|
|
|
|
cmd = mock.Mock()
|
|
|
|
|
|
|
|
get_runroot_cmd = KojiWrapperMock.return_value.get_runroot_cmd
|
|
|
|
|
|
|
|
run_runroot_cmd = KojiWrapperMock.return_value.run_runroot_cmd
|
|
|
|
run_runroot_cmd.return_value = {
|
|
|
|
'output': 'Foo bar baz',
|
|
|
|
'retcode': 0,
|
|
|
|
'task_id': 1234,
|
|
|
|
}
|
|
|
|
|
|
|
|
t = BuildinstallThread(pool)
|
|
|
|
|
|
|
|
with mock.patch('time.sleep'):
|
|
|
|
t.process((compose, 'x86_64', None, cmd), 0)
|
|
|
|
|
2016-02-11 15:45:56 +00:00
|
|
|
self.assertItemsEqual(
|
|
|
|
get_runroot_cmd.mock_calls,
|
|
|
|
[mock.call('rrt', 'x86_64', cmd, channel=None,
|
|
|
|
use_shell=True, task_id=True,
|
|
|
|
packages=['strace', 'anaconda'], mounts=[self.topdir])])
|
2016-02-23 14:29:33 +00:00
|
|
|
self.assertItemsEqual(
|
|
|
|
run_runroot_cmd.mock_calls,
|
|
|
|
[mock.call(get_runroot_cmd.return_value,
|
|
|
|
log_file=self.topdir + '/logs/x86_64/buildinstall.x86_64.log')])
|
2016-02-23 14:26:28 +00:00
|
|
|
with open(self.topdir + '/logs/x86_64/buildinstall-RPMs.x86_64.log') as f:
|
|
|
|
rpms = f.read().strip().split('\n')
|
|
|
|
self.assertItemsEqual(rpms, ['bash', 'zsh'])
|
2016-02-08 11:13:56 +00:00
|
|
|
|
|
|
|
@mock.patch('pungi.phases.buildinstall.KojiWrapper')
|
|
|
|
@mock.patch('pungi.phases.buildinstall.get_buildroot_rpms')
|
|
|
|
@mock.patch('pungi.phases.buildinstall.run')
|
2016-02-23 14:26:28 +00:00
|
|
|
def test_buildinstall_fail_exit_code(self, run, get_buildroot_rpms, KojiWrapperMock):
|
2016-02-11 15:45:56 +00:00
|
|
|
compose = BuildInstallCompose(self.topdir, {
|
2016-02-08 11:13:56 +00:00
|
|
|
'buildinstall_method': 'buildinstall',
|
|
|
|
'runroot': True,
|
|
|
|
'runroot_tag': 'rrt',
|
|
|
|
'koji_profile': 'koji',
|
|
|
|
'failable_deliverables': [
|
|
|
|
('^.+$', {'*': ['buildinstall']})
|
|
|
|
],
|
|
|
|
})
|
|
|
|
|
|
|
|
get_buildroot_rpms.return_value = ['bash', 'zsh']
|
|
|
|
pool = mock.Mock()
|
|
|
|
cmd = mock.Mock()
|
|
|
|
|
|
|
|
run_runroot_cmd = KojiWrapperMock.return_value.run_runroot_cmd
|
|
|
|
run_runroot_cmd.return_value = {
|
|
|
|
'output': 'Foo bar baz',
|
|
|
|
'retcode': 1,
|
|
|
|
'task_id': 1234,
|
|
|
|
}
|
|
|
|
|
|
|
|
t = BuildinstallThread(pool)
|
|
|
|
|
|
|
|
with mock.patch('time.sleep'):
|
|
|
|
t.process((compose, 'x86_64', None, cmd), 0)
|
|
|
|
|
2016-11-18 20:33:03 +00:00
|
|
|
compose._logger.info.assert_has_calls([
|
2016-03-24 09:12:20 +00:00
|
|
|
mock.call('[FAIL] Buildinstall (variant None, arch x86_64) failed, but going on anyway.'),
|
|
|
|
mock.call('Runroot task failed: 1234. See %s/logs/x86_64/buildinstall.x86_64.log for more details.'
|
|
|
|
% self.topdir)
|
2016-02-08 11:13:56 +00:00
|
|
|
])
|
|
|
|
|
|
|
|
@mock.patch('pungi.phases.buildinstall.KojiWrapper')
|
|
|
|
@mock.patch('pungi.phases.buildinstall.get_buildroot_rpms')
|
|
|
|
@mock.patch('pungi.phases.buildinstall.run')
|
2016-02-23 14:26:28 +00:00
|
|
|
def test_lorax_fail_exit_code(self, run, get_buildroot_rpms, KojiWrapperMock):
|
2016-02-11 15:45:56 +00:00
|
|
|
compose = BuildInstallCompose(self.topdir, {
|
2016-02-08 11:13:56 +00:00
|
|
|
'buildinstall_method': 'lorax',
|
|
|
|
'runroot': True,
|
|
|
|
'runroot_tag': 'rrt',
|
|
|
|
'koji_profile': 'koji',
|
|
|
|
'failable_deliverables': [
|
|
|
|
('^.+$', {'*': ['buildinstall']})
|
|
|
|
],
|
|
|
|
})
|
|
|
|
|
|
|
|
get_buildroot_rpms.return_value = ['bash', 'zsh']
|
|
|
|
pool = mock.Mock()
|
|
|
|
cmd = mock.Mock()
|
|
|
|
|
|
|
|
run_runroot_cmd = KojiWrapperMock.return_value.run_runroot_cmd
|
|
|
|
run_runroot_cmd.return_value = {
|
|
|
|
'output': 'Foo bar baz',
|
|
|
|
'retcode': 1,
|
|
|
|
'task_id': 1234,
|
|
|
|
}
|
|
|
|
|
|
|
|
t = BuildinstallThread(pool)
|
|
|
|
|
|
|
|
with mock.patch('time.sleep'):
|
2016-02-11 15:45:56 +00:00
|
|
|
t.process((compose, 'x86_64', compose.variants['Server'], cmd), 0)
|
2016-02-08 11:13:56 +00:00
|
|
|
|
2016-11-18 20:33:03 +00:00
|
|
|
compose._logger.info.assert_has_calls([
|
2016-03-24 09:12:20 +00:00
|
|
|
mock.call('[FAIL] Buildinstall (variant Server, arch x86_64) failed, but going on anyway.'),
|
|
|
|
mock.call('Runroot task failed: 1234. See %s/logs/x86_64/buildinstall-Server.x86_64.log for more details.' % self.topdir)
|
2016-02-08 11:13:56 +00:00
|
|
|
])
|
|
|
|
|
2016-08-17 10:30:42 +00:00
|
|
|
@mock.patch('pungi.phases.buildinstall.KojiWrapper')
|
|
|
|
@mock.patch('pungi.phases.buildinstall.get_buildroot_rpms')
|
|
|
|
@mock.patch('pungi.phases.buildinstall.run')
|
|
|
|
def test_skips_on_existing_output_dir(self, run, get_buildroot_rpms, KojiWrapperMock):
|
|
|
|
compose = BuildInstallCompose(self.topdir, {
|
|
|
|
'buildinstall_method': 'lorax',
|
|
|
|
'runroot': True,
|
|
|
|
'runroot_tag': 'rrt',
|
|
|
|
'koji_profile': 'koji',
|
|
|
|
'failable_deliverables': [
|
|
|
|
('^.+$', {'*': ['buildinstall']})
|
|
|
|
],
|
|
|
|
})
|
|
|
|
|
|
|
|
get_buildroot_rpms.return_value = ['bash', 'zsh']
|
|
|
|
pool = mock.Mock()
|
|
|
|
cmd = mock.Mock()
|
|
|
|
|
|
|
|
dummy_file = os.path.join(self.topdir, 'work/x86_64/buildinstall/Server/dummy')
|
|
|
|
touch(os.path.join(dummy_file))
|
|
|
|
|
|
|
|
t = BuildinstallThread(pool)
|
|
|
|
|
|
|
|
with mock.patch('time.sleep'):
|
|
|
|
t.process((compose, 'x86_64', compose.variants['Server'], cmd), 0)
|
|
|
|
|
|
|
|
self.assertEqual(0, len(run.mock_calls))
|
|
|
|
|
|
|
|
self.assertTrue(os.path.exists(dummy_file))
|
|
|
|
|
2016-02-08 11:13:56 +00:00
|
|
|
|
2016-02-26 09:31:43 +00:00
|
|
|
class TestSymlinkIso(PungiTestCase):
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
super(TestSymlinkIso, self).setUp()
|
|
|
|
self.compose = BuildInstallCompose(self.topdir, {})
|
|
|
|
os_tree = self.compose.paths.compose.os_tree('x86_64', self.compose.variants['Server'])
|
|
|
|
self.boot_iso_path = os.path.join(os_tree, "images", "boot.iso")
|
|
|
|
touch(self.boot_iso_path)
|
|
|
|
|
|
|
|
@mock.patch('pungi.phases.buildinstall.Image')
|
|
|
|
@mock.patch('pungi.phases.buildinstall.get_mtime')
|
|
|
|
@mock.patch('pungi.phases.buildinstall.get_file_size')
|
2016-10-12 11:56:19 +00:00
|
|
|
@mock.patch('pungi.phases.buildinstall.iso')
|
2016-02-26 09:31:43 +00:00
|
|
|
@mock.patch('pungi.phases.buildinstall.run')
|
2016-10-12 11:56:19 +00:00
|
|
|
def test_hardlink(self, run, iso, get_file_size, get_mtime, ImageCls):
|
2016-08-22 14:08:25 +00:00
|
|
|
self.compose.conf = {'buildinstall_symlink': False, 'disc_types': {}}
|
2016-02-26 09:31:43 +00:00
|
|
|
get_file_size.return_value = 1024
|
|
|
|
get_mtime.return_value = 13579
|
|
|
|
|
2016-06-24 07:44:40 +00:00
|
|
|
link_boot_iso(self.compose, 'x86_64', self.compose.variants['Server'], False)
|
2016-02-26 09:31:43 +00:00
|
|
|
|
|
|
|
tgt = self.topdir + '/compose/Server/x86_64/iso/image-name'
|
|
|
|
self.assertTrue(os.path.isfile(tgt))
|
|
|
|
self.assertEqual(os.stat(tgt).st_ino,
|
|
|
|
os.stat(self.topdir + '/compose/Server/x86_64/os/images/boot.iso').st_ino)
|
|
|
|
|
|
|
|
self.assertItemsEqual(
|
|
|
|
self.compose.get_image_name.mock_calls,
|
|
|
|
[mock.call('x86_64', self.compose.variants['Server'],
|
|
|
|
disc_type='boot', disc_num=None, suffix='.iso')])
|
2016-10-12 11:56:19 +00:00
|
|
|
self.assertItemsEqual(iso.get_implanted_md5.mock_calls,
|
2016-02-26 09:31:43 +00:00
|
|
|
[mock.call(tgt)])
|
2016-10-12 11:56:19 +00:00
|
|
|
self.assertItemsEqual(iso.get_manifest_cmd.mock_calls,
|
2016-02-26 09:31:43 +00:00
|
|
|
[mock.call('image-name')])
|
2016-10-12 11:56:19 +00:00
|
|
|
self.assertItemsEqual(iso.get_volume_id.mock_calls,
|
2016-03-08 11:36:28 +00:00
|
|
|
[mock.call(tgt)])
|
|
|
|
self.assertItemsEqual(run.mock_calls,
|
2016-10-12 11:56:19 +00:00
|
|
|
[mock.call(iso.get_manifest_cmd.return_value,
|
2016-03-08 11:36:28 +00:00
|
|
|
workdir=self.topdir + '/compose/Server/x86_64/iso')])
|
|
|
|
|
|
|
|
image = ImageCls.return_value
|
|
|
|
self.assertEqual(image.path, 'Server/x86_64/iso/image-name')
|
|
|
|
self.assertEqual(image.mtime, 13579)
|
|
|
|
self.assertEqual(image.size, 1024)
|
|
|
|
self.assertEqual(image.arch, 'x86_64')
|
|
|
|
self.assertEqual(image.type, "boot")
|
|
|
|
self.assertEqual(image.format, "iso")
|
|
|
|
self.assertEqual(image.disc_number, 1)
|
|
|
|
self.assertEqual(image.disc_count, 1)
|
|
|
|
self.assertEqual(image.bootable, True)
|
2016-10-12 11:56:19 +00:00
|
|
|
self.assertEqual(image.implant_md5, iso.get_implanted_md5.return_value)
|
2016-06-24 07:44:40 +00:00
|
|
|
self.assertEqual(image.can_fail, False)
|
2016-03-08 11:36:28 +00:00
|
|
|
self.assertEqual(self.compose.im.add.mock_calls,
|
|
|
|
[mock.call('Server', 'x86_64', image)])
|
|
|
|
|
|
|
|
@mock.patch('pungi.phases.buildinstall.Image')
|
|
|
|
@mock.patch('pungi.phases.buildinstall.get_mtime')
|
|
|
|
@mock.patch('pungi.phases.buildinstall.get_file_size')
|
2016-10-12 11:56:19 +00:00
|
|
|
@mock.patch('pungi.phases.buildinstall.iso')
|
2016-03-08 11:36:28 +00:00
|
|
|
@mock.patch('pungi.phases.buildinstall.run')
|
2016-10-12 11:56:19 +00:00
|
|
|
def test_hardlink_with_custom_type(self, run, iso, get_file_size, get_mtime, ImageCls):
|
2016-03-08 11:36:28 +00:00
|
|
|
self.compose.conf = {
|
|
|
|
'buildinstall_symlink': False,
|
|
|
|
'disc_types': {'boot': 'netinst'},
|
|
|
|
}
|
|
|
|
get_file_size.return_value = 1024
|
|
|
|
get_mtime.return_value = 13579
|
|
|
|
|
2016-06-24 07:44:40 +00:00
|
|
|
link_boot_iso(self.compose, 'x86_64', self.compose.variants['Server'], True)
|
2016-03-08 11:36:28 +00:00
|
|
|
|
|
|
|
tgt = self.topdir + '/compose/Server/x86_64/iso/image-name'
|
|
|
|
self.assertTrue(os.path.isfile(tgt))
|
|
|
|
self.assertEqual(os.stat(tgt).st_ino,
|
|
|
|
os.stat(self.topdir + '/compose/Server/x86_64/os/images/boot.iso').st_ino)
|
|
|
|
|
|
|
|
self.assertItemsEqual(
|
|
|
|
self.compose.get_image_name.mock_calls,
|
|
|
|
[mock.call('x86_64', self.compose.variants['Server'],
|
|
|
|
disc_type='netinst', disc_num=None, suffix='.iso')])
|
2016-10-12 11:56:19 +00:00
|
|
|
self.assertItemsEqual(iso.get_implanted_md5.mock_calls,
|
2016-03-08 11:36:28 +00:00
|
|
|
[mock.call(tgt)])
|
2016-10-12 11:56:19 +00:00
|
|
|
self.assertItemsEqual(iso.get_manifest_cmd.mock_calls,
|
2016-03-08 11:36:28 +00:00
|
|
|
[mock.call('image-name')])
|
2016-10-12 11:56:19 +00:00
|
|
|
self.assertItemsEqual(iso.get_volume_id.mock_calls,
|
2016-02-26 09:31:43 +00:00
|
|
|
[mock.call(tgt)])
|
|
|
|
self.assertItemsEqual(run.mock_calls,
|
2016-10-12 11:56:19 +00:00
|
|
|
[mock.call(iso.get_manifest_cmd.return_value,
|
2016-02-26 09:31:43 +00:00
|
|
|
workdir=self.topdir + '/compose/Server/x86_64/iso')])
|
|
|
|
|
|
|
|
image = ImageCls.return_value
|
|
|
|
self.assertEqual(image.path, 'Server/x86_64/iso/image-name')
|
|
|
|
self.assertEqual(image.mtime, 13579)
|
|
|
|
self.assertEqual(image.size, 1024)
|
|
|
|
self.assertEqual(image.arch, 'x86_64')
|
|
|
|
self.assertEqual(image.type, "boot")
|
|
|
|
self.assertEqual(image.format, "iso")
|
|
|
|
self.assertEqual(image.disc_number, 1)
|
|
|
|
self.assertEqual(image.disc_count, 1)
|
|
|
|
self.assertEqual(image.bootable, True)
|
2016-10-12 11:56:19 +00:00
|
|
|
self.assertEqual(image.implant_md5, iso.get_implanted_md5.return_value)
|
2016-06-24 07:44:40 +00:00
|
|
|
self.assertEqual(image.can_fail, True)
|
2016-02-26 09:31:43 +00:00
|
|
|
self.assertEqual(self.compose.im.add.mock_calls,
|
|
|
|
[mock.call('Server', 'x86_64', image)])
|
|
|
|
|
|
|
|
|
2015-12-02 14:55:53 +00:00
|
|
|
if __name__ == "__main__":
|
|
|
|
unittest.main()
|