Skip to content

Commit efcaa0d

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 2c74c65 commit efcaa0d

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
@@ -782,24 +782,14 @@ def test_send_ctrl_alt_del(uvm_plain):
782782
test_microvm.spawn()
783783

784784
test_microvm.basic_config()
785+
test_microvm.add_net_iface()
785786
test_microvm.start()
786787

787-
# Wait around for the guest to boot up and initialize the user space
788-
time.sleep(2)
789-
790788
test_microvm.api.actions.put(action_type="SendCtrlAltDel")
791789

792-
firecracker_pid = test_microvm.firecracker_pid
793-
794790
# If everything goes as expected, the guest OS will issue a reboot,
795791
# causing Firecracker to exit.
796-
# waitpid should block until the Firecracker process has exited. If
797-
# it has already exited by the time we call waitpid, WNOHANG causes
798-
# waitpid to raise a ChildProcessError exception.
799-
try:
800-
os.waitpid(firecracker_pid, os.WNOHANG)
801-
except ChildProcessError:
802-
pass
792+
test_microvm.mark_killed()
803793

804794

805795
def _drive_patch(test_microvm):

0 commit comments

Comments
 (0)