Skip to content

Commit 155e2d6

Browse files
committed
test: introduce Microvm.mark_killed()
Call this method on microvms that have met an untimely demise during test execution (for example, because we are specifically testing that firecracker exits correctly after receiving a signal). The function raises an exception if the Firecracker process is not actually dead, to avoid leaking processes. Signed-off-by: Patrick Roy <[email protected]>
1 parent fb9c567 commit 155e2d6

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tests/framework/microvm.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,17 @@ def __init__(
255255
def __repr__(self):
256256
return f"<Microvm id={self.id}>"
257257

258+
def mark_killed(self):
259+
"""
260+
Marks this `Microvm` as killed, meaning test tear down should not try to kill it
261+
262+
raises an exception if the Firecracker process managing this VM is not actually dead
263+
"""
264+
if self.firecracker_pid is not None:
265+
utils.wait_process_termination(self.firecracker_pid)
266+
267+
self._killed = True
268+
258269
def kill(self):
259270
"""All clean up associated with this microVM should go here."""
260271
# pylint: disable=subprocess-run-check

0 commit comments

Comments
 (0)