Skip to content

Commit

Permalink
WIP export to XVA after install, and use it for separate firstboot test
Browse files Browse the repository at this point in the history
  • Loading branch information
ydirson committed May 23, 2024
1 parent 54dd773 commit 64d0e9c
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 4 deletions.
17 changes: 14 additions & 3 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,16 +494,21 @@ def create_vms(request, host):
raise Exception("No vm_definitions marker specified.")
for marker in markers.args:
assert "name" in marker
assert "template" in marker
# FIXME should check optional vdis contents
assert "template" in marker or "image" in marker
if "template" in marker:
assert not "image" in marker
# FIXME should check optional vdis contents
# FIXME should check for extra args

try:
vms = []
vdis = []
vbds = []
for marker in markers.args:
_create_vm(marker, host, vms, vdis, vbds)
if "template" in marker:
_create_vm(marker, host, vms, vdis, vbds)
elif "image" in marker:
_import_vm(marker, host, vms)
yield vms

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

def _import_vm(marker, host, vms):
vm_name = marker["name"]
vm_image = marker["image"]
vm = host.import_vm(vm_image)
vms.append(vm)

@pytest.fixture(scope="module")
def running_vm(imported_vm):
vm = imported_vm
Expand Down
34 changes: 33 additions & 1 deletion tests/install/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,44 @@ def test_install_nested_821_uefi(self, iso_remaster, create_vms):
wait_for(host_vm.is_halted, "Wait for host VM halted")
host_vm.eject_cd()

# FIXME: make a snapshot here
except Exception as e:
logging.critical("caught exception %s", e)
# wait_for(lambda: False, 'Wait "forever"', timeout_secs=100*60)
host_vm.shutdown(force=True)
raise
except KeyboardInterrupt:
logging.warning("keyboard interrupt")
# wait_for(lambda: False, 'Wait "forever"', timeout_secs=100*60)
host_vm.shutdown(force=True)
raise

# record this state
# FIXME move to fixture
# FIXME where to store?
host_vm.host.ssh(["rm -f test_install_nested_821_uefi-vm1.xva"])
host_vm.export("test_install_nested_821_uefi-vm1.xva", "zstd")

@pytest.mark.vm_definitions(
dict(name="vm 1",
image="test_install_nested_821_uefi-vm1.xva"
))
def test_firstboot_nested_821_uefi(self, create_vms):
assert len(create_vms) == 1
host_vm = create_vms[0]

vif = host_vm.vifs()[0]
mac_address = vif.param_get('MAC')
logging.info("Host VM has MAC %s", mac_address)

try:
# FIXME: evict MAC from ARP cache first?
host_vm.start()
wait_for(host_vm.is_running, "Wait for host VM running")

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

0 comments on commit 64d0e9c

Please sign in to comment.