summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/kpod_rm.bats75
-rw-r--r--test/kpod_wait.bats55
2 files changed, 33 insertions, 97 deletions
diff --git a/test/kpod_rm.bats b/test/kpod_rm.bats
index 73d469ca2..3a7551ea6 100644
--- a/test/kpod_rm.bats
+++ b/test/kpod_rm.bats
@@ -2,60 +2,28 @@
load helpers
-IMAGE="alpine:latest"
-
-function teardown() {
- cleanup_test
-}
-
function setup() {
copy_images
}
@test "remove a stopped container" {
- skip "Test needs to be converted to kpod run"
- start_crio
- run crioctl pod run --config "$TESTDATA"/sandbox_config.json
- echo "$output"
- [ "$status" -eq 0 ]
- pod_id="$output"
- run crioctl ctr create --config "$TESTDATA"/container_config.json --pod "$pod_id"
+ run ${KPOD_BINARY} $KPOD_OPTIONS run -d ${ALPINE} ls
echo "$output"
[ "$status" -eq 0 ]
ctr_id="$output"
- run crioctl ctr start --id "$ctr_id"
- echo "$output"
- [ "$status" -eq 0 ]
- run crioctl ctr stop --id "$ctr_id"
- echo "$output"
- [ "$status" -eq 0 ]
run bash -c ${KPOD_BINARY} $KPOD_OPTIONS rm "$ctr_id"
echo "$output"
[ "$status" -eq 0 ]
- cleanup_pods
- stop_crio
}
@test "refuse to remove a running container" {
- skip "Test needs to be converted to kpod run"
- start_crio
- run crioctl pod run --config "$TESTDATA"/sandbox_config.json
- echo "$output"
- [ "$status" -eq 0 ]
- pod_id="$output"
- run crioctl ctr create --config "$TESTDATA"/container_redis.json --pod "$pod_id"
+ run ${KPOD_BINARY} $KPOD_OPTIONS run -d ${ALPINE} sleep 15
echo "$output"
[ "$status" -eq 0 ]
ctr_id="$output"
- run crioctl ctr start --id "$ctr_id"
- echo "$output"
- [ "$status" -eq 0 ]
- run bash -c ${KPOD_BINARY} $KPOD_OPTIONS rm "$ctr_id"
+ run bash ${KPOD_BINARY} $KPOD_OPTIONS rm "$ctr_id"
echo "$output"
[ "$status" -ne 0 ]
- cleanup_ctrs
- cleanup_pods
- stop_crio
}
@test "remove a created container" {
@@ -69,22 +37,33 @@ function setup() {
}
@test "remove a running container" {
- skip "Test needs to be converted to kpod run"
- start_crio
- run crioctl pod run --config "$TESTDATA"/sandbox_config.json
- echo "$output"
- [ "$status" -eq 0 ]
- pod_id="$output"
- run crioctl ctr create --config "$TESTDATA"/container_redis.json --pod "$pod_id"
+ skip "Skipping until kpod stop is implemented"
+ run ${KPOD_BINARY} $KPOD_OPTIONS run -d ${ALPINE} sleep 15
echo "$output"
[ "$status" -eq 0 ]
ctr_id="$output"
- run crioctl ctr start --id "$ctr_id"
- echo "$output"
- [ "$status" -eq 0 ]
run bash -c ${KPOD_BINARY} $KPOD_OPTIONS rm -f "$ctr_id"
echo "$output"
- [ "$status" -eq 0 ]
- cleanup_pods
- stop_crio
+ [ "$status" -eq 1 ]
+}
+
+@test "remove all containers" {
+ ${KPOD_BINARY} ${KPOD_OPTIONS} create $BB ls
+ ${KPOD_BINARY} ${KPOD_OPTIONS} create $BB ls -l
+ ${KPOD_BINARY} ${KPOD_OPTIONS} create $BB true
+ ${KPOD_BINARY} ${KPOD_OPTIONS} create $BB whoami
+ run ${KPOD_BINARY} $KPOD_OPTIONS rm -a
+ echo "$output"
+ [ "$status" -eq 1 ]
+}
+
+@test "remove all containers with one running" {
+ skip "Skipping until kpod stop is implemented"
+ ${KPOD_BINARY} ${KPOD_OPTIONS} create $BB ls
+ ${KPOD_BINARY} ${KPOD_OPTIONS} create $BB ls -l
+ ${KPOD_BINARY} ${KPOD_OPTIONS} create $BB whoami
+ ${KPOD_BINARY} ${KPOD_OPTIONS} run -d ${ALPINE} sleep 30
+ run ${KPOD_BINARY} $KPOD_OPTIONS rm -a -f
+ echo "$output"
+ [ "$status" -eq 1 ]
}
diff --git a/test/kpod_wait.bats b/test/kpod_wait.bats
index beb2c246d..b7bcb072c 100644
--- a/test/kpod_wait.bats
+++ b/test/kpod_wait.bats
@@ -2,74 +2,31 @@
load helpers
-IMAGE="redis:alpine"
function setup() {
copy_images
}
-# 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" {
- skip "Needs to be converted to kpod run"
- start_crio
- run bash -c ${KPOD_BINARY} ${KPOD_OPTIONS} wait 12343
+ run ${KPOD_BINARY} ${KPOD_OPTIONS} wait 12343
echo $output
+ echo $status
[ "$status" -eq 1 ]
- stop_crio
}
@test "wait on a stopped container" {
- skip "Needs to be converted to kpod run"
- run bash -c ${KPOD_BINARY} ${KPOD_OPTIONS} pull docker.io/library/busybox:latest
+ run ${KPOD_BINARY} ${KPOD_OPTIONS} run -d ${ALPINE} ls
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
+ ctr_id=${output}
run bash -c ${KPOD_BINARY} ${KPOD_OPTIONS} wait $ctr_id
[ "$status" -eq 0 ]
- cleanup_ctrs
- cleanup_pods
- stop_crio
}
@test "wait on a sleeping container" {
- skip "Needs to be converted to kpod run"
- run bash -c ${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
+ run ${KPOD_BINARY} ${KPOD_OPTIONS} run -d ${ALPINE} sleep 10
echo $output
[ "$status" -eq 0 ]
+ ctr_id=${output}
run bash -c ${KPOD_BINARY} ${KPOD_OPTIONS} wait $ctr_id
- echo $output
[ "$status" -eq 0 ]
- cleanup_ctrs
- cleanup_pods
- stop_crio
}