Skip to content

Commit

Permalink
WIP XVA names depend on test name
Browse files Browse the repository at this point in the history
FIXME: should be folded into other commits?
  • Loading branch information
ydirson committed Jun 19, 2024
1 parent 9904672 commit ca026b2
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 22 deletions.
13 changes: 13 additions & 0 deletions lib/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ def prefix_object_name(label):
name_prefix = f"[{getpass.getuser()}]"
return f"{name_prefix} {label}"

def shortened_nodeid(nodeid):
components = nodeid.split("::")
# module
components[0] = strip_prefix(components[0], "tests/")
components[0] = strip_suffix(components[0], ".py")
# function
components[-1] = strip_prefix(components[-1], "test_")
# class
if len(components) > 2:
components[1] = strip_prefix(components[1], "Test")

return "::".join(components)

def wait_for(fn, msg=None, timeout_secs=2 * 60, retry_delay_secs=2, invert=False):
if msg is not None:
logging.info(msg)
Expand Down
46 changes: 24 additions & 22 deletions tests/install/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import time

from lib import commands, pxe
from lib.common import wait_for
from lib.common import shortened_nodeid, wait_for
from lib.host import Host
from lib.pool import Pool

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


@pytest.mark.parametrize("base", [
pytest.param("install", marks=pytest.mark.dependency(
depends=["TestNested::test_install_821_uefi"])),
pytest.param("upgrade", marks=pytest.mark.dependency(
depends=["TestNested::test_upgrade_821_uefi"])),
pytest.param("install", marks=[
pytest.mark.dependency(depends=["TestNested::test_install_821_uefi"]),
pytest.mark.vm_definitions(
dict(name="vm 1", image="install/test::Nested::install_821_uefi")),
]),
pytest.param("upgrade", marks=[
pytest.mark.dependency(depends=["TestNested::test_upgrade_821_uefi"]),
pytest.mark.vm_definitions(
dict(name="vm 1", image="install/test::Nested::upgrade_821_uefi")),
]),
])
@pytest.mark.vm_definitions(
dict(name="vm 1",
image="test_install_821_uefi-vm1.xva"
))
def test_firstboot_821_uefi(self, create_vms, base):
def test_firstboot_821_uefi(self, request, create_vms, base):
host_vm = create_vms[0]
vif = host_vm.vifs()[0]
mac_address = vif.param_get('MAC')
Expand Down Expand Up @@ -232,14 +234,14 @@ def test_firstboot_821_uefi(self, create_vms, base):
# record this state
# FIXME move to fixture
# FIXME where to store?
host_vm.host.ssh(["rm -f test_firstboot_821_uefi-vm1.xva"])
host_vm.export("test_firstboot_821_uefi-vm1.xva", "zstd",
use_cache=CACHE_IMPORTED_VM)
xva_name = shortened_nodeid(request.node.nodeid) + ".xva"
host_vm.host.ssh(["rm -f", xva_name])
host_vm.export(xva_name, "zstd", use_cache=CACHE_IMPORTED_VM)

@pytest.mark.dependency(depends=["TestNested::test_firstboot_821_uefi[install]"])
@pytest.mark.vm_definitions(
dict(name="vm 1",
image="test_firstboot_821_uefi-vm1.xva"
image="install/test::Nested::firstboot_821_uefi[install]"
))
@pytest.mark.answerfile(
{
Expand All @@ -248,7 +250,7 @@ def test_firstboot_821_uefi(self, create_vms, base):
"existing-installation": {"text": "nvme0n1"},
})
@pytest.mark.installer_iso("xcpng-8.2.1-2023")
def test_upgrade_821_uefi(self, iso_remaster, create_vms):
def test_upgrade_821_uefi(self, request, iso_remaster, create_vms):
host_vm = create_vms[0]
vif = host_vm.vifs()[0]
mac_address = vif.param_get('MAC')
Expand Down Expand Up @@ -328,6 +330,6 @@ def test_upgrade_821_uefi(self, iso_remaster, create_vms):
# record this state
# FIXME move to fixture
# FIXME where to store?
host_vm.host.ssh(["rm -f test_upgrade_821_uefi-vm1.xva"])
host_vm.export("test_upgrade_821_uefi-vm1.xva", "zstd",
use_cache=CACHE_IMPORTED_VM)
xva_name = shortened_nodeid(request.node.nodeid) + ".xva"
host_vm.host.ssh(["rm -f", xva_name])
host_vm.export(xva_name, "zstd", use_cache=CACHE_IMPORTED_VM)

0 comments on commit ca026b2

Please sign in to comment.