Skip to content

Commit dc30149

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

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
@@ -378,16 +378,21 @@ def create_vms(request, host):
378378
raise Exception("No vm_definitions marker specified.")
379379
for marker in markers.args:
380380
assert "name" in marker
381-
assert "template" in marker
382-
# FIXME should check optional vdis contents
381+
assert "template" in marker or "image" in marker
382+
if "template" in marker:
383+
assert not "image" in marker
384+
# FIXME should check optional vdis contents
383385
# FIXME should check for extra args
384386

385387
try:
386388
vms = []
387389
vdis = []
388390
vbds = []
389391
for marker in markers.args:
390-
_create_vm(marker, host, vms, vdis, vbds)
392+
if "template" in marker:
393+
_create_vm(marker, host, vms, vdis, vbds)
394+
elif "image" in marker:
395+
_import_vm(marker, host, vms)
391396
yield vms
392397

393398
except Exception:
@@ -435,6 +440,12 @@ def _create_vm(marker, host, vms, vdis, vbds):
435440
logging.info("Setting param %s", param_def)
436441
vm.param_set(**param_def)
437442

443+
def _import_vm(marker, host, vms):
444+
vm_name = marker["name"]
445+
vm_image = marker["image"]
446+
vm = host.import_vm(vm_image)
447+
vms.append(vm)
448+
438449
@pytest.fixture(scope="module")
439450
def running_vm(imported_vm):
440451
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)