2018-05-09 13:39:36 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
|
|
|
|
import mock
|
2019-10-04 12:45:03 +00:00
|
|
|
import six
|
2018-05-09 13:39:36 +00:00
|
|
|
|
|
|
|
import os
|
|
|
|
|
|
|
|
from tests import helpers
|
|
|
|
from pungi.phases import extra_isos
|
|
|
|
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.phases.extra_isos.ThreadPool")
|
2018-05-09 13:39:36 +00:00
|
|
|
class ExtraIsosPhaseTest(helpers.PungiTestCase):
|
|
|
|
def test_logs_extra_arches(self, ThreadPool):
|
|
|
|
cfg = {
|
2020-01-22 10:02:22 +00:00
|
|
|
"include_variants": ["Client"],
|
|
|
|
"arches": ["x86_64", "ppc64le", "aarch64"],
|
2018-05-09 13:39:36 +00:00
|
|
|
}
|
2020-01-22 10:02:22 +00:00
|
|
|
compose = helpers.DummyCompose(self.topdir, {"extra_isos": {"^Server$": [cfg]}})
|
2018-05-09 13:39:36 +00:00
|
|
|
|
|
|
|
phase = extra_isos.ExtraIsosPhase(compose)
|
|
|
|
phase.validate()
|
|
|
|
|
|
|
|
self.assertEqual(len(compose.log_warning.call_args_list), 1)
|
|
|
|
|
|
|
|
def test_one_task_for_each_arch(self, ThreadPool):
|
|
|
|
cfg = {
|
2020-01-22 10:02:22 +00:00
|
|
|
"include_variants": ["Client"],
|
2018-05-09 13:39:36 +00:00
|
|
|
}
|
2020-01-22 10:02:22 +00:00
|
|
|
compose = helpers.DummyCompose(self.topdir, {"extra_isos": {"^Server$": [cfg]}})
|
2018-05-09 13:39:36 +00:00
|
|
|
|
|
|
|
phase = extra_isos.ExtraIsosPhase(compose)
|
|
|
|
phase.run()
|
|
|
|
|
|
|
|
self.assertEqual(len(ThreadPool.return_value.add.call_args_list), 3)
|
2019-10-04 12:45:03 +00:00
|
|
|
six.assertCountEqual(
|
|
|
|
self,
|
2018-05-09 13:39:36 +00:00
|
|
|
ThreadPool.return_value.queue_put.call_args_list,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call((compose, cfg, compose.variants["Server"], "x86_64")),
|
|
|
|
mock.call((compose, cfg, compose.variants["Server"], "amd64")),
|
|
|
|
mock.call((compose, cfg, compose.variants["Server"], "src")),
|
|
|
|
],
|
2018-05-09 13:39:36 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
def test_filter_arches(self, ThreadPool):
|
|
|
|
cfg = {
|
2020-01-22 10:02:22 +00:00
|
|
|
"include_variants": ["Client"],
|
|
|
|
"arches": ["x86_64"],
|
2018-05-09 13:39:36 +00:00
|
|
|
}
|
2020-01-22 10:02:22 +00:00
|
|
|
compose = helpers.DummyCompose(self.topdir, {"extra_isos": {"^Server$": [cfg]}})
|
2018-05-09 13:39:36 +00:00
|
|
|
|
|
|
|
phase = extra_isos.ExtraIsosPhase(compose)
|
|
|
|
phase.run()
|
|
|
|
|
|
|
|
self.assertEqual(len(ThreadPool.return_value.add.call_args_list), 2)
|
2019-10-04 12:45:03 +00:00
|
|
|
six.assertCountEqual(
|
|
|
|
self,
|
2018-05-09 13:39:36 +00:00
|
|
|
ThreadPool.return_value.queue_put.call_args_list,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call((compose, cfg, compose.variants["Server"], "x86_64")),
|
|
|
|
mock.call((compose, cfg, compose.variants["Server"], "src")),
|
|
|
|
],
|
2018-05-09 13:39:36 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
def test_skip_source(self, ThreadPool):
|
|
|
|
cfg = {
|
2020-01-22 10:02:22 +00:00
|
|
|
"include_variants": ["Client"],
|
|
|
|
"skip_src": True,
|
2018-05-09 13:39:36 +00:00
|
|
|
}
|
2020-01-22 10:02:22 +00:00
|
|
|
compose = helpers.DummyCompose(self.topdir, {"extra_isos": {"^Server$": [cfg]}})
|
2018-05-09 13:39:36 +00:00
|
|
|
|
|
|
|
phase = extra_isos.ExtraIsosPhase(compose)
|
|
|
|
phase.run()
|
|
|
|
|
|
|
|
self.assertEqual(len(ThreadPool.return_value.add.call_args_list), 2)
|
2019-10-04 12:45:03 +00:00
|
|
|
six.assertCountEqual(
|
|
|
|
self,
|
2018-05-09 13:39:36 +00:00
|
|
|
ThreadPool.return_value.queue_put.call_args_list,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call((compose, cfg, compose.variants["Server"], "x86_64")),
|
|
|
|
mock.call((compose, cfg, compose.variants["Server"], "amd64")),
|
|
|
|
],
|
2018-05-09 13:39:36 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.phases.extra_isos.prepare_media_metadata")
|
|
|
|
@mock.patch("pungi.phases.extra_isos.get_volume_id")
|
|
|
|
@mock.patch("pungi.phases.extra_isos.get_filename")
|
|
|
|
@mock.patch("pungi.phases.extra_isos.get_iso_contents")
|
|
|
|
@mock.patch("pungi.phases.extra_isos.get_extra_files")
|
|
|
|
@mock.patch("pungi.phases.extra_isos.run_createiso_command")
|
|
|
|
@mock.patch("pungi.phases.extra_isos.add_iso_to_metadata")
|
2018-05-09 13:39:36 +00:00
|
|
|
class ExtraIsosThreadTest(helpers.PungiTestCase):
|
2018-10-17 12:06:43 +00:00
|
|
|
def test_binary_bootable_image(self, aitm, rcc, gef, gic, gfn, gvi, pmm):
|
2020-01-22 10:02:22 +00:00
|
|
|
compose = helpers.DummyCompose(
|
|
|
|
self.topdir, {"bootable": True, "buildinstall_method": "lorax"}
|
|
|
|
)
|
|
|
|
server = compose.variants["Server"]
|
2018-05-09 13:39:36 +00:00
|
|
|
cfg = {
|
2020-01-22 10:02:22 +00:00
|
|
|
"include_variants": ["Client"],
|
2018-05-09 13:39:36 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
gfn.return_value = "my.iso"
|
|
|
|
gvi.return_value = "my volume id"
|
|
|
|
gic.return_value = "/tmp/iso-graft-points"
|
2018-05-09 13:39:36 +00:00
|
|
|
|
2018-10-10 14:06:46 +00:00
|
|
|
t = extra_isos.ExtraIsosThread(mock.Mock())
|
2020-01-22 10:02:22 +00:00
|
|
|
with mock.patch("time.sleep"):
|
|
|
|
t.process((compose, cfg, server, "x86_64"), 1)
|
2018-10-10 14:06:46 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertEqual(
|
|
|
|
gfn.call_args_list, [mock.call(compose, server, "x86_64", None)]
|
|
|
|
)
|
|
|
|
self.assertEqual(gvi.call_args_list, [mock.call(compose, server, "x86_64", [])])
|
|
|
|
self.assertEqual(gef.call_args_list, [mock.call(compose, server, "x86_64", [])])
|
2018-11-09 09:29:28 +00:00
|
|
|
self.assertEqual(
|
|
|
|
gic.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
compose,
|
|
|
|
server,
|
2020-01-22 10:02:22 +00:00
|
|
|
"x86_64",
|
|
|
|
["Client"],
|
|
|
|
"my.iso",
|
2018-11-09 09:29:28 +00:00
|
|
|
bootable=True,
|
|
|
|
inherit_extra_files=False,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
2018-10-10 14:06:46 +00:00
|
|
|
self.assertEqual(
|
|
|
|
rcc.call_args_list,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
1,
|
|
|
|
compose,
|
|
|
|
True,
|
|
|
|
"x86_64",
|
|
|
|
[
|
|
|
|
"bash",
|
|
|
|
os.path.join(
|
|
|
|
self.topdir, "work/x86_64/tmp-Server/extraiso-my.iso.sh"
|
|
|
|
),
|
|
|
|
],
|
|
|
|
[self.topdir],
|
|
|
|
log_file=os.path.join(
|
|
|
|
self.topdir, "logs/x86_64/extraiso-my.iso.x86_64.log"
|
|
|
|
),
|
|
|
|
with_jigdo=True,
|
|
|
|
)
|
|
|
|
],
|
2018-10-10 14:06:46 +00:00
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
aitm.call_args_list,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
compose,
|
|
|
|
server,
|
|
|
|
"x86_64",
|
|
|
|
os.path.join(self.topdir, "compose/Server/x86_64/iso/my.iso"),
|
|
|
|
True,
|
|
|
|
additional_variants=["Client"],
|
|
|
|
)
|
|
|
|
],
|
2018-10-10 14:06:46 +00:00
|
|
|
)
|
2018-10-17 12:06:43 +00:00
|
|
|
self.assertEqual(pmm.call_args_list, [mock.call(compose, server, "x86_64")])
|
2018-10-10 14:06:46 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
def test_binary_bootable_image_without_jigdo(
|
|
|
|
self, aitm, rcc, gef, gic, gfn, gvi, pmm
|
|
|
|
):
|
|
|
|
compose = helpers.DummyCompose(
|
|
|
|
self.topdir,
|
|
|
|
{"bootable": True, "buildinstall_method": "lorax", "create_jigdo": False},
|
|
|
|
)
|
|
|
|
server = compose.variants["Server"]
|
2018-10-10 14:06:46 +00:00
|
|
|
cfg = {
|
2020-01-22 10:02:22 +00:00
|
|
|
"include_variants": ["Client"],
|
2018-10-10 14:06:46 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
gfn.return_value = "my.iso"
|
|
|
|
gvi.return_value = "my volume id"
|
|
|
|
gic.return_value = "/tmp/iso-graft-points"
|
2018-10-10 14:06:46 +00:00
|
|
|
|
2018-05-09 13:39:36 +00:00
|
|
|
t = extra_isos.ExtraIsosThread(mock.Mock())
|
2020-01-22 10:02:22 +00:00
|
|
|
with mock.patch("time.sleep"):
|
|
|
|
t.process((compose, cfg, server, "x86_64"), 1)
|
2018-05-09 13:39:36 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertEqual(
|
|
|
|
gfn.call_args_list, [mock.call(compose, server, "x86_64", None)]
|
|
|
|
)
|
|
|
|
self.assertEqual(gvi.call_args_list, [mock.call(compose, server, "x86_64", [])])
|
|
|
|
self.assertEqual(gef.call_args_list, [mock.call(compose, server, "x86_64", [])])
|
2018-11-09 09:29:28 +00:00
|
|
|
self.assertEqual(
|
|
|
|
gic.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
compose,
|
|
|
|
server,
|
2020-01-22 10:02:22 +00:00
|
|
|
"x86_64",
|
|
|
|
["Client"],
|
|
|
|
"my.iso",
|
2018-11-09 09:29:28 +00:00
|
|
|
bootable=True,
|
|
|
|
inherit_extra_files=False,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
2018-05-09 13:39:36 +00:00
|
|
|
self.assertEqual(
|
|
|
|
rcc.call_args_list,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
1,
|
|
|
|
compose,
|
|
|
|
True,
|
|
|
|
"x86_64",
|
|
|
|
[
|
|
|
|
"bash",
|
|
|
|
os.path.join(
|
|
|
|
self.topdir, "work/x86_64/tmp-Server/extraiso-my.iso.sh"
|
|
|
|
),
|
|
|
|
],
|
|
|
|
[self.topdir],
|
|
|
|
log_file=os.path.join(
|
|
|
|
self.topdir, "logs/x86_64/extraiso-my.iso.x86_64.log"
|
|
|
|
),
|
|
|
|
with_jigdo=False,
|
|
|
|
)
|
|
|
|
],
|
2018-05-09 13:39:36 +00:00
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
aitm.call_args_list,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
compose,
|
|
|
|
server,
|
|
|
|
"x86_64",
|
|
|
|
os.path.join(self.topdir, "compose/Server/x86_64/iso/my.iso"),
|
|
|
|
True,
|
|
|
|
additional_variants=["Client"],
|
|
|
|
)
|
|
|
|
],
|
2018-05-09 13:39:36 +00:00
|
|
|
)
|
2018-10-17 12:06:43 +00:00
|
|
|
self.assertEqual(pmm.call_args_list, [mock.call(compose, server, "x86_64")])
|
2018-05-09 13:39:36 +00:00
|
|
|
|
2019-02-12 11:09:08 +00:00
|
|
|
def test_image_with_max_size(self, aitm, rcc, gef, gic, gfn, gvi, pmm):
|
2020-01-22 10:02:22 +00:00
|
|
|
compose = helpers.DummyCompose(
|
|
|
|
self.topdir, {"bootable": True, "buildinstall_method": "lorax"}
|
|
|
|
)
|
2019-02-12 11:09:08 +00:00
|
|
|
server = compose.variants["Server"]
|
|
|
|
cfg = {
|
|
|
|
"include_variants": ["Client"],
|
|
|
|
"max_size": 15,
|
|
|
|
}
|
|
|
|
|
|
|
|
gfn.return_value = "my.iso"
|
|
|
|
gvi.return_value = "my volume id"
|
|
|
|
gic.return_value = "/tmp/iso-graft-points"
|
|
|
|
|
|
|
|
t = extra_isos.ExtraIsosThread(mock.Mock())
|
|
|
|
with mock.patch("time.sleep"):
|
|
|
|
t.process((compose, cfg, server, "x86_64"), 1)
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertEqual(
|
|
|
|
gfn.call_args_list, [mock.call(compose, server, "x86_64", None)]
|
|
|
|
)
|
|
|
|
self.assertEqual(gvi.call_args_list, [mock.call(compose, server, "x86_64", [])])
|
|
|
|
self.assertEqual(gef.call_args_list, [mock.call(compose, server, "x86_64", [])])
|
2019-02-12 11:09:08 +00:00
|
|
|
self.assertEqual(
|
|
|
|
gic.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
compose,
|
|
|
|
server,
|
|
|
|
"x86_64",
|
|
|
|
["Client"],
|
|
|
|
"my.iso",
|
|
|
|
bootable=True,
|
|
|
|
inherit_extra_files=False,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
rcc.call_args_list,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
1,
|
|
|
|
compose,
|
|
|
|
True,
|
|
|
|
"x86_64",
|
|
|
|
[
|
|
|
|
"bash",
|
|
|
|
os.path.join(
|
|
|
|
self.topdir, "work/x86_64/tmp-Server/extraiso-my.iso.sh"
|
|
|
|
),
|
|
|
|
],
|
|
|
|
[self.topdir],
|
|
|
|
log_file=os.path.join(
|
|
|
|
self.topdir, "logs/x86_64/extraiso-my.iso.x86_64.log"
|
|
|
|
),
|
|
|
|
with_jigdo=True,
|
|
|
|
)
|
|
|
|
],
|
2019-02-12 11:09:08 +00:00
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
aitm.call_args_list,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
compose,
|
|
|
|
server,
|
|
|
|
"x86_64",
|
|
|
|
os.path.join(self.topdir, "compose/Server/x86_64/iso/my.iso"),
|
|
|
|
True,
|
|
|
|
additional_variants=["Client"],
|
|
|
|
)
|
|
|
|
],
|
2019-02-12 11:09:08 +00:00
|
|
|
)
|
|
|
|
self.assertEqual(aitm.return_value._max_size, 15)
|
|
|
|
self.assertEqual(pmm.call_args_list, [mock.call(compose, server, "x86_64")])
|
|
|
|
|
2018-10-17 12:06:43 +00:00
|
|
|
def test_binary_image_custom_naming(self, aitm, rcc, gef, gic, gfn, gvi, pmm):
|
2018-05-09 13:39:36 +00:00
|
|
|
compose = helpers.DummyCompose(self.topdir, {})
|
2020-01-22 10:02:22 +00:00
|
|
|
server = compose.variants["Server"]
|
2018-05-09 13:39:36 +00:00
|
|
|
cfg = {
|
2020-01-22 10:02:22 +00:00
|
|
|
"include_variants": ["Client"],
|
|
|
|
"filename": "fn",
|
|
|
|
"volid": ["v1", "v2"],
|
2018-05-09 13:39:36 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
gfn.return_value = "my.iso"
|
|
|
|
gvi.return_value = "my volume id"
|
|
|
|
gic.return_value = "/tmp/iso-graft-points"
|
2018-05-09 13:39:36 +00:00
|
|
|
|
|
|
|
t = extra_isos.ExtraIsosThread(mock.Mock())
|
2020-01-22 10:02:22 +00:00
|
|
|
with mock.patch("time.sleep"):
|
|
|
|
t.process((compose, cfg, server, "x86_64"), 1)
|
2018-05-09 13:39:36 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertEqual(
|
|
|
|
gfn.call_args_list, [mock.call(compose, server, "x86_64", "fn")]
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
gvi.call_args_list, [mock.call(compose, server, "x86_64", ["v1", "v2"])]
|
|
|
|
)
|
|
|
|
self.assertEqual(gef.call_args_list, [mock.call(compose, server, "x86_64", [])])
|
2018-11-09 09:29:28 +00:00
|
|
|
self.assertEqual(
|
|
|
|
gic.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
compose,
|
|
|
|
server,
|
2020-01-22 10:02:22 +00:00
|
|
|
"x86_64",
|
|
|
|
["Client"],
|
|
|
|
"my.iso",
|
2018-11-09 09:29:28 +00:00
|
|
|
bootable=False,
|
|
|
|
inherit_extra_files=False,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
2018-05-09 13:39:36 +00:00
|
|
|
self.assertEqual(
|
|
|
|
rcc.call_args_list,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
1,
|
|
|
|
compose,
|
|
|
|
False,
|
|
|
|
"x86_64",
|
|
|
|
[
|
|
|
|
"bash",
|
|
|
|
os.path.join(
|
|
|
|
self.topdir, "work/x86_64/tmp-Server/extraiso-my.iso.sh"
|
|
|
|
),
|
|
|
|
],
|
|
|
|
[self.topdir],
|
|
|
|
log_file=os.path.join(
|
|
|
|
self.topdir, "logs/x86_64/extraiso-my.iso.x86_64.log"
|
|
|
|
),
|
|
|
|
with_jigdo=True,
|
|
|
|
)
|
|
|
|
],
|
2018-05-09 13:39:36 +00:00
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
aitm.call_args_list,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
compose,
|
|
|
|
server,
|
|
|
|
"x86_64",
|
|
|
|
os.path.join(self.topdir, "compose/Server/x86_64/iso/my.iso"),
|
|
|
|
False,
|
|
|
|
additional_variants=["Client"],
|
|
|
|
)
|
|
|
|
],
|
2018-05-09 13:39:36 +00:00
|
|
|
)
|
2018-10-17 12:06:43 +00:00
|
|
|
self.assertEqual(pmm.call_args_list, [mock.call(compose, server, "x86_64")])
|
2018-05-09 13:39:36 +00:00
|
|
|
|
2018-10-17 12:06:43 +00:00
|
|
|
def test_source_is_not_bootable(self, aitm, rcc, gef, gic, gfn, gvi, pmm):
|
2020-01-22 10:02:22 +00:00
|
|
|
compose = helpers.DummyCompose(
|
|
|
|
self.topdir, {"bootable": True, "buildinstall_method": "lorax"}
|
|
|
|
)
|
|
|
|
server = compose.variants["Server"]
|
2018-05-09 13:39:36 +00:00
|
|
|
cfg = {
|
2020-01-22 10:02:22 +00:00
|
|
|
"include_variants": ["Client"],
|
2018-05-09 13:39:36 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
gfn.return_value = "my.iso"
|
|
|
|
gvi.return_value = "my volume id"
|
|
|
|
gic.return_value = "/tmp/iso-graft-points"
|
2018-05-09 13:39:36 +00:00
|
|
|
|
|
|
|
t = extra_isos.ExtraIsosThread(mock.Mock())
|
2020-01-22 10:02:22 +00:00
|
|
|
with mock.patch("time.sleep"):
|
|
|
|
t.process((compose, cfg, server, "src"), 1)
|
2018-05-09 13:39:36 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertEqual(gfn.call_args_list, [mock.call(compose, server, "src", None)])
|
|
|
|
self.assertEqual(gvi.call_args_list, [mock.call(compose, server, "src", [])])
|
|
|
|
self.assertEqual(gef.call_args_list, [mock.call(compose, server, "src", [])])
|
2018-11-09 09:29:28 +00:00
|
|
|
self.assertEqual(
|
|
|
|
gic.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
compose,
|
|
|
|
server,
|
2020-01-22 10:02:22 +00:00
|
|
|
"src",
|
|
|
|
["Client"],
|
|
|
|
"my.iso",
|
2018-11-09 09:29:28 +00:00
|
|
|
bootable=False,
|
|
|
|
inherit_extra_files=False,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
2018-05-09 13:39:36 +00:00
|
|
|
self.assertEqual(
|
|
|
|
rcc.call_args_list,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
1,
|
|
|
|
compose,
|
|
|
|
False,
|
|
|
|
"src",
|
|
|
|
[
|
|
|
|
"bash",
|
|
|
|
os.path.join(
|
|
|
|
self.topdir, "work/src/tmp-Server/extraiso-my.iso.sh"
|
|
|
|
),
|
|
|
|
],
|
|
|
|
[self.topdir],
|
|
|
|
log_file=os.path.join(
|
|
|
|
self.topdir, "logs/src/extraiso-my.iso.src.log"
|
|
|
|
),
|
|
|
|
with_jigdo=True,
|
|
|
|
)
|
|
|
|
],
|
2018-05-09 13:39:36 +00:00
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
aitm.call_args_list,
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
compose,
|
|
|
|
server,
|
|
|
|
"src",
|
|
|
|
os.path.join(self.topdir, "compose/Server/source/iso/my.iso"),
|
|
|
|
False,
|
|
|
|
additional_variants=["Client"],
|
|
|
|
)
|
|
|
|
],
|
2018-05-09 13:39:36 +00:00
|
|
|
)
|
2018-10-17 12:06:43 +00:00
|
|
|
self.assertEqual(pmm.call_args_list, [mock.call(compose, server, "src")])
|
2018-05-09 13:39:36 +00:00
|
|
|
|
2018-10-17 12:06:43 +00:00
|
|
|
def test_failable_failed(self, aitm, rcc, gef, gic, gfn, gvi, pmm):
|
2018-05-09 13:39:36 +00:00
|
|
|
compose = helpers.DummyCompose(self.topdir, {})
|
2020-01-22 10:02:22 +00:00
|
|
|
server = compose.variants["Server"]
|
2018-05-09 13:39:36 +00:00
|
|
|
cfg = {
|
2020-01-22 10:02:22 +00:00
|
|
|
"include_variants": ["Client"],
|
|
|
|
"failable_arches": ["x86_64"],
|
2018-05-09 13:39:36 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
gfn.return_value = "my.iso"
|
|
|
|
gvi.return_value = "my volume id"
|
|
|
|
gic.return_value = "/tmp/iso-graft-points"
|
2018-05-09 13:39:36 +00:00
|
|
|
rcc.side_effect = helpers.mk_boom()
|
|
|
|
|
|
|
|
t = extra_isos.ExtraIsosThread(mock.Mock())
|
2020-01-22 10:02:22 +00:00
|
|
|
with mock.patch("time.sleep"):
|
|
|
|
t.process((compose, cfg, server, "x86_64"), 1)
|
2018-05-09 13:39:36 +00:00
|
|
|
|
|
|
|
self.assertEqual(aitm.call_args_list, [])
|
|
|
|
|
2018-10-17 12:06:43 +00:00
|
|
|
def test_non_failable_failed(self, aitm, rcc, gef, gic, gfn, gvi, pmm):
|
2018-05-09 13:39:36 +00:00
|
|
|
compose = helpers.DummyCompose(self.topdir, {})
|
2020-01-22 10:02:22 +00:00
|
|
|
server = compose.variants["Server"]
|
2018-05-09 13:39:36 +00:00
|
|
|
cfg = {
|
2020-01-22 10:02:22 +00:00
|
|
|
"include_variants": ["Client"],
|
2018-05-09 13:39:36 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
gfn.return_value = "my.iso"
|
|
|
|
gvi.return_value = "my volume id"
|
|
|
|
gic.return_value = "/tmp/iso-graft-points"
|
2018-05-09 13:39:36 +00:00
|
|
|
rcc.side_effect = helpers.mk_boom(RuntimeError)
|
|
|
|
|
|
|
|
t = extra_isos.ExtraIsosThread(mock.Mock())
|
|
|
|
with self.assertRaises(RuntimeError):
|
2020-01-22 10:02:22 +00:00
|
|
|
with mock.patch("time.sleep"):
|
|
|
|
t.process((compose, cfg, server, "x86_64"), 1)
|
2018-05-09 13:39:36 +00:00
|
|
|
|
|
|
|
self.assertEqual(aitm.call_args_list, [])
|
|
|
|
|
|
|
|
|
2019-11-01 08:10:34 +00:00
|
|
|
@mock.patch("pungi.metadata.populate_extra_files_metadata")
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.phases.extra_isos.get_file_from_scm")
|
|
|
|
@mock.patch("pungi.phases.extra_isos.get_dir_from_scm")
|
2018-05-09 13:39:36 +00:00
|
|
|
class GetExtraFilesTest(helpers.PungiTestCase):
|
|
|
|
def setUp(self):
|
|
|
|
super(GetExtraFilesTest, self).setUp()
|
|
|
|
self.compose = helpers.DummyCompose(self.topdir, {})
|
2020-01-22 10:02:22 +00:00
|
|
|
self.variant = self.compose.variants["Server"]
|
|
|
|
self.arch = "x86_64"
|
2018-11-14 14:41:36 +00:00
|
|
|
self.dir = os.path.join(
|
|
|
|
self.topdir, "work", self.arch, self.variant.uid, "extra-iso-extra-files"
|
|
|
|
)
|
2018-05-09 13:39:36 +00:00
|
|
|
|
2019-11-01 08:10:34 +00:00
|
|
|
def test_no_config(self, get_dir, get_file, populate_md):
|
2018-05-09 13:39:36 +00:00
|
|
|
extra_isos.get_extra_files(self.compose, self.variant, self.arch, [])
|
|
|
|
|
|
|
|
self.assertEqual(get_dir.call_args_list, [])
|
|
|
|
self.assertEqual(get_file.call_args_list, [])
|
2019-11-01 08:10:34 +00:00
|
|
|
self.assertEqual(populate_md.call_args_list, [])
|
2018-05-09 13:39:36 +00:00
|
|
|
|
2019-11-01 08:10:34 +00:00
|
|
|
def test_get_file(self, get_dir, get_file, populate_md):
|
2018-11-14 14:41:36 +00:00
|
|
|
get_file.return_value = ["GPL"]
|
2018-05-09 13:39:36 +00:00
|
|
|
cfg = {
|
2020-01-22 10:02:22 +00:00
|
|
|
"scm": "git",
|
|
|
|
"repo": "https://pagure.io/pungi.git",
|
|
|
|
"file": "GPL",
|
|
|
|
"target": "legalese",
|
2018-05-09 13:39:36 +00:00
|
|
|
}
|
|
|
|
extra_isos.get_extra_files(self.compose, self.variant, self.arch, [cfg])
|
|
|
|
|
|
|
|
self.assertEqual(get_dir.call_args_list, [])
|
2018-11-14 14:41:36 +00:00
|
|
|
self.assertEqual(
|
|
|
|
get_file.call_args_list,
|
2020-01-22 10:02:22 +00:00
|
|
|
[mock.call(cfg, os.path.join(self.dir, "legalese"), compose=self.compose)],
|
2018-11-14 14:41:36 +00:00
|
|
|
)
|
|
|
|
self.assertEqual(
|
2019-11-01 08:10:34 +00:00
|
|
|
populate_md.call_args_list,
|
2018-11-14 14:41:36 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
2019-11-01 08:10:34 +00:00
|
|
|
mock.ANY,
|
|
|
|
self.variant,
|
|
|
|
self.arch,
|
2018-11-14 14:41:36 +00:00
|
|
|
self.dir,
|
|
|
|
["legalese/GPL"],
|
|
|
|
self.compose.conf["media_checksums"],
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2019-11-01 08:10:34 +00:00
|
|
|
def test_get_dir(self, get_dir, get_file, populate_md):
|
2018-11-14 14:41:36 +00:00
|
|
|
get_dir.return_value = ["a", "b"]
|
2018-05-09 13:39:36 +00:00
|
|
|
cfg = {
|
2020-01-22 10:02:22 +00:00
|
|
|
"scm": "git",
|
|
|
|
"repo": "https://pagure.io/pungi.git",
|
|
|
|
"dir": "docs",
|
|
|
|
"target": "foo",
|
2018-05-09 13:39:36 +00:00
|
|
|
}
|
|
|
|
extra_isos.get_extra_files(self.compose, self.variant, self.arch, [cfg])
|
|
|
|
|
|
|
|
self.assertEqual(get_file.call_args_list, [])
|
2018-11-14 14:41:36 +00:00
|
|
|
self.assertEqual(
|
|
|
|
get_dir.call_args_list,
|
2019-11-01 08:10:34 +00:00
|
|
|
[mock.call(cfg, os.path.join(self.dir, "foo"), compose=self.compose)],
|
2018-11-14 14:41:36 +00:00
|
|
|
)
|
|
|
|
self.assertEqual(
|
2019-11-01 08:10:34 +00:00
|
|
|
populate_md.call_args_list,
|
2018-11-14 14:41:36 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
2019-11-01 08:10:34 +00:00
|
|
|
mock.ANY,
|
|
|
|
self.variant,
|
|
|
|
self.arch,
|
2018-11-14 14:41:36 +00:00
|
|
|
self.dir,
|
|
|
|
["foo/a", "foo/b"],
|
|
|
|
self.compose.conf["media_checksums"],
|
2019-11-01 08:10:34 +00:00
|
|
|
),
|
2018-11-14 14:41:36 +00:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2019-11-01 08:10:34 +00:00
|
|
|
def test_get_multiple_files(self, get_dir, get_file, populate_md):
|
2018-11-14 14:41:36 +00:00
|
|
|
get_file.side_effect = [["GPL"], ["setup.py"]]
|
|
|
|
cfg1 = {
|
2020-01-22 10:02:22 +00:00
|
|
|
"scm": "git",
|
|
|
|
"repo": "https://pagure.io/pungi.git",
|
|
|
|
"file": "GPL",
|
|
|
|
"target": "legalese",
|
2018-11-14 14:41:36 +00:00
|
|
|
}
|
|
|
|
cfg2 = {"scm": "git", "repo": "https://pagure.io/pungi.git", "file": "setup.py"}
|
|
|
|
extra_isos.get_extra_files(self.compose, self.variant, self.arch, [cfg1, cfg2])
|
|
|
|
|
|
|
|
self.assertEqual(get_dir.call_args_list, [])
|
|
|
|
self.assertEqual(
|
|
|
|
get_file.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
2021-03-02 10:19:05 +00:00
|
|
|
cfg1,
|
|
|
|
os.path.join(self.dir, "legalese"),
|
|
|
|
compose=self.compose,
|
2018-11-14 14:41:36 +00:00
|
|
|
),
|
2019-10-07 10:26:22 +00:00
|
|
|
mock.call(cfg2, self.dir, compose=self.compose),
|
2018-11-14 14:41:36 +00:00
|
|
|
],
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
2019-11-01 08:10:34 +00:00
|
|
|
populate_md.call_args_list,
|
2018-11-14 14:41:36 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
2019-11-01 08:10:34 +00:00
|
|
|
mock.ANY,
|
|
|
|
self.variant,
|
|
|
|
self.arch,
|
2018-11-14 14:41:36 +00:00
|
|
|
self.dir,
|
|
|
|
["legalese/GPL", "setup.py"],
|
|
|
|
self.compose.conf["media_checksums"],
|
2019-11-01 08:10:34 +00:00
|
|
|
),
|
2018-11-14 14:41:36 +00:00
|
|
|
],
|
|
|
|
)
|
2018-05-09 13:39:36 +00:00
|
|
|
|
|
|
|
|
2018-07-19 12:47:06 +00:00
|
|
|
@mock.patch("pungi.phases.extra_isos.tweak_treeinfo")
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("pungi.wrappers.iso.write_graft_points")
|
|
|
|
@mock.patch("pungi.wrappers.iso.get_graft_points")
|
2018-05-09 13:39:36 +00:00
|
|
|
class GetIsoContentsTest(helpers.PungiTestCase):
|
|
|
|
def setUp(self):
|
|
|
|
super(GetIsoContentsTest, self).setUp()
|
|
|
|
self.compose = helpers.DummyCompose(self.topdir, {})
|
2020-01-22 10:02:22 +00:00
|
|
|
self.variant = self.compose.variants["Server"]
|
2018-05-09 13:39:36 +00:00
|
|
|
|
2018-07-19 12:47:06 +00:00
|
|
|
def test_non_bootable_binary(self, ggp, wgp, tt):
|
2018-05-09 13:39:36 +00:00
|
|
|
gp = {
|
2020-01-22 10:02:22 +00:00
|
|
|
"compose/Client/x86_64/os/Packages": {"f/foo.rpm": "/mnt/f/foo.rpm"},
|
|
|
|
"compose/Client/x86_64/os/repodata": {
|
|
|
|
"primary.xml": "/mnt/repodata/primary.xml"
|
|
|
|
},
|
|
|
|
"compose/Server/x86_64/os/Packages": {"b/bar.rpm": "/mnt/b/bar.rpm"},
|
|
|
|
"compose/Server/x86_64/os/repodata": {
|
|
|
|
"repomd.xml": "/mnt/repodata/repomd.xml"
|
|
|
|
},
|
|
|
|
"work/x86_64/Server/extra-iso-extra-files": {"EULA": "/mnt/EULA"},
|
2018-05-09 13:39:36 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
ggp.side_effect = lambda compose, x: gp[x[0][len(self.topdir) + 1 :]]
|
|
|
|
gp_file = os.path.join(self.topdir, "work/x86_64/iso/my.iso-graft-points")
|
2018-05-09 13:39:36 +00:00
|
|
|
|
|
|
|
self.assertEqual(
|
2018-11-09 09:29:28 +00:00
|
|
|
extra_isos.get_iso_contents(
|
|
|
|
self.compose,
|
|
|
|
self.variant,
|
2020-01-22 10:02:22 +00:00
|
|
|
"x86_64",
|
|
|
|
["Client"],
|
|
|
|
"my.iso",
|
2018-11-09 09:29:28 +00:00
|
|
|
False,
|
|
|
|
inherit_extra_files=False,
|
|
|
|
),
|
|
|
|
gp_file,
|
2018-05-09 13:39:36 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
expected = {
|
2020-01-22 10:02:22 +00:00
|
|
|
"Client/Packages/f/foo.rpm": "/mnt/f/foo.rpm",
|
|
|
|
"Client/repodata/primary.xml": "/mnt/repodata/primary.xml",
|
|
|
|
"EULA": "/mnt/EULA",
|
|
|
|
"Server/Packages/b/bar.rpm": "/mnt/b/bar.rpm",
|
|
|
|
"Server/repodata/repomd.xml": "/mnt/repodata/repomd.xml",
|
2018-05-09 13:39:36 +00:00
|
|
|
}
|
|
|
|
|
2019-10-04 12:45:03 +00:00
|
|
|
six.assertCountEqual(
|
|
|
|
self,
|
2018-05-09 13:39:36 +00:00
|
|
|
ggp.call_args_list,
|
2020-08-20 13:09:27 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
self.compose.paths.compose.topdir(), [os.path.join(self.topdir, x)]
|
|
|
|
)
|
|
|
|
for x in gp
|
|
|
|
],
|
2018-05-09 13:39:36 +00:00
|
|
|
)
|
|
|
|
self.assertEqual(len(wgp.call_args_list), 1)
|
|
|
|
self.assertEqual(wgp.call_args_list[0][0][0], gp_file)
|
|
|
|
self.assertDictEqual(dict(wgp.call_args_list[0][0][1]), expected)
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertEqual(
|
|
|
|
wgp.call_args_list[0][1], {"exclude": ["*/lost+found", "*/boot.iso"]}
|
|
|
|
)
|
2018-05-09 13:39:36 +00:00
|
|
|
|
2018-07-19 12:47:06 +00:00
|
|
|
# Check correct call to tweak_treeinfo
|
|
|
|
self.assertEqual(
|
|
|
|
tt.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
self.compose,
|
|
|
|
["Client"],
|
|
|
|
os.path.join(self.topdir, "compose/Server/x86_64/os/.treeinfo"),
|
|
|
|
os.path.join(
|
|
|
|
self.topdir,
|
|
|
|
"work/x86_64/Server/extra-iso-extra-files/.treeinfo",
|
2020-01-22 10:02:22 +00:00
|
|
|
),
|
2018-07-19 12:47:06 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2018-11-09 09:29:28 +00:00
|
|
|
def test_inherit_extra_files(self, ggp, wgp, tt):
|
|
|
|
gp = {
|
|
|
|
"compose/Client/x86_64/os/Packages": {"f/foo.rpm": "/mnt/f/foo.rpm"},
|
2020-01-22 10:02:22 +00:00
|
|
|
"compose/Client/x86_64/os/repodata": {
|
|
|
|
"primary.xml": "/mnt/repodata/primary.xml"
|
|
|
|
},
|
2018-11-09 09:29:28 +00:00
|
|
|
"compose/Server/x86_64/os/Packages": {"b/bar.rpm": "/mnt/b/bar.rpm"},
|
2020-01-22 10:02:22 +00:00
|
|
|
"compose/Server/x86_64/os/repodata": {
|
|
|
|
"repomd.xml": "/mnt/repodata/repomd.xml"
|
|
|
|
},
|
2018-11-09 09:29:28 +00:00
|
|
|
"work/x86_64/Client/extra-files": {"GPL": "/mnt/GPL"},
|
|
|
|
"work/x86_64/Server/extra-files": {"AUTHORS": "/mnt/AUTHORS"},
|
|
|
|
"work/x86_64/Server/extra-iso-extra-files": {"EULA": "/mnt/EULA"},
|
|
|
|
}
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
ggp.side_effect = lambda compose, x: gp[x[0][len(self.topdir) + 1 :]]
|
2018-11-09 09:29:28 +00:00
|
|
|
gp_file = os.path.join(self.topdir, "work/x86_64/iso/my.iso-graft-points")
|
|
|
|
|
|
|
|
self.assertEqual(
|
|
|
|
extra_isos.get_iso_contents(
|
|
|
|
self.compose,
|
|
|
|
self.variant,
|
|
|
|
"x86_64",
|
|
|
|
["Client"],
|
|
|
|
"my.iso",
|
|
|
|
False,
|
|
|
|
inherit_extra_files=True,
|
|
|
|
),
|
|
|
|
gp_file,
|
|
|
|
)
|
|
|
|
|
|
|
|
expected = {
|
|
|
|
"Client/GPL": "/mnt/GPL",
|
|
|
|
"Client/Packages/f/foo.rpm": "/mnt/f/foo.rpm",
|
|
|
|
"Client/repodata/primary.xml": "/mnt/repodata/primary.xml",
|
|
|
|
"EULA": "/mnt/EULA",
|
|
|
|
"Server/AUTHORS": "/mnt/AUTHORS",
|
|
|
|
"Server/Packages/b/bar.rpm": "/mnt/b/bar.rpm",
|
|
|
|
"Server/repodata/repomd.xml": "/mnt/repodata/repomd.xml",
|
|
|
|
}
|
|
|
|
|
2019-10-04 12:45:03 +00:00
|
|
|
six.assertCountEqual(
|
|
|
|
self,
|
2018-11-09 09:29:28 +00:00
|
|
|
ggp.call_args_list,
|
2020-08-20 13:09:27 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
self.compose.paths.compose.topdir(), [os.path.join(self.topdir, x)]
|
|
|
|
)
|
|
|
|
for x in gp
|
|
|
|
],
|
2018-11-09 09:29:28 +00:00
|
|
|
)
|
|
|
|
self.assertEqual(len(wgp.call_args_list), 1)
|
|
|
|
self.assertEqual(wgp.call_args_list[0][0][0], gp_file)
|
|
|
|
self.assertDictEqual(dict(wgp.call_args_list[0][0][1]), expected)
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertEqual(
|
|
|
|
wgp.call_args_list[0][1], {"exclude": ["*/lost+found", "*/boot.iso"]}
|
|
|
|
)
|
2018-11-09 09:29:28 +00:00
|
|
|
|
|
|
|
# Check correct call to tweak_treeinfo
|
|
|
|
self.assertEqual(
|
|
|
|
tt.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
self.compose,
|
|
|
|
["Client"],
|
|
|
|
os.path.join(self.topdir, "compose/Server/x86_64/os/.treeinfo"),
|
|
|
|
os.path.join(
|
|
|
|
self.topdir,
|
|
|
|
"work/x86_64/Server/extra-iso-extra-files/.treeinfo",
|
2020-01-22 10:02:22 +00:00
|
|
|
),
|
2018-11-09 09:29:28 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2018-07-19 12:47:06 +00:00
|
|
|
def test_source(self, ggp, wgp, tt):
|
2018-05-09 13:39:36 +00:00
|
|
|
gp = {
|
2020-01-22 10:02:22 +00:00
|
|
|
"compose/Client/source/tree/Packages": {"f/foo.rpm": "/mnt/f/foo.rpm"},
|
|
|
|
"compose/Client/source/tree/repodata": {
|
|
|
|
"primary.xml": "/mnt/repodata/primary.xml"
|
|
|
|
},
|
|
|
|
"compose/Server/source/tree/Packages": {"b/bar.rpm": "/mnt/b/bar.rpm"},
|
|
|
|
"compose/Server/source/tree/repodata": {
|
|
|
|
"repomd.xml": "/mnt/repodata/repomd.xml"
|
|
|
|
},
|
|
|
|
"work/src/Server/extra-iso-extra-files": {"EULA": "/mnt/EULA"},
|
2018-05-09 13:39:36 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
ggp.side_effect = lambda compose, x: gp[x[0][len(self.topdir) + 1 :]]
|
|
|
|
gp_file = os.path.join(self.topdir, "work/src/iso/my.iso-graft-points")
|
2018-05-09 13:39:36 +00:00
|
|
|
|
|
|
|
self.assertEqual(
|
2018-11-09 09:29:28 +00:00
|
|
|
extra_isos.get_iso_contents(
|
|
|
|
self.compose,
|
|
|
|
self.variant,
|
2020-01-22 10:02:22 +00:00
|
|
|
"src",
|
|
|
|
["Client"],
|
|
|
|
"my.iso",
|
2018-11-09 09:29:28 +00:00
|
|
|
bootable=False,
|
|
|
|
inherit_extra_files=False,
|
|
|
|
),
|
|
|
|
gp_file,
|
2018-05-09 13:39:36 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
expected = {
|
2020-01-22 10:02:22 +00:00
|
|
|
"Client/Packages/f/foo.rpm": "/mnt/f/foo.rpm",
|
|
|
|
"Client/repodata/primary.xml": "/mnt/repodata/primary.xml",
|
|
|
|
"EULA": "/mnt/EULA",
|
|
|
|
"Server/Packages/b/bar.rpm": "/mnt/b/bar.rpm",
|
|
|
|
"Server/repodata/repomd.xml": "/mnt/repodata/repomd.xml",
|
2018-05-09 13:39:36 +00:00
|
|
|
}
|
|
|
|
|
2019-10-04 12:45:03 +00:00
|
|
|
six.assertCountEqual(
|
|
|
|
self,
|
2018-05-09 13:39:36 +00:00
|
|
|
ggp.call_args_list,
|
2020-08-20 13:09:27 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
self.compose.paths.compose.topdir(), [os.path.join(self.topdir, x)]
|
|
|
|
)
|
|
|
|
for x in gp
|
|
|
|
],
|
2018-05-09 13:39:36 +00:00
|
|
|
)
|
|
|
|
self.assertEqual(len(wgp.call_args_list), 1)
|
|
|
|
self.assertEqual(wgp.call_args_list[0][0][0], gp_file)
|
|
|
|
self.assertDictEqual(dict(wgp.call_args_list[0][0][1]), expected)
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertEqual(
|
|
|
|
wgp.call_args_list[0][1], {"exclude": ["*/lost+found", "*/boot.iso"]}
|
|
|
|
)
|
2018-05-09 13:39:36 +00:00
|
|
|
|
2018-07-19 12:47:06 +00:00
|
|
|
# Check correct call to tweak_treeinfo
|
|
|
|
self.assertEqual(
|
|
|
|
tt.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
self.compose,
|
|
|
|
["Client"],
|
|
|
|
os.path.join(self.topdir, "compose/Server/source/tree/.treeinfo"),
|
|
|
|
os.path.join(
|
2021-03-02 10:19:05 +00:00
|
|
|
self.topdir,
|
|
|
|
"work/src/Server/extra-iso-extra-files/.treeinfo",
|
2020-01-22 10:02:22 +00:00
|
|
|
),
|
2018-07-19 12:47:06 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
def test_bootable(self, ggp, wgp, tt):
|
2020-01-22 10:02:22 +00:00
|
|
|
self.compose.conf["buildinstall_method"] = "lorax"
|
2018-05-09 13:39:36 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
bi_dir = os.path.join(self.topdir, "work/x86_64/buildinstall/Server")
|
|
|
|
iso_dir = os.path.join(self.topdir, "work/x86_64/iso/my.iso")
|
|
|
|
helpers.touch(os.path.join(bi_dir, "isolinux/isolinux.bin"))
|
|
|
|
helpers.touch(os.path.join(bi_dir, "images/boot.img"))
|
|
|
|
helpers.touch(os.path.join(bi_dir, "images/efiboot.img"))
|
2018-05-09 13:39:36 +00:00
|
|
|
|
|
|
|
gp = {
|
2020-01-22 10:02:22 +00:00
|
|
|
"compose/Client/x86_64/os/Packages": {"f/foo.rpm": "/mnt/f/foo.rpm"},
|
|
|
|
"compose/Client/x86_64/os/repodata": {
|
|
|
|
"primary.xml": "/mnt/repodata/primary.xml"
|
|
|
|
},
|
|
|
|
"compose/Server/x86_64/os/Packages": {"b/bar.rpm": "/mnt/b/bar.rpm"},
|
|
|
|
"compose/Server/x86_64/os/repodata": {
|
|
|
|
"repomd.xml": "/mnt/repodata/repomd.xml"
|
|
|
|
},
|
|
|
|
"work/x86_64/Server/extra-iso-extra-files": {"EULA": "/mnt/EULA"},
|
2018-05-09 13:39:36 +00:00
|
|
|
}
|
|
|
|
bi_gp = {
|
2020-01-22 10:02:22 +00:00
|
|
|
"isolinux/isolinux.bin": os.path.join(iso_dir, "isolinux/isolinux.bin"),
|
|
|
|
"images/boot.img": os.path.join(iso_dir, "images/boot.img"),
|
|
|
|
"images/efiboot.img": os.path.join(iso_dir, "images/efiboot.img"),
|
2018-05-09 13:39:36 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
ggp.side_effect = (
|
|
|
|
lambda compose, x: gp[x[0][len(self.topdir) + 1 :]]
|
|
|
|
if len(x) == 1
|
|
|
|
else bi_gp
|
|
|
|
)
|
|
|
|
gp_file = os.path.join(self.topdir, "work/x86_64/iso/my.iso-graft-points")
|
2018-05-09 13:39:36 +00:00
|
|
|
|
|
|
|
self.assertEqual(
|
2018-07-19 12:47:06 +00:00
|
|
|
extra_isos.get_iso_contents(
|
|
|
|
self.compose,
|
|
|
|
self.variant,
|
2020-01-22 10:02:22 +00:00
|
|
|
"x86_64",
|
|
|
|
["Client"],
|
|
|
|
"my.iso",
|
2018-11-09 09:29:28 +00:00
|
|
|
bootable=True,
|
|
|
|
inherit_extra_files=False,
|
|
|
|
),
|
|
|
|
gp_file,
|
2018-05-09 13:39:36 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
self.maxDiff = None
|
|
|
|
|
|
|
|
expected = {
|
2020-01-22 10:02:22 +00:00
|
|
|
"Client/Packages/f/foo.rpm": "/mnt/f/foo.rpm",
|
|
|
|
"Client/repodata/primary.xml": "/mnt/repodata/primary.xml",
|
|
|
|
"EULA": "/mnt/EULA",
|
|
|
|
"Server/Packages/b/bar.rpm": "/mnt/b/bar.rpm",
|
|
|
|
"Server/repodata/repomd.xml": "/mnt/repodata/repomd.xml",
|
|
|
|
"isolinux/isolinux.bin": os.path.join(iso_dir, "isolinux/isolinux.bin"),
|
|
|
|
"images/boot.img": os.path.join(iso_dir, "images/boot.img"),
|
|
|
|
"images/efiboot.img": os.path.join(
|
|
|
|
self.topdir,
|
|
|
|
"compose",
|
|
|
|
self.variant.uid,
|
|
|
|
"x86_64/os/images/efiboot.img",
|
2018-10-11 13:24:09 +00:00
|
|
|
),
|
2018-05-09 13:39:36 +00:00
|
|
|
}
|
|
|
|
|
2019-10-04 12:45:03 +00:00
|
|
|
six.assertCountEqual(
|
|
|
|
self,
|
2018-05-09 13:39:36 +00:00
|
|
|
ggp.call_args_list,
|
2020-08-20 13:09:27 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
self.compose.paths.compose.topdir(), [os.path.join(self.topdir, x)]
|
|
|
|
)
|
|
|
|
for x in gp
|
|
|
|
]
|
|
|
|
+ [mock.call(self.compose.paths.compose.topdir(), [bi_dir, iso_dir])],
|
2018-05-09 13:39:36 +00:00
|
|
|
)
|
|
|
|
self.assertEqual(len(wgp.call_args_list), 1)
|
|
|
|
self.assertEqual(wgp.call_args_list[0][0][0], gp_file)
|
|
|
|
self.assertDictEqual(dict(wgp.call_args_list[0][0][1]), expected)
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertEqual(
|
|
|
|
wgp.call_args_list[0][1], {"exclude": ["*/lost+found", "*/boot.iso"]}
|
|
|
|
)
|
2018-05-09 13:39:36 +00:00
|
|
|
|
|
|
|
# Check files were copied to temp directory
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertTrue(os.path.exists(os.path.join(iso_dir, "isolinux/isolinux.bin")))
|
|
|
|
self.assertTrue(os.path.exists(os.path.join(iso_dir, "images/boot.img")))
|
2018-05-09 13:39:36 +00:00
|
|
|
|
2018-07-19 12:47:06 +00:00
|
|
|
# Check correct call to tweak_treeinfo
|
|
|
|
self.assertEqual(
|
|
|
|
tt.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
self.compose,
|
|
|
|
["Client"],
|
|
|
|
os.path.join(self.topdir, "compose/Server/x86_64/os/.treeinfo"),
|
|
|
|
os.path.join(
|
|
|
|
self.topdir,
|
|
|
|
"work/x86_64/Server/extra-iso-extra-files/.treeinfo",
|
2020-01-22 10:02:22 +00:00
|
|
|
),
|
2018-07-19 12:47:06 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2018-05-09 13:39:36 +00:00
|
|
|
|
|
|
|
class GetFilenameTest(helpers.PungiTestCase):
|
|
|
|
def test_use_original_name(self):
|
|
|
|
compose = helpers.DummyCompose(self.topdir, {})
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
fn = extra_isos.get_filename(
|
|
|
|
compose,
|
|
|
|
compose.variants["Server"],
|
|
|
|
"x86_64",
|
|
|
|
"foo-{variant}-{arch}-{filename}",
|
|
|
|
)
|
2018-05-09 13:39:36 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertEqual(fn, "foo-Server-x86_64-image-name")
|
2018-05-09 13:39:36 +00:00
|
|
|
|
|
|
|
def test_use_default_without_format(self):
|
|
|
|
compose = helpers.DummyCompose(self.topdir, {})
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
fn = extra_isos.get_filename(
|
|
|
|
compose, compose.variants["Server"], "x86_64", None
|
|
|
|
)
|
2018-05-09 13:39:36 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertEqual(fn, "image-name")
|
2018-05-09 13:39:36 +00:00
|
|
|
|
|
|
|
def test_reports_unknown_placeholder(self):
|
|
|
|
compose = helpers.DummyCompose(self.topdir, {})
|
|
|
|
|
|
|
|
with self.assertRaises(RuntimeError) as ctx:
|
2020-01-22 10:02:22 +00:00
|
|
|
extra_isos.get_filename(
|
|
|
|
compose, compose.variants["Server"], "x86_64", "foo-{boom}"
|
|
|
|
)
|
2018-05-09 13:39:36 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertIn("boom", str(ctx.exception))
|
2018-05-09 13:39:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
class GetVolumeIDTest(helpers.PungiTestCase):
|
|
|
|
def test_use_original_volume_id(self):
|
|
|
|
compose = helpers.DummyCompose(self.topdir, {})
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
volid = extra_isos.get_volume_id(
|
|
|
|
compose, compose.variants["Server"], "x86_64", "f-{volid}"
|
|
|
|
)
|
2018-05-09 13:39:36 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertEqual(volid, "f-test-1.0 Server.x86_64")
|
2018-05-09 13:39:36 +00:00
|
|
|
|
|
|
|
def test_falls_back_to_shorter(self):
|
|
|
|
compose = helpers.DummyCompose(self.topdir, {})
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
volid = extra_isos.get_volume_id(
|
|
|
|
compose,
|
|
|
|
compose.variants["Server"],
|
|
|
|
"x86_64",
|
|
|
|
["long-foobar-{volid}", "f-{volid}"],
|
|
|
|
)
|
2018-05-09 13:39:36 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertEqual(volid, "f-test-1.0 Server.x86_64")
|
2018-05-09 13:39:36 +00:00
|
|
|
|
|
|
|
def test_reports_unknown_placeholder(self):
|
|
|
|
compose = helpers.DummyCompose(self.topdir, {})
|
|
|
|
|
|
|
|
with self.assertRaises(RuntimeError) as ctx:
|
2020-01-22 10:02:22 +00:00
|
|
|
extra_isos.get_volume_id(
|
|
|
|
compose, compose.variants["Server"], "x86_64", "f-{boom}"
|
|
|
|
)
|
2018-05-09 13:39:36 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertIn("boom", str(ctx.exception))
|
2018-05-09 13:39:36 +00:00
|
|
|
|
|
|
|
|
2018-07-19 12:47:06 +00:00
|
|
|
class TweakTreeinfoTest(helpers.PungiTestCase):
|
|
|
|
def test_tweak(self):
|
|
|
|
compose = helpers.DummyCompose(self.topdir, {})
|
2018-08-15 12:57:43 +00:00
|
|
|
input = os.path.join(helpers.FIXTURE_DIR, "extraiso.treeinfo")
|
2018-07-19 12:47:06 +00:00
|
|
|
output = os.path.join(self.topdir, "actual-treeinfo")
|
2018-08-15 12:57:43 +00:00
|
|
|
expected = os.path.join(helpers.FIXTURE_DIR, "extraiso-expected.treeinfo")
|
2018-07-19 12:47:06 +00:00
|
|
|
extra_isos.tweak_treeinfo(compose, ["Client"], input, output)
|
|
|
|
|
2018-10-11 08:15:08 +00:00
|
|
|
self.assertFilesEqual(output, expected)
|
2018-07-19 12:47:06 +00:00
|
|
|
|
|
|
|
|
2018-10-17 12:06:43 +00:00
|
|
|
class PrepareMetadataTest(helpers.PungiTestCase):
|
|
|
|
@mock.patch("pungi.metadata.create_media_repo")
|
|
|
|
@mock.patch("pungi.metadata.create_discinfo")
|
|
|
|
@mock.patch("pungi.metadata.get_description")
|
|
|
|
def test_write_files(self, get_description, create_discinfo, create_media_repo):
|
|
|
|
compose = helpers.DummyCompose(self.topdir, {})
|
|
|
|
variant = compose.variants["Server"]
|
|
|
|
arch = "x86_64"
|
|
|
|
|
|
|
|
extra_isos.prepare_media_metadata(compose, variant, arch)
|
|
|
|
|
|
|
|
self.assertEqual(
|
|
|
|
get_description.call_args_list, [mock.call(compose, variant, arch)]
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
create_discinfo.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
os.path.join(
|
|
|
|
self.topdir,
|
|
|
|
"work/x86_64/Server/extra-iso-extra-files/.discinfo",
|
|
|
|
),
|
|
|
|
get_description.return_value,
|
|
|
|
arch,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
create_media_repo.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
os.path.join(
|
|
|
|
self.topdir,
|
|
|
|
"work/x86_64/Server/extra-iso-extra-files/media.repo",
|
|
|
|
),
|
|
|
|
get_description.return_value,
|
|
|
|
timestamp=None,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|