summaryrefslogtreecommitdiff
path: root/test/kpod_wait.bats
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@gmail.com>2017-11-01 11:24:59 -0400
committerMatthew Heon <matthew.heon@gmail.com>2017-11-01 11:24:59 -0400
commita031b83a09a8628435317a03f199cdc18b78262f (patch)
treebc017a96769ce6de33745b8b0b1304ccf38e9df0 /test/kpod_wait.bats
parent2b74391cd5281f6fdf391ff8ad50fd1490f6bf89 (diff)
downloadpodman-a031b83a09a8628435317a03f199cdc18b78262f.tar.gz
podman-a031b83a09a8628435317a03f199cdc18b78262f.tar.bz2
podman-a031b83a09a8628435317a03f199cdc18b78262f.zip
Initial checkin from CRI-O repo
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
Diffstat (limited to 'test/kpod_wait.bats')
-rw-r--r--test/kpod_wait.bats69
1 files changed, 69 insertions, 0 deletions
diff --git a/test/kpod_wait.bats b/test/kpod_wait.bats
new file mode 100644
index 000000000..ba7556b2e
--- /dev/null
+++ b/test/kpod_wait.bats
@@ -0,0 +1,69 @@
+#!/usr/bin/env bats
+
+load helpers
+
+IMAGE="redis:alpine"
+
+# Returns the POD ID
+function pod_run_from_template(){
+ #1=name, 2=uid, 3=namespace) {
+ NAME=$1 CUID=$2 NAMESPACE=$3 envsubst < ${TESTDATA}/template_sandbox_config.json > ${TESTDIR}/pod-${1}.json
+ crioctl pod run --config ${TESTDIR}/pod-${1}.json
+}
+
+# Returns the container ID
+function container_create_from_template() {
+ #1=name, 2=image, 3=command, 4=id) {
+ NAME=$1 IMAGE=$2 COMMAND=$3 envsubst < ${TESTDATA}/template_container_config.json > ${TESTDIR}/ctr-${1}.json
+ crioctl ctr create --config ${TESTDIR}/ctr-${1}.json --pod "$4"
+}
+
+function container_start() {
+ #1=id
+ crioctl ctr start --id "$1"
+
+}
+@test "wait on a bogus container" {
+ start_crio
+ run ${KPOD_BINARY} ${KPOD_OPTIONS} wait 12343
+ echo $output
+ [ "$status" -eq 1 ]
+ stop_crio
+}
+
+@test "wait on a stopped container" {
+ run ${KPOD_BINARY} ${KPOD_OPTIONS} pull docker.io/library/busybox:latest
+ echo $output
+ [ "$status" -eq 0 ]
+ start_crio
+ pod_id=$( pod_run_from_template "test" "test" "test1-1" )
+ echo $pod_id
+ ctr_id=$(container_create_from_template "test-CTR" "docker.io/library/busybox:latest" '["ls"]' "${pod_id}")
+ echo $ctr_id
+ container_start $ctr_id
+ run ${KPOD_BINARY} ${KPOD_OPTIONS} wait $ctr_id
+ [ "$status" -eq 0 ]
+ cleanup_ctrs
+ cleanup_pods
+ stop_crio
+}
+
+@test "wait on a sleeping container" {
+ run ${KPOD_BINARY} ${KPOD_OPTIONS} pull docker.io/library/busybox:latest
+ echo $output
+ [ "$status" -eq 0 ]
+ start_crio
+ pod_id=$( pod_run_from_template "test" "test" "test1-1" )
+ echo $pod_id
+ ctr_id=$(container_create_from_template "test-CTR" "docker.io/library/busybox:latest" '["sleep", "5"]' "${pod_id}")
+ echo $ctr_id
+ run container_start $ctr_id
+ echo $output
+ [ "$status" -eq 0 ]
+ run ${KPOD_BINARY} ${KPOD_OPTIONS} wait $ctr_id
+ echo $output
+ [ "$status" -eq 0 ]
+ cleanup_ctrs
+ cleanup_pods
+ stop_crio
+}