Skip to content

Commit

Permalink
WIP installer_iso: allow use of a callable to depend on version
Browse files Browse the repository at this point in the history
FIXME:
- doc
- squash into "add "version" test parameter" ?
  • Loading branch information
ydirson committed Jun 13, 2024
1 parent c29fc28 commit 1fda4a1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
7 changes: 7 additions & 0 deletions tests/install/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ def iso_remaster(request, answerfile):
assert marker is not None, "iso_remaster fixture requires 'installer_iso' marker"
iso_key = marker.args[0]

if callable(iso_key):
try:
version = request.getfixturevalue("version")
except pytest.FixtureLookupError as e:
raise RuntimeError("'version' test parameter not found") from e
iso_key = iso_key(version=version)

from data import ISO_IMAGES, ISOSR_SRV, ISOSR_PATH, PXE_CONFIG_SERVER, TEST_SSH_PUBKEY, TOOLS
assert "iso-remaster" in TOOLS
iso_remaster = TOOLS["iso-remaster"]
Expand Down
18 changes: 6 additions & 12 deletions tests/install/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,10 @@ class TestNested:
"source": {"type": "local"},
"primary-disk": {"text": "nvme0n1"},
})
@pytest.mark.parametrize("version", [
pytest.param("821.1", marks=[
pytest.mark.installer_iso("xcpng-8.2.1-2023"),
]),
pytest.param("83b2", marks=[
pytest.mark.installer_iso("xcpng-8.3-beta2"),
]),
])
def test_install_uefi(self, request, iso_remaster, create_vms, version):
@pytest.mark.installer_iso(lambda version: {"821.1": "xcpng-8.2.1-2023",
"83b2": "xcpng-8.3-beta2"}[version])
@pytest.mark.parametrize("version", ("821.1", "83b2"))
def test_install_uefi(self, request, version, iso_remaster, create_vms):
assert len(create_vms) == 1
host_vm = create_vms[0]
# FIXME should be part of vm def
Expand Down Expand Up @@ -260,19 +255,16 @@ def test_firstboot_uefi(self, request, create_vms, mode):
pytest.mark.dependency(depends=["TestNested::test_firstboot_uefi[821.1_install]"]),
pytest.mark.vm_definitions(
dict(name="vm 1", image="install/test::Nested::firstboot_uefi[821.1_install]")),
pytest.mark.installer_iso("xcpng-8.2.1-2023"),
]),
pytest.param("821.1", "83b2", marks=[
pytest.mark.dependency(depends=["TestNested::test_firstboot_uefi[821.1_install]"]),
pytest.mark.vm_definitions(
dict(name="vm 1", image="install/test::Nested::firstboot_uefi[821.1_install]")),
pytest.mark.installer_iso("xcpng-8.3-beta2"),
]),
pytest.param("83b2", "83b2", marks=[
pytest.mark.dependency(depends=["TestNested::test_firstboot_uefi[83b2_install]"]),
pytest.mark.vm_definitions(
dict(name="vm 1", image="install/test::Nested::firstboot_uefi[83b2_install]")),
pytest.mark.installer_iso("xcpng-8.3-beta2"),
]),
])
@pytest.mark.answerfile(
Expand All @@ -281,6 +273,8 @@ def test_firstboot_uefi(self, request, create_vms, mode):
"source": {"type": "local"},
"existing-installation": {"text": "nvme0n1"},
})
@pytest.mark.installer_iso(lambda version: {"821.1": "xcpng-8.2.1-2023",
"83b2": "xcpng-8.3-beta2"}[version])
def test_upgrade_uefi(self, request, iso_remaster, create_vms, orig_version, version):
host_vm = create_vms[0]
vif = host_vm.vifs()[0]
Expand Down

0 comments on commit 1fda4a1

Please sign in to comment.