diff --git a/test/helpers.bash b/test/helpers.bash index 6d185527..e0723e8b 100644 --- a/test/helpers.bash +++ b/test/helpers.bash @@ -59,6 +59,11 @@ PIDS_LIMIT=${PIDS_LIMIT:-1024} # Log size max limit LOG_SIZE_MAX_LIMIT=${LOG_SIZE_MAX_LIMIT:--1} +# Options for kpod. +ROOT="${TESTDIR}/crio" +RUNROOT="${TESTDIR}/crio-run" +KPOD_OPTIONS="--root ${ROOT} --runroot ${RUNROOT} ${STORAGE_OPTS} --runtime ${RUNTIME_BINARY}" + TESTDIR=$(mktemp -d) # kpod pull needs a configuration file for shortname pulls diff --git a/test/kpod.bats b/test/kpod.bats deleted file mode 100644 index b88b65be..00000000 --- a/test/kpod.bats +++ /dev/null @@ -1,208 +0,0 @@ -#!/usr/bin/env bats - -load helpers - -IMAGE="alpine:latest" -ROOT="$TESTDIR/crio" -RUNROOT="$TESTDIR/crio-run" -KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT --storage-driver vfs" - -function teardown() { - cleanup_test -} - -@test "kpod version test" { - run ${KPOD_BINARY} version - echo "$output" - [ "$status" -eq 0 ] -} - -@test "kpod history default" { - run ${KPOD_BINARY} ${KPOD_OPTIONS} pull $IMAGE - [ "$status" -eq 0 ] - run ${KPOD_BINARY} ${KPOD_OPTIONS} history $IMAGE - echo "$output" - [ "$status" -eq 0 ] - run ${KPOD_BINARY} $KPOD_OPTIONS rmi $IMAGE - [ "$status" -eq 0 ] -} - -@test "kpod history with Go template format" { - run ${KPOD_BINARY} ${KPOD_OPTIONS} pull $IMAGE - [ "$status" -eq 0 ] - run ${KPOD_BINARY} ${KPOD_OPTIONS} history --format "{{.ID}} {{.Created}}" $IMAGE - echo "$output" - [ "$status" -eq 0 ] - run ${KPOD_BINARY} $KPOD_OPTIONS rmi $IMAGE - [ "$status" -eq 0 ] -} - -@test "kpod history human flag" { - run ${KPOD_BINARY} ${KPOD_OPTIONS} pull $IMAGE - [ "$status" -eq 0 ] - run ${KPOD_BINARY} ${KPOD_OPTIONS} history --human=false $IMAGE - echo "$output" - [ "$status" -eq 0 ] - run ${KPOD_BINARY} $KPOD_OPTIONS rmi $IMAGE - [ "$status" -eq 0 ] -} - -@test "kpod history quiet flag" { - run ${KPOD_BINARY} ${KPOD_OPTIONS} pull $IMAGE - [ "$status" -eq 0 ] - run ${KPOD_BINARY} ${KPOD_OPTIONS} history -q $IMAGE - echo "$output" - [ "$status" -eq 0 ] - run ${KPOD_BINARY} $KPOD_OPTIONS rmi $IMAGE - [ "$status" -eq 0 ] -} - -@test "kpod history no-trunc flag" { - run ${KPOD_BINARY} ${KPOD_OPTIONS} pull $IMAGE - [ "$status" -eq 0 ] - run ${KPOD_BINARY} ${KPOD_OPTIONS} history --no-trunc $IMAGE - echo "$output" - [ "$status" -eq 0 ] - run ${KPOD_BINARY} $KPOD_OPTIONS rmi $IMAGE - [ "$status" -eq 0 ] -} - -@test "kpod history json flag" { - run ${KPOD_BINARY} ${KPOD_OPTIONS} pull $IMAGE - [ "$status" -eq 0 ] - run bash -c "${KPOD_BINARY} ${KPOD_OPTIONS} history --format json $IMAGE | python -m json.tool" - echo "$output" - [ "$status" -eq 0 ] - run ${KPOD_BINARY} $KPOD_OPTIONS rmi $IMAGE - [ "$status" -eq 0 ] -} - -@test "kpod push to containers/storage" { - run ${KPOD_BINARY} $KPOD_OPTIONS pull "$IMAGE" - echo "$output" - [ "$status" -eq 0 ] - run ${KPOD_BINARY} $KPOD_OPTIONS push "$IMAGE" containers-storage:[$ROOT]busybox:test - echo "$output" - [ "$status" -eq 0 ] - run crioctl image remove "$IMAGE" - run crioctl image remove busybox:test - stop_crio -} - -@test "kpod push to directory" { - run ${KPOD_BINARY} $KPOD_OPTIONS pull "$IMAGE" - echo "$output" - [ "$status" -eq 0 ] - run mkdir /tmp/busybox - echo "$output" - [ "$status" -eq 0 ] - run ${KPOD_BINARY} $KPOD_OPTIONS push "$IMAGE" dir:/tmp/busybox - echo "$output" - [ "$status" -eq 0 ] - run crioctl image remove "$IMAGE" - run rm -rf /tmp/busybox - stop_crio -} - -@test "kpod push to docker archive" { - run ${KPOD_BINARY} $KPOD_OPTIONS pull "$IMAGE" - echo "$output" - [ "$status" -eq 0 ] - run ${KPOD_BINARY} $KPOD_OPTIONS push "$IMAGE" docker-archive:/tmp/busybox-archive:1.26 - echo "$output" - [ "$status" -eq 0 ] - rm /tmp/busybox-archive - run crioctl image remove "$IMAGE" - stop_crio -} - -@test "kpod push to oci without compression" { - run ${KPOD_BINARY} $KPOD_OPTIONS pull "$IMAGE" - echo "$output" - [ "$status" -eq 0 ] - run mkdir /tmp/oci-busybox - echo "$output" - [ "$status" -eq 0 ] - run ${KPOD_BINARY} $KPOD_OPTIONS push "$IMAGE" oci:/tmp/oci-busybox:"$IMAGE" - echo "$output" - [ "$status" -eq 0 ] - run rm -rf /tmp/oci-busybox - run crioctl image remove "$IMAGE" - stop_crio -} - -@test "kpod push without signatures" { - run ${KPOD_BINARY} $KPOD_OPTIONS pull "$IMAGE" - echo "$output" - [ "$status" -eq 0 ] - run mkdir /tmp/busybox - echo "$output" - [ "$status" -eq 0 ] - run ${KPOD_BINARY} $KPOD_OPTIONS push --remove-signatures "$IMAGE" dir:/tmp/busybox - echo "$output" - [ "$status" -eq 0 ] - run rm -rf /tmp/busybox - run crioctl image remove "$IMAGE" - stop_crio -} - -@test "kpod inspect image" { - run ${KPOD_BINARY} $KPOD_OPTIONS pull redis:alpine - [ "$status" -eq 0 ] - run bash -c "${KPOD_BINARY} $KPOD_OPTIONS inspect redis:alpine | python -m json.tool" - echo "$output" - [ "$status" -eq 0 ] - run ${KPOD_BINARY} $KPOD_OPTIONS rmi redis:alpine - [ "$status" -eq 0 ] -} - - -@test "kpod inspect non-existent container" { - run ${KPOD_BINARY} $KPOD_OPTIONS inspect 14rcole/non-existent - echo "$output" - [ "$status" -ne 0 ] -} - -@test "kpod inspect with format" { - run ${KPOD_BINARY} $KPOD_OPTIONS pull redis:alpine - [ "$status" -eq 0 ] - run ${KPOD_BINARY} $KPOD_OPTIONS inspect --format {{.ID}} redis:alpine - [ "$status" -eq 0 ] - inspectOutput="$output" - run ${KPOD_BINARY} $KPOD_OPTIONS images --quiet redis:alpine - [ "$status" -eq 0 ] - [ "$output" = "$inspectOutput" ] - run ${KPOD_BINARY} $KPOD_OPTIONS rmi redis:alpine - [ "$status" -eq 0 ] -} - -@test "kpod inspect specified type" { - run ${KPOD_BINARY} $KPOD_OPTIONS pull redis:alpine - [ "$status" -eq 0 ] - run bash -c "${KPOD_BINARY} $KPOD_OPTIONS inspect --type image redis:alpine | python -m json.tool" - echo "$output" - [ "$status" -eq 0 ] - run ${KPOD_BINARY} $KPOD_OPTIONS rmi redis:alpine - [ "$status" -eq 0 ] -} - -@test "kpod images" { - run ${KPOD_BINARY} $KPOD_OPTIONS pull debian:6.0.10 - run ${KPOD_BINARY} $KPOD_OPTIONS images - [ "$status" -eq 0 ] -} - -@test "kpod images test valid json" { - run ${KPOD_BINARY} $KPOD_OPTIONS pull debian:6.0.10 - run ${KPOD_BINARY} $KPOD_OPTIONS images --format json - echo "$output" | python -m json.tool - [ "$status" -eq 0 ] -} - -@test "kpod images check name json output" { - run ${KPOD_BINARY} $KPOD_OPTIONS pull debian:6.0.10 - run ${KPOD_BINARY} $KPOD_OPTIONS images --format json - echo "$output" - name=$(echo $output | python -c 'import sys; import json; print(json.loads(sys.stdin.read())[0])["names"][0]') - [ "$name" = "docker.io/library/debian:6.0.10" ] -} diff --git a/test/kpod_diff.bats b/test/kpod_diff.bats index 50a82d5c..53a94d01 100644 --- a/test/kpod_diff.bats +++ b/test/kpod_diff.bats @@ -1,11 +1,8 @@ -#/usr/bin/env bats +#!/usr/bin/env bats load helpers IMAGE="alpine:latest" -ROOT="$TESTDIR/crio" -RUNROOT="$TESTDIR/crio-run" -KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT $STORAGE_OPTS" function teardown() { cleanup_test @@ -18,14 +15,15 @@ function teardown() { run ${KPOD_BINARY} $KPOD_OPTIONS diff $IMAGE echo "$output" [ "$status" -eq 0 ] + run ${KPOD_BINARY} $KPOD_OPTIONS rmi $IMAGE echo "$output" - run ${KKPOD_BINARY} $KPOD_OPTIONS rmi $IMAGE + [ "$status" -eq 0 ] } @test "test diff on non-existent layer" { run ${KPOD_BINARY} $KPOD_OPTIONS diff "abc123" - [ "$status" -ne 0 ] echo "$output" + [ "$status" -ne 0 ] } @test "test diff with json output" { @@ -36,5 +34,7 @@ function teardown() { run ${KPOD_BINARY} $KPOD_OPTIONS diff --format json $IMAGE echo "$output" [ "$status" -eq 0 ] - run ${KKPOD_BINARY} $KPOD_OPTIONS rmi $IMAGE + run ${KPOD_BINARY} $KPOD_OPTIONS rmi $IMAGE + echo "$output" + [ "$status" -eq 0 ] } diff --git a/test/kpod_export.bats b/test/kpod_export.bats index 808d39ff..fca3021a 100644 --- a/test/kpod_export.bats +++ b/test/kpod_export.bats @@ -3,19 +3,23 @@ load helpers IMAGE="redis:alpine" -ROOT="$TESTDIR/crio" -RUNROOT="$TESTDIR/crio-run" -KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT ${STORAGE_OPTS}" +ROOT="${TESTDIR}/crio" +RUNROOT="${TESTDIR}/crio-run" +# Do not add --storage-driver vfs +KPOD_OPTIONS="--root ${ROOT} --runroot ${RUNROOT} --runtime ${RUNTIME_BINARY}" +function teardown() { + cleanup_test +} @test "kpod export output flag" { start_crio - [ "$status" -eq 0 ] run crioctl pod run --config "$TESTDATA"/sandbox_config.json echo "$output" [ "$status" -eq 0 ] pod_id="$output" run crioctl image pull "$IMAGE" + echo "$output" [ "$status" -eq 0 ] run crioctl ctr create --config "$TESTDATA"/container_config.json --pod "$pod_id" echo "$output" @@ -25,11 +29,7 @@ KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT ${STORAGE_OPTS}" echo "$output" [ "$status" -eq 0 ] cleanup_ctrs - [ "$status" -eq 0 ] cleanup_pods - [ "$status" -eq 0 ] stop_crio - [ "$status" -eq 0 ] rm -f container.tar - [ "$status" -eq 0 ] } diff --git a/test/kpod_history.bats b/test/kpod_history.bats new file mode 100644 index 00000000..aa89cfe6 --- /dev/null +++ b/test/kpod_history.bats @@ -0,0 +1,80 @@ +#!/usr/bin/env bats + +load helpers + +IMAGE="alpine:latest" + +function teardown() { + cleanup_test +} + +@test "kpod history default" { + run ${KPOD_BINARY} ${KPOD_OPTIONS} pull $IMAGE + echo "$output" + [ "$status" -eq 0 ] + run ${KPOD_BINARY} ${KPOD_OPTIONS} history $IMAGE + echo "$output" + [ "$status" -eq 0 ] + run ${KPOD_BINARY} $KPOD_OPTIONS rmi $IMAGE + echo "$output" + [ "$status" -eq 0 ] +} + +@test "kpod history with Go template format" { + run ${KPOD_BINARY} ${KPOD_OPTIONS} pull $IMAGE + echo "$output" + [ "$status" -eq 0 ] + run ${KPOD_BINARY} ${KPOD_OPTIONS} history --format "{{.ID}} {{.Created}}" $IMAGE + echo "$output" + [ "$status" -eq 0 ] + run ${KPOD_BINARY} $KPOD_OPTIONS rmi $IMAGE + echo "$output" + [ "$status" -eq 0 ] +} + +@test "kpod history human flag" { + run ${KPOD_BINARY} ${KPOD_OPTIONS} pull $IMAGE + echo "$output" + [ "$status" -eq 0 ] + run ${KPOD_BINARY} ${KPOD_OPTIONS} history --human=false $IMAGE + echo "$output" + [ "$status" -eq 0 ] + run ${KPOD_BINARY} $KPOD_OPTIONS rmi $IMAGE + echo "$output" + [ "$status" -eq 0 ] +} + +@test "kpod history quiet flag" { + run ${KPOD_BINARY} ${KPOD_OPTIONS} pull $IMAGE + [ "$status" -eq 0 ] + run ${KPOD_BINARY} ${KPOD_OPTIONS} history -q $IMAGE + echo "$output" + [ "$status" -eq 0 ] + run ${KPOD_BINARY} $KPOD_OPTIONS rmi $IMAGE + echo "$output" + [ "$status" -eq 0 ] +} + +@test "kpod history no-trunc flag" { + run ${KPOD_BINARY} ${KPOD_OPTIONS} pull $IMAGE + echo "$output" + [ "$status" -eq 0 ] + run ${KPOD_BINARY} ${KPOD_OPTIONS} history --no-trunc $IMAGE + echo "$output" + [ "$status" -eq 0 ] + run ${KPOD_BINARY} $KPOD_OPTIONS rmi $IMAGE + echo "$output" + [ "$status" -eq 0 ] +} + +@test "kpod history json flag" { + run ${KPOD_BINARY} ${KPOD_OPTIONS} pull $IMAGE + echo "$output" + [ "$status" -eq 0 ] + run bash -c "${KPOD_BINARY} ${KPOD_OPTIONS} history --format json $IMAGE | python -m json.tool" + echo "$output" + [ "$status" -eq 0 ] + run ${KPOD_BINARY} $KPOD_OPTIONS rmi $IMAGE + echo "$output" + [ "$status" -eq 0 ] +} diff --git a/test/kpod_images.bats b/test/kpod_images.bats new file mode 100644 index 00000000..92e63aa3 --- /dev/null +++ b/test/kpod_images.bats @@ -0,0 +1,46 @@ +#!/usr/bin/env bats + +load helpers + +IMAGE="debian:6.0.10" + +function teardown() { + cleanup_test +} + +@test "kpod images" { + run ${KPOD_BINARY} ${KPOD_OPTIONS} pull ${IMAGE} + echo "$output" + [ "$status" -eq 0 ] + run ${KPOD_BINARY} ${KPOD_OPTIONS} images + echo "$output" + [ "$status" -eq 0 ] + run ${KPOD_BINARY} ${KPOD_OPTIONS} rmi ${IMAGE} + echo "$output" + [ "$status" -eq 0 ] +} + +@test "kpod images test valid json" { + run ${KPOD_BINARY} ${KPOD_OPTIONS} pull ${IMAGE} + echo "$output" + [ "$status" -eq 0 ] + run ${KPOD_BINARY} ${KPOD_OPTIONS} images --format json + echo "$output" | python -m json.tool + [ "$status" -eq 0 ] + run ${KPOD_BINARY} ${KPOD_OPTIONS} rmi ${IMAGE} + echo "$output" + [ "$status" -eq 0 ] +} + +@test "kpod images check name json output" { + run ${KPOD_BINARY} ${KPOD_OPTIONS} pull ${IMAGE} + echo "$output" + [ "$status" -eq 0 ] + run ${KPOD_BINARY} ${KPOD_OPTIONS} images --format json + echo "$output" + name=$(echo $output | python -c 'import sys; import json; print(json.loads(sys.stdin.read())[0])["names"][0]') + [ "$name" = "docker.io/library/${IMAGE}" ] + run ${KPOD_BINARY} ${KPOD_OPTIONS} rmi ${IMAGE} + echo "$output" + [ "$status" -eq 0 ] +} diff --git a/test/kpod_inspect.bats b/test/kpod_inspect.bats new file mode 100644 index 00000000..e587735e --- /dev/null +++ b/test/kpod_inspect.bats @@ -0,0 +1,58 @@ +#!/usr/bin/env bats + +load helpers + +IMAGE="redis:alpine" + +function teardown() { + cleanup_test +} + +@test "kpod inspect image" { + run ${KPOD_BINARY} $KPOD_OPTIONS pull ${IMAGE} + echo "$output" + [ "$status" -eq 0 ] + run bash -c "${KPOD_BINARY} $KPOD_OPTIONS inspect ${IMAGE} | python -m json.tool" + echo "$output" + [ "$status" -eq 0 ] + run ${KPOD_BINARY} $KPOD_OPTIONS rmi ${IMAGE} + echo "$output" + [ "$status" -eq 0 ] +} + + +@test "kpod inspect non-existent container" { + run ${KPOD_BINARY} $KPOD_OPTIONS inspect 14rcole/non-existent + echo "$output" + [ "$status" -ne 0 ] +} + +@test "kpod inspect with format" { + run ${KPOD_BINARY} $KPOD_OPTIONS pull ${IMAGE} + echo "$output" + [ "$status" -eq 0 ] + run ${KPOD_BINARY} $KPOD_OPTIONS inspect --format {{.ID}} ${IMAGE} + echo "$output" + [ "$status" -eq 0 ] + inspectOutput="$output" + run ${KPOD_BINARY} $KPOD_OPTIONS images --quiet ${IMAGE} + echo "$output" + [ "$status" -eq 0 ] + [ "$output" = "$inspectOutput" ] + run ${KPOD_BINARY} $KPOD_OPTIONS rmi ${IMAGE} + echo "$output" + [ "$status" -eq 0 ] +} + +@test "kpod inspect specified type" { + run ${KPOD_BINARY} $KPOD_OPTIONS pull ${IMAGE} + echo "$output" + [ "$status" -eq 0 ] + run bash -c "${KPOD_BINARY} $KPOD_OPTIONS inspect --type image ${IMAGE} | python -m json.tool" + echo "$output" + echo "$output" + [ "$status" -eq 0 ] + run ${KPOD_BINARY} $KPOD_OPTIONS rmi ${IMAGE} + echo "$output" + [ "$status" -eq 0 ] +} diff --git a/test/kpod_load.bats b/test/kpod_load.bats index 61f9a2b8..bb8dd086 100644 --- a/test/kpod_load.bats +++ b/test/kpod_load.bats @@ -3,9 +3,6 @@ load helpers IMAGE="alpine:latest" -ROOT="$TESTDIR/crio" -RUNROOT="$TESTDIR/crio-run" -KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT $STORAGE_OPTS" function teardown() { cleanup_test @@ -13,17 +10,20 @@ function teardown() { @test "kpod load input flag" { run ${KPOD_BINARY} ${KPOD_OPTIONS} pull $IMAGE + echo "$output" [ "$status" -eq 0 ] run ${KPOD_BINARY} ${KPOD_OPTIONS} save -o alpine.tar $IMAGE + echo "$output" [ "$status" -eq 0 ] - run ${KPOD_BINARY} $KPOD_OPTIONS rmi $IMAGE + run ${KPOD_BINARY} ${KPOD_OPTIONS} rmi $IMAGE + echo "$output" [ "$status" -eq 0 ] run ${KPOD_BINARY} ${KPOD_OPTIONS} load -i alpine.tar echo "$output" [ "$status" -eq 0 ] rm -f alpine.tar - [ "$status" -eq 0 ] - run ${KPOD_BINARY} $KPOD_OPTIONS rmi $IMAGE + run ${KPOD_BINARY} ${KPOD_OPTIONS} rmi $IMAGE + echo "$output" [ "$status" -eq 0 ] } @@ -38,24 +38,25 @@ function teardown() { echo "$output" [ "$status" -eq 0 ] rm -f alpine.tar - [ "$status" -eq 0 ] run ${KPOD_BINARY} $KPOD_OPTIONS rmi $IMAGE [ "$status" -eq 0 ] } @test "kpod load using quiet flag" { run ${KPOD_BINARY} ${KPOD_OPTIONS} pull $IMAGE + echo "$output" [ "$status" -eq 0 ] run ${KPOD_BINARY} ${KPOD_OPTIONS} save -o alpine.tar $IMAGE + echo "$output" [ "$status" -eq 0 ] - run ${KPOD_BINARY} $KPOD_OPTIONS rmi $IMAGE + run ${KPOD_BINARY} ${KPOD_OPTIONS} rmi $IMAGE + echo "$output" [ "$status" -eq 0 ] run ${KPOD_BINARY} ${KPOD_OPTIONS} load -q -i alpine.tar echo "$output" [ "$status" -eq 0 ] rm -f alpine.tar - [ "$status" -eq 0 ] - run ${KPOD_BINARY} $KPOD_OPTIONS rmi $IMAGE + run ${KPOD_BINARY} ${KPOD_OPTIONS} rmi $IMAGE [ "$status" -eq 0 ] } diff --git a/test/kpod_logs.bats b/test/kpod_logs.bats index d11b69c1..1e301556 100644 --- a/test/kpod_logs.bats +++ b/test/kpod_logs.bats @@ -3,9 +3,6 @@ load helpers IMAGE="alpine:latest" -ROOT="$TESTDIR/crio" -RUNROOT="$TESTDIR/crio-run" -KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT ${STORAGE_OPTS}" function teardown() { cleanup_test diff --git a/test/kpod_mount.bats b/test/kpod_mount.bats index 517b627c..7b947722 100644 --- a/test/kpod_mount.bats +++ b/test/kpod_mount.bats @@ -7,9 +7,10 @@ function teardown() { load helpers IMAGE="redis:alpine" -ROOT="$TESTDIR/crio" -RUNROOT="$TESTDIR/crio-run" -KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT ${STORAGE_OPTS}" +ROOT="${TESTDIR}/crio" +RUNROOT="${TESTDIR}/crio-run" +# Do not add --storage-driver vfs +KPOD_OPTIONS="--root ${ROOT} --runroot ${RUNROOT} --runtime ${RUNTIME_BINARY}" @test "mount" { start_crio @@ -42,7 +43,9 @@ KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT ${STORAGE_OPTS}" echo "$output" [ "$status" -eq 0 ] touch $root/foobar - ${KPOD_BINARY} ${KPOD_OPTIONS} unmount $ctr_id + run ${KPOD_BINARY} ${KPOD_OPTIONS} unmount $ctr_id + echo "$output" + [ "$status" -eq 0 ] cleanup_ctrs cleanup_pods stop_crio diff --git a/test/kpod_ps.bats b/test/kpod_ps.bats index cd1be60c..4b2628d3 100644 --- a/test/kpod_ps.bats +++ b/test/kpod_ps.bats @@ -3,9 +3,6 @@ load helpers IMAGE="redis:alpine" -ROOT="$TESTDIR/crio" -RUNROOT="$TESTDIR/crio-run" -KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT ${STORAGE_OPTS}" @test "kpod ps with no containers" { run ${KPOD_BINARY} ${KPOD_OPTIONS} ps @@ -15,12 +12,12 @@ KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT ${STORAGE_OPTS}" @test "kpod ps default" { start_crio - [ "$status" -eq 0 ] run crioctl pod run --config "$TESTDATA"/sandbox_config.json echo "$output" [ "$status" -eq 0 ] pod_id="$output" run crioctl image pull "$IMAGE" + echo "$output" [ "$status" -eq 0 ] run crioctl ctr create --config "$TESTDATA"/container_config.json --pod "$pod_id" echo "$output" @@ -35,17 +32,16 @@ KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT ${STORAGE_OPTS}" cleanup_ctrs cleanup_pods stop_crio - [ "$status" -eq 0 ] } @test "kpod ps all flag" { start_crio - [ "$status" -eq 0 ] run crioctl pod run --config "$TESTDATA"/sandbox_config.json echo "$output" [ "$status" -eq 0 ] pod_id="$output" run crioctl image pull "$IMAGE" + echo "$output" [ "$status" -eq 0 ] run crioctl ctr create --config "$TESTDATA"/container_config.json --pod "$pod_id" echo "$output" @@ -59,17 +55,16 @@ KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT ${STORAGE_OPTS}" cleanup_ctrs cleanup_pods stop_crio - [ "$status" -eq 0 ] } @test "kpod ps size flag" { start_crio - [ "$status" -eq 0 ] run crioctl pod run --config "$TESTDATA"/sandbox_config.json echo "$output" [ "$status" -eq 0 ] pod_id="$output" run crioctl image pull "$IMAGE" + echo "$output" [ "$status" -eq 0 ] run crioctl ctr create --config "$TESTDATA"/container_config.json --pod "$pod_id" echo "$output" @@ -83,17 +78,16 @@ KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT ${STORAGE_OPTS}" cleanup_ctrs cleanup_pods stop_crio - [ "$status" -eq 0 ] } @test "kpod ps quiet flag" { start_crio - [ "$status" -eq 0 ] run crioctl pod run --config "$TESTDATA"/sandbox_config.json echo "$output" [ "$status" -eq 0 ] pod_id="$output" run crioctl image pull "$IMAGE" + echo "$output" [ "$status" -eq 0 ] run crioctl ctr create --config "$TESTDATA"/container_config.json --pod "$pod_id" echo "$output" @@ -107,17 +101,16 @@ KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT ${STORAGE_OPTS}" cleanup_ctrs cleanup_pods stop_crio - [ "$status" -eq 0 ] } @test "kpod ps latest flag" { start_crio - [ "$status" -eq 0 ] run crioctl pod run --config "$TESTDATA"/sandbox_config.json echo "$output" [ "$status" -eq 0 ] pod_id="$output" run crioctl image pull "$IMAGE" + echo "$output" [ "$status" -eq 0 ] run crioctl ctr create --config "$TESTDATA"/container_config.json --pod "$pod_id" echo "$output" @@ -131,17 +124,16 @@ KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT ${STORAGE_OPTS}" cleanup_ctrs cleanup_pods stop_crio - [ "$status" -eq 0 ] } @test "kpod ps last flag" { start_crio - [ "$status" -eq 0 ] run crioctl pod run --config "$TESTDATA"/sandbox_config.json echo "$output" [ "$status" -eq 0 ] pod_id="$output" run crioctl image pull "$IMAGE" + echo "$output" [ "$status" -eq 0 ] run crioctl ctr create --config "$TESTDATA"/container_config.json --pod "$pod_id" echo "$output" @@ -155,17 +147,16 @@ KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT ${STORAGE_OPTS}" cleanup_ctrs cleanup_pods stop_crio - [ "$status" -eq 0 ] } @test "kpod ps no-trunc flag" { start_crio - [ "$status" -eq 0 ] run crioctl pod run --config "$TESTDATA"/sandbox_config.json echo "$output" [ "$status" -eq 0 ] pod_id="$output" run crioctl image pull "$IMAGE" + echo "$output" [ "$status" -eq 0 ] run crioctl ctr create --config "$TESTDATA"/container_config.json --pod "$pod_id" echo "$output" @@ -200,17 +191,16 @@ KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT ${STORAGE_OPTS}" cleanup_ctrs cleanup_pods stop_crio - [ "$status" -eq 0 ] } @test "kpod ps namespace flag and format flag = json" { start_crio - [ "$status" -eq 0 ] run crioctl pod run --config "$TESTDATA"/sandbox_config.json echo "$output" [ "$status" -eq 0 ] pod_id="$output" run crioctl image pull "$IMAGE" + echo "$output" [ "$status" -eq 0 ] run crioctl ctr create --config "$TESTDATA"/container_config.json --pod "$pod_id" echo "$output" @@ -221,7 +211,6 @@ KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT ${STORAGE_OPTS}" cleanup_ctrs cleanup_pods stop_crio - [ "$status" -eq 0 ] } @test "kpod ps without namespace flag and format flag = json" { @@ -247,12 +236,12 @@ KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT ${STORAGE_OPTS}" @test "kpod ps format flag = go template" { start_crio - [ "$status" -eq 0 ] run crioctl pod run --config "$TESTDATA"/sandbox_config.json echo "$output" [ "$status" -eq 0 ] pod_id="$output" run crioctl image pull "$IMAGE" + echo "$output" [ "$status" -eq 0 ] run crioctl ctr create --config "$TESTDATA"/container_config.json --pod "$pod_id" echo "$output" @@ -263,17 +252,16 @@ KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT ${STORAGE_OPTS}" cleanup_ctrs cleanup_pods stop_crio - [ "$status" -eq 0 ] } @test "kpod ps filter flag - ancestor" { start_crio - [ "$status" -eq 0 ] run crioctl pod run --config "$TESTDATA"/sandbox_config.json echo "$output" [ "$status" -eq 0 ] pod_id="$output" run crioctl image pull "$IMAGE" + echo "$output" [ "$status" -eq 0 ] run crioctl ctr create --config "$TESTDATA"/container_config.json --pod "$pod_id" echo "$output" @@ -284,17 +272,16 @@ KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT ${STORAGE_OPTS}" cleanup_ctrs cleanup_pods stop_crio - [ "$status" -eq 0 ] } @test "kpod ps filter flag - id" { start_crio - [ "$status" -eq 0 ] run crioctl pod run --config "$TESTDATA"/sandbox_config.json echo "$output" [ "$status" -eq 0 ] pod_id="$output" run crioctl image pull "$IMAGE" + echo "$output" [ "$status" -eq 0 ] run crioctl ctr create --config "$TESTDATA"/container_config.json --pod "$pod_id" echo "$output" @@ -306,17 +293,16 @@ KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT ${STORAGE_OPTS}" cleanup_ctrs cleanup_pods stop_crio - [ "$status" -eq 0 ] } @test "kpod ps filter flag - status" { start_crio - [ "$status" -eq 0 ] run crioctl pod run --config "$TESTDATA"/sandbox_config.json echo "$output" [ "$status" -eq 0 ] pod_id="$output" run crioctl image pull "$IMAGE" + echo "$output" [ "$status" -eq 0 ] run crioctl ctr create --config "$TESTDATA"/container_config.json --pod "$pod_id" echo "$output" @@ -328,5 +314,4 @@ KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT ${STORAGE_OPTS}" cleanup_ctrs cleanup_pods stop_crio - [ "$status" -eq 0 ] } diff --git a/test/kpod_pull.bats b/test/kpod_pull.bats index 2103eecc..3e58397d 100644 --- a/test/kpod_pull.bats +++ b/test/kpod_pull.bats @@ -3,9 +3,6 @@ load helpers IMAGE="alpine:latest" -ROOT="$TESTDIR/crio" -RUNROOT="$TESTDIR/crio-run" -KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT ${STORAGE_OPTS}" function teardown() { cleanup_test @@ -16,6 +13,7 @@ function teardown() { echo "$output" [ "$status" -eq 0 ] run ${KPOD_BINARY} $KPOD_OPTIONS rmi debian:6.0.10 + echo "$output" [ "$status" -eq 0 ] } @@ -24,6 +22,7 @@ function teardown() { echo "$output" [ "$status" -eq 0 ] run ${KPOD_BINARY} $KPOD_OPTIONS rmi debian + echo "$output" [ "$status" -eq 0 ] } @@ -32,6 +31,7 @@ function teardown() { echo "$output" [ "$status" -eq 0 ] run ${KPOD_BINARY} $KPOD_OPTIONS rmi registry.fedoraproject.org/fedora:rawhide + echo "$output" [ "$status" -eq 0 ] } @@ -40,6 +40,7 @@ function teardown() { echo "$output" [ "$status" -eq 0 ] run ${KPOD_BINARY} $KPOD_OPTIONS rmi registry.fedoraproject.org/fedora + echo "$output" [ "$status" -eq 0 ] } @@ -48,6 +49,7 @@ function teardown() { echo "$output" [ "$status" -eq 0 ] run ${KPOD_BINARY} $KPOD_OPTIONS rmi alpine:latest + echo "$output" [ "$status" -eq 0 ] } @@ -62,6 +64,7 @@ function teardown() { echo "$output" [ "$status" -eq 0 ] run ${KPOD_BINARY} $KPOD_OPTIONS rmi docker.io/debian:latest + echo "$output" [ "$status" -eq 0 ] } @@ -70,5 +73,6 @@ function teardown() { echo "$output" [ "$status" -eq 0 ] run ${KPOD_BINARY} $KPOD_OPTIONS rmi docker.io/debian:6.0.10 + echo "$output" [ "$status" -eq 0 ] } diff --git a/test/kpod_push.bats b/test/kpod_push.bats new file mode 100644 index 00000000..983f1409 --- /dev/null +++ b/test/kpod_push.bats @@ -0,0 +1,82 @@ +#!/usr/bin/env bats + +load helpers + +IMAGE="alpine:latest" + +function teardown() { + cleanup_test +} + +@test "kpod push to containers/storage" { + run ${KPOD_BINARY} $KPOD_OPTIONS pull "$IMAGE" + echo "$output" + [ "$status" -eq 0 ] + run ${KPOD_BINARY} $KPOD_OPTIONS push "$IMAGE" containers-storage:[$ROOT]busybox:test + echo "$output" + [ "$status" -eq 0 ] + run ${KPOD_BINARY} $KPOD_OPTIONS rmi "$IMAGE" busybox:test + echo "$output" + [ "$status" -eq 0 ] +} + +@test "kpod push to directory" { + run ${KPOD_BINARY} $KPOD_OPTIONS pull "$IMAGE" + echo "$output" + [ "$status" -eq 0 ] + run mkdir /tmp/busybox + echo "$output" + [ "$status" -eq 0 ] + run ${KPOD_BINARY} $KPOD_OPTIONS push "$IMAGE" dir:/tmp/busybox + echo "$output" + [ "$status" -eq 0 ] + rm -rf /tmp/busybox + run ${KPOD_BINARY} $KPOD_OPTIONS rmi "$IMAGE" + echo "$output" + [ "$status" -eq 0 ] +} + +@test "kpod push to docker archive" { + run ${KPOD_BINARY} $KPOD_OPTIONS pull "$IMAGE" + echo "$output" + [ "$status" -eq 0 ] + run ${KPOD_BINARY} $KPOD_OPTIONS push "$IMAGE" docker-archive:/tmp/busybox-archive:1.26 + echo "$output" + [ "$status" -eq 0 ] + rm /tmp/busybox-archive + run ${KPOD_BINARY} $KPOD_OPTIONS rmi "$IMAGE" + echo "$output" + [ "$status" -eq 0 ] +} + +@test "kpod push to oci without compression" { + run ${KPOD_BINARY} $KPOD_OPTIONS pull "$IMAGE" + echo "$output" + [ "$status" -eq 0 ] + run mkdir /tmp/oci-busybox + echo "$output" + [ "$status" -eq 0 ] + run ${KPOD_BINARY} $KPOD_OPTIONS push "$IMAGE" oci:/tmp/oci-busybox:busybox + echo "$output" + [ "$status" -eq 0 ] + rm -rf /tmp/oci-busybox + run ${KPOD_BINARY} $KPOD_OPTIONS rmi "$IMAGE" + echo "$output" + [ "$status" -eq 0 ] +} + +@test "kpod push without signatures" { + run ${KPOD_BINARY} $KPOD_OPTIONS pull "$IMAGE" + echo "$output" + [ "$status" -eq 0 ] + run mkdir /tmp/busybox + echo "$output" + [ "$status" -eq 0 ] + run ${KPOD_BINARY} $KPOD_OPTIONS push --remove-signatures "$IMAGE" dir:/tmp/busybox + echo "$output" + [ "$status" -eq 0 ] + rm -rf /tmp/busybox + run ${KPOD_BINARY} $KPOD_OPTIONS rmi "$IMAGE" + echo "$output" + [ "$status" -eq 0 ] +} diff --git a/test/kpod_rename.bats b/test/kpod_rename.bats index 9419ce2d..488449aa 100644 --- a/test/kpod_rename.bats +++ b/test/kpod_rename.bats @@ -3,10 +3,6 @@ load helpers IMAGE="redis:alpine" -ROOT="$TESTDIR/crio" -RUNROOT="$TESTDIR/crio-run" -KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT $STORAGE_OPTS" -NEW_NAME="rename-test" function teardown() { cleanup_test @@ -15,6 +11,7 @@ function teardown() { @test "kpod rename successful" { start_crio run ${KPOD_BINARY} ${KPOD_OPTIONS} pull $IMAGE + echo "$output" [ "$status" -eq 0 ] run crioctl pod run --config "$TESTDATA"/sandbox_config.json echo "$output" diff --git a/test/kpod_rm.bats b/test/kpod_rm.bats index b41f58dd..022e3efc 100644 --- a/test/kpod_rm.bats +++ b/test/kpod_rm.bats @@ -3,9 +3,7 @@ load helpers IMAGE="alpine:latest" -ROOT="$TESTDIR/crio" -RUNROOT="$TESTDIR/crio-run" -KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT $STORAGE_OPTS --runtime $RUNTIME_BINARY" + function teardown() { cleanup_test } diff --git a/test/kpod_save.bats b/test/kpod_save.bats index d961d69e..4f71ae78 100644 --- a/test/kpod_save.bats +++ b/test/kpod_save.bats @@ -3,9 +3,6 @@ load helpers IMAGE="alpine:latest" -ROOT="$TESTDIR/crio" -RUNROOT="$TESTDIR/crio-run" -KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT $STORAGE_OPTS" function teardown() { cleanup_test @@ -13,14 +10,15 @@ function teardown() { @test "kpod save output flag" { run ${KPOD_BINARY} ${KPOD_OPTIONS} pull $IMAGE + echo "$output" [ "$status" -eq 0 ] run ${KPOD_BINARY} ${KPOD_OPTIONS} save -o alpine.tar $IMAGE echo "$output" [ "$status" -eq 0 ] run ${KPOD_BINARY} ${KPOD_OPTIONS} rmi $IMAGE + echo "$output" [ "$status" -eq 0 ] rm -f alpine.tar - [ "$status" -eq 0 ] } @test "kpod save oci flag" { @@ -37,26 +35,28 @@ function teardown() { @test "kpod save using stdout" { run ${KPOD_BINARY} ${KPOD_OPTIONS} pull $IMAGE + echo "$output" [ "$status" -eq 0 ] run ${KPOD_BINARY} ${KPOD_OPTIONS} save > alpine.tar $IMAGE echo "$output" [ "$status" -eq 0 ] run ${KPOD_BINARY} ${KPOD_OPTIONS} rmi $IMAGE + echo "$output" [ "$status" -eq 0 ] rm -f alpine.tar - [ "$status" -eq 0 ] } @test "kpod save quiet flag" { run ${KPOD_BINARY} ${KPOD_OPTIONS} pull $IMAGE + echo "$output" [ "$status" -eq 0 ] run ${KPOD_BINARY} ${KPOD_OPTIONS} save -q -o alpine.tar $IMAGE echo "$output" [ "$status" -eq 0 ] run ${KPOD_BINARY} ${KPOD_OPTIONS} rmi $IMAGE + echo "$output" [ "$status" -eq 0 ] rm -f alpine.tar - [ "$status" -eq 0 ] } @test "kpod save non-existent image" { diff --git a/test/kpod_stats.bats b/test/kpod_stats.bats index c9f58cc9..a4b8e61e 100644 --- a/test/kpod_stats.bats +++ b/test/kpod_stats.bats @@ -2,10 +2,6 @@ load helpers -ROOT="$TESTDIR/crio" -RUNROOT="$TESTDIR/crio-run" -KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT $STORAGE_OPTS" - function teardown() { cleanup_test } @@ -23,7 +19,7 @@ function teardown() { run crioctl ctr start --id "$ctr_id" echo "$output" [ "$status" -eq 0 ] - run ${KPOD_BINARY} $KPOD_OPTIONS stats --no-stream "$ctr_id" + run ${KPOD_BINARY} ${KPOD_OPTIONS} stats --no-stream "$ctr_id" echo "$output" [ "$status" -eq 0 ] cleanup_ctrs @@ -41,7 +37,7 @@ function teardown() { echo "$output" [ "$status" -eq 0 ] ctr_id="$output" - run ${KPOD_BINARY} $KPOD_OPTIONS stats --no-stream + run ${KPOD_BINARY} ${KPOD_OPTIONS} stats --no-stream echo "$output" [ "$status" -eq 0 ] cleanup_ctrs @@ -59,7 +55,7 @@ function teardown() { echo "$output" [ "$status" -eq 0 ] ctr_id="$output" - run ${KPOD_BINARY} $KPOD_OPTIONS stats --no-stream --all + run ${KPOD_BINARY} ${KPOD_OPTIONS} stats --no-stream --all echo "$output" [ "$status" -eq 0 ] cleanup_ctrs @@ -80,7 +76,8 @@ function teardown() { run crioctl ctr start --id "$ctr_id" echo "$output" [ "$status" -eq 0 ] - run ${KPOD_BINARY} $KPOD_OPTIONS stats --no-stream --format {{.ID}} "$ctr_id" + run ${KPOD_BINARY} ${KPOD_OPTIONS} stats --no-stream --format {{.ID}} "$ctr_id" + echo "$output" [ "$status" -eq 0 ] # once ps is implemented, run ps -q and see if that equals the output from above cleanup_ctrs @@ -98,7 +95,7 @@ function teardown() { echo "$output" [ "$status" -eq 0 ] ctr_id="$output" - run timeout 5s bash -c "${KPOD_BINARY} $KPOD_OPTIONS stats --all" + run timeout 5s bash -c "${KPOD_BINARY} ${KPOD_OPTIONS} stats --all" echo "$output" [ "$status" -eq 124 ] #124 is the status set by timeout when it has to kill the command at the end of the given time cleanup_ctrs diff --git a/test/kpod_stop.bats b/test/kpod_stop.bats index 4532ff51..08b4c933 100644 --- a/test/kpod_stop.bats +++ b/test/kpod_stop.bats @@ -2,9 +2,6 @@ load helpers -ROOT="$TESTDIR/crio" -RUNROOT="$TESTDIR/crio-run" -KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT --storage-driver vfs" function teardown() { cleanup_test } diff --git a/test/kpod_version.bats b/test/kpod_version.bats new file mode 100644 index 00000000..e6c062b8 --- /dev/null +++ b/test/kpod_version.bats @@ -0,0 +1,13 @@ +#!/usr/bin/env bats + +load helpers + +function teardown() { + cleanup_test +} + +@test "kpod version test" { + run ${KPOD_BINARY} version + echo "$output" + [ "$status" -eq 0 ] +}