Skip to content

Commit 1fda4a1

Browse files
committed
WIP installer_iso: allow use of a callable to depend on version
FIXME: - doc - squash into "add "version" test parameter" ?
1 parent c29fc28 commit 1fda4a1

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

tests/install/conftest.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ def iso_remaster(request, answerfile):
8888
assert marker is not None, "iso_remaster fixture requires 'installer_iso' marker"
8989
iso_key = marker.args[0]
9090

91+
if callable(iso_key):
92+
try:
93+
version = request.getfixturevalue("version")
94+
except pytest.FixtureLookupError as e:
95+
raise RuntimeError("'version' test parameter not found") from e
96+
iso_key = iso_key(version=version)
97+
9198
from data import ISO_IMAGES, ISOSR_SRV, ISOSR_PATH, PXE_CONFIG_SERVER, TEST_SSH_PUBKEY, TOOLS
9299
assert "iso-remaster" in TOOLS
93100
iso_remaster = TOOLS["iso-remaster"]

tests/install/test.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,10 @@ class TestNested:
3838
"source": {"type": "local"},
3939
"primary-disk": {"text": "nvme0n1"},
4040
})
41-
@pytest.mark.parametrize("version", [
42-
pytest.param("821.1", marks=[
43-
pytest.mark.installer_iso("xcpng-8.2.1-2023"),
44-
]),
45-
pytest.param("83b2", marks=[
46-
pytest.mark.installer_iso("xcpng-8.3-beta2"),
47-
]),
48-
])
49-
def test_install_uefi(self, request, iso_remaster, create_vms, version):
41+
@pytest.mark.installer_iso(lambda version: {"821.1": "xcpng-8.2.1-2023",
42+
"83b2": "xcpng-8.3-beta2"}[version])
43+
@pytest.mark.parametrize("version", ("821.1", "83b2"))
44+
def test_install_uefi(self, request, version, iso_remaster, create_vms):
5045
assert len(create_vms) == 1
5146
host_vm = create_vms[0]
5247
# FIXME should be part of vm def
@@ -260,19 +255,16 @@ def test_firstboot_uefi(self, request, create_vms, mode):
260255
pytest.mark.dependency(depends=["TestNested::test_firstboot_uefi[821.1_install]"]),
261256
pytest.mark.vm_definitions(
262257
dict(name="vm 1", image="install/test::Nested::firstboot_uefi[821.1_install]")),
263-
pytest.mark.installer_iso("xcpng-8.2.1-2023"),
264258
]),
265259
pytest.param("821.1", "83b2", marks=[
266260
pytest.mark.dependency(depends=["TestNested::test_firstboot_uefi[821.1_install]"]),
267261
pytest.mark.vm_definitions(
268262
dict(name="vm 1", image="install/test::Nested::firstboot_uefi[821.1_install]")),
269-
pytest.mark.installer_iso("xcpng-8.3-beta2"),
270263
]),
271264
pytest.param("83b2", "83b2", marks=[
272265
pytest.mark.dependency(depends=["TestNested::test_firstboot_uefi[83b2_install]"]),
273266
pytest.mark.vm_definitions(
274267
dict(name="vm 1", image="install/test::Nested::firstboot_uefi[83b2_install]")),
275-
pytest.mark.installer_iso("xcpng-8.3-beta2"),
276268
]),
277269
])
278270
@pytest.mark.answerfile(
@@ -281,6 +273,8 @@ def test_firstboot_uefi(self, request, create_vms, mode):
281273
"source": {"type": "local"},
282274
"existing-installation": {"text": "nvme0n1"},
283275
})
276+
@pytest.mark.installer_iso(lambda version: {"821.1": "xcpng-8.2.1-2023",
277+
"83b2": "xcpng-8.3-beta2"}[version])
284278
def test_upgrade_uefi(self, request, iso_remaster, create_vms, orig_version, version):
285279
host_vm = create_vms[0]
286280
vif = host_vm.vifs()[0]

0 commit comments

Comments
 (0)