Skip to content

Commit

Permalink
WIP allow use of a callable to depend on orig_version
Browse files Browse the repository at this point in the history
- now uses a single list item, so a single callable can return a all
  decls

FIXME:
- added dependencies not taken into account?
- apply to firstboot
- hardcoding "orig_version" feels bad for further usage
  => derive param name from lambda introspection?
- squash?
  • Loading branch information
ydirson committed Jun 14, 2024
1 parent 24afe83 commit 2dd8ec0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
9 changes: 8 additions & 1 deletion tests/install/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,14 @@ def xcpng_chained(request):
# take test name from mark
marker = request.node.get_closest_marker("continuation_of")
assert marker is not None, "xcpng_chained fixture requires 'continuation_of' marker"
continuation_of = marker.args
continuation_of = marker.args[0]
if callable(continuation_of):
try:
orig_version = request.getfixturevalue("orig_version")
except pytest.FixtureLookupError as e:
raise RuntimeError("'orig_version' test parameter not found") from e
continuation_of = continuation_of(orig_version=orig_version)

vm_defs = [dict(name=vm_spec['vm'],
image=shortened_nodeid(
_expand_scope_relative_nodeid(vm_spec['test'],
Expand Down
41 changes: 17 additions & 24 deletions tests/install/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,25 +127,25 @@ def test_install_uefi(self, request, version, iso_remaster, create_vms):
@pytest.mark.usefixtures("xcpng_chained")
@pytest.mark.parametrize("mode", [
pytest.param("821.1", marks=[
pytest.mark.continuation_of(dict(vm="vm 1",
test="TestNested::test_install_uefi[821.1]")),
pytest.mark.continuation_of([dict(vm="vm 1",
test="TestNested::test_install_uefi[821.1]")]),
]),
pytest.param("821.1_821.1", marks=[
pytest.mark.continuation_of(dict(vm="vm 1",
test="TestNested::test_upgrade_uefi[821.1-821.1]")),
pytest.mark.continuation_of([dict(vm="vm 1",
test="TestNested::test_upgrade_uefi[821.1-821.1]")]),
]),
pytest.param("821.1_83b2", marks=[
pytest.mark.continuation_of(dict(vm="vm 1",
test="TestNested::test_upgrade_uefi[821.1-83b2]")),
pytest.mark.continuation_of([dict(vm="vm 1",
test="TestNested::test_upgrade_uefi[821.1-83b2]")]),
]),
pytest.param("83b2", marks=[
pytest.mark.continuation_of(dict(vm="vm 1",
test="TestNested::test_install_uefi[83b2]")),
pytest.mark.continuation_of([dict(vm="vm 1",
test="TestNested::test_install_uefi[83b2]")]),
]),
# 8.3b2 disabled the upgrade from 8.3
#pytest.param("83b2_83b2", marks=[
# pytest.mark.continuation_of(dict(vm="vm 1",
# test="TestNested::test_upgrade_uefi[83b2-83b2]")),
# pytest.mark.continuation_of([dict(vm="vm 1",
# test="TestNested::test_upgrade_uefi[83b2-83b2]")]),
#]),
])
def test_firstboot_uefi(self, request, create_vms, mode):
Expand Down Expand Up @@ -249,20 +249,13 @@ def test_firstboot_uefi(self, request, create_vms, mode):

@pytest.mark.usefixtures("xcpng_chained")
@pytest.mark.parametrize(("orig_version", "version"), [
pytest.param("821.1", "821.1", marks=[
pytest.mark.continuation_of(dict(vm="vm 1",
test="TestNested::test_firstboot_uefi[821.1]")),
]),
pytest.param("821.1", "83b2", marks=[
pytest.mark.continuation_of(dict(vm="vm 1",
test="TestNested::test_firstboot_uefi[821.1]")),
]),
# 8.3b2 disabled the upgrade from 8.3
#pytest.param("83b2", "83b2", marks=[
# pytest.mark.continuation_of(dict(vm="vm 1",
# test="TestNested::test_firstboot_uefi[83b2]")),
#]),
("821.1", "821.1"),
("821.1", "83b2"),
#("83b2", "83b2"), # 8.3b2 disabled the upgrade from 8.3
])
@pytest.mark.continuation_of(
lambda orig_version: [dict(vm="vm 1",
test=f"TestNested::test_firstboot_uefi[{orig_version}]")])
@pytest.mark.answerfile(
{
"base": "UPGRADE",
Expand All @@ -271,7 +264,7 @@ def test_firstboot_uefi(self, request, create_vms, mode):
})
@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):
def test_upgrade_uefi(self, request, orig_version, version, iso_remaster, create_vms):
host_vm = create_vms[0]
vif = host_vm.vifs()[0]
mac_address = vif.param_get('MAC')
Expand Down

0 comments on commit 2dd8ec0

Please sign in to comment.