Skip to content

Commit 24afe83

Browse files
committed
WIP install: use xcpng_chained/continuation_of to simplify dependency spec
1 parent b6a27fa commit 24afe83

File tree

3 files changed

+38
-25
lines changed

3 files changed

+38
-25
lines changed

pytest.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ markers =
2020
windows_vm: tests that require a Windows VM to run.
2121

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

2526
# * installation-related markers to customize installer run
2627
answerfile: dict defining an answerfile

tests/install/conftest.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,3 +205,21 @@ def iso_remaster(request, answerfile):
205205
finally:
206206
logging.info("Removing %s from ISO-SR server", os.path.basename(remote_iso))
207207
ssh(ISOSR_SRV, ["rm", remote_iso])
208+
209+
@pytest.fixture(scope='function')
210+
def xcpng_chained(request):
211+
# take test name from mark
212+
marker = request.node.get_closest_marker("continuation_of")
213+
assert marker is not None, "xcpng_chained fixture requires 'continuation_of' marker"
214+
continuation_of = marker.args
215+
vm_defs = [dict(name=vm_spec['vm'],
216+
image=shortened_nodeid(
217+
_expand_scope_relative_nodeid(vm_spec['test'],
218+
vm_spec.get("scope", "module"),
219+
request.node.nodeid)),
220+
)
221+
for vm_spec in continuation_of]
222+
223+
request.applymarker(pytest.mark.dependency(
224+
depends=[vm_spec['test'] for vm_spec in continuation_of]))
225+
request.applymarker(pytest.mark.vm_definitions(*vm_defs))

tests/install/test.py

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -124,32 +124,28 @@ def test_install_uefi(self, request, version, iso_remaster, create_vms):
124124
host_vm.export(xva_name, "zstd", use_cache=CACHE_IMPORTED_VM)
125125

126126

127+
@pytest.mark.usefixtures("xcpng_chained")
127128
@pytest.mark.parametrize("mode", [
128129
pytest.param("821.1", marks=[
129-
pytest.mark.dependency(depends=["TestNested::test_install_uefi[821.1]"]),
130-
pytest.mark.vm_definitions(
131-
dict(name="vm 1", image="install/test::Nested::install_uefi[821.1]")),
130+
pytest.mark.continuation_of(dict(vm="vm 1",
131+
test="TestNested::test_install_uefi[821.1]")),
132132
]),
133133
pytest.param("821.1_821.1", marks=[
134-
pytest.mark.dependency(depends=["TestNested::test_upgrade_uefi[821.1-821.1]"]),
135-
pytest.mark.vm_definitions(
136-
dict(name="vm 1", image="install/test::Nested::upgrade_uefi[821.1-821.1]")),
134+
pytest.mark.continuation_of(dict(vm="vm 1",
135+
test="TestNested::test_upgrade_uefi[821.1-821.1]")),
137136
]),
138137
pytest.param("821.1_83b2", marks=[
139-
pytest.mark.dependency(depends=["TestNested::test_upgrade_uefi[821.1-83b2]"]),
140-
pytest.mark.vm_definitions(
141-
dict(name="vm 1", image="install/test::Nested::upgrade_uefi[821.1-83b2]")),
138+
pytest.mark.continuation_of(dict(vm="vm 1",
139+
test="TestNested::test_upgrade_uefi[821.1-83b2]")),
142140
]),
143141
pytest.param("83b2", marks=[
144-
pytest.mark.dependency(depends=["TestNested::test_install_uefi[83b2]"]),
145-
pytest.mark.vm_definitions(
146-
dict(name="vm 1", image="install/test::Nested::install_uefi[83b2]")),
142+
pytest.mark.continuation_of(dict(vm="vm 1",
143+
test="TestNested::test_install_uefi[83b2]")),
147144
]),
148145
# 8.3b2 disabled the upgrade from 8.3
149146
#pytest.param("83b2_83b2", marks=[
150-
# pytest.mark.dependency(depends=["TestNested::test_upgrade_uefi[83b2-83b2]"]),
151-
# pytest.mark.vm_definitions(
152-
# dict(name="vm 1", image="install/test::Nested::upgrade_uefi[83b2-83b2]")),
147+
# pytest.mark.continuation_of(dict(vm="vm 1",
148+
# test="TestNested::test_upgrade_uefi[83b2-83b2]")),
153149
#]),
154150
])
155151
def test_firstboot_uefi(self, request, create_vms, mode):
@@ -251,22 +247,20 @@ def test_firstboot_uefi(self, request, create_vms, mode):
251247
host_vm.host.ssh(["rm -f", xva_name])
252248
host_vm.export(xva_name, "zstd", use_cache=CACHE_IMPORTED_VM)
253249

250+
@pytest.mark.usefixtures("xcpng_chained")
254251
@pytest.mark.parametrize(("orig_version", "version"), [
255252
pytest.param("821.1", "821.1", marks=[
256-
pytest.mark.dependency(depends=["TestNested::test_firstboot_uefi[821.1]"]),
257-
pytest.mark.vm_definitions(
258-
dict(name="vm 1", image="install/test::Nested::firstboot_uefi[821.1]")),
253+
pytest.mark.continuation_of(dict(vm="vm 1",
254+
test="TestNested::test_firstboot_uefi[821.1]")),
259255
]),
260256
pytest.param("821.1", "83b2", marks=[
261-
pytest.mark.dependency(depends=["TestNested::test_firstboot_uefi[821.1]"]),
262-
pytest.mark.vm_definitions(
263-
dict(name="vm 1", image="install/test::Nested::firstboot_uefi[821.1]")),
257+
pytest.mark.continuation_of(dict(vm="vm 1",
258+
test="TestNested::test_firstboot_uefi[821.1]")),
264259
]),
265260
# 8.3b2 disabled the upgrade from 8.3
266261
#pytest.param("83b2", "83b2", marks=[
267-
# pytest.mark.dependency(depends=["TestNested::test_firstboot_uefi[83b2]"]),
268-
# pytest.mark.vm_definitions(
269-
# dict(name="vm 1", image="install/test::Nested::firstboot_uefi[83b2]")),
262+
# pytest.mark.continuation_of(dict(vm="vm 1",
263+
# test="TestNested::test_firstboot_uefi[83b2]")),
270264
#]),
271265
])
272266
@pytest.mark.answerfile(

0 commit comments

Comments
 (0)