Skip to content

Commit 35e961f

Browse files
committed
WIP export to XVA after install, and use it for separate firstboot test
1 parent c745cf7 commit 35e961f

File tree

2 files changed

+45
-4
lines changed

2 files changed

+45
-4
lines changed

conftest.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,16 +347,21 @@ def create_vms(request, host):
347347
raise Exception("No vm_definitions marker specified.")
348348
for marker in markers.args:
349349
assert "name" in marker
350-
assert "template" in marker
351-
# FIXME should check optional vdis contents
350+
assert "template" in marker or "image" in marker
351+
if "template" in marker:
352+
assert not "image" in marker
353+
# FIXME should check optional vdis contents
352354
# FIXME should check for extra args
353355

354356
try:
355357
vms = []
356358
vdis = []
357359
vbds = []
358360
for marker in markers.args:
359-
_create_vm(marker, host, vms, vdis, vbds)
361+
if "template" in marker:
362+
_create_vm(marker, host, vms, vdis, vbds)
363+
elif "image" in marker:
364+
_import_vm(marker, host, vms)
360365
yield vms
361366

362367
except Exception:
@@ -404,6 +409,12 @@ def _create_vm(marker, host, vms, vdis, vbds):
404409
logging.info("Setting param %s", param_def)
405410
vm.param_set(**param_def)
406411

412+
def _import_vm(marker, host, vms):
413+
vm_name = marker["name"]
414+
vm_image = marker["image"]
415+
vm = host.import_vm(vm_image)
416+
vms.append(vm)
417+
407418
@pytest.fixture(scope="module")
408419
def running_vm(imported_vm):
409420
vm = imported_vm

tests/install/test_install.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,42 @@ def test_install_nested_821_uefi(self, iso_remaster, create_vms):
9696
wait_for(host_vm.is_halted, "Wait for host VM halted")
9797
host_vm.eject_cd()
9898

99-
# FIXME: make a snapshot here
99+
except Exception as e:
100+
logging.critical("caught exception %s", e)
101+
# wait_for(lambda: False, 'Wait "forever"', timeout_secs=100*60)
102+
host_vm.shutdown(force=True)
103+
raise
104+
except KeyboardInterrupt:
105+
logging.warning("keyboard interrupt")
106+
# wait_for(lambda: False, 'Wait "forever"', timeout_secs=100*60)
107+
host_vm.shutdown(force=True)
108+
raise
109+
110+
# record this state
111+
# FIXME move to fixture
112+
# FIXME where to store?
113+
host_vm.host.ssh(["rm -f test_install_nested_821_uefi-vm1.xva"])
114+
host_vm.export("test_install_nested_821_uefi-vm1.xva", "zstd")
100115

116+
@pytest.mark.vm_definitions(
117+
dict(name="vm 1",
118+
image="test_install_nested_821_uefi-vm1.xva"
119+
))
120+
def test_firstboot_nested_821_uefi(self, create_vms):
121+
host_vm = create_vms[0]
122+
vif = host_vm.vifs()[0]
123+
mac_address = vif.param_get('MAC')
124+
logging.info("Host VM has MAC %s", mac_address)
125+
126+
try:
101127
# FIXME: evict MAC from ARP cache first?
102128
host_vm.start()
103129
wait_for(host_vm.is_running, "Wait for host VM running")
104130

131+
# catch host-vm IP address
132+
wait_for(lambda: pxe.arp_addresses_for(mac_address),
133+
"Wait for DHCP server to see Host VM in ARP tables",
134+
timeout_secs=10*60)
105135
ips = pxe.arp_addresses_for(mac_address)
106136
logging.info("Host VM has IPs %s", ips)
107137
assert len(ips) == 1

0 commit comments

Comments
 (0)