Skip to content

Commit 9d4c415

Browse files
committed
WIP XVA names depend on test name
FIXME: should be folded into other commits?
1 parent 13b93ee commit 9d4c415

File tree

2 files changed

+37
-22
lines changed

2 files changed

+37
-22
lines changed

lib/common.py

Lines changed: 13 additions & 0 deletions
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

Lines changed: 24 additions & 22 deletions
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')
@@ -227,14 +229,14 @@ def test_firstboot_821_uefi(self, create_vms, base):
227229
# record this state
228230
# FIXME move to fixture
229231
# FIXME where to store?
230-
host_vm.host.ssh(["rm -f test_firstboot_821_uefi-vm1.xva"])
231-
host_vm.export("test_firstboot_821_uefi-vm1.xva", "zstd",
232-
use_cache=CACHE_IMPORTED_VM)
232+
xva_name = shortened_nodeid(request.node.nodeid) + ".xva"
233+
host_vm.host.ssh(["rm -f", xva_name])
234+
host_vm.export(xva_name, "zstd", use_cache=CACHE_IMPORTED_VM)
233235

234236
@pytest.mark.dependency(depends=["TestNested::test_firstboot_821_uefi[install]"])
235237
@pytest.mark.vm_definitions(
236238
dict(name="vm 1",
237-
image="test_firstboot_821_uefi-vm1.xva"
239+
image="install/test::Nested::firstboot_821_uefi[install]"
238240
))
239241
@pytest.mark.answerfile(
240242
{
@@ -243,7 +245,7 @@ def test_firstboot_821_uefi(self, create_vms, base):
243245
"existing-installation": {"text": "nvme0n1"},
244246
})
245247
@pytest.mark.installer_iso("xcpng-8.2.1-2023")
246-
def test_upgrade_821_uefi(self, iso_remaster, create_vms):
248+
def test_upgrade_821_uefi(self, request, iso_remaster, create_vms):
247249
host_vm = create_vms[0]
248250
vif = host_vm.vifs()[0]
249251
mac_address = vif.param_get('MAC')
@@ -323,6 +325,6 @@ def test_upgrade_821_uefi(self, iso_remaster, create_vms):
323325
# record this state
324326
# FIXME move to fixture
325327
# FIXME where to store?
326-
host_vm.host.ssh(["rm -f test_upgrade_821_uefi-vm1.xva"])
327-
host_vm.export("test_upgrade_821_uefi-vm1.xva", "zstd",
328-
use_cache=CACHE_IMPORTED_VM)
328+
xva_name = shortened_nodeid(request.node.nodeid) + ".xva"
329+
host_vm.host.ssh(["rm -f", xva_name])
330+
host_vm.export(xva_name, "zstd", use_cache=CACHE_IMPORTED_VM)

0 commit comments

Comments
 (0)