Skip to content

Commit cd93703

Browse files
committed
test: Modernize test_send_ctrl_alt_del
Instead of sleeping for 2 seconds to wait for booting, add a network device and wait for ssh availability (happens automatically in .start()). Use mark_killed() to assert that Firecracker exited instead of "waitpid". Using `waitpid(2)` here is wrong, because it only works on child processes, and Firecracker is no child of the pytest process (it is daemonized, for starters). The reason we never caught this being broken is because the test also simply ignores all exceptions raised. But there's more issues here: The test never caused _killed to be set to `True`, so if Firecracker really did exit, then we would have been seeing intermittent failures during microvm teardown (as Microvm.kill() asserts that the process is still alive if _killed is False). In fact, our guest kernels do not have the required drivers compiled in to support CTRL+ALT+DEL (thanks Riccardo for figuring this part out). Signed-off-by: Patrick Roy <[email protected]>
1 parent cce210a commit cd93703

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

tests/integration_tests/functional/test_api.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -767,24 +767,14 @@ def test_send_ctrl_alt_del(uvm_plain_any):
767767
test_microvm.spawn()
768768

769769
test_microvm.basic_config()
770+
test_microvm.add_net_iface()
770771
test_microvm.start()
771772

772-
# Wait around for the guest to boot up and initialize the user space
773-
time.sleep(2)
774-
775773
test_microvm.api.actions.put(action_type="SendCtrlAltDel")
776774

777-
firecracker_pid = test_microvm.firecracker_pid
778-
779775
# If everything goes as expected, the guest OS will issue a reboot,
780776
# causing Firecracker to exit.
781-
# waitpid should block until the Firecracker process has exited. If
782-
# it has already exited by the time we call waitpid, WNOHANG causes
783-
# waitpid to raise a ChildProcessError exception.
784-
try:
785-
os.waitpid(firecracker_pid, os.WNOHANG)
786-
except ChildProcessError:
787-
pass
777+
test_microvm.mark_killed()
788778

789779

790780
def _drive_patch(test_microvm, io_engine):

0 commit comments

Comments
 (0)