Skip to content

Commit 64d0e9c

Browse files
committed
WIP export to XVA after install, and use it for separate firstboot test
1 parent 54dd773 commit 64d0e9c

File tree

2 files changed

+47
-4
lines changed

2 files changed

+47
-4
lines changed

conftest.py

+14-3
Original file line numberDiff line numberDiff line change
@@ -494,16 +494,21 @@ def create_vms(request, host):
494494
raise Exception("No vm_definitions marker specified.")
495495
for marker in markers.args:
496496
assert "name" in marker
497-
assert "template" in marker
498-
# FIXME should check optional vdis contents
497+
assert "template" in marker or "image" in marker
498+
if "template" in marker:
499+
assert not "image" in marker
500+
# FIXME should check optional vdis contents
499501
# FIXME should check for extra args
500502

501503
try:
502504
vms = []
503505
vdis = []
504506
vbds = []
505507
for marker in markers.args:
506-
_create_vm(marker, host, vms, vdis, vbds)
508+
if "template" in marker:
509+
_create_vm(marker, host, vms, vdis, vbds)
510+
elif "image" in marker:
511+
_import_vm(marker, host, vms)
507512
yield vms
508513

509514
except Exception:
@@ -551,6 +556,12 @@ def _create_vm(marker, host, vms, vdis, vbds):
551556
logging.info("Setting param %s", param_def)
552557
vm.param_set(**param_def)
553558

559+
def _import_vm(marker, host, vms):
560+
vm_name = marker["name"]
561+
vm_image = marker["image"]
562+
vm = host.import_vm(vm_image)
563+
vms.append(vm)
564+
554565
@pytest.fixture(scope="module")
555566
def running_vm(imported_vm):
556567
vm = imported_vm

tests/install/test_install.py

+33-1
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,44 @@ def test_install_nested_821_uefi(self, iso_remaster, create_vms):
9292
wait_for(host_vm.is_halted, "Wait for host VM halted")
9393
host_vm.eject_cd()
9494

95-
# FIXME: make a snapshot here
95+
except Exception as e:
96+
logging.critical("caught exception %s", e)
97+
# wait_for(lambda: False, 'Wait "forever"', timeout_secs=100*60)
98+
host_vm.shutdown(force=True)
99+
raise
100+
except KeyboardInterrupt:
101+
logging.warning("keyboard interrupt")
102+
# wait_for(lambda: False, 'Wait "forever"', timeout_secs=100*60)
103+
host_vm.shutdown(force=True)
104+
raise
105+
106+
# record this state
107+
# FIXME move to fixture
108+
# FIXME where to store?
109+
host_vm.host.ssh(["rm -f test_install_nested_821_uefi-vm1.xva"])
110+
host_vm.export("test_install_nested_821_uefi-vm1.xva", "zstd")
111+
112+
@pytest.mark.vm_definitions(
113+
dict(name="vm 1",
114+
image="test_install_nested_821_uefi-vm1.xva"
115+
))
116+
def test_firstboot_nested_821_uefi(self, create_vms):
117+
assert len(create_vms) == 1
118+
host_vm = create_vms[0]
96119

120+
vif = host_vm.vifs()[0]
121+
mac_address = vif.param_get('MAC')
122+
logging.info("Host VM has MAC %s", mac_address)
123+
124+
try:
97125
# FIXME: evict MAC from ARP cache first?
98126
host_vm.start()
99127
wait_for(host_vm.is_running, "Wait for host VM running")
100128

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

0 commit comments

Comments
 (0)