2015-12-02 14:55:53 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
|
2020-06-16 07:15:17 +00:00
|
|
|
try:
|
|
|
|
import unittest2 as unittest
|
|
|
|
except ImportError:
|
|
|
|
import unittest
|
|
|
|
|
2015-12-02 14:55:53 +00:00
|
|
|
import mock
|
2019-10-04 12:45:03 +00:00
|
|
|
import six
|
2020-04-01 08:00:48 +00:00
|
|
|
from copy import copy
|
2020-06-16 07:15:17 +00:00
|
|
|
from six.moves import StringIO
|
2015-12-02 14:55:53 +00:00
|
|
|
|
|
|
|
import os
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
from pungi.phases.buildinstall import (
|
|
|
|
BuildinstallPhase,
|
|
|
|
BuildinstallThread,
|
|
|
|
link_boot_iso,
|
|
|
|
BOOT_CONFIGS,
|
|
|
|
tweak_configs,
|
|
|
|
)
|
2020-04-01 08:00:48 +00:00
|
|
|
from tests.helpers import DummyCompose, PungiTestCase, touch, MockPackageSet, MockPkg
|
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 = {
|
2020-01-22 10:02:22 +00:00
|
|
|
"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-02-11 15:45:56 +00:00
|
|
|
}
|
2016-11-09 12:39:01 +00:00
|
|
|
self.all_variants = self.variants.copy()
|
2018-04-09 13:32:33 +00:00
|
|
|
self.has_comps = True
|
2018-04-23 06:18:39 +00:00
|
|
|
self.just_phases = []
|
|
|
|
self.skip_phases = []
|
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())
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.phases.buildinstall.ThreadPool")
|
|
|
|
@mock.patch("pungi.phases.buildinstall.LoraxWrapper")
|
|
|
|
@mock.patch("pungi.phases.buildinstall.get_volid")
|
2018-03-13 14:54:52 +00:00
|
|
|
def test_skip_option(self, get_volid, loraxCls, poolCls):
|
2020-01-22 10:02:22 +00:00
|
|
|
compose = BuildInstallCompose(
|
|
|
|
self.topdir,
|
|
|
|
{
|
|
|
|
"bootable": True,
|
|
|
|
"buildinstall_method": "lorax",
|
|
|
|
"buildinstall_skip": [
|
|
|
|
("^Server$", {"amd64": True}),
|
|
|
|
("^Client$", {"*": True}),
|
|
|
|
],
|
|
|
|
},
|
|
|
|
)
|
2018-03-13 14:54:52 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
get_volid.return_value = "vol_id"
|
|
|
|
loraxCls.return_value.get_lorax_cmd.return_value = ["lorax", "..."]
|
2018-03-13 14:54:52 +00:00
|
|
|
|
2019-08-01 13:38:21 +00:00
|
|
|
phase = BuildinstallPhase(compose, self._make_pkgset_phase(["p1"]))
|
2018-03-13 14:54:52 +00:00
|
|
|
|
|
|
|
phase.run()
|
|
|
|
|
|
|
|
pool = poolCls.return_value
|
|
|
|
self.assertEqual(1, len(pool.queue_put.mock_calls))
|
|
|
|
|
2015-12-02 14:55:53 +00:00
|
|
|
def test_does_not_skip_on_bootable(self):
|
2020-01-22 10:02:22 +00:00
|
|
|
compose = BuildInstallCompose(self.topdir, {"buildinstall_method": "lorax"})
|
2015-12-02 14:55:53 +00:00
|
|
|
compose.just_phases = None
|
|
|
|
compose.skip_phases = []
|
|
|
|
|
|
|
|
phase = BuildinstallPhase(compose)
|
|
|
|
|
|
|
|
self.assertFalse(phase.skip())
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.phases.buildinstall.ThreadPool")
|
|
|
|
@mock.patch("pungi.phases.buildinstall.LoraxWrapper")
|
|
|
|
@mock.patch("pungi.phases.buildinstall.get_volid")
|
2015-12-02 14:55:53 +00:00
|
|
|
def test_starts_threads_for_each_cmd_with_lorax(self, get_volid, loraxCls, poolCls):
|
2020-01-22 10:02:22 +00:00
|
|
|
compose = BuildInstallCompose(
|
|
|
|
self.topdir,
|
|
|
|
{
|
|
|
|
"bootable": True,
|
|
|
|
"release_name": "Test",
|
|
|
|
"release_short": "t",
|
|
|
|
"release_version": "1",
|
|
|
|
"buildinstall_method": "lorax",
|
|
|
|
"disc_types": {"dvd": "DVD"},
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
get_volid.return_value = "vol_id"
|
|
|
|
loraxCls.return_value.get_lorax_cmd.return_value = ["lorax", "..."]
|
2015-12-02 14:55:53 +00:00
|
|
|
|
2019-08-01 13:38:21 +00:00
|
|
|
phase = BuildinstallPhase(compose, self._make_pkgset_phase(["p1", "p2"]))
|
2015-12-02 14:55:53 +00:00
|
|
|
|
|
|
|
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))
|
2019-10-04 12:45:03 +00:00
|
|
|
six.assertCountEqual(
|
|
|
|
self,
|
2016-08-17 10:30:42 +00:00
|
|
|
[call[0][0][3] for call in pool.queue_put.call_args_list],
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
"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.
|
2019-10-04 12:45:03 +00:00
|
|
|
six.assertCountEqual(
|
|
|
|
self,
|
2016-02-11 15:45:56 +00:00
|
|
|
loraxCls.return_value.get_lorax_cmd.mock_calls,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
"Test",
|
|
|
|
"1",
|
|
|
|
"1",
|
|
|
|
[
|
|
|
|
self.topdir + "/work/x86_64/repo/p1",
|
2019-08-01 13:38:21 +00:00
|
|
|
self.topdir + "/work/x86_64/repo/p2",
|
2020-01-22 10:02:22 +00:00
|
|
|
self.topdir + "/work/x86_64/comps_repo_Server",
|
|
|
|
],
|
|
|
|
self.topdir + "/work/x86_64/buildinstall/Server",
|
|
|
|
buildarch="x86_64",
|
|
|
|
is_final=True,
|
|
|
|
nomacboot=True,
|
|
|
|
noupgrade=True,
|
|
|
|
volid="vol_id",
|
|
|
|
variant="Server",
|
|
|
|
buildinstallpackages=["bash", "vim"],
|
|
|
|
bugurl=None,
|
|
|
|
add_template=[],
|
|
|
|
add_arch_template=[],
|
|
|
|
add_template_var=[],
|
|
|
|
add_arch_template_var=[],
|
|
|
|
rootfs_size=None,
|
|
|
|
log_dir=self.topdir + "/logs/x86_64/buildinstall-Server-logs",
|
|
|
|
dracut_args=[],
|
2020-05-14 02:22:09 +00:00
|
|
|
skip_branding=False,
|
2020-08-05 13:53:58 +00:00
|
|
|
squashfs_only=False,
|
|
|
|
configuration_file=None,
|
2020-01-22 10:02:22 +00:00
|
|
|
),
|
|
|
|
mock.call(
|
|
|
|
"Test",
|
|
|
|
"1",
|
|
|
|
"1",
|
|
|
|
[
|
|
|
|
self.topdir + "/work/amd64/repo/p1",
|
2019-08-01 13:38:21 +00:00
|
|
|
self.topdir + "/work/amd64/repo/p2",
|
2020-01-22 10:02:22 +00:00
|
|
|
self.topdir + "/work/amd64/comps_repo_Server",
|
|
|
|
],
|
|
|
|
self.topdir + "/work/amd64/buildinstall/Server",
|
|
|
|
buildarch="amd64",
|
|
|
|
is_final=True,
|
|
|
|
nomacboot=True,
|
|
|
|
noupgrade=True,
|
|
|
|
volid="vol_id",
|
|
|
|
variant="Server",
|
|
|
|
buildinstallpackages=["bash", "vim"],
|
|
|
|
bugurl=None,
|
|
|
|
add_template=[],
|
|
|
|
add_arch_template=[],
|
|
|
|
add_template_var=[],
|
|
|
|
add_arch_template_var=[],
|
|
|
|
rootfs_size=None,
|
|
|
|
log_dir=self.topdir + "/logs/amd64/buildinstall-Server-logs",
|
|
|
|
dracut_args=[],
|
2020-05-14 02:22:09 +00:00
|
|
|
skip_branding=False,
|
2020-08-05 13:53:58 +00:00
|
|
|
squashfs_only=False,
|
|
|
|
configuration_file=None,
|
2020-01-22 10:02:22 +00:00
|
|
|
),
|
|
|
|
mock.call(
|
|
|
|
"Test",
|
|
|
|
"1",
|
|
|
|
"1",
|
|
|
|
[
|
|
|
|
self.topdir + "/work/amd64/repo/p1",
|
2019-08-01 13:38:21 +00:00
|
|
|
self.topdir + "/work/amd64/repo/p2",
|
2020-01-22 10:02:22 +00:00
|
|
|
self.topdir + "/work/amd64/comps_repo_Client",
|
|
|
|
],
|
|
|
|
self.topdir + "/work/amd64/buildinstall/Client",
|
|
|
|
buildarch="amd64",
|
|
|
|
is_final=True,
|
|
|
|
nomacboot=True,
|
|
|
|
noupgrade=True,
|
|
|
|
volid="vol_id",
|
|
|
|
variant="Client",
|
|
|
|
buildinstallpackages=[],
|
|
|
|
bugurl=None,
|
|
|
|
add_template=[],
|
|
|
|
add_arch_template=[],
|
|
|
|
add_template_var=[],
|
|
|
|
add_arch_template_var=[],
|
|
|
|
rootfs_size=None,
|
|
|
|
log_dir=self.topdir + "/logs/amd64/buildinstall-Client-logs",
|
|
|
|
dracut_args=[],
|
2020-05-14 02:22:09 +00:00
|
|
|
skip_branding=False,
|
2020-08-05 13:53:58 +00:00
|
|
|
squashfs_only=False,
|
|
|
|
configuration_file=None,
|
2020-01-22 10:02:22 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
six.assertCountEqual(
|
|
|
|
self,
|
2016-02-26 10:30:37 +00:00
|
|
|
get_volid.mock_calls,
|
2020-01-22 10:02:22 +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
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.phases.buildinstall.ThreadPool")
|
|
|
|
@mock.patch("pungi.phases.buildinstall.get_volid")
|
2020-01-22 06:55:37 +00:00
|
|
|
def test_starts_threads_for_each_cmd_with_lorax_koji_plugin(
|
2020-01-22 10:02:22 +00:00
|
|
|
self, get_volid, poolCls
|
|
|
|
):
|
|
|
|
compose = BuildInstallCompose(
|
|
|
|
self.topdir,
|
|
|
|
{
|
|
|
|
"bootable": True,
|
|
|
|
"release_name": "Test",
|
|
|
|
"release_short": "t",
|
|
|
|
"release_version": "1",
|
|
|
|
"buildinstall_method": "lorax",
|
|
|
|
"lorax_use_koji_plugin": True,
|
|
|
|
"disc_types": {"dvd": "DVD"},
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
get_volid.return_value = "vol_id"
|
2020-01-22 06:55:37 +00:00
|
|
|
|
|
|
|
phase = BuildinstallPhase(compose, self._make_pkgset_phase(["p1", "p2"]))
|
|
|
|
|
|
|
|
phase.run()
|
|
|
|
self.maxDiff = None
|
|
|
|
|
|
|
|
expected_args = [
|
|
|
|
{
|
2020-01-22 10:02:22 +00:00
|
|
|
"product": "Test",
|
|
|
|
"version": "1",
|
|
|
|
"release": "1",
|
|
|
|
"sources": [
|
|
|
|
self.topdir + "/work/amd64/repo/p1",
|
|
|
|
self.topdir + "/work/amd64/repo/p2",
|
|
|
|
self.topdir + "/work/amd64/comps_repo_Server",
|
|
|
|
],
|
|
|
|
"variant": "Server",
|
|
|
|
"installpkgs": ["bash", "vim"],
|
|
|
|
"isfinal": True,
|
|
|
|
"buildarch": "amd64",
|
|
|
|
"volid": "vol_id",
|
|
|
|
"nomacboot": True,
|
|
|
|
"bugurl": None,
|
|
|
|
"add-template": [],
|
|
|
|
"add-arch-template": [],
|
|
|
|
"add-template-var": [],
|
|
|
|
"add-arch-template-var": [],
|
|
|
|
"noupgrade": True,
|
|
|
|
"rootfs-size": None,
|
|
|
|
"dracut-args": [],
|
2020-05-14 02:22:09 +00:00
|
|
|
"skip_branding": False,
|
2020-01-22 10:02:22 +00:00
|
|
|
"outputdir": self.topdir + "/work/amd64/buildinstall/Server",
|
2020-08-05 13:53:58 +00:00
|
|
|
"squashfs_only": False,
|
|
|
|
"configuration_file": None,
|
2020-01-22 06:55:37 +00:00
|
|
|
},
|
|
|
|
{
|
2020-01-22 10:02:22 +00:00
|
|
|
"product": "Test",
|
|
|
|
"version": "1",
|
|
|
|
"release": "1",
|
|
|
|
"sources": [
|
|
|
|
self.topdir + "/work/amd64/repo/p1",
|
|
|
|
self.topdir + "/work/amd64/repo/p2",
|
|
|
|
self.topdir + "/work/amd64/comps_repo_Client",
|
|
|
|
],
|
|
|
|
"variant": "Client",
|
|
|
|
"installpkgs": [],
|
|
|
|
"isfinal": True,
|
|
|
|
"buildarch": "amd64",
|
|
|
|
"volid": "vol_id",
|
|
|
|
"nomacboot": True,
|
|
|
|
"bugurl": None,
|
|
|
|
"add-template": [],
|
|
|
|
"add-arch-template": [],
|
|
|
|
"add-template-var": [],
|
|
|
|
"add-arch-template-var": [],
|
|
|
|
"noupgrade": True,
|
|
|
|
"rootfs-size": None,
|
|
|
|
"dracut-args": [],
|
2020-05-14 02:22:09 +00:00
|
|
|
"skip_branding": False,
|
2020-01-22 10:02:22 +00:00
|
|
|
"outputdir": self.topdir + "/work/amd64/buildinstall/Client",
|
2020-08-05 13:53:58 +00:00
|
|
|
"squashfs_only": False,
|
|
|
|
"configuration_file": None,
|
2020-01-22 06:55:37 +00:00
|
|
|
},
|
|
|
|
{
|
2020-01-22 10:02:22 +00:00
|
|
|
"product": "Test",
|
|
|
|
"version": "1",
|
|
|
|
"release": "1",
|
|
|
|
"sources": [
|
|
|
|
self.topdir + "/work/x86_64/repo/p1",
|
|
|
|
self.topdir + "/work/x86_64/repo/p2",
|
|
|
|
self.topdir + "/work/x86_64/comps_repo_Server",
|
|
|
|
],
|
|
|
|
"variant": "Server",
|
|
|
|
"installpkgs": ["bash", "vim"],
|
|
|
|
"isfinal": True,
|
|
|
|
"buildarch": "x86_64",
|
|
|
|
"volid": "vol_id",
|
|
|
|
"nomacboot": True,
|
|
|
|
"bugurl": None,
|
|
|
|
"add-template": [],
|
|
|
|
"add-arch-template": [],
|
|
|
|
"add-template-var": [],
|
|
|
|
"add-arch-template-var": [],
|
|
|
|
"noupgrade": True,
|
|
|
|
"rootfs-size": None,
|
|
|
|
"dracut-args": [],
|
2020-05-14 02:22:09 +00:00
|
|
|
"skip_branding": False,
|
2020-01-22 10:02:22 +00:00
|
|
|
"outputdir": self.topdir + "/work/x86_64/buildinstall/Server",
|
2020-08-05 13:53:58 +00:00
|
|
|
"squashfs_only": False,
|
|
|
|
"configuration_file": None,
|
2020-01-22 06:55:37 +00:00
|
|
|
},
|
|
|
|
]
|
|
|
|
|
|
|
|
# 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))
|
|
|
|
six.assertCountEqual(
|
|
|
|
self,
|
|
|
|
[call[0][0][3] for call in pool.queue_put.call_args_list],
|
2020-01-22 10:02:22 +00:00
|
|
|
expected_args,
|
|
|
|
)
|
2020-01-22 06:55:37 +00:00
|
|
|
|
|
|
|
six.assertCountEqual(
|
|
|
|
self,
|
|
|
|
get_volid.mock_calls,
|
2020-01-22 10:02:22 +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",
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
2020-01-22 06:55:37 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.phases.buildinstall.ThreadPool")
|
|
|
|
@mock.patch("pungi.phases.buildinstall.LoraxWrapper")
|
|
|
|
@mock.patch("pungi.phases.buildinstall.get_volid")
|
2016-02-18 15:12:23 +00:00
|
|
|
def test_lorax_skips_empty_variants(self, get_volid, loraxCls, poolCls):
|
2020-01-22 10:02:22 +00:00
|
|
|
compose = BuildInstallCompose(
|
|
|
|
self.topdir,
|
|
|
|
{
|
|
|
|
"bootable": True,
|
|
|
|
"release_name": "Test",
|
|
|
|
"release_short": "t",
|
|
|
|
"release_version": "1",
|
|
|
|
"buildinstall_method": "lorax",
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
get_volid.return_value = "vol_id"
|
|
|
|
compose.variants["Server"].is_empty = True
|
|
|
|
loraxCls.return_value.get_lorax_cmd.return_value = ["lorax", "..."]
|
2016-02-18 15:12:23 +00:00
|
|
|
|
2019-08-01 13:38:21 +00:00
|
|
|
phase = BuildinstallPhase(compose, self._make_pkgset_phase(["p1"]))
|
2016-02-18 15:12:23 +00:00
|
|
|
|
|
|
|
phase.run()
|
|
|
|
|
|
|
|
pool = poolCls.return_value
|
|
|
|
self.assertEqual(1, len(pool.queue_put.mock_calls))
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(
|
2016-08-17 10:30:42 +00:00
|
|
|
[call[0][0][3] for call in pool.queue_put.call_args_list],
|
2020-01-22 10:02:22 +00:00
|
|
|
["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(
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
"Test",
|
|
|
|
"1",
|
|
|
|
"1",
|
|
|
|
[
|
|
|
|
self.topdir + "/work/amd64/repo/p1",
|
|
|
|
self.topdir + "/work/amd64/comps_repo_Client",
|
|
|
|
],
|
|
|
|
self.topdir + "/work/amd64/buildinstall/Client",
|
|
|
|
buildarch="amd64",
|
|
|
|
is_final=True,
|
|
|
|
nomacboot=True,
|
|
|
|
noupgrade=True,
|
|
|
|
volid="vol_id",
|
|
|
|
variant="Client",
|
|
|
|
buildinstallpackages=[],
|
|
|
|
bugurl=None,
|
|
|
|
add_template=[],
|
|
|
|
add_arch_template=[],
|
|
|
|
add_template_var=[],
|
|
|
|
add_arch_template_var=[],
|
|
|
|
rootfs_size=None,
|
|
|
|
log_dir=self.topdir + "/logs/amd64/buildinstall-Client-logs",
|
|
|
|
dracut_args=[],
|
2020-05-14 02:22:09 +00:00
|
|
|
skip_branding=False,
|
2020-08-05 13:53:58 +00:00
|
|
|
squashfs_only=False,
|
|
|
|
configuration_file=None,
|
2020-01-22 10:02:22 +00:00
|
|
|
)
|
|
|
|
],
|
|
|
|
any_order=True,
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(
|
2016-02-26 10:30:37 +00:00
|
|
|
get_volid.mock_calls,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
compose,
|
|
|
|
"amd64",
|
|
|
|
variant=compose.variants["Client"],
|
|
|
|
disc_type="dvd",
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
@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
|
|
|
|
):
|
|
|
|
compose = BuildInstallCompose(
|
|
|
|
self.topdir,
|
|
|
|
{
|
|
|
|
"bootable": True,
|
|
|
|
"release_name": "Test",
|
|
|
|
"release_short": "t",
|
|
|
|
"release_version": "1",
|
|
|
|
"buildinstall_method": "buildinstall",
|
|
|
|
"disc_types": {"dvd": "DVD"},
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
get_volid.return_value = "vol_id"
|
2015-12-02 14:55:53 +00:00
|
|
|
|
2019-08-01 13:38:21 +00:00
|
|
|
phase = BuildinstallPhase(compose, self._make_pkgset_phase(["p1"]))
|
2015-12-02 14:55:53 +00:00
|
|
|
|
|
|
|
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.
|
2019-10-04 12:45:03 +00:00
|
|
|
six.assertCountEqual(
|
|
|
|
self,
|
2016-02-11 15:45:56 +00:00
|
|
|
loraxCls.return_value.get_buildinstall_cmd.mock_calls,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
"Test",
|
|
|
|
"1",
|
|
|
|
"1",
|
|
|
|
[self.topdir + "/work/x86_64/repo/p1"],
|
|
|
|
self.topdir + "/work/x86_64/buildinstall",
|
|
|
|
buildarch="x86_64",
|
|
|
|
is_final=True,
|
|
|
|
volid="vol_id",
|
|
|
|
),
|
|
|
|
mock.call(
|
|
|
|
"Test",
|
|
|
|
"1",
|
|
|
|
"1",
|
|
|
|
[self.topdir + "/work/amd64/repo/p1"],
|
|
|
|
self.topdir + "/work/amd64/buildinstall",
|
|
|
|
buildarch="amd64",
|
|
|
|
is_final=True,
|
|
|
|
volid="vol_id",
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
six.assertCountEqual(
|
|
|
|
self,
|
2016-02-26 10:30:37 +00:00
|
|
|
get_volid.mock_calls,
|
2020-01-22 10:02:22 +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
|
|
|
|
2020-08-05 13:53:58 +00:00
|
|
|
@mock.patch("pungi.phases.buildinstall.get_file")
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.phases.buildinstall.ThreadPool")
|
|
|
|
@mock.patch("pungi.phases.buildinstall.LoraxWrapper")
|
|
|
|
@mock.patch("pungi.phases.buildinstall.get_volid")
|
2020-08-05 13:53:58 +00:00
|
|
|
def test_uses_lorax_options(self, get_volid, loraxCls, poolCls, get_file):
|
2020-01-22 10:02:22 +00:00
|
|
|
compose = BuildInstallCompose(
|
|
|
|
self.topdir,
|
|
|
|
{
|
|
|
|
"bootable": True,
|
|
|
|
"release_name": "Test",
|
|
|
|
"release_short": "t",
|
|
|
|
"release_version": "1",
|
|
|
|
"buildinstall_method": "lorax",
|
|
|
|
"lorax_options": [
|
|
|
|
(
|
|
|
|
"^Server$",
|
|
|
|
{
|
|
|
|
"x86_64": {
|
|
|
|
"bugurl": "http://example.com",
|
|
|
|
"add_template": ["foo", "FOO"],
|
|
|
|
"add_arch_template": ["bar"],
|
|
|
|
"add_template_var": ["baz=1"],
|
|
|
|
"add_arch_template_var": ["quux=2"],
|
|
|
|
"rootfs_size": 3,
|
|
|
|
"version": "1.2.3",
|
|
|
|
"dracut_args": ["--xz", "--install", "/.buildstamp"],
|
2020-08-05 13:53:58 +00:00
|
|
|
"configuration_file": "/tmp/lorax.conf",
|
2020-01-22 10:02:22 +00:00
|
|
|
},
|
2020-08-05 13:53:58 +00:00
|
|
|
"amd64": {"noupgrade": False, "squashfs_only": True},
|
2020-01-22 10:02:22 +00:00
|
|
|
},
|
|
|
|
),
|
|
|
|
("^Client$", {"*": {"nomacboot": False}}),
|
|
|
|
],
|
|
|
|
},
|
|
|
|
)
|
2015-12-08 08:29:24 +00:00
|
|
|
|
2020-08-05 13:53:58 +00:00
|
|
|
def _mocked_get_file(source, destination, compose):
|
|
|
|
return destination
|
|
|
|
|
|
|
|
get_file.side_effect = _mocked_get_file
|
2020-01-22 10:02:22 +00:00
|
|
|
get_volid.return_value = "vol_id"
|
|
|
|
loraxCls.return_value.get_lorax_cmd.return_value = ["lorax", "..."]
|
2015-12-08 08:29:24 +00:00
|
|
|
|
2019-08-01 13:38:21 +00:00
|
|
|
phase = BuildinstallPhase(compose, self._make_pkgset_phase(["p1"]))
|
2015-12-08 08:29:24 +00:00
|
|
|
|
|
|
|
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))
|
2019-10-04 12:45:03 +00:00
|
|
|
six.assertCountEqual(
|
|
|
|
self,
|
2016-08-17 10:30:42 +00:00
|
|
|
[call[0][0][3] for call in pool.queue_put.call_args_list],
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
"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.
|
2019-10-04 12:45:03 +00:00
|
|
|
six.assertCountEqual(
|
|
|
|
self,
|
2016-02-11 15:45:56 +00:00
|
|
|
loraxCls.return_value.get_lorax_cmd.mock_calls,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
"Test",
|
|
|
|
"1.2.3",
|
|
|
|
"1.2.3",
|
|
|
|
[
|
|
|
|
self.topdir + "/work/x86_64/repo/p1",
|
|
|
|
self.topdir + "/work/x86_64/comps_repo_Server",
|
|
|
|
],
|
|
|
|
self.topdir + "/work/x86_64/buildinstall/Server",
|
|
|
|
buildarch="x86_64",
|
|
|
|
is_final=True,
|
|
|
|
nomacboot=True,
|
|
|
|
noupgrade=True,
|
|
|
|
volid="vol_id",
|
|
|
|
variant="Server",
|
|
|
|
buildinstallpackages=["bash", "vim"],
|
|
|
|
add_template=["foo", "FOO"],
|
|
|
|
add_arch_template=["bar"],
|
|
|
|
add_template_var=["baz=1"],
|
|
|
|
add_arch_template_var=["quux=2"],
|
|
|
|
bugurl="http://example.com",
|
|
|
|
rootfs_size=3,
|
2020-08-05 13:53:58 +00:00
|
|
|
log_dir=os.path.join(
|
|
|
|
self.topdir, "logs/x86_64/buildinstall-Server-logs"
|
|
|
|
),
|
2020-01-22 10:02:22 +00:00
|
|
|
dracut_args=["--xz", "--install", "/.buildstamp"],
|
2020-05-14 02:22:09 +00:00
|
|
|
skip_branding=False,
|
2020-08-05 13:53:58 +00:00
|
|
|
squashfs_only=False,
|
|
|
|
configuration_file=os.path.join(
|
|
|
|
self.topdir,
|
|
|
|
"logs/x86_64/buildinstall-Server-logs",
|
|
|
|
"lorax.conf",
|
|
|
|
),
|
2020-01-22 10:02:22 +00:00
|
|
|
),
|
|
|
|
mock.call(
|
|
|
|
"Test",
|
|
|
|
"1",
|
|
|
|
"1",
|
|
|
|
[
|
|
|
|
self.topdir + "/work/amd64/repo/p1",
|
|
|
|
self.topdir + "/work/amd64/comps_repo_Server",
|
|
|
|
],
|
|
|
|
self.topdir + "/work/amd64/buildinstall/Server",
|
|
|
|
buildarch="amd64",
|
|
|
|
is_final=True,
|
|
|
|
nomacboot=True,
|
|
|
|
noupgrade=False,
|
|
|
|
volid="vol_id",
|
|
|
|
variant="Server",
|
|
|
|
buildinstallpackages=["bash", "vim"],
|
|
|
|
bugurl=None,
|
|
|
|
add_template=[],
|
|
|
|
add_arch_template=[],
|
|
|
|
add_template_var=[],
|
|
|
|
add_arch_template_var=[],
|
|
|
|
rootfs_size=None,
|
|
|
|
log_dir=self.topdir + "/logs/amd64/buildinstall-Server-logs",
|
|
|
|
dracut_args=[],
|
2020-05-14 02:22:09 +00:00
|
|
|
skip_branding=False,
|
2020-08-05 13:53:58 +00:00
|
|
|
squashfs_only=True,
|
|
|
|
configuration_file=None,
|
2020-01-22 10:02:22 +00:00
|
|
|
),
|
|
|
|
mock.call(
|
|
|
|
"Test",
|
|
|
|
"1",
|
|
|
|
"1",
|
|
|
|
[
|
|
|
|
self.topdir + "/work/amd64/repo/p1",
|
|
|
|
self.topdir + "/work/amd64/comps_repo_Client",
|
|
|
|
],
|
|
|
|
self.topdir + "/work/amd64/buildinstall/Client",
|
|
|
|
buildarch="amd64",
|
|
|
|
is_final=True,
|
|
|
|
nomacboot=False,
|
|
|
|
noupgrade=True,
|
|
|
|
volid="vol_id",
|
|
|
|
variant="Client",
|
|
|
|
buildinstallpackages=[],
|
|
|
|
bugurl=None,
|
|
|
|
add_template=[],
|
|
|
|
add_arch_template=[],
|
|
|
|
add_template_var=[],
|
|
|
|
add_arch_template_var=[],
|
|
|
|
rootfs_size=None,
|
|
|
|
log_dir=self.topdir + "/logs/amd64/buildinstall-Client-logs",
|
|
|
|
dracut_args=[],
|
2020-05-14 02:22:09 +00:00
|
|
|
skip_branding=False,
|
2020-08-05 13:53:58 +00:00
|
|
|
squashfs_only=False,
|
|
|
|
configuration_file=None,
|
2020-01-22 10:02:22 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
six.assertCountEqual(
|
|
|
|
self,
|
2016-02-26 10:30:37 +00:00
|
|
|
get_volid.mock_calls,
|
2020-01-22 10:02:22 +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",
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
2020-08-05 13:53:58 +00:00
|
|
|
"""
|
|
|
|
There should be one get_file call. This is because the configuration_file
|
|
|
|
option was used only once in the above configuration.
|
|
|
|
"""
|
|
|
|
six.assertCountEqual(
|
|
|
|
self,
|
|
|
|
get_file.mock_calls,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
"/tmp/lorax.conf",
|
|
|
|
os.path.join(
|
|
|
|
compose.topdir,
|
|
|
|
"logs/x86_64/buildinstall-Server-logs",
|
|
|
|
"lorax.conf",
|
|
|
|
),
|
|
|
|
compose=compose,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
2015-12-08 08:29:24 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.phases.buildinstall.ThreadPool")
|
|
|
|
@mock.patch("pungi.phases.buildinstall.LoraxWrapper")
|
|
|
|
@mock.patch("pungi.phases.buildinstall.get_volid")
|
2015-12-08 08:29:24 +00:00
|
|
|
def test_multiple_lorax_options(self, get_volid, loraxCls, poolCls):
|
2020-01-22 10:02:22 +00:00
|
|
|
compose = BuildInstallCompose(
|
|
|
|
self.topdir,
|
|
|
|
{
|
|
|
|
"bootable": True,
|
|
|
|
"release_name": "Test",
|
|
|
|
"release_short": "t",
|
|
|
|
"release_version": "1",
|
|
|
|
"buildinstall_method": "lorax",
|
|
|
|
"lorax_options": [
|
|
|
|
(
|
|
|
|
"^.*$",
|
|
|
|
{"x86_64": {"nomacboot": False}, "*": {"noupgrade": False}},
|
|
|
|
),
|
|
|
|
],
|
|
|
|
},
|
|
|
|
)
|
2015-12-08 08:29:24 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
get_volid.return_value = "vol_id"
|
|
|
|
loraxCls.return_value.get_lorax_cmd.return_value = ["lorax", "..."]
|
2015-12-08 08:29:24 +00:00
|
|
|
|
2019-08-01 13:38:21 +00:00
|
|
|
phase = BuildinstallPhase(compose, self._make_pkgset_phase(["p1"]))
|
2015-12-08 08:29:24 +00:00
|
|
|
|
|
|
|
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))
|
2019-10-04 12:45:03 +00:00
|
|
|
six.assertCountEqual(
|
|
|
|
self,
|
2016-08-17 10:30:42 +00:00
|
|
|
[call[0][0][3] for call in pool.queue_put.call_args_list],
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
"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.
|
2019-10-04 12:45:03 +00:00
|
|
|
six.assertCountEqual(
|
|
|
|
self,
|
2016-02-11 15:45:56 +00:00
|
|
|
loraxCls.return_value.get_lorax_cmd.mock_calls,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
"Test",
|
|
|
|
"1",
|
|
|
|
"1",
|
|
|
|
[
|
|
|
|
self.topdir + "/work/x86_64/repo/p1",
|
|
|
|
self.topdir + "/work/x86_64/comps_repo_Server",
|
|
|
|
],
|
|
|
|
self.topdir + "/work/x86_64/buildinstall/Server",
|
|
|
|
buildarch="x86_64",
|
|
|
|
is_final=True,
|
|
|
|
nomacboot=False,
|
|
|
|
noupgrade=False,
|
|
|
|
volid="vol_id",
|
|
|
|
variant="Server",
|
|
|
|
buildinstallpackages=["bash", "vim"],
|
|
|
|
bugurl=None,
|
|
|
|
add_template=[],
|
|
|
|
add_arch_template=[],
|
|
|
|
add_template_var=[],
|
|
|
|
add_arch_template_var=[],
|
|
|
|
rootfs_size=None,
|
|
|
|
log_dir=self.topdir + "/logs/x86_64/buildinstall-Server-logs",
|
|
|
|
dracut_args=[],
|
2020-05-14 02:22:09 +00:00
|
|
|
skip_branding=False,
|
2020-08-05 13:53:58 +00:00
|
|
|
squashfs_only=False,
|
|
|
|
configuration_file=None,
|
2020-01-22 10:02:22 +00:00
|
|
|
),
|
|
|
|
mock.call(
|
|
|
|
"Test",
|
|
|
|
"1",
|
|
|
|
"1",
|
|
|
|
[
|
|
|
|
self.topdir + "/work/amd64/repo/p1",
|
|
|
|
self.topdir + "/work/amd64/comps_repo_Server",
|
|
|
|
],
|
|
|
|
self.topdir + "/work/amd64/buildinstall/Server",
|
|
|
|
buildarch="amd64",
|
|
|
|
is_final=True,
|
|
|
|
nomacboot=True,
|
|
|
|
noupgrade=False,
|
|
|
|
volid="vol_id",
|
|
|
|
variant="Server",
|
|
|
|
buildinstallpackages=["bash", "vim"],
|
|
|
|
bugurl=None,
|
|
|
|
add_template=[],
|
|
|
|
add_arch_template=[],
|
|
|
|
add_template_var=[],
|
|
|
|
add_arch_template_var=[],
|
|
|
|
rootfs_size=None,
|
|
|
|
log_dir=self.topdir + "/logs/amd64/buildinstall-Server-logs",
|
|
|
|
dracut_args=[],
|
2020-05-14 02:22:09 +00:00
|
|
|
skip_branding=False,
|
2020-08-05 13:53:58 +00:00
|
|
|
squashfs_only=False,
|
|
|
|
configuration_file=None,
|
2020-01-22 10:02:22 +00:00
|
|
|
),
|
|
|
|
mock.call(
|
|
|
|
"Test",
|
|
|
|
"1",
|
|
|
|
"1",
|
|
|
|
[
|
|
|
|
self.topdir + "/work/amd64/repo/p1",
|
|
|
|
self.topdir + "/work/amd64/comps_repo_Client",
|
|
|
|
],
|
|
|
|
self.topdir + "/work/amd64/buildinstall/Client",
|
|
|
|
buildarch="amd64",
|
|
|
|
is_final=True,
|
|
|
|
nomacboot=True,
|
|
|
|
noupgrade=False,
|
|
|
|
volid="vol_id",
|
|
|
|
variant="Client",
|
|
|
|
buildinstallpackages=[],
|
|
|
|
bugurl=None,
|
|
|
|
add_template=[],
|
|
|
|
add_arch_template=[],
|
|
|
|
add_template_var=[],
|
|
|
|
add_arch_template_var=[],
|
|
|
|
rootfs_size=None,
|
|
|
|
log_dir=self.topdir + "/logs/amd64/buildinstall-Client-logs",
|
|
|
|
dracut_args=[],
|
2020-05-14 02:22:09 +00:00
|
|
|
skip_branding=False,
|
2020-08-05 13:53:58 +00:00
|
|
|
squashfs_only=False,
|
|
|
|
configuration_file=None,
|
2020-01-22 10:02:22 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
six.assertCountEqual(
|
|
|
|
self,
|
2016-02-26 10:30:37 +00:00
|
|
|
get_volid.mock_calls,
|
2020-01-22 10:02:22 +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
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.phases.buildinstall.ThreadPool")
|
|
|
|
@mock.patch("pungi.phases.buildinstall.LoraxWrapper")
|
|
|
|
@mock.patch("pungi.phases.buildinstall.get_volid")
|
2017-11-22 09:50:14 +00:00
|
|
|
def test_uses_lorax_options_buildinstall_topdir(self, get_volid, loraxCls, poolCls):
|
2020-01-22 10:02:22 +00:00
|
|
|
compose = BuildInstallCompose(
|
|
|
|
self.topdir,
|
|
|
|
{
|
|
|
|
"bootable": True,
|
|
|
|
"release_name": "Test",
|
|
|
|
"release_short": "t",
|
|
|
|
"release_version": "1",
|
|
|
|
"buildinstall_method": "lorax",
|
|
|
|
"buildinstall_topdir": "/buildinstall_topdir",
|
|
|
|
"translate_paths": [(self.topdir, "http://localhost/")],
|
|
|
|
},
|
|
|
|
)
|
2017-11-22 09:50:14 +00:00
|
|
|
|
|
|
|
buildinstall_topdir = os.path.join(
|
2020-01-22 10:02:22 +00:00
|
|
|
"/buildinstall_topdir", "buildinstall-" + os.path.basename(self.topdir)
|
|
|
|
)
|
2017-11-22 09:50:14 +00:00
|
|
|
self.maxDiff = None
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
get_volid.return_value = "vol_id"
|
|
|
|
loraxCls.return_value.get_lorax_cmd.return_value = ["lorax", "..."]
|
2017-11-22 09:50:14 +00:00
|
|
|
|
2019-08-01 13:38:21 +00:00
|
|
|
phase = BuildinstallPhase(compose, self._make_pkgset_phase(["p1"]))
|
2017-11-22 09:50:14 +00:00
|
|
|
|
|
|
|
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))
|
2019-10-04 12:45:03 +00:00
|
|
|
six.assertCountEqual(
|
|
|
|
self,
|
2017-11-22 09:50:14 +00:00
|
|
|
[call[0][0][3] for call in pool.queue_put.call_args_list],
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
"rm -rf %s/amd64/Client && lorax ..." % buildinstall_topdir,
|
|
|
|
"rm -rf %s/amd64/Server && lorax ..." % buildinstall_topdir,
|
|
|
|
"rm -rf %s/x86_64/Server && lorax ..." % buildinstall_topdir,
|
|
|
|
],
|
|
|
|
)
|
2017-11-22 09:50:14 +00:00
|
|
|
|
|
|
|
# Obtained correct lorax commands.
|
2019-10-04 12:45:03 +00:00
|
|
|
six.assertCountEqual(
|
|
|
|
self,
|
2017-11-22 09:50:14 +00:00
|
|
|
loraxCls.return_value.get_lorax_cmd.mock_calls,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
"Test",
|
|
|
|
"1",
|
|
|
|
"1",
|
|
|
|
[
|
|
|
|
"http://localhost/work/x86_64/repo/p1",
|
|
|
|
"http://localhost/work/x86_64/comps_repo_Server",
|
|
|
|
],
|
|
|
|
buildinstall_topdir + "/x86_64/Server/results",
|
|
|
|
buildarch="x86_64",
|
|
|
|
is_final=True,
|
|
|
|
nomacboot=True,
|
|
|
|
noupgrade=True,
|
|
|
|
volid="vol_id",
|
|
|
|
variant="Server",
|
|
|
|
buildinstallpackages=["bash", "vim"],
|
|
|
|
add_template=[],
|
|
|
|
add_arch_template=[],
|
|
|
|
add_template_var=[],
|
|
|
|
add_arch_template_var=[],
|
|
|
|
bugurl=None,
|
|
|
|
rootfs_size=None,
|
|
|
|
log_dir=buildinstall_topdir + "/x86_64/Server/logs",
|
|
|
|
dracut_args=[],
|
2020-05-14 02:22:09 +00:00
|
|
|
skip_branding=False,
|
2020-08-05 13:53:58 +00:00
|
|
|
squashfs_only=False,
|
|
|
|
configuration_file=None,
|
2020-01-22 10:02:22 +00:00
|
|
|
),
|
|
|
|
mock.call(
|
|
|
|
"Test",
|
|
|
|
"1",
|
|
|
|
"1",
|
|
|
|
[
|
|
|
|
"http://localhost/work/amd64/repo/p1",
|
|
|
|
"http://localhost/work/amd64/comps_repo_Server",
|
|
|
|
],
|
|
|
|
buildinstall_topdir + "/amd64/Server/results",
|
|
|
|
buildarch="amd64",
|
|
|
|
is_final=True,
|
|
|
|
nomacboot=True,
|
|
|
|
noupgrade=True,
|
|
|
|
volid="vol_id",
|
|
|
|
variant="Server",
|
|
|
|
buildinstallpackages=["bash", "vim"],
|
|
|
|
bugurl=None,
|
|
|
|
add_template=[],
|
|
|
|
add_arch_template=[],
|
|
|
|
add_template_var=[],
|
|
|
|
add_arch_template_var=[],
|
|
|
|
rootfs_size=None,
|
|
|
|
log_dir=buildinstall_topdir + "/amd64/Server/logs",
|
|
|
|
dracut_args=[],
|
2020-05-14 02:22:09 +00:00
|
|
|
skip_branding=False,
|
2020-08-05 13:53:58 +00:00
|
|
|
squashfs_only=False,
|
|
|
|
configuration_file=None,
|
2020-01-22 10:02:22 +00:00
|
|
|
),
|
|
|
|
mock.call(
|
|
|
|
"Test",
|
|
|
|
"1",
|
|
|
|
"1",
|
|
|
|
[
|
|
|
|
"http://localhost/work/amd64/repo/p1",
|
|
|
|
"http://localhost/work/amd64/comps_repo_Client",
|
|
|
|
],
|
|
|
|
buildinstall_topdir + "/amd64/Client/results",
|
|
|
|
buildarch="amd64",
|
|
|
|
is_final=True,
|
|
|
|
nomacboot=True,
|
|
|
|
noupgrade=True,
|
|
|
|
volid="vol_id",
|
|
|
|
variant="Client",
|
|
|
|
buildinstallpackages=[],
|
|
|
|
bugurl=None,
|
|
|
|
add_template=[],
|
|
|
|
add_arch_template=[],
|
|
|
|
add_template_var=[],
|
|
|
|
add_arch_template_var=[],
|
|
|
|
rootfs_size=None,
|
|
|
|
log_dir=buildinstall_topdir + "/amd64/Client/logs",
|
|
|
|
dracut_args=[],
|
2020-05-14 02:22:09 +00:00
|
|
|
skip_branding=False,
|
2020-08-05 13:53:58 +00:00
|
|
|
squashfs_only=False,
|
|
|
|
configuration_file=None,
|
2020-01-22 10:02:22 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
six.assertCountEqual(
|
|
|
|
self,
|
2017-11-22 09:50:14 +00:00
|
|
|
get_volid.mock_calls,
|
2020-01-22 10:02:22 +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",
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
2017-11-22 09:50:14 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.phases.buildinstall.ThreadPool")
|
|
|
|
@mock.patch("pungi.phases.buildinstall.LoraxWrapper")
|
|
|
|
@mock.patch("pungi.phases.buildinstall.get_volid")
|
2018-04-04 13:22:28 +00:00
|
|
|
def test_uses_lorax_extra_repos(self, get_volid, loraxCls, poolCls):
|
2020-01-22 10:02:22 +00:00
|
|
|
compose = BuildInstallCompose(
|
|
|
|
self.topdir,
|
|
|
|
{
|
|
|
|
"bootable": True,
|
|
|
|
"release_name": "Test",
|
|
|
|
"release_short": "t",
|
|
|
|
"release_version": "1",
|
|
|
|
"buildinstall_method": "lorax",
|
|
|
|
"lorax_extra_sources": [
|
|
|
|
("^Server$", {"x86_64": "http://example.com/repo1"}),
|
|
|
|
(
|
|
|
|
"^Client$",
|
|
|
|
{
|
|
|
|
"*": [
|
|
|
|
"http://example.com/repo2",
|
|
|
|
"http://example.com/repo3",
|
|
|
|
],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
],
|
|
|
|
},
|
|
|
|
)
|
2018-04-04 13:22:28 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
get_volid.return_value = "vol_id"
|
|
|
|
loraxCls.return_value.get_lorax_cmd.return_value = ["lorax", "..."]
|
2018-04-04 13:22:28 +00:00
|
|
|
|
2019-08-01 13:38:21 +00:00
|
|
|
phase = BuildinstallPhase(compose, self._make_pkgset_phase(["p1"]))
|
2018-04-04 13:22:28 +00:00
|
|
|
|
|
|
|
phase.run()
|
|
|
|
|
2018-04-09 13:32:33 +00:00
|
|
|
self.maxDiff = None
|
2019-10-04 12:45:03 +00:00
|
|
|
six.assertCountEqual(
|
|
|
|
self,
|
2018-04-04 13:22:28 +00:00
|
|
|
loraxCls.return_value.get_lorax_cmd.mock_calls,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
"Test",
|
|
|
|
"1",
|
|
|
|
"1",
|
|
|
|
[
|
|
|
|
self.topdir + "/work/x86_64/repo/p1",
|
2018-04-09 13:32:33 +00:00
|
|
|
"http://example.com/repo1",
|
2020-01-22 10:02:22 +00:00
|
|
|
self.topdir + "/work/x86_64/comps_repo_Server",
|
|
|
|
],
|
|
|
|
self.topdir + "/work/x86_64/buildinstall/Server",
|
|
|
|
buildarch="x86_64",
|
|
|
|
is_final=True,
|
|
|
|
nomacboot=True,
|
|
|
|
noupgrade=True,
|
|
|
|
volid="vol_id",
|
|
|
|
variant="Server",
|
|
|
|
buildinstallpackages=["bash", "vim"],
|
|
|
|
add_template=[],
|
|
|
|
add_arch_template=[],
|
|
|
|
add_template_var=[],
|
|
|
|
add_arch_template_var=[],
|
|
|
|
bugurl=None,
|
|
|
|
rootfs_size=None,
|
|
|
|
log_dir=self.topdir + "/logs/x86_64/buildinstall-Server-logs",
|
|
|
|
dracut_args=[],
|
2020-05-14 02:22:09 +00:00
|
|
|
skip_branding=False,
|
2020-08-05 13:53:58 +00:00
|
|
|
squashfs_only=False,
|
|
|
|
configuration_file=None,
|
2020-01-22 10:02:22 +00:00
|
|
|
),
|
|
|
|
mock.call(
|
|
|
|
"Test",
|
|
|
|
"1",
|
|
|
|
"1",
|
|
|
|
[
|
|
|
|
self.topdir + "/work/amd64/repo/p1",
|
|
|
|
self.topdir + "/work/amd64/comps_repo_Server",
|
|
|
|
],
|
|
|
|
self.topdir + "/work/amd64/buildinstall/Server",
|
|
|
|
buildarch="amd64",
|
|
|
|
is_final=True,
|
|
|
|
nomacboot=True,
|
|
|
|
noupgrade=True,
|
|
|
|
volid="vol_id",
|
|
|
|
variant="Server",
|
|
|
|
buildinstallpackages=["bash", "vim"],
|
|
|
|
bugurl=None,
|
|
|
|
add_template=[],
|
|
|
|
add_arch_template=[],
|
|
|
|
add_template_var=[],
|
|
|
|
add_arch_template_var=[],
|
|
|
|
rootfs_size=None,
|
|
|
|
log_dir=self.topdir + "/logs/amd64/buildinstall-Server-logs",
|
|
|
|
dracut_args=[],
|
2020-05-14 02:22:09 +00:00
|
|
|
skip_branding=False,
|
2020-08-05 13:53:58 +00:00
|
|
|
squashfs_only=False,
|
|
|
|
configuration_file=None,
|
2020-01-22 10:02:22 +00:00
|
|
|
),
|
|
|
|
mock.call(
|
|
|
|
"Test",
|
|
|
|
"1",
|
|
|
|
"1",
|
|
|
|
[
|
|
|
|
self.topdir + "/work/amd64/repo/p1",
|
2018-04-04 13:22:28 +00:00
|
|
|
"http://example.com/repo2",
|
2018-04-09 13:32:33 +00:00
|
|
|
"http://example.com/repo3",
|
2020-01-22 10:02:22 +00:00
|
|
|
self.topdir + "/work/amd64/comps_repo_Client",
|
|
|
|
],
|
|
|
|
self.topdir + "/work/amd64/buildinstall/Client",
|
|
|
|
buildarch="amd64",
|
|
|
|
is_final=True,
|
|
|
|
nomacboot=True,
|
|
|
|
noupgrade=True,
|
|
|
|
volid="vol_id",
|
|
|
|
variant="Client",
|
|
|
|
buildinstallpackages=[],
|
|
|
|
bugurl=None,
|
|
|
|
add_template=[],
|
|
|
|
add_arch_template=[],
|
|
|
|
add_template_var=[],
|
|
|
|
add_arch_template_var=[],
|
|
|
|
rootfs_size=None,
|
|
|
|
log_dir=self.topdir + "/logs/amd64/buildinstall-Client-logs",
|
|
|
|
dracut_args=[],
|
2020-05-14 02:22:09 +00:00
|
|
|
skip_branding=False,
|
2020-08-05 13:53:58 +00:00
|
|
|
squashfs_only=False,
|
|
|
|
configuration_file=None,
|
2020-01-22 10:02:22 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
2018-04-04 13:22:28 +00:00
|
|
|
|
2017-11-22 09:50:14 +00:00
|
|
|
|
2019-05-09 08:53:00 +00:00
|
|
|
@mock.patch(
|
2020-01-22 10:02:22 +00:00
|
|
|
"pungi.phases.buildinstall.get_volid", new=lambda *args, **kwargs: "dummy-volid"
|
2019-05-09 08:53:00 +00:00
|
|
|
)
|
2016-02-11 15:45:56 +00:00
|
|
|
class BuildinstallThreadTestCase(PungiTestCase):
|
2017-08-25 10:08:22 +00:00
|
|
|
def setUp(self):
|
|
|
|
super(BuildinstallThreadTestCase, self).setUp()
|
|
|
|
self.pool = mock.Mock(finished_tasks=set())
|
2020-04-01 08:00:48 +00:00
|
|
|
self.cmd = ["echo", "1"]
|
2017-08-25 10:08:22 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.phases.buildinstall.link_boot_iso")
|
|
|
|
@mock.patch("pungi.phases.buildinstall.tweak_buildinstall")
|
|
|
|
@mock.patch("pungi.wrappers.kojiwrapper.KojiWrapper")
|
|
|
|
@mock.patch("pungi.wrappers.kojiwrapper.get_buildroot_rpms")
|
|
|
|
@mock.patch("pungi.phases.buildinstall.run")
|
2019-05-09 08:53:00 +00:00
|
|
|
def test_buildinstall_thread_with_lorax_in_runroot(
|
|
|
|
self, run, get_buildroot_rpms, KojiWrapperMock, mock_tweak, mock_link
|
|
|
|
):
|
2020-01-22 10:02:22 +00:00
|
|
|
compose = BuildInstallCompose(
|
|
|
|
self.topdir,
|
|
|
|
{
|
|
|
|
"buildinstall_method": "lorax",
|
|
|
|
"runroot_tag": "rrt",
|
|
|
|
"koji_profile": "koji",
|
|
|
|
"runroot_weights": {"buildinstall": 123},
|
|
|
|
},
|
|
|
|
)
|
2016-02-08 11:13:56 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
get_buildroot_rpms.return_value = ["bash", "zsh"]
|
2016-02-08 11:13:56 +00:00
|
|
|
|
|
|
|
get_runroot_cmd = KojiWrapperMock.return_value.get_runroot_cmd
|
|
|
|
|
|
|
|
run_runroot_cmd = KojiWrapperMock.return_value.run_runroot_cmd
|
|
|
|
run_runroot_cmd.return_value = {
|
2020-01-22 10:02:22 +00:00
|
|
|
"output": "Foo bar baz",
|
|
|
|
"retcode": 0,
|
|
|
|
"task_id": 1234,
|
2016-02-08 11:13:56 +00:00
|
|
|
}
|
|
|
|
|
2017-08-25 10:08:22 +00:00
|
|
|
t = BuildinstallThread(self.pool)
|
2016-02-08 11:13:56 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
with mock.patch("time.sleep"):
|
2020-04-01 08:00:48 +00:00
|
|
|
pkgset_phase = self._make_pkgset_phase(["p1"])
|
|
|
|
t.process(
|
|
|
|
(compose, "x86_64", compose.variants["Server"], self.cmd, pkgset_phase),
|
|
|
|
0,
|
|
|
|
)
|
2016-02-08 11:13:56 +00:00
|
|
|
|
2019-05-09 08:53:00 +00:00
|
|
|
destdir = os.path.join(self.topdir, "work/x86_64/buildinstall/Server")
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(
|
2016-02-11 15:45:56 +00:00
|
|
|
get_runroot_cmd.mock_calls,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
"rrt",
|
|
|
|
"x86_64",
|
|
|
|
self.cmd,
|
|
|
|
channel=None,
|
|
|
|
use_shell=True,
|
|
|
|
packages=["lorax"],
|
|
|
|
mounts=[self.topdir],
|
|
|
|
weight=123,
|
|
|
|
chown_paths=[
|
|
|
|
destdir,
|
|
|
|
os.path.join(
|
|
|
|
self.topdir, "logs/x86_64/buildinstall-Server-logs"
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(
|
2016-02-23 14:29:33 +00:00
|
|
|
run_runroot_cmd.mock_calls,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
get_runroot_cmd.return_value,
|
|
|
|
log_file=self.topdir
|
|
|
|
+ "/logs/x86_64/buildinstall-Server.x86_64.log",
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
|
|
|
with open(
|
|
|
|
self.topdir + "/logs/x86_64/buildinstall-Server-RPMs.x86_64.log"
|
|
|
|
) as f:
|
|
|
|
rpms = f.read().strip().split("\n")
|
2019-10-04 12:45:03 +00:00
|
|
|
six.assertCountEqual(self, rpms, ["bash", "zsh"])
|
|
|
|
six.assertCountEqual(self, self.pool.finished_tasks, [("Server", "x86_64")])
|
2016-02-08 11:13:56 +00:00
|
|
|
|
2020-01-22 06:55:37 +00:00
|
|
|
self.assertEqual(
|
|
|
|
mock_tweak.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
compose,
|
|
|
|
destdir,
|
|
|
|
os.path.join(self.topdir, "compose/Server/x86_64/os"),
|
|
|
|
"x86_64",
|
|
|
|
"Server",
|
|
|
|
"",
|
|
|
|
"dummy-volid",
|
|
|
|
self.pool.kickstart_file,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
mock_link.call_args_list,
|
|
|
|
[mock.call(compose, "x86_64", compose.variants["Server"], False)],
|
|
|
|
)
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.phases.buildinstall.link_boot_iso")
|
|
|
|
@mock.patch("pungi.phases.buildinstall.tweak_buildinstall")
|
|
|
|
@mock.patch("pungi.wrappers.kojiwrapper.KojiWrapper")
|
|
|
|
@mock.patch("pungi.wrappers.kojiwrapper.get_buildroot_rpms")
|
|
|
|
@mock.patch("pungi.phases.buildinstall.run")
|
2020-03-03 07:07:42 +00:00
|
|
|
@mock.patch("pungi.phases.buildinstall.move_all")
|
2020-01-22 06:55:37 +00:00
|
|
|
def test_buildinstall_thread_with_lorax_using_koji_plugin(
|
2020-03-03 07:07:42 +00:00
|
|
|
self, move_all, run, get_buildroot_rpms, KojiWrapperMock, mock_tweak, mock_link
|
2020-01-22 06:55:37 +00:00
|
|
|
):
|
2020-01-22 10:02:22 +00:00
|
|
|
compose = BuildInstallCompose(
|
|
|
|
self.topdir,
|
|
|
|
{
|
|
|
|
"buildinstall_method": "lorax",
|
|
|
|
"lorax_use_koji_plugin": True,
|
|
|
|
"runroot_tag": "rrt",
|
|
|
|
"koji_profile": "koji",
|
|
|
|
"runroot_weights": {"buildinstall": 123},
|
|
|
|
},
|
|
|
|
)
|
2020-01-22 06:55:37 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
get_buildroot_rpms.return_value = ["bash", "zsh"]
|
2020-01-22 06:55:37 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
get_pungi_buildinstall_cmd = (
|
|
|
|
KojiWrapperMock.return_value.get_pungi_buildinstall_cmd
|
|
|
|
)
|
2020-01-22 06:55:37 +00:00
|
|
|
|
|
|
|
run_runroot_cmd = KojiWrapperMock.return_value.run_runroot_cmd
|
|
|
|
run_runroot_cmd.return_value = {
|
2020-01-22 10:02:22 +00:00
|
|
|
"output": "Foo bar baz",
|
|
|
|
"retcode": 0,
|
|
|
|
"task_id": 1234,
|
2020-01-22 06:55:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
t = BuildinstallThread(self.pool)
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
with mock.patch("time.sleep"):
|
2020-04-01 08:00:48 +00:00
|
|
|
pkgset_phase = self._make_pkgset_phase(["p1"])
|
|
|
|
t.process(
|
|
|
|
(compose, "x86_64", compose.variants["Server"], self.cmd, pkgset_phase),
|
|
|
|
0,
|
|
|
|
)
|
2020-01-22 06:55:37 +00:00
|
|
|
|
|
|
|
destdir = os.path.join(self.topdir, "work/x86_64/buildinstall/Server")
|
|
|
|
self.assertEqual(
|
|
|
|
get_pungi_buildinstall_cmd.mock_calls,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
"rrt",
|
|
|
|
"x86_64",
|
|
|
|
self.cmd,
|
|
|
|
channel=None,
|
|
|
|
packages=["lorax"],
|
|
|
|
mounts=[self.topdir],
|
|
|
|
weight=123,
|
|
|
|
chown_uid=os.getuid(),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
2020-01-22 06:55:37 +00:00
|
|
|
self.assertEqual(
|
|
|
|
run_runroot_cmd.mock_calls,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
get_pungi_buildinstall_cmd.return_value,
|
|
|
|
log_file=self.topdir
|
|
|
|
+ "/logs/x86_64/buildinstall-Server.x86_64.log",
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
|
|
|
with open(
|
|
|
|
self.topdir + "/logs/x86_64/buildinstall-Server-RPMs.x86_64.log"
|
|
|
|
) as f:
|
|
|
|
rpms = f.read().strip().split("\n")
|
2020-01-22 06:55:37 +00:00
|
|
|
six.assertCountEqual(self, rpms, ["bash", "zsh"])
|
|
|
|
six.assertCountEqual(self, self.pool.finished_tasks, [("Server", "x86_64")])
|
|
|
|
|
2019-05-09 08:53:00 +00:00
|
|
|
self.assertEqual(
|
|
|
|
mock_tweak.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
compose,
|
|
|
|
destdir,
|
|
|
|
os.path.join(self.topdir, "compose/Server/x86_64/os"),
|
|
|
|
"x86_64",
|
|
|
|
"Server",
|
|
|
|
"",
|
|
|
|
"dummy-volid",
|
|
|
|
self.pool.kickstart_file,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
mock_link.call_args_list,
|
|
|
|
[mock.call(compose, "x86_64", compose.variants["Server"], False)],
|
|
|
|
)
|
2020-03-03 07:07:42 +00:00
|
|
|
self.assertEqual(
|
|
|
|
move_all.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(os.path.join(destdir, "results"), destdir, rm_src_dir=True),
|
|
|
|
mock.call(
|
|
|
|
os.path.join(destdir, "logs"),
|
|
|
|
os.path.join(self.topdir, "logs/x86_64/buildinstall-Server-logs"),
|
|
|
|
rm_src_dir=True,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
2019-05-09 08:53:00 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.phases.buildinstall.link_boot_iso")
|
|
|
|
@mock.patch("pungi.phases.buildinstall.tweak_buildinstall")
|
|
|
|
@mock.patch("pungi.wrappers.kojiwrapper.KojiWrapper")
|
|
|
|
@mock.patch("pungi.wrappers.kojiwrapper.get_buildroot_rpms")
|
|
|
|
@mock.patch("pungi.phases.buildinstall.run")
|
2019-05-09 08:53:00 +00:00
|
|
|
def test_buildinstall_thread_with_buildinstall_in_runroot(
|
|
|
|
self, run, get_buildroot_rpms, KojiWrapperMock, mock_tweak, mock_link
|
|
|
|
):
|
2020-01-22 10:02:22 +00:00
|
|
|
compose = BuildInstallCompose(
|
|
|
|
self.topdir,
|
|
|
|
{
|
|
|
|
"buildinstall_method": "buildinstall",
|
|
|
|
"runroot_tag": "rrt",
|
|
|
|
"koji_profile": "koji",
|
|
|
|
},
|
|
|
|
)
|
2016-02-08 11:13:56 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
get_buildroot_rpms.return_value = ["bash", "zsh"]
|
2016-02-08 11:13:56 +00:00
|
|
|
|
|
|
|
get_runroot_cmd = KojiWrapperMock.return_value.get_runroot_cmd
|
|
|
|
|
|
|
|
run_runroot_cmd = KojiWrapperMock.return_value.run_runroot_cmd
|
|
|
|
run_runroot_cmd.return_value = {
|
2020-01-22 10:02:22 +00:00
|
|
|
"output": "Foo bar baz",
|
|
|
|
"retcode": 0,
|
|
|
|
"task_id": 1234,
|
2016-02-08 11:13:56 +00:00
|
|
|
}
|
|
|
|
|
2017-08-25 10:08:22 +00:00
|
|
|
t = BuildinstallThread(self.pool)
|
2016-02-08 11:13:56 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
with mock.patch("time.sleep"):
|
2020-04-01 08:00:48 +00:00
|
|
|
pkgset_phase = self._make_pkgset_phase(["p1"])
|
|
|
|
t.process((compose, "amd64", None, self.cmd, pkgset_phase), 0)
|
2016-02-08 11:13:56 +00:00
|
|
|
|
2019-05-09 08:53:00 +00:00
|
|
|
destdir = os.path.join(self.topdir, "work/amd64/buildinstall")
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(
|
2016-02-11 15:45:56 +00:00
|
|
|
get_runroot_cmd.mock_calls,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
"rrt",
|
|
|
|
"amd64",
|
|
|
|
self.cmd,
|
|
|
|
channel=None,
|
|
|
|
use_shell=True,
|
|
|
|
packages=["anaconda"],
|
|
|
|
mounts=[self.topdir],
|
|
|
|
weight=None,
|
|
|
|
chown_paths=[destdir],
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(
|
2016-02-23 14:29:33 +00:00
|
|
|
run_runroot_cmd.mock_calls,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
get_runroot_cmd.return_value,
|
|
|
|
log_file=self.topdir + "/logs/amd64/buildinstall.amd64.log",
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
2019-05-09 08:53:00 +00:00
|
|
|
with open(self.topdir + "/logs/amd64/buildinstall-RPMs.amd64.log") as f:
|
2020-01-22 10:02:22 +00:00
|
|
|
rpms = f.read().strip().split("\n")
|
2019-10-04 12:45:03 +00:00
|
|
|
six.assertCountEqual(self, rpms, ["bash", "zsh"])
|
|
|
|
six.assertCountEqual(self, self.pool.finished_tasks, [(None, "amd64")])
|
|
|
|
six.assertCountEqual(
|
|
|
|
self,
|
2019-05-09 08:53:00 +00:00
|
|
|
mock_tweak.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
compose,
|
|
|
|
destdir,
|
|
|
|
os.path.join(self.topdir, "compose", var, "amd64/os"),
|
|
|
|
"amd64",
|
|
|
|
var,
|
|
|
|
"",
|
|
|
|
"dummy-volid",
|
|
|
|
self.pool.kickstart_file,
|
|
|
|
)
|
|
|
|
for var in ["Client", "Server"]
|
|
|
|
],
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
six.assertCountEqual(
|
|
|
|
self,
|
2019-05-09 08:53:00 +00:00
|
|
|
mock_link.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(compose, "amd64", compose.variants["Client"], False),
|
|
|
|
mock.call(compose, "amd64", compose.variants["Server"], False),
|
|
|
|
],
|
|
|
|
)
|
2016-02-08 11:13:56 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.wrappers.kojiwrapper.KojiWrapper")
|
|
|
|
@mock.patch("pungi.wrappers.kojiwrapper.get_buildroot_rpms")
|
|
|
|
@mock.patch("pungi.phases.buildinstall.run")
|
|
|
|
def test_buildinstall_fail_exit_code(
|
|
|
|
self, run, get_buildroot_rpms, KojiWrapperMock
|
|
|
|
):
|
|
|
|
compose = BuildInstallCompose(
|
|
|
|
self.topdir,
|
|
|
|
{
|
|
|
|
"buildinstall_method": "buildinstall",
|
|
|
|
"runroot_tag": "rrt",
|
|
|
|
"koji_profile": "koji",
|
|
|
|
"failable_deliverables": [("^.+$", {"*": ["buildinstall"]})],
|
|
|
|
},
|
|
|
|
)
|
2016-02-08 11:13:56 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
get_buildroot_rpms.return_value = ["bash", "zsh"]
|
2016-02-08 11:13:56 +00:00
|
|
|
|
|
|
|
run_runroot_cmd = KojiWrapperMock.return_value.run_runroot_cmd
|
|
|
|
run_runroot_cmd.return_value = {
|
2020-01-22 10:02:22 +00:00
|
|
|
"output": "Foo bar baz",
|
|
|
|
"retcode": 1,
|
|
|
|
"task_id": 1234,
|
2016-02-08 11:13:56 +00:00
|
|
|
}
|
|
|
|
|
2017-08-25 10:08:22 +00:00
|
|
|
t = BuildinstallThread(self.pool)
|
2016-02-08 11:13:56 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
with mock.patch("time.sleep"):
|
2020-04-01 08:00:48 +00:00
|
|
|
pkgset_phase = self._make_pkgset_phase(["p1"])
|
|
|
|
t.process((compose, "x86_64", None, self.cmd, pkgset_phase), 0)
|
2016-02-08 11:13:56 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
compose._logger.error.assert_has_calls(
|
|
|
|
[
|
|
|
|
mock.call(
|
2020-02-06 07:09:32 +00:00
|
|
|
"[FAIL] Buildinstall (variant None, arch x86_64) failed, but going on anyway." # noqa: E501
|
2020-01-22 10:02:22 +00:00
|
|
|
),
|
|
|
|
mock.call(
|
2020-02-06 07:09:32 +00:00
|
|
|
"Runroot task failed: 1234. See %s/logs/x86_64/buildinstall.x86_64.log for more details." # noqa: E501
|
2020-01-22 10:02:22 +00:00
|
|
|
% self.topdir
|
|
|
|
),
|
|
|
|
]
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(self.pool.finished_tasks, set())
|
2016-02-08 11:13:56 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.wrappers.kojiwrapper.KojiWrapper")
|
|
|
|
@mock.patch("pungi.wrappers.kojiwrapper.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):
|
2020-01-22 10:02:22 +00:00
|
|
|
compose = BuildInstallCompose(
|
|
|
|
self.topdir,
|
|
|
|
{
|
|
|
|
"buildinstall_method": "lorax",
|
|
|
|
"runroot_tag": "rrt",
|
|
|
|
"koji_profile": "koji",
|
|
|
|
"failable_deliverables": [("^.+$", {"*": ["buildinstall"]})],
|
|
|
|
},
|
|
|
|
)
|
2016-02-08 11:13:56 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
get_buildroot_rpms.return_value = ["bash", "zsh"]
|
2016-02-08 11:13:56 +00:00
|
|
|
|
|
|
|
run_runroot_cmd = KojiWrapperMock.return_value.run_runroot_cmd
|
|
|
|
run_runroot_cmd.return_value = {
|
2020-01-22 10:02:22 +00:00
|
|
|
"output": "Foo bar baz",
|
|
|
|
"retcode": 1,
|
|
|
|
"task_id": 1234,
|
2016-02-08 11:13:56 +00:00
|
|
|
}
|
|
|
|
|
2017-08-25 10:08:22 +00:00
|
|
|
t = BuildinstallThread(self.pool)
|
2016-02-08 11:13:56 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
with mock.patch("time.sleep"):
|
2020-04-01 08:00:48 +00:00
|
|
|
pkgset_phase = self._make_pkgset_phase(["p1"])
|
|
|
|
t.process(
|
|
|
|
(compose, "x86_64", compose.variants["Server"], self.cmd, pkgset_phase),
|
|
|
|
0,
|
|
|
|
)
|
2016-02-08 11:13:56 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
compose._logger.error.assert_has_calls(
|
|
|
|
[
|
|
|
|
mock.call(
|
2020-02-06 07:09:32 +00:00
|
|
|
"[FAIL] Buildinstall (variant Server, arch x86_64) failed, but going on anyway." # noqa: E501
|
2020-01-22 10:02:22 +00:00
|
|
|
),
|
2020-06-16 07:15:17 +00:00
|
|
|
mock.call(
|
|
|
|
"Runroot task failed: 1234. See %s/logs/x86_64/buildinstall-Server.x86_64.log for more details." # noqa: E501
|
|
|
|
% self.topdir
|
|
|
|
),
|
|
|
|
]
|
|
|
|
)
|
|
|
|
self.assertEqual(self.pool.finished_tasks, set())
|
|
|
|
|
|
|
|
@unittest.skipUnless(six.PY3, "PY2 StringIO does not work with 'with' statement")
|
|
|
|
@mock.patch("pungi.wrappers.kojiwrapper.KojiWrapper")
|
|
|
|
@mock.patch("pungi.wrappers.kojiwrapper.get_buildroot_rpms")
|
|
|
|
@mock.patch("pungi.phases.buildinstall.run")
|
|
|
|
@mock.patch("pungi.phases.buildinstall.open")
|
|
|
|
def test_lorax_fail_with_depsolve_error(
|
|
|
|
self, mock_open, run, get_buildroot_rpms, KojiWrapperMock
|
|
|
|
):
|
|
|
|
compose = BuildInstallCompose(
|
|
|
|
self.topdir,
|
|
|
|
{
|
|
|
|
"buildinstall_method": "lorax",
|
|
|
|
"runroot_tag": "rrt",
|
|
|
|
"koji_profile": "koji",
|
|
|
|
"failable_deliverables": [("^.+$", {"*": ["buildinstall"]})],
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
get_buildroot_rpms.return_value = ["bash", "zsh"]
|
|
|
|
|
|
|
|
run_runroot_cmd = KojiWrapperMock.return_value.run_runroot_cmd
|
|
|
|
run_runroot_cmd.return_value = {
|
|
|
|
"output": "Foo bar baz",
|
|
|
|
"retcode": 1,
|
|
|
|
"task_id": 1234,
|
|
|
|
}
|
|
|
|
|
|
|
|
error_log = (
|
|
|
|
"Dependency check failed\n"
|
|
|
|
" Problem: conflicting requests\n"
|
|
|
|
" - nothing provides /bin/python3 needed by nfs-utils-1:2.3.3-34.el8.s390x\n" # noqa: E501
|
|
|
|
"template command error in runtime-install.tmpl:\n"
|
|
|
|
" run_pkg_transaction\n"
|
|
|
|
" dnf.exceptions.DepsolveError:\n"
|
|
|
|
" Problem: conflicting requests\n"
|
|
|
|
" - nothing provides /bin/python3 needed by nfs-utils-1:2.3.3-34.el8.s390x\n" # noqa: E501
|
|
|
|
" Traceback (most recent call last):\n"
|
|
|
|
' File "/usr/lib/python3.6/site-packages/pylorax/ltmpl.py", line 633, in run_pkg_transaction\n' # noqa: E501
|
|
|
|
" self.dbo.resolve()\n"
|
|
|
|
' File "/usr/lib/python3.6/site-packages/dnf/base.py", line 777, in resolve\n' # noqa: E501
|
|
|
|
" raise exc\n"
|
|
|
|
" dnf.exceptions.DepsolveError:\n"
|
|
|
|
" Problem: conflicting requests\n"
|
|
|
|
" - nothing provides /bin/python3 needed by nfs-utils-1:2.3.3-34.el8.s390x" # noqa: E501
|
|
|
|
)
|
|
|
|
mock_open.return_value = StringIO("Checking dependencies\n" + error_log)
|
|
|
|
|
|
|
|
t = BuildinstallThread(self.pool)
|
|
|
|
|
|
|
|
with mock.patch("time.sleep"):
|
|
|
|
pkgset_phase = self._make_pkgset_phase(["p1"])
|
|
|
|
t.process(
|
|
|
|
(compose, "x86_64", compose.variants["Server"], self.cmd, pkgset_phase),
|
|
|
|
0,
|
|
|
|
)
|
|
|
|
|
|
|
|
self.assertEqual(
|
|
|
|
compose.log_error.call_args_list,
|
|
|
|
[mock.call(line) for line in error_log.split("\n")],
|
|
|
|
)
|
|
|
|
|
|
|
|
compose._logger.error.assert_has_calls(
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
"[FAIL] Buildinstall (variant Server, arch x86_64) failed, but going on anyway." # noqa: E501
|
|
|
|
),
|
2020-01-22 10:02:22 +00:00
|
|
|
mock.call(
|
2020-02-06 07:09:32 +00:00
|
|
|
"Runroot task failed: 1234. See %s/logs/x86_64/buildinstall-Server.x86_64.log for more details." # noqa: E501
|
2020-01-22 10:02:22 +00:00
|
|
|
% self.topdir
|
|
|
|
),
|
|
|
|
]
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(self.pool.finished_tasks, set())
|
2016-02-08 11:13:56 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.wrappers.kojiwrapper.KojiWrapper")
|
|
|
|
@mock.patch("pungi.wrappers.kojiwrapper.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_tag": "rrt",
|
|
|
|
"koji_profile": "koji",
|
|
|
|
"failable_deliverables": [("^.+$", {"*": ["buildinstall"]})],
|
|
|
|
},
|
|
|
|
)
|
2016-08-17 10:30:42 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
get_buildroot_rpms.return_value = ["bash", "zsh"]
|
2016-08-17 10:30:42 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
dummy_file = os.path.join(self.topdir, "work/x86_64/buildinstall/Server/dummy")
|
2016-08-17 10:30:42 +00:00
|
|
|
touch(os.path.join(dummy_file))
|
|
|
|
|
2017-08-25 10:08:22 +00:00
|
|
|
t = BuildinstallThread(self.pool)
|
2016-08-17 10:30:42 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
with mock.patch("time.sleep"):
|
2020-04-01 08:00:48 +00:00
|
|
|
pkgset_phase = self._make_pkgset_phase(["p1"])
|
|
|
|
t.process(
|
|
|
|
(compose, "x86_64", compose.variants["Server"], self.cmd, pkgset_phase),
|
|
|
|
0,
|
|
|
|
)
|
2016-08-17 10:30:42 +00:00
|
|
|
|
|
|
|
self.assertEqual(0, len(run.mock_calls))
|
|
|
|
|
|
|
|
self.assertTrue(os.path.exists(dummy_file))
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(self.pool.finished_tasks, set())
|
2016-08-17 10:30:42 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.phases.buildinstall.link_boot_iso")
|
|
|
|
@mock.patch("pungi.phases.buildinstall.tweak_buildinstall")
|
|
|
|
@mock.patch("pungi.wrappers.kojiwrapper.KojiWrapper")
|
|
|
|
@mock.patch("pungi.wrappers.kojiwrapper.get_buildroot_rpms")
|
|
|
|
@mock.patch("pungi.phases.buildinstall.run")
|
|
|
|
@mock.patch("pungi.phases.buildinstall.copy_all")
|
2017-11-22 09:50:14 +00:00
|
|
|
def test_buildinstall_thread_with_lorax_custom_buildinstall_topdir(
|
2020-01-22 10:02:22 +00:00
|
|
|
self, copy_all, run, get_buildroot_rpms, KojiWrapperMock, mock_tweak, mock_link
|
2019-05-09 08:53:00 +00:00
|
|
|
):
|
2020-01-22 10:02:22 +00:00
|
|
|
compose = BuildInstallCompose(
|
|
|
|
self.topdir,
|
|
|
|
{
|
|
|
|
"buildinstall_method": "lorax",
|
|
|
|
"runroot_tag": "rrt",
|
|
|
|
"koji_profile": "koji",
|
|
|
|
"runroot_weights": {"buildinstall": 123},
|
|
|
|
"buildinstall_topdir": "/buildinstall_topdir",
|
|
|
|
},
|
|
|
|
)
|
2017-11-22 09:50:14 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
get_buildroot_rpms.return_value = ["bash", "zsh"]
|
2017-11-22 09:50:14 +00:00
|
|
|
|
|
|
|
get_runroot_cmd = KojiWrapperMock.return_value.get_runroot_cmd
|
|
|
|
|
|
|
|
run_runroot_cmd = KojiWrapperMock.return_value.run_runroot_cmd
|
|
|
|
run_runroot_cmd.return_value = {
|
2020-01-22 10:02:22 +00:00
|
|
|
"output": "Foo bar baz",
|
|
|
|
"retcode": 0,
|
|
|
|
"task_id": 1234,
|
2017-11-22 09:50:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
t = BuildinstallThread(self.pool)
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
with mock.patch("time.sleep"):
|
2020-04-01 08:00:48 +00:00
|
|
|
pkgset_phase = self._make_pkgset_phase(["p1"])
|
|
|
|
t.process(
|
|
|
|
(compose, "x86_64", compose.variants["Server"], self.cmd, pkgset_phase),
|
|
|
|
0,
|
|
|
|
)
|
2017-11-22 09:50:14 +00:00
|
|
|
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(
|
2017-11-22 09:50:14 +00:00
|
|
|
get_runroot_cmd.mock_calls,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
"rrt",
|
|
|
|
"x86_64",
|
|
|
|
self.cmd,
|
|
|
|
channel=None,
|
|
|
|
use_shell=True,
|
|
|
|
packages=["lorax"],
|
|
|
|
mounts=[self.topdir],
|
|
|
|
weight=123,
|
|
|
|
chown_paths=[
|
|
|
|
"/buildinstall_topdir/buildinstall-%s/x86_64/Server"
|
|
|
|
% os.path.basename(self.topdir),
|
|
|
|
"/buildinstall_topdir/buildinstall-%s/x86_64/Server/logs"
|
|
|
|
% os.path.basename(self.topdir),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(
|
2017-11-22 09:50:14 +00:00
|
|
|
run_runroot_cmd.mock_calls,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
get_runroot_cmd.return_value,
|
|
|
|
log_file=self.topdir
|
|
|
|
+ "/logs/x86_64/buildinstall-Server.x86_64.log",
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
|
|
|
with open(
|
|
|
|
self.topdir + "/logs/x86_64/buildinstall-Server-RPMs.x86_64.log"
|
|
|
|
) as f:
|
|
|
|
rpms = f.read().strip().split("\n")
|
2019-10-04 12:45:03 +00:00
|
|
|
six.assertCountEqual(self, rpms, ["bash", "zsh"])
|
|
|
|
six.assertCountEqual(self, self.pool.finished_tasks, [("Server", "x86_64")])
|
2017-11-22 09:50:14 +00:00
|
|
|
|
|
|
|
buildinstall_topdir = os.path.join(
|
2020-01-22 10:02:22 +00:00
|
|
|
"/buildinstall_topdir", "buildinstall-" + os.path.basename(self.topdir)
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
six.assertCountEqual(
|
|
|
|
self,
|
2017-11-22 09:50:14 +00:00
|
|
|
copy_all.mock_calls,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
os.path.join(buildinstall_topdir, "x86_64/Server/results"),
|
|
|
|
os.path.join(self.topdir, "work/x86_64/buildinstall/Server"),
|
|
|
|
),
|
|
|
|
mock.call(
|
|
|
|
os.path.join(buildinstall_topdir, "x86_64/Server/logs"),
|
|
|
|
os.path.join(self.topdir, "logs/x86_64/buildinstall-Server-logs"),
|
|
|
|
),
|
|
|
|
],
|
2017-11-22 09:50:14 +00:00
|
|
|
)
|
|
|
|
|
2019-05-09 08:53:00 +00:00
|
|
|
self.assertEqual(
|
|
|
|
mock_tweak.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
compose,
|
|
|
|
os.path.join(self.topdir, "work/x86_64/buildinstall/Server"),
|
|
|
|
os.path.join(self.topdir, "compose/Server/x86_64/os"),
|
|
|
|
"x86_64",
|
|
|
|
"Server",
|
|
|
|
"",
|
|
|
|
"dummy-volid",
|
|
|
|
self.pool.kickstart_file,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
mock_link.call_args_list,
|
|
|
|
[mock.call(compose, "x86_64", compose.variants["Server"], False)],
|
|
|
|
)
|
|
|
|
|
2020-04-01 08:00:48 +00:00
|
|
|
def _prepare_buildinstall_reuse_test(self):
|
|
|
|
compose = BuildInstallCompose(
|
|
|
|
self.topdir,
|
|
|
|
{
|
|
|
|
"buildinstall_allow_reuse": True,
|
|
|
|
"buildinstall_method": "lorax",
|
|
|
|
"runroot_tag": "rrt",
|
|
|
|
"koji_profile": "koji",
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
pkgset = MockPackageSet(
|
|
|
|
MockPkg("/build/kernel-1.0.0-1.x86_64.rpm"),
|
|
|
|
MockPkg("/build/kernel-1.0.0-1.i686.rpm"),
|
|
|
|
MockPkg("/build/bash-1.0.0-1.x86_64.rpm"),
|
|
|
|
)
|
|
|
|
pkgset.file_cache = pkgset
|
|
|
|
pkgsets = [{"global": pkgset, "x86_64": pkgset}]
|
|
|
|
pkgset_phase = mock.Mock(package_sets=pkgsets)
|
|
|
|
|
|
|
|
cmd = {
|
|
|
|
"add-arch-template": [],
|
|
|
|
"buildarch": "x86_64",
|
|
|
|
"outputdir": self.topdir,
|
|
|
|
"product": "Fedora",
|
|
|
|
"release": "31",
|
|
|
|
"sources": ["/tmp/test/repo"],
|
|
|
|
"variant": "Server",
|
|
|
|
"version": "1",
|
|
|
|
}
|
|
|
|
return compose, pkgset_phase, cmd
|
|
|
|
|
|
|
|
@mock.patch("os.listdir")
|
|
|
|
@mock.patch("os.path.exists")
|
|
|
|
def test_generate_buildinstall_metadata(self, exists, listdir):
|
|
|
|
compose, pkgset_phase, cmd = self._prepare_buildinstall_reuse_test()
|
|
|
|
buildroot_rpms = ["bash-1-1.x86_64", "httpd-1-1.x86_64"]
|
|
|
|
listdir.return_value = ["kernel"]
|
|
|
|
|
|
|
|
t = BuildinstallThread(self.pool)
|
|
|
|
metadata = t._generate_buildinstall_metadata(
|
|
|
|
compose,
|
|
|
|
"x86_64",
|
|
|
|
compose.variants["Server"],
|
|
|
|
cmd,
|
|
|
|
buildroot_rpms,
|
|
|
|
pkgset_phase,
|
|
|
|
)
|
|
|
|
self.assertEqual(metadata["cmd"], cmd)
|
|
|
|
self.assertEqual(metadata["buildroot_rpms"], buildroot_rpms)
|
|
|
|
self.assertEqual(
|
|
|
|
metadata["installed_rpms"],
|
|
|
|
["/build/kernel-1.0.0-1.i686.rpm", "/build/kernel-1.0.0-1.x86_64.rpm"],
|
|
|
|
)
|
|
|
|
|
|
|
|
@mock.patch(
|
|
|
|
"pungi.phases.buildinstall.BuildinstallThread._write_buildinstall_metadata"
|
|
|
|
)
|
|
|
|
@mock.patch(
|
|
|
|
"pungi.phases.buildinstall.BuildinstallThread._load_old_buildinstall_metadata"
|
|
|
|
)
|
|
|
|
@mock.patch("pungi.wrappers.kojiwrapper.KojiWrapper")
|
|
|
|
@mock.patch("pungi.phases.buildinstall.copy_all")
|
|
|
|
def test_reuse_old_buildinstall_result(
|
|
|
|
self,
|
|
|
|
copy_all,
|
|
|
|
KojiWrapperMock,
|
|
|
|
load_old_buildinstall_metadata,
|
|
|
|
write_buildinstall_metadata,
|
|
|
|
):
|
|
|
|
compose, pkgset_phase, cmd = self._prepare_buildinstall_reuse_test()
|
|
|
|
|
|
|
|
listTaggedRPMS = KojiWrapperMock.return_value.koji_proxy.listTaggedRPMS
|
|
|
|
listTaggedRPMS.return_value = [
|
|
|
|
[{"name": "bash", "version": "1", "release": 1, "arch": "x86_64"}],
|
|
|
|
[],
|
|
|
|
]
|
|
|
|
|
|
|
|
load_old_buildinstall_metadata.return_value = {
|
|
|
|
"cmd": cmd,
|
|
|
|
"installed_rpms": ["/build/kernel-1.0.0-1.x86_64.rpm"],
|
|
|
|
"buildroot_rpms": ["bash-1-1.x86_64"],
|
|
|
|
}
|
|
|
|
|
|
|
|
t = BuildinstallThread(self.pool)
|
|
|
|
with mock.patch.object(compose.paths, "old_compose_path") as old_compose_path:
|
|
|
|
old_compose_path.side_effect = ["/tmp/old/1", "/tmp/old/2"]
|
|
|
|
ret = t._reuse_old_buildinstall_result(
|
|
|
|
compose, "x86_64", compose.variants["Server"], cmd, pkgset_phase
|
|
|
|
)
|
|
|
|
|
|
|
|
self.assertEqual(ret, True)
|
|
|
|
self.assertEqual(
|
|
|
|
copy_all.mock_calls,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
"/tmp/old/1",
|
|
|
|
os.path.join(self.topdir, "work/x86_64/buildinstall/Server"),
|
|
|
|
),
|
|
|
|
mock.call(
|
|
|
|
"/tmp/old/2",
|
|
|
|
os.path.join(self.topdir, "logs/x86_64/buildinstall-Server-logs"),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
write_buildinstall_metadata.assert_called_once_with(
|
|
|
|
compose,
|
|
|
|
"x86_64",
|
|
|
|
compose.variants["Server"],
|
|
|
|
cmd,
|
|
|
|
["bash-1-1.x86_64"],
|
|
|
|
pkgset_phase,
|
|
|
|
)
|
|
|
|
|
|
|
|
@mock.patch(
|
|
|
|
"pungi.phases.buildinstall.BuildinstallThread._load_old_buildinstall_metadata"
|
|
|
|
)
|
|
|
|
def test_reuse_old_buildinstall_result_no_old_compose(
|
2021-03-02 10:19:05 +00:00
|
|
|
self,
|
|
|
|
load_old_buildinstall_metadata,
|
2020-04-01 08:00:48 +00:00
|
|
|
):
|
|
|
|
compose, pkgset_phase, cmd = self._prepare_buildinstall_reuse_test()
|
|
|
|
load_old_buildinstall_metadata.return_value = None
|
|
|
|
|
|
|
|
t = BuildinstallThread(self.pool)
|
|
|
|
ret = t._reuse_old_buildinstall_result(
|
|
|
|
compose, "x86_64", compose.variants["Server"], cmd, pkgset_phase
|
|
|
|
)
|
|
|
|
self.assertEqual(ret, None)
|
|
|
|
|
|
|
|
@mock.patch(
|
|
|
|
"pungi.phases.buildinstall.BuildinstallThread._load_old_buildinstall_metadata"
|
|
|
|
)
|
|
|
|
def test_reuse_old_buildinstall_result_different_cmd(
|
2021-03-02 10:19:05 +00:00
|
|
|
self,
|
|
|
|
load_old_buildinstall_metadata,
|
2020-04-01 08:00:48 +00:00
|
|
|
):
|
|
|
|
compose, pkgset_phase, cmd = self._prepare_buildinstall_reuse_test()
|
|
|
|
|
|
|
|
old_cmd = copy(cmd)
|
|
|
|
old_cmd["version"] = "32"
|
|
|
|
|
|
|
|
load_old_buildinstall_metadata.return_value = {
|
|
|
|
"cmd": old_cmd,
|
|
|
|
"installed_rpms": ["/build/kernel-1.0.0-1.x86_64.rpm"],
|
|
|
|
"buildroot_rpms": ["bash-1-1.x86_64"],
|
|
|
|
}
|
|
|
|
|
|
|
|
t = BuildinstallThread(self.pool)
|
|
|
|
ret = t._reuse_old_buildinstall_result(
|
|
|
|
compose, "x86_64", compose.variants["Server"], cmd, pkgset_phase
|
|
|
|
)
|
|
|
|
self.assertEqual(ret, None)
|
|
|
|
|
|
|
|
@mock.patch(
|
|
|
|
"pungi.phases.buildinstall.BuildinstallThread._load_old_buildinstall_metadata"
|
|
|
|
)
|
|
|
|
def test_reuse_old_buildinstall_result_different_installed_pkgs(
|
2021-03-02 10:19:05 +00:00
|
|
|
self,
|
|
|
|
load_old_buildinstall_metadata,
|
2020-04-01 08:00:48 +00:00
|
|
|
):
|
|
|
|
compose, pkgset_phase, cmd = self._prepare_buildinstall_reuse_test()
|
|
|
|
load_old_buildinstall_metadata.return_value = {
|
|
|
|
"cmd": cmd,
|
|
|
|
"installed_rpms": ["/build/kernel-1.0.0-0.x86_64.rpm"],
|
|
|
|
"buildroot_rpms": ["bash-1-1.x86_64"],
|
|
|
|
}
|
|
|
|
|
|
|
|
t = BuildinstallThread(self.pool)
|
|
|
|
ret = t._reuse_old_buildinstall_result(
|
|
|
|
compose, "x86_64", compose.variants["Server"], cmd, pkgset_phase
|
|
|
|
)
|
|
|
|
self.assertEqual(ret, None)
|
|
|
|
|
|
|
|
@mock.patch(
|
|
|
|
"pungi.phases.buildinstall.BuildinstallThread._load_old_buildinstall_metadata"
|
|
|
|
)
|
|
|
|
@mock.patch("pungi.wrappers.kojiwrapper.KojiWrapper")
|
|
|
|
def test_reuse_old_buildinstall_result_different_buildroot_rpms(
|
2021-03-02 10:19:05 +00:00
|
|
|
self,
|
|
|
|
KojiWrapperMock,
|
|
|
|
load_old_buildinstall_metadata,
|
2020-04-01 08:00:48 +00:00
|
|
|
):
|
|
|
|
compose, pkgset_phase, cmd = self._prepare_buildinstall_reuse_test()
|
|
|
|
load_old_buildinstall_metadata.return_value = {
|
|
|
|
"cmd": cmd,
|
|
|
|
"installed_rpms": ["/build/kernel-1.0.0-1.x86_64.rpm"],
|
|
|
|
"buildroot_rpms": ["bash-1-1.x86_64"],
|
|
|
|
}
|
|
|
|
|
|
|
|
listTaggedRPMS = KojiWrapperMock.return_value.koji_proxy.listTaggedRPMS
|
|
|
|
listTaggedRPMS.return_value = [
|
|
|
|
[{"name": "bash", "version": "1", "release": 2, "arch": "x86_64"}],
|
|
|
|
[],
|
|
|
|
]
|
|
|
|
|
|
|
|
t = BuildinstallThread(self.pool)
|
|
|
|
ret = t._reuse_old_buildinstall_result(
|
|
|
|
compose, "x86_64", compose.variants["Server"], cmd, pkgset_phase
|
|
|
|
)
|
|
|
|
self.assertEqual(ret, None)
|
|
|
|
|
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, {})
|
2020-01-22 10:02:22 +00:00
|
|
|
os_tree = self.compose.paths.compose.os_tree(
|
|
|
|
"x86_64", self.compose.variants["Server"]
|
|
|
|
)
|
2016-02-26 09:31:43 +00:00
|
|
|
self.boot_iso_path = os.path.join(os_tree, "images", "boot.iso")
|
|
|
|
touch(self.boot_iso_path)
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.phases.buildinstall.Image")
|
|
|
|
@mock.patch("pungi.phases.buildinstall.get_mtime")
|
|
|
|
@mock.patch("pungi.phases.buildinstall.get_file_size")
|
|
|
|
@mock.patch("pungi.phases.buildinstall.iso")
|
|
|
|
@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):
|
2020-01-22 10:02:22 +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
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
link_boot_iso(self.compose, "x86_64", self.compose.variants["Server"], False)
|
2016-02-26 09:31:43 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
tgt = self.topdir + "/compose/Server/x86_64/iso/image-name"
|
2016-02-26 09:31:43 +00:00
|
|
|
self.assertTrue(os.path.isfile(tgt))
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertEqual(
|
|
|
|
os.stat(tgt).st_ino,
|
|
|
|
os.stat(self.topdir + "/compose/Server/x86_64/os/images/boot.iso").st_ino,
|
|
|
|
)
|
2016-02-26 09:31:43 +00:00
|
|
|
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(
|
2016-02-26 09:31:43 +00:00
|
|
|
self.compose.get_image_name.mock_calls,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
"x86_64",
|
|
|
|
self.compose.variants["Server"],
|
|
|
|
disc_type="boot",
|
|
|
|
disc_num=None,
|
|
|
|
suffix=".iso",
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(iso.get_implanted_md5.mock_calls, [mock.call(tgt)])
|
|
|
|
self.assertEqual(iso.get_manifest_cmd.mock_calls, [mock.call("image-name")])
|
|
|
|
self.assertEqual(iso.get_volume_id.mock_calls, [mock.call(tgt)])
|
|
|
|
self.assertEqual(
|
|
|
|
run.mock_calls,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
iso.get_manifest_cmd.return_value,
|
|
|
|
workdir=self.topdir + "/compose/Server/x86_64/iso",
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
2016-03-08 11:36:28 +00:00
|
|
|
|
|
|
|
image = ImageCls.return_value
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertEqual(image.path, "Server/x86_64/iso/image-name")
|
2016-03-08 11:36:28 +00:00
|
|
|
self.assertEqual(image.mtime, 13579)
|
|
|
|
self.assertEqual(image.size, 1024)
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertEqual(image.arch, "x86_64")
|
2016-03-08 11:36:28 +00:00
|
|
|
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)
|
2020-01-22 10:02:22 +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")
|
|
|
|
@mock.patch("pungi.phases.buildinstall.iso")
|
|
|
|
@mock.patch("pungi.phases.buildinstall.run")
|
|
|
|
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 = {
|
2020-01-22 10:02:22 +00:00
|
|
|
"buildinstall_symlink": False,
|
|
|
|
"disc_types": {"boot": "netinst"},
|
2016-03-08 11:36:28 +00:00
|
|
|
}
|
|
|
|
get_file_size.return_value = 1024
|
|
|
|
get_mtime.return_value = 13579
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
link_boot_iso(self.compose, "x86_64", self.compose.variants["Server"], True)
|
2016-03-08 11:36:28 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
tgt = self.topdir + "/compose/Server/x86_64/iso/image-name"
|
2016-03-08 11:36:28 +00:00
|
|
|
self.assertTrue(os.path.isfile(tgt))
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertEqual(
|
|
|
|
os.stat(tgt).st_ino,
|
|
|
|
os.stat(self.topdir + "/compose/Server/x86_64/os/images/boot.iso").st_ino,
|
|
|
|
)
|
2016-03-08 11:36:28 +00:00
|
|
|
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(
|
2016-03-08 11:36:28 +00:00
|
|
|
self.compose.get_image_name.mock_calls,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
"x86_64",
|
|
|
|
self.compose.variants["Server"],
|
|
|
|
disc_type="netinst",
|
|
|
|
disc_num=None,
|
|
|
|
suffix=".iso",
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(iso.get_implanted_md5.mock_calls, [mock.call(tgt)])
|
|
|
|
self.assertEqual(iso.get_manifest_cmd.mock_calls, [mock.call("image-name")])
|
|
|
|
self.assertEqual(iso.get_volume_id.mock_calls, [mock.call(tgt)])
|
|
|
|
self.assertEqual(
|
|
|
|
run.mock_calls,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
iso.get_manifest_cmd.return_value,
|
|
|
|
workdir=self.topdir + "/compose/Server/x86_64/iso",
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
2016-02-26 09:31:43 +00:00
|
|
|
|
|
|
|
image = ImageCls.return_value
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertEqual(image.path, "Server/x86_64/iso/image-name")
|
2016-02-26 09:31:43 +00:00
|
|
|
self.assertEqual(image.mtime, 13579)
|
|
|
|
self.assertEqual(image.size, 1024)
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertEqual(image.arch, "x86_64")
|
2016-02-26 09:31:43 +00:00
|
|
|
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)
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertEqual(
|
|
|
|
self.compose.im.add.mock_calls, [mock.call("Server", "x86_64", image)]
|
|
|
|
)
|
2016-02-26 09:31:43 +00:00
|
|
|
|
|
|
|
|
2017-02-20 09:34:13 +00:00
|
|
|
class TestTweakConfigs(PungiTestCase):
|
|
|
|
def test_tweak_configs(self):
|
2019-11-21 03:39:02 +00:00
|
|
|
logger = mock.Mock()
|
2017-02-20 09:34:13 +00:00
|
|
|
configs = []
|
|
|
|
for cfg in BOOT_CONFIGS:
|
2020-01-22 10:02:22 +00:00
|
|
|
if "yaboot" not in cfg:
|
2017-02-20 09:34:13 +00:00
|
|
|
configs.append(os.path.join(self.topdir, cfg))
|
2020-01-22 10:02:22 +00:00
|
|
|
touch(configs[-1], ":LABEL=baz")
|
|
|
|
found_configs = tweak_configs(
|
|
|
|
self.topdir, "new volid", os.path.join(self.topdir, "ks.cfg"), logger=logger
|
|
|
|
)
|
2019-11-21 03:39:02 +00:00
|
|
|
self.assertEqual(
|
|
|
|
logger.info.call_args_list,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call("Boot config %s changed" % os.path.join(self.topdir, cfg))
|
|
|
|
for cfg in found_configs
|
|
|
|
],
|
2019-11-21 03:39:02 +00:00
|
|
|
)
|
2017-02-20 09:34:13 +00:00
|
|
|
for cfg in configs:
|
2019-10-04 13:10:14 +00:00
|
|
|
self.assertFileContent(
|
|
|
|
cfg, ":LABEL=new\\x20volid ks=hd:LABEL=new\\x20volid:/ks.cfg\n"
|
|
|
|
)
|
2017-02-20 09:34:13 +00:00
|
|
|
|
|
|
|
def test_tweak_configs_yaboot(self):
|
|
|
|
configs = []
|
|
|
|
for cfg in BOOT_CONFIGS:
|
2020-01-22 10:02:22 +00:00
|
|
|
if "yaboot" in cfg:
|
2017-02-20 09:34:13 +00:00
|
|
|
configs.append(os.path.join(self.topdir, cfg))
|
2020-01-22 10:02:22 +00:00
|
|
|
touch(configs[-1], ":LABEL=baz")
|
|
|
|
tweak_configs(self.topdir, "new volid", os.path.join(self.topdir, "ks.cfg"))
|
2017-02-20 09:34:13 +00:00
|
|
|
for cfg in configs:
|
2019-10-04 13:10:14 +00:00
|
|
|
self.assertFileContent(
|
|
|
|
cfg, ":LABEL=new\\\\x20volid ks=hd:LABEL=new\\\\x20volid:/ks.cfg\n"
|
|
|
|
)
|