Skip to content

Commit 0b125e1

Browse files
committed
WIP export to XVA after install, and use it for separate firstboot test
FIXME: - settle for a location to save XVA? - move to fixture
1 parent 126f9e3 commit 0b125e1

File tree

2 files changed

+51
-8
lines changed

2 files changed

+51
-8
lines changed

conftest.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,16 +394,21 @@ def create_vms(request, host):
394394
raise Exception("No vm_definitions marker specified.")
395395
for vm_def in marker.args:
396396
assert "name" in vm_def
397-
assert "template" in vm_def
398-
# FIXME should check optional vdis contents
397+
assert "template" in vm_def or "image" in vm_def
398+
if "template" in vm_def:
399+
assert not "image" in vm_def
400+
# FIXME should check optional vdis contents
399401
# FIXME should check for extra args
400402

401403
try:
402404
vms = []
403405
vdis = []
404406
vbds = []
405407
for vm_def in marker.args:
406-
_create_vm(vm_def, host, vms, vdis, vbds)
408+
if "template" in vm_def:
409+
_create_vm(vm_def, host, vms, vdis, vbds)
410+
elif "image" in vm_def:
411+
_import_vm(vm_def, host, vms)
407412
yield vms
408413

409414
except Exception:
@@ -451,6 +456,12 @@ def _create_vm(marker, host, vms, vdis, vbds):
451456
logging.info("Setting param %s", param_def)
452457
vm.param_set(**param_def)
453458

459+
def _import_vm(marker, host, vms):
460+
vm_name = marker["name"]
461+
vm_image = marker["image"]
462+
vm = host.import_vm(vm_image)
463+
vms.append(vm)
464+
454465
@pytest.fixture(scope="module")
455466
def running_vm(imported_vm):
456467
vm = imported_vm

tests/install/test.py

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,8 @@ def test_install_821_uefi(self, iso_remaster, create_vms):
8383
).returncode == 1,
8484
"Wait for installer to terminate")
8585

86-
# powercycle, catch any change of IP
8786
logging.info("Shutting down Host VM after successful installation")
8887
try:
89-
# use "poweroff" because "reboot" would cause ARP and
90-
# SSH to be checked before host is down, and require
91-
# ssh retries
9288
host_vm.ssh(["poweroff"])
9389
except commands.SSHCommandFailed as e:
9490
# ignore connection closed by reboot
@@ -100,12 +96,42 @@ def test_install_821_uefi(self, iso_remaster, create_vms):
10096
wait_for(host_vm.is_halted, "Wait for host VM halted")
10197
host_vm.eject_cd()
10298

103-
# 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_821_uefi-vm1.xva"])
114+
host_vm.export("test_install_821_uefi-vm1.xva", "zstd")
104115

116+
@pytest.mark.vm_definitions(
117+
dict(name="vm 1",
118+
image="test_install_821_uefi-vm1.xva"
119+
))
120+
def test_firstboot_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:
105127
# FIXME: evict MAC from ARP cache first?
106128
host_vm.start()
107129
wait_for(host_vm.is_running, "Wait for host VM running")
108130

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)
109135
ips = pxe.arp_addresses_for(mac_address)
110136
logging.info("Host VM has IPs %s", ips)
111137
assert len(ips) == 1
@@ -187,3 +213,9 @@ def test_install_821_uefi(self, iso_remaster, create_vms):
187213
# wait_for(lambda: False, 'Wait "forever"', timeout_secs=100*60)
188214
host_vm.shutdown(force=True)
189215
raise
216+
217+
# record this state
218+
# FIXME move to fixture
219+
# FIXME where to store?
220+
host_vm.host.ssh(["rm -f test_firstboot_821_uefi-vm1.xva"])
221+
host_vm.export("test_firstboot_821_uefi-vm1.xva", "zstd")

0 commit comments

Comments
 (0)