Skip to content

Commit b6a27fa

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 27c0125 commit b6a27fa

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
@@ -16,14 +16,9 @@
1616

1717
@pytest.mark.dependency()
1818
class TestNested:
19-
@pytest.mark.parametrize("version", [
20-
pytest.param("821.1", marks=[
21-
pytest.mark.installer_iso("xcpng-8.2.1-2023"),
22-
]),
23-
pytest.param("83b2", marks=[
24-
pytest.mark.installer_iso("xcpng-8.3-beta2"),
25-
]),
26-
])
19+
@pytest.mark.parametrize("version", ("821.1", "83b2"))
20+
@pytest.mark.installer_iso(lambda version: {"821.1": "xcpng-8.2.1-2023",
21+
"83b2": "xcpng-8.3-beta2"}[version])
2722
@pytest.mark.vm_definitions(
2823
dict(name="vm 1",
2924
template="Other install media",
@@ -46,7 +41,7 @@ class TestNested:
4641
"source": {"type": "local"},
4742
"primary-disk": {"text": "nvme0n1"},
4843
})
49-
def test_install_uefi(self, request, iso_remaster, create_vms, version):
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
@@ -261,20 +256,17 @@ def test_firstboot_uefi(self, request, create_vms, mode):
261256
pytest.mark.dependency(depends=["TestNested::test_firstboot_uefi[821.1]"]),
262257
pytest.mark.vm_definitions(
263258
dict(name="vm 1", image="install/test::Nested::firstboot_uefi[821.1]")),
264-
pytest.mark.installer_iso("xcpng-8.2.1-2023"),
265259
]),
266260
pytest.param("821.1", "83b2", marks=[
267261
pytest.mark.dependency(depends=["TestNested::test_firstboot_uefi[821.1]"]),
268262
pytest.mark.vm_definitions(
269263
dict(name="vm 1", image="install/test::Nested::firstboot_uefi[821.1]")),
270-
pytest.mark.installer_iso("xcpng-8.3-beta2"),
271264
]),
272265
# 8.3b2 disabled the upgrade from 8.3
273266
#pytest.param("83b2", "83b2", marks=[
274267
# pytest.mark.dependency(depends=["TestNested::test_firstboot_uefi[83b2]"]),
275268
# pytest.mark.vm_definitions(
276269
# dict(name="vm 1", image="install/test::Nested::firstboot_uefi[83b2]")),
277-
# pytest.mark.installer_iso("xcpng-8.3-beta2"),
278270
#]),
279271
])
280272
@pytest.mark.answerfile(
@@ -283,6 +275,8 @@ def test_firstboot_uefi(self, request, create_vms, mode):
283275
"source": {"type": "local"},
284276
"existing-installation": {"text": "nvme0n1"},
285277
})
278+
@pytest.mark.installer_iso(lambda version: {"821.1": "xcpng-8.2.1-2023",
279+
"83b2": "xcpng-8.3-beta2"}[version])
286280
def test_upgrade_uefi(self, request, iso_remaster, create_vms, orig_version, version):
287281
host_vm = create_vms[0]
288282
vif = host_vm.vifs()[0]

0 commit comments

Comments
 (0)