Skip to content

Commit

Permalink
WIP install: use xcpng_chained/continuation_of to simplify dependency…
Browse files Browse the repository at this point in the history
… spec
  • Loading branch information
ydirson committed Jun 14, 2024
1 parent b6a27fa commit 24afe83
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 25 deletions.
3 changes: 2 additions & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ markers =
windows_vm: tests that require a Windows VM to run.

# * VM-related markers to give parameters to fixtures
vm_definitions: dicts of VM defs for create_vms fixture.
vm_definitions: dicts of VM nick to VM defs for create_vms fixture.
continuation_of: dicts of VM nick to test (and soon VM nick) from which to start

# * installation-related markers to customize installer run
answerfile: dict defining an answerfile
Expand Down
18 changes: 18 additions & 0 deletions tests/install/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,21 @@ def iso_remaster(request, answerfile):
finally:
logging.info("Removing %s from ISO-SR server", os.path.basename(remote_iso))
ssh(ISOSR_SRV, ["rm", remote_iso])

@pytest.fixture(scope='function')
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
vm_defs = [dict(name=vm_spec['vm'],
image=shortened_nodeid(
_expand_scope_relative_nodeid(vm_spec['test'],
vm_spec.get("scope", "module"),
request.node.nodeid)),
)
for vm_spec in continuation_of]

request.applymarker(pytest.mark.dependency(
depends=[vm_spec['test'] for vm_spec in continuation_of]))
request.applymarker(pytest.mark.vm_definitions(*vm_defs))
42 changes: 18 additions & 24 deletions tests/install/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,32 +124,28 @@ def test_install_uefi(self, request, version, iso_remaster, create_vms):
host_vm.export(xva_name, "zstd", use_cache=CACHE_IMPORTED_VM)


@pytest.mark.usefixtures("xcpng_chained")
@pytest.mark.parametrize("mode", [
pytest.param("821.1", marks=[
pytest.mark.dependency(depends=["TestNested::test_install_uefi[821.1]"]),
pytest.mark.vm_definitions(
dict(name="vm 1", image="install/test::Nested::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.dependency(depends=["TestNested::test_upgrade_uefi[821.1-821.1]"]),
pytest.mark.vm_definitions(
dict(name="vm 1", image="install/test::Nested::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.dependency(depends=["TestNested::test_upgrade_uefi[821.1-83b2]"]),
pytest.mark.vm_definitions(
dict(name="vm 1", image="install/test::Nested::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.dependency(depends=["TestNested::test_install_uefi[83b2]"]),
pytest.mark.vm_definitions(
dict(name="vm 1", image="install/test::Nested::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.dependency(depends=["TestNested::test_upgrade_uefi[83b2-83b2]"]),
# pytest.mark.vm_definitions(
# dict(name="vm 1", image="install/test::Nested::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 @@ -251,22 +247,20 @@ def test_firstboot_uefi(self, request, create_vms, mode):
host_vm.host.ssh(["rm -f", xva_name])
host_vm.export(xva_name, "zstd", use_cache=CACHE_IMPORTED_VM)

@pytest.mark.usefixtures("xcpng_chained")
@pytest.mark.parametrize(("orig_version", "version"), [
pytest.param("821.1", "821.1", marks=[
pytest.mark.dependency(depends=["TestNested::test_firstboot_uefi[821.1]"]),
pytest.mark.vm_definitions(
dict(name="vm 1", image="install/test::Nested::firstboot_uefi[821.1]")),
pytest.mark.continuation_of(dict(vm="vm 1",
test="TestNested::test_firstboot_uefi[821.1]")),
]),
pytest.param("821.1", "83b2", marks=[
pytest.mark.dependency(depends=["TestNested::test_firstboot_uefi[821.1]"]),
pytest.mark.vm_definitions(
dict(name="vm 1", image="install/test::Nested::firstboot_uefi[821.1]")),
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.dependency(depends=["TestNested::test_firstboot_uefi[83b2]"]),
# pytest.mark.vm_definitions(
# dict(name="vm 1", image="install/test::Nested::firstboot_uefi[83b2]")),
# pytest.mark.continuation_of(dict(vm="vm 1",
# test="TestNested::test_firstboot_uefi[83b2]")),
#]),
])
@pytest.mark.answerfile(
Expand Down

0 comments on commit 24afe83

Please sign in to comment.