Files
runc/tests/integration/root.bats
T
Kir Kolyshkin 41670e21f0 tests/int: rework/simplify setup and teardown
1. Get rid of fixed ROOT, *_BUNDLE, and CONSOLE_SOCKET dirs.
   Now they are temporary directories created in setup_bundle.

2. Automate containers cleanup: instead of having to specify all
   containers to be removed, list and destroy everything (which is
   now possible since every test case has its own unique root).

3. Randomize cgroup paths so two tests running in parallel won't
   use the same cgroup.

Now it's theoretically possible to execute tests in parallel.
Practically it's not possible yet because bats uses GNU parallel,
which do not provide a terminal for whatever it executes, and
many runc tests (all those that run containers with terminal:
true) needs a tty. This may possibly be addressed later.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-02-09 20:05:54 -08:00

54 lines
1.1 KiB
Bash

#!/usr/bin/env bats
load helpers
function setup() {
setup_busybox
ALT_ROOT="$ROOT/alt"
mkdir -p "$ALT_ROOT/state"
}
function teardown() {
if [ -n "$ALT_ROOT" ]; then
ROOT=$ALT_ROOT __runc delete -f test_dotbox
rm -rf "$ALT_ROOT"
fi
teardown_bundle
}
@test "global --root" {
# run busybox detached using $ALT_ROOT for state
ROOT=$ALT_ROOT runc run -d --console-socket "$CONSOLE_SOCKET" test_dotbox
[ "$status" -eq 0 ]
# run busybox detached in default root
runc run -d --console-socket "$CONSOLE_SOCKET" test_busybox
[ "$status" -eq 0 ]
runc state test_busybox
[ "$status" -eq 0 ]
[[ "${output}" == *"running"* ]]
ROOT=$ALT_ROOT runc state test_dotbox
[ "$status" -eq 0 ]
[[ "${output}" == *"running"* ]]
ROOT=$ALT_ROOT runc state test_busybox
[ "$status" -ne 0 ]
runc state test_dotbox
[ "$status" -ne 0 ]
runc kill test_busybox KILL
[ "$status" -eq 0 ]
wait_for_container 10 1 test_busybox stopped
runc delete test_busybox
[ "$status" -eq 0 ]
ROOT=$ALT_ROOT runc kill test_dotbox KILL
[ "$status" -eq 0 ]
ROOT=$ALT_ROOT wait_for_container 10 1 test_dotbox stopped
ROOT=$ALT_ROOT runc delete test_dotbox
[ "$status" -eq 0 ]
}