Skip to content

Commit 5f347e2

Browse files
committed
Simplify test and add expected failure case
Adding an expected failure case to ensure that the renaming code is not silently failing. Signed-off-by: Andrew Laucius <[email protected]>
1 parent b138302 commit 5f347e2

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

tests/integration_tests/functional/test_snapshot_basic.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -616,20 +616,25 @@ def test_snapshot_rename_interface(uvm_nano, microvm_factory):
616616
vm.start()
617617

618618
snapshot = vm.snapshot_full()
619-
620-
restored_vm = microvm_factory.build()
621-
restored_vm.spawn()
622-
iface2 = dataclasses.replace(base_iface, tap_name="tap2")
623-
624619
# The snapshot.net_faces is used by the test framework to create the
625620
# appropriate tap devices on the host; we replace those here with the new
626-
# name, otherwise the framework would create `tap1` when restoring the
627-
# snapshot
621+
# name.
622+
iface2 = dataclasses.replace(base_iface, tap_name="tap-restore")
628623
snapshot.net_ifaces.clear()
629624
snapshot.net_ifaces.append(iface2)
630625

626+
# Verify that the vm will not restore with the default interface name
627+
restored_vm_bad = microvm_factory.build()
628+
restored_vm_bad.spawn()
629+
with pytest.raises(RuntimeError):
630+
restored_vm_bad.restore_from_snapshot(snapshot, resume=True)
631+
restored_vm_bad.mark_killed()
632+
633+
restored_vm = microvm_factory.build()
634+
restored_vm.spawn()
631635
restored_vm.restore_from_snapshot(
632-
snapshot, rename_interfaces={base_iface.dev_name: "tap2"}
636+
snapshot,
637+
rename_interfaces={base_iface.dev_name: "tap-restore"},
638+
resume=True
633639
)
634-
restored_vm.resume()
635640
restored_vm.wait_for_ssh_up()

0 commit comments

Comments
 (0)