Skip to content

Commit 2aaea37

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 the homegrown "waitpid" solution (which I'm pretty sure didn't work, because this test would have always failed during microvm teardown otherwise, since it never set _killed to True). Signed-off-by: Patrick Roy <[email protected]>
1 parent 49ae164 commit 2aaea37

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)