diff --git a/conftest.py b/conftest.py index 7343b6c42..77aab9b03 100644 --- a/conftest.py +++ b/conftest.py @@ -494,8 +494,10 @@ 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: @@ -503,7 +505,10 @@ def create_vms(request, host): 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: @@ -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 diff --git a/tests/install/test_install.py b/tests/install/test_install.py index 6e650d294..e1d7aa86b 100644 --- a/tests/install/test_install.py +++ b/tests/install/test_install.py @@ -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