Skip to content

Commit ca026b2

Browse files
committed
WIP XVA names depend on test name
FIXME: should be folded into other commits?
1 parent 9904672 commit ca026b2

File tree

2 files changed

+37
-22
lines changed

2 files changed

+37
-22
lines changed

lib/common.py

+13
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,19 @@ def prefix_object_name(label):
3030
name_prefix = f"[{getpass.getuser()}]"
3131
return f"{name_prefix} {label}"
3232

33+
def shortened_nodeid(nodeid):
34+
components = nodeid.split("::")
35+
# module
36+
components[0] = strip_prefix(components[0], "tests/")
37+
components[0] = strip_suffix(components[0], ".py")
38+
# function
39+
components[-1] = strip_prefix(components[-1], "test_")
40+
# class
41+
if len(components) > 2:
42+
components[1] = strip_prefix(components[1], "Test")
43+
44+
return "::".join(components)
45+
3346
def wait_for(fn, msg=None, timeout_secs=2 * 60, retry_delay_secs=2, invert=False):
3447
if msg is not None:
3548
logging.info(msg)

tests/install/test.py

+24-22
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import time
55

66
from lib import commands, pxe
7-
from lib.common import wait_for
7+
from lib.common import shortened_nodeid, wait_for
88
from lib.host import Host
99
from lib.pool import Pool
1010

@@ -39,7 +39,7 @@ class TestNested:
3939
"primary-disk": {"text": "nvme0n1"},
4040
})
4141
@pytest.mark.installer_iso("xcpng-8.2.1-2023")
42-
def test_install_821_uefi(self, iso_remaster, create_vms):
42+
def test_install_821_uefi(self, request, iso_remaster, create_vms):
4343
assert len(create_vms) == 1
4444
host_vm = create_vms[0]
4545
# FIXME should be part of vm def
@@ -117,22 +117,24 @@ def test_install_821_uefi(self, iso_remaster, create_vms):
117117
# record this state
118118
# FIXME move to fixture
119119
# FIXME where to store?
120-
host_vm.host.ssh(["rm -f test_install_821_uefi-vm1.xva"])
121-
host_vm.export("test_install_821_uefi-vm1.xva", "zstd",
122-
use_cache=CACHE_IMPORTED_VM)
120+
xva_name = shortened_nodeid(request.node.nodeid) + ".xva"
121+
host_vm.host.ssh(["rm -f", xva_name])
122+
host_vm.export(xva_name, "zstd", use_cache=CACHE_IMPORTED_VM)
123123

124124

125125
@pytest.mark.parametrize("base", [
126-
pytest.param("install", marks=pytest.mark.dependency(
127-
depends=["TestNested::test_install_821_uefi"])),
128-
pytest.param("upgrade", marks=pytest.mark.dependency(
129-
depends=["TestNested::test_upgrade_821_uefi"])),
126+
pytest.param("install", marks=[
127+
pytest.mark.dependency(depends=["TestNested::test_install_821_uefi"]),
128+
pytest.mark.vm_definitions(
129+
dict(name="vm 1", image="install/test::Nested::install_821_uefi")),
130+
]),
131+
pytest.param("upgrade", marks=[
132+
pytest.mark.dependency(depends=["TestNested::test_upgrade_821_uefi"]),
133+
pytest.mark.vm_definitions(
134+
dict(name="vm 1", image="install/test::Nested::upgrade_821_uefi")),
135+
]),
130136
])
131-
@pytest.mark.vm_definitions(
132-
dict(name="vm 1",
133-
image="test_install_821_uefi-vm1.xva"
134-
))
135-
def test_firstboot_821_uefi(self, create_vms, base):
137+
def test_firstboot_821_uefi(self, request, create_vms, base):
136138
host_vm = create_vms[0]
137139
vif = host_vm.vifs()[0]
138140
mac_address = vif.param_get('MAC')
@@ -232,14 +234,14 @@ def test_firstboot_821_uefi(self, create_vms, base):
232234
# record this state
233235
# FIXME move to fixture
234236
# FIXME where to store?
235-
host_vm.host.ssh(["rm -f test_firstboot_821_uefi-vm1.xva"])
236-
host_vm.export("test_firstboot_821_uefi-vm1.xva", "zstd",
237-
use_cache=CACHE_IMPORTED_VM)
237+
xva_name = shortened_nodeid(request.node.nodeid) + ".xva"
238+
host_vm.host.ssh(["rm -f", xva_name])
239+
host_vm.export(xva_name, "zstd", use_cache=CACHE_IMPORTED_VM)
238240

239241
@pytest.mark.dependency(depends=["TestNested::test_firstboot_821_uefi[install]"])
240242
@pytest.mark.vm_definitions(
241243
dict(name="vm 1",
242-
image="test_firstboot_821_uefi-vm1.xva"
244+
image="install/test::Nested::firstboot_821_uefi[install]"
243245
))
244246
@pytest.mark.answerfile(
245247
{
@@ -248,7 +250,7 @@ def test_firstboot_821_uefi(self, create_vms, base):
248250
"existing-installation": {"text": "nvme0n1"},
249251
})
250252
@pytest.mark.installer_iso("xcpng-8.2.1-2023")
251-
def test_upgrade_821_uefi(self, iso_remaster, create_vms):
253+
def test_upgrade_821_uefi(self, request, iso_remaster, create_vms):
252254
host_vm = create_vms[0]
253255
vif = host_vm.vifs()[0]
254256
mac_address = vif.param_get('MAC')
@@ -328,6 +330,6 @@ def test_upgrade_821_uefi(self, iso_remaster, create_vms):
328330
# record this state
329331
# FIXME move to fixture
330332
# FIXME where to store?
331-
host_vm.host.ssh(["rm -f test_upgrade_821_uefi-vm1.xva"])
332-
host_vm.export("test_upgrade_821_uefi-vm1.xva", "zstd",
333-
use_cache=CACHE_IMPORTED_VM)
333+
xva_name = shortened_nodeid(request.node.nodeid) + ".xva"
334+
host_vm.host.ssh(["rm -f", xva_name])
335+
host_vm.export(xva_name, "zstd", use_cache=CACHE_IMPORTED_VM)

0 commit comments

Comments
 (0)