Skip to content

Commit 49ab17b

Browse files
author
Sudan Landge
committed
tests: test all combinations of daemonize and new_pid_ns
Microvm kill() has the logic to detect if Firecracker was actually killed using the PID stored in the Jailers root directory but, not all combinations of Jailers daemonize/new_pid_ns flags are tested so add new a test to try all 4 use cases. Signed-off-by: Sudan Landge <[email protected]>
1 parent c30632f commit 49ab17b

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tests/integration_tests/security/test_jail.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,3 +581,35 @@ def test_new_pid_namespace(uvm_plain):
581581
assert len(nstgid_list) == 2
582582
assert int(nstgid_list[1]) == 1
583583
assert int(nstgid_list[0]) == fc_pid
584+
585+
586+
@pytest.mark.parametrize(
587+
"daemonize",
588+
[True, False],
589+
)
590+
@pytest.mark.parametrize(
591+
"new_pid_ns",
592+
[True, False],
593+
)
594+
def test_firecracker_kill_by_pid(uvm_plain, daemonize, new_pid_ns):
595+
"""
596+
Test that Firecracker is spawned in a new PID namespace if requested.
597+
"""
598+
microvm = uvm_plain
599+
microvm.jailer.daemonize = daemonize
600+
microvm.jailer.new_pid_ns = new_pid_ns
601+
microvm.spawn()
602+
microvm.basic_config()
603+
microvm.add_net_iface()
604+
microvm.start()
605+
606+
# verify the guest is active
607+
exit_code, _, _ = microvm.ssh.run("ls")
608+
assert exit_code == 0
609+
610+
# before killing microvm make sure the Jailer config is what we set it to be.
611+
assert (
612+
microvm.jailer.daemonize == daemonize
613+
and microvm.jailer.new_pid_ns == new_pid_ns
614+
)
615+
microvm.kill()

0 commit comments

Comments
 (0)