Skip to content

Commit 83ff609

Browse files
committed
WIP don't export on failure
should likely be part of the "fixup! WIP export to XVA after install"
1 parent a189b01 commit 83ff609

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

conftest.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -446,12 +446,19 @@ def create_vms(request, host):
446446
_import_vm(vm_def, host, vms, use_cache=CACHE_IMPORTED_VM)
447447
yield vms
448448

449-
# record this state
450-
for vm_def, vm in zip(vm_defs, vms):
451-
# FIXME where to store?
452-
xva_name = f"{shortened_nodeid(request.node.nodeid)}-{vm_def['name']}.xva"
453-
host.ssh(["rm -f", xva_name])
454-
vm.export(xva_name, "zstd", use_cache=CACHE_IMPORTED_VM)
449+
# request.node is an "item" because this fixture has "function" scope
450+
report = request.node.stash[PHASE_REPORT_KEY]
451+
if report["setup"].failed:
452+
logging.warning("setting up a test failed or skipped: not exporting VMs")
453+
elif ("call" not in report) or report["call"].failed:
454+
logging.warning("executing test failed or skipped: not exporting VMs")
455+
else:
456+
# record this state
457+
for vm_def, vm in zip(vm_defs, vms):
458+
# FIXME where to store?
459+
xva_name = f"{shortened_nodeid(request.node.nodeid)}-{vm_def['name']}.xva"
460+
host.ssh(["rm -f", xva_name])
461+
vm.export(xva_name, "zstd", use_cache=CACHE_IMPORTED_VM)
455462

456463
except Exception:
457464
logging.error("exception caught...")

0 commit comments

Comments
 (0)