From f22dc5244fbda5d1f3da30045110a1d1195eb763 Mon Sep 17 00:00:00 2001 From: Antonio Murdaca Date: Fri, 9 Dec 2016 11:56:25 +0100 Subject: [PATCH] test: add restart ocid with pod stopped test Signed-off-by: Antonio Murdaca --- test/helpers.bash | 10 ++++++++++ test/pod.bats | 26 ++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/test/helpers.bash b/test/helpers.bash index 3d61d1a5..24627777 100644 --- a/test/helpers.bash +++ b/test/helpers.bash @@ -143,6 +143,16 @@ function stop_ocid() { fi } +function restart_ocid() { + if [ "$OCID_PID" != "" ]; then + kill "$OCID_PID" >/dev/null 2>&1 + start_ocid + else + echo "you must start ocid first" + exit 1 + fi +} + function cleanup_test() { rm -rf "$TESTDIR" } diff --git a/test/pod.bats b/test/pod.bats index 7525a7c7..8b1eb690 100644 --- a/test/pod.bats +++ b/test/pod.bats @@ -306,3 +306,29 @@ function teardown() { cleanup_pods stop_ocid } + +@test "restart ocid and still get pod status" { + # 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 + run ocic pod create --config "$TESTDATA"/sandbox_config.json + echo "$output" + [ "$status" -eq 0 ] + pod_id="$output" + run ocic pod stop --id "$pod_id" + echo "$output" + [ "$status" -eq 0 ] + + restart_ocid + run ocic pod status --id "$pod_id" + echo "$output" + [ "$status" -eq 0 ] + [ "$output" != "" ] + + cleanup_ctrs + cleanup_pods + stop_ocid +}