Skip to content

Commit 695b5bc

Browse files
committed
tests: Add option to specify path for snapshot artifacts
Previously, it would always use the same file names, which makes taking two snapshots from the same microvm slightly tedious (as the first snapshot has to be copied out before making the second snapshot). Signed-off-by: Patrick Roy <[email protected]>
1 parent 49f0057 commit 695b5bc

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

tests/framework/microvm.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -807,13 +807,20 @@ def resume(self):
807807
"""Resume the microVM"""
808808
self.api.vm.patch(state="Resumed")
809809

810-
def make_snapshot(self, snapshot_type: SnapshotType | str):
810+
def make_snapshot(
811+
self,
812+
snapshot_type: SnapshotType | str,
813+
*,
814+
mem_path: str = "mem",
815+
vmstate_path="vmstate",
816+
):
811817
"""Create a Snapshot object from a microvm.
812818
819+
The snapshot's memory and vstate files will be saved at the specified paths
820+
relative to the Microvm's chroot.
821+
813822
It pauses the microvm before taking the snapshot.
814823
"""
815-
vmstate_path = "vmstate"
816-
mem_path = "mem"
817824
snapshot_type = SnapshotType(snapshot_type)
818825
self.pause()
819826
self.api.snapshot_create.put(
@@ -831,13 +838,13 @@ def make_snapshot(self, snapshot_type: SnapshotType | str):
831838
snapshot_type=snapshot_type,
832839
)
833840

834-
def snapshot_diff(self):
841+
def snapshot_diff(self, *, mem_path: str = "mem", vmstate_path="vmstate"):
835842
"""Make a Diff snapshot"""
836-
return self.make_snapshot("Diff")
843+
return self.make_snapshot("Diff", mem_path=mem_path, vmstate_path=vmstate_path)
837844

838-
def snapshot_full(self):
845+
def snapshot_full(self, *, mem_path: str = "mem", vmstate_path="vmstate"):
839846
"""Make a Full snapshot"""
840-
return self.make_snapshot("Full")
847+
return self.make_snapshot("Full", mem_path=mem_path, vmstate_path=vmstate_path)
841848

842849
def restore_from_snapshot(
843850
self,

0 commit comments

Comments
 (0)