From 77c40487de98dcbcded877452eeccfcfe8b45590 Mon Sep 17 00:00:00 2001 From: Antonio Murdaca Date: Tue, 27 Sep 2016 10:54:16 +0200 Subject: [PATCH] test: suggests sudo make localintegration Signed-off-by: Antonio Murdaca --- test/helpers.bash | 23 ++++++++++++----------- test/pod.bats | 7 +++++-- test/runtimeversion.bats | 1 + 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/test/helpers.bash b/test/helpers.bash index 43e2ea86..1657c70e 100644 --- a/test/helpers.bash +++ b/test/helpers.bash @@ -76,23 +76,24 @@ function start_ocid() { 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 + if [ "$status" -eq 0 ]; then + 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 + fi } # Stop ocid. function stop_ocid() { - kill "$OCID_PID" + if [ "$OCID_PID" != "" ]; then + kill "$OCID_PID" >/dev/null 2>&1 + fi } function cleanup_test() { - cleanup_pods - stop_ocid rm -rf "$TESTDIR" } diff --git a/test/pod.bats b/test/pod.bats index 0ed6496c..0a347a4e 100644 --- a/test/pod.bats +++ b/test/pod.bats @@ -8,8 +8,9 @@ function teardown() { # PR#59 @test "pod release name on remove" { - if "$TRAVIS"; then - skip "cannot yet run this test in a container" + # this test requires docker, thus it can't yet be run in a container + if [ "$TRAVIS" = "true" ]; then # instead of $TRAVIS, add a function is_containerized to skip here + skip "cannot yet run this test in a container, use sudo make localintegration" fi start_ocid @@ -24,4 +25,6 @@ function teardown() { [ "$status" -eq 0 ] run ocic pod create --config "$TESTDATA"/sandbox_config.json [ "$status" -eq 0 ] + stop_ocid + cleanup_pods } diff --git a/test/runtimeversion.bats b/test/runtimeversion.bats index bda02af5..60bbfa2e 100644 --- a/test/runtimeversion.bats +++ b/test/runtimeversion.bats @@ -10,4 +10,5 @@ function teardown() { start_ocid ocic runtimeversion [ "$status" -eq 0 ] + stop_ocid }