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>
This commit is contained in:
Kir Kolyshkin
2021-01-21 15:25:52 -08:00
parent c34a9b1025
commit 41670e21f0
29 changed files with 69 additions and 123 deletions
+4 -8
View File
@@ -3,20 +3,16 @@
load helpers
function setup() {
unset ALT_ROOT
teardown
setup_busybox
ALT_ROOT=$(mktemp -d "$BATS_RUN_TMPDIR/runc-2.XXXXXX")
ALT_ROOT="$ROOT/alt"
mkdir -p "$ALT_ROOT/state"
}
function teardown() {
if [ -n "$ALT_ROOT" ]; then
ROOT="$ALT_ROOT" teardown_running_container test_box1
ROOT="$ALT_ROOT" teardown_running_container test_box2
ROOT="$ALT_ROOT" teardown_running_container test_box3
rm -rf "$ALT_ROOT"
ROOT="$ALT_ROOT" teardown_bundle
fi
teardown_busybox
teardown_bundle
}
@test "list" {