Skip to content

Commit 656399a

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 49ae164 commit 656399a

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
@@ -779,24 +779,14 @@ def test_send_ctrl_alt_del(uvm_plain):
779779
test_microvm.spawn()
780780

781781
test_microvm.basic_config()
782+
test_microvm.add_net_iface()
782783
test_microvm.start()
783784

784-
# Wait around for the guest to boot up and initialize the user space
785-
time.sleep(2)
786-
787785
test_microvm.api.actions.put(action_type="SendCtrlAltDel")
788786

789-
firecracker_pid = test_microvm.firecracker_pid
790-
791787
# If everything goes as expected, the guest OS will issue a reboot,
792788
# causing Firecracker to exit.
793-
# waitpid should block until the Firecracker process has exited. If
794-
# it has already exited by the time we call waitpid, WNOHANG causes
795-
# waitpid to raise a ChildProcessError exception.
796-
try:
797-
os.waitpid(firecracker_pid, os.WNOHANG)
798-
except ChildProcessError:
799-
pass
789+
test_microvm.mark_killed()
800790

801791

802792
def _drive_patch(test_microvm):

0 commit comments

Comments
 (0)