Skip to content

Commit

Permalink
fix(test): don't try to kill after CtrlAltDel
Browse files Browse the repository at this point in the history
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 <bchalios@amazon.es>
  • Loading branch information
bchalios committed Dec 1, 2023
1 parent 25e3dbf commit 2c5a3a0
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions tests/integration_tests/functional/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -795,19 +795,13 @@ def test_send_ctrl_alt_del(test_microvm_with_api):

# If everything goes as expected, the guest OS will issue a reboot,
# causing Firecracker to exit.
# We'll keep poking Firecracker for at most 30 seconds, waiting for it
# to die.
start_time = time.time()
shutdown_ok = False
while time.time() - start_time < 30:
try:
os.kill(firecracker_pid, 0)
time.sleep(0.01)
except OSError:
shutdown_ok = True
break

assert shutdown_ok
# waitpid should block until the Firecracker process has exited. If
# it has already exited by the time we call waitpid, WNOHANG causes
# waitpid to raise a ChildProcessError exception.
try:
os.waitpid(firecracker_pid, os.WNOHANG)
except ChildProcessError:
pass


def _drive_patch(test_microvm):
Expand Down

0 comments on commit 2c5a3a0

Please sign in to comment.