test: cleanup pods at test teardown

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
Antonio Murdaca 2016-09-27 10:40:33 +02:00
parent 4578cc93d1
commit ab8b65b09e
No known key found for this signature in database
GPG key ID: B2BEAD150DE936B9
3 changed files with 18 additions and 7 deletions

View file

@ -74,12 +74,25 @@ function start_ocid() {
wait_until_reachable 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. # Stop ocid.
function stop_ocid() { function stop_ocid() {
kill "$OCID_PID" kill "$OCID_PID"
} }
function cleanup_test() { function cleanup_test() {
cleanup_pods
stop_ocid
rm -rf "$TESTDIR" rm -rf "$TESTDIR"
# TODO(runcom): runc list and kill/delete everything!
} }

View file

@ -3,17 +3,19 @@
load helpers load helpers
function teardown() { function teardown() {
stop_ocid
cleanup_test cleanup_test
} }
# PR#59 # PR#59
@test "pod release name on remove" { @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 start_ocid
run ocic pod create --config "$TESTDATA"/sandbox_config.json run ocic pod create --config "$TESTDATA"/sandbox_config.json
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
echo "$output"
id="$output" id="$output"
run ocic pod stop --id "$id" run ocic pod stop --id "$id"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
@ -22,7 +24,4 @@ function teardown() {
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
run ocic pod create --config "$TESTDATA"/sandbox_config.json run ocic pod create --config "$TESTDATA"/sandbox_config.json
[ "$status" -eq 0 ] [ "$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
} }

View file

@ -3,7 +3,6 @@
load helpers load helpers
function teardown() { function teardown() {
stop_ocid
cleanup_test cleanup_test
} }