Skip to content

Commit 2c5a3a0

Browse files
committed
fix(test): don't try to kill after CtrlAltDel
In test test_send_ctrl_alt_del we send a CTRL+ALT+DEL to the microVM, which, in x86, makes the microVM to shutdown. Then we send a signal to the Firecracker process with `os.kill(firecracker_pid, 0)` and wait for it to fail. This works but logs an error in the test logs which can be confusing. Instead we can call os.waitpid() which waits for the Firecracker process to exit and returns immediately if the process has already exited. Signed-off-by: Babis Chalios <[email protected]>
1 parent 25e3dbf commit 2c5a3a0

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

tests/integration_tests/functional/test_api.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -795,19 +795,13 @@ def test_send_ctrl_alt_del(test_microvm_with_api):
795795

796796
# If everything goes as expected, the guest OS will issue a reboot,
797797
# causing Firecracker to exit.
798-
# We'll keep poking Firecracker for at most 30 seconds, waiting for it
799-
# to die.
800-
start_time = time.time()
801-
shutdown_ok = False
802-
while time.time() - start_time < 30:
803-
try:
804-
os.kill(firecracker_pid, 0)
805-
time.sleep(0.01)
806-
except OSError:
807-
shutdown_ok = True
808-
break
809-
810-
assert shutdown_ok
798+
# waitpid should block until the Firecracker process has exited. If
799+
# it has already exited by the time we call waitpid, WNOHANG causes
800+
# waitpid to raise a ChildProcessError exception.
801+
try:
802+
os.waitpid(firecracker_pid, os.WNOHANG)
803+
except ChildProcessError:
804+
pass
811805

812806

813807
def _drive_patch(test_microvm):

0 commit comments

Comments
 (0)