diff --git a/test/helpers.bash b/test/helpers.bash index 14547b13..43e2ea86 100644 --- a/test/helpers.bash +++ b/test/helpers.bash @@ -74,12 +74,25 @@ function start_ocid() { wait_until_reachable } +function cleanup_pods() { + run ocic pod list + [ "$status" -eq 0 ] + printf '%s\n' "$output" | while IFS= read -r line + do + pod=$(echo "$line" | sed -e 's/ID: //g') + ocic pod stop --id "$pod" + sleep 1 + ocic pod remove --id "$pod" + done +} + # Stop ocid. function stop_ocid() { kill "$OCID_PID" } function cleanup_test() { + cleanup_pods + stop_ocid rm -rf "$TESTDIR" - # TODO(runcom): runc list and kill/delete everything! } diff --git a/test/pod.bats b/test/pod.bats index 5217f5af..c1ab938f 100644 --- a/test/pod.bats +++ b/test/pod.bats @@ -3,17 +3,19 @@ load helpers function teardown() { - stop_ocid cleanup_test } # PR#59 @test "pod release name on remove" { - skip "cannot be run in a container yet" + if "$TRAVIS"; then + skip "cannot yet run this test in a container" + fi start_ocid run ocic pod create --config "$TESTDATA"/sandbox_config.json [ "$status" -eq 0 ] + echo "$output" id="$output" run ocic pod stop --id "$id" [ "$status" -eq 0 ] @@ -22,7 +24,4 @@ function teardown() { [ "$status" -eq 0 ] run ocic pod create --config "$TESTDATA"/sandbox_config.json [ "$status" -eq 0 ] - - # TODO: cleanup all the stuff from runc, meaning list pods and stop remove them - # pod list + pod stop + pod remove in cleanup } diff --git a/test/runtimeversion.bats b/test/runtimeversion.bats index 8c83ae21..bda02af5 100644 --- a/test/runtimeversion.bats +++ b/test/runtimeversion.bats @@ -3,7 +3,6 @@ load helpers function teardown() { - stop_ocid cleanup_test }