Refactor kpod tests

Move kpod tests from kpod.bats to kpod_[commandname].bats
Also make sure all status checks have a echo $output before them.

Signed-off-by: Ryan Cole <rcyoalne@gmail.com>

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Signed-off-by: umohnani8 <umohnani@redhat.com>
This commit is contained in:
Daniel J Walsh 2017-08-31 08:46:26 -04:00 committed by umohnani8
parent e838611fdd
commit e16bb3feb3
19 changed files with 350 additions and 295 deletions

View file

@ -59,6 +59,11 @@ PIDS_LIMIT=${PIDS_LIMIT:-1024}
# Log size max limit # Log size max limit
LOG_SIZE_MAX_LIMIT=${LOG_SIZE_MAX_LIMIT:--1} 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) TESTDIR=$(mktemp -d)
# kpod pull needs a configuration file for shortname pulls # kpod pull needs a configuration file for shortname pulls

View file

@ -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" ]
}

View file

@ -1,11 +1,8 @@
#/usr/bin/env bats #!/usr/bin/env bats
load helpers load helpers
IMAGE="alpine:latest" IMAGE="alpine:latest"
ROOT="$TESTDIR/crio"
RUNROOT="$TESTDIR/crio-run"
KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT $STORAGE_OPTS"
function teardown() { function teardown() {
cleanup_test cleanup_test
@ -18,14 +15,15 @@ function teardown() {
run ${KPOD_BINARY} $KPOD_OPTIONS diff $IMAGE run ${KPOD_BINARY} $KPOD_OPTIONS diff $IMAGE
echo "$output" echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
run ${KPOD_BINARY} $KPOD_OPTIONS rmi $IMAGE
echo "$output" echo "$output"
run ${KKPOD_BINARY} $KPOD_OPTIONS rmi $IMAGE [ "$status" -eq 0 ]
} }
@test "test diff on non-existent layer" { @test "test diff on non-existent layer" {
run ${KPOD_BINARY} $KPOD_OPTIONS diff "abc123" run ${KPOD_BINARY} $KPOD_OPTIONS diff "abc123"
[ "$status" -ne 0 ]
echo "$output" echo "$output"
[ "$status" -ne 0 ]
} }
@test "test diff with json output" { @test "test diff with json output" {
@ -36,5 +34,7 @@ function teardown() {
run ${KPOD_BINARY} $KPOD_OPTIONS diff --format json $IMAGE run ${KPOD_BINARY} $KPOD_OPTIONS diff --format json $IMAGE
echo "$output" echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
run ${KKPOD_BINARY} $KPOD_OPTIONS rmi $IMAGE run ${KPOD_BINARY} $KPOD_OPTIONS rmi $IMAGE
echo "$output"
[ "$status" -eq 0 ]
} }

View file

@ -3,19 +3,23 @@
load helpers load helpers
IMAGE="redis:alpine" IMAGE="redis:alpine"
ROOT="$TESTDIR/crio" ROOT="${TESTDIR}/crio"
RUNROOT="$TESTDIR/crio-run" RUNROOT="${TESTDIR}/crio-run"
KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT ${STORAGE_OPTS}" # Do not add --storage-driver vfs
KPOD_OPTIONS="--root ${ROOT} --runroot ${RUNROOT} --runtime ${RUNTIME_BINARY}"
function teardown() {
cleanup_test
}
@test "kpod export output flag" { @test "kpod export output flag" {
start_crio start_crio
[ "$status" -eq 0 ]
run crioctl pod run --config "$TESTDATA"/sandbox_config.json run crioctl pod run --config "$TESTDATA"/sandbox_config.json
echo "$output" echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
pod_id="$output" pod_id="$output"
run crioctl image pull "$IMAGE" run crioctl image pull "$IMAGE"
echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
run crioctl ctr create --config "$TESTDATA"/container_config.json --pod "$pod_id" run crioctl ctr create --config "$TESTDATA"/container_config.json --pod "$pod_id"
echo "$output" echo "$output"
@ -25,11 +29,7 @@ KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT ${STORAGE_OPTS}"
echo "$output" echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
cleanup_ctrs cleanup_ctrs
[ "$status" -eq 0 ]
cleanup_pods cleanup_pods
[ "$status" -eq 0 ]
stop_crio stop_crio
[ "$status" -eq 0 ]
rm -f container.tar rm -f container.tar
[ "$status" -eq 0 ]
} }

80
test/kpod_history.bats Normal file
View file

@ -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 ]
}

46
test/kpod_images.bats Normal file
View file

@ -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 ]
}

58
test/kpod_inspect.bats Normal file
View file

@ -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 ]
}

View file

@ -3,9 +3,6 @@
load helpers load helpers
IMAGE="alpine:latest" IMAGE="alpine:latest"
ROOT="$TESTDIR/crio"
RUNROOT="$TESTDIR/crio-run"
KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT $STORAGE_OPTS"
function teardown() { function teardown() {
cleanup_test cleanup_test
@ -13,17 +10,20 @@ function teardown() {
@test "kpod load input flag" { @test "kpod load input flag" {
run ${KPOD_BINARY} ${KPOD_OPTIONS} pull $IMAGE run ${KPOD_BINARY} ${KPOD_OPTIONS} pull $IMAGE
echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
run ${KPOD_BINARY} ${KPOD_OPTIONS} save -o alpine.tar $IMAGE run ${KPOD_BINARY} ${KPOD_OPTIONS} save -o alpine.tar $IMAGE
echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
run ${KPOD_BINARY} $KPOD_OPTIONS rmi $IMAGE run ${KPOD_BINARY} ${KPOD_OPTIONS} rmi $IMAGE
echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
run ${KPOD_BINARY} ${KPOD_OPTIONS} load -i alpine.tar run ${KPOD_BINARY} ${KPOD_OPTIONS} load -i alpine.tar
echo "$output" echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
rm -f alpine.tar 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 ] [ "$status" -eq 0 ]
} }
@ -38,24 +38,25 @@ function teardown() {
echo "$output" echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
rm -f alpine.tar rm -f alpine.tar
[ "$status" -eq 0 ]
run ${KPOD_BINARY} $KPOD_OPTIONS rmi $IMAGE run ${KPOD_BINARY} $KPOD_OPTIONS rmi $IMAGE
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
} }
@test "kpod load using quiet flag" { @test "kpod load using quiet flag" {
run ${KPOD_BINARY} ${KPOD_OPTIONS} pull $IMAGE run ${KPOD_BINARY} ${KPOD_OPTIONS} pull $IMAGE
echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
run ${KPOD_BINARY} ${KPOD_OPTIONS} save -o alpine.tar $IMAGE run ${KPOD_BINARY} ${KPOD_OPTIONS} save -o alpine.tar $IMAGE
echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
run ${KPOD_BINARY} $KPOD_OPTIONS rmi $IMAGE run ${KPOD_BINARY} ${KPOD_OPTIONS} rmi $IMAGE
echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
run ${KPOD_BINARY} ${KPOD_OPTIONS} load -q -i alpine.tar run ${KPOD_BINARY} ${KPOD_OPTIONS} load -q -i alpine.tar
echo "$output" echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
rm -f alpine.tar rm -f alpine.tar
[ "$status" -eq 0 ] run ${KPOD_BINARY} ${KPOD_OPTIONS} rmi $IMAGE
run ${KPOD_BINARY} $KPOD_OPTIONS rmi $IMAGE
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
} }

View file

@ -3,9 +3,6 @@
load helpers load helpers
IMAGE="alpine:latest" IMAGE="alpine:latest"
ROOT="$TESTDIR/crio"
RUNROOT="$TESTDIR/crio-run"
KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT ${STORAGE_OPTS}"
function teardown() { function teardown() {
cleanup_test cleanup_test

View file

@ -7,9 +7,10 @@ function teardown() {
load helpers load helpers
IMAGE="redis:alpine" IMAGE="redis:alpine"
ROOT="$TESTDIR/crio" ROOT="${TESTDIR}/crio"
RUNROOT="$TESTDIR/crio-run" RUNROOT="${TESTDIR}/crio-run"
KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT ${STORAGE_OPTS}" # Do not add --storage-driver vfs
KPOD_OPTIONS="--root ${ROOT} --runroot ${RUNROOT} --runtime ${RUNTIME_BINARY}"
@test "mount" { @test "mount" {
start_crio start_crio
@ -42,7 +43,9 @@ KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT ${STORAGE_OPTS}"
echo "$output" echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
touch $root/foobar 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_ctrs
cleanup_pods cleanup_pods
stop_crio stop_crio

View file

@ -3,9 +3,6 @@
load helpers load helpers
IMAGE="redis:alpine" IMAGE="redis:alpine"
ROOT="$TESTDIR/crio"
RUNROOT="$TESTDIR/crio-run"
KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT ${STORAGE_OPTS}"
@test "kpod ps with no containers" { @test "kpod ps with no containers" {
run ${KPOD_BINARY} ${KPOD_OPTIONS} ps run ${KPOD_BINARY} ${KPOD_OPTIONS} ps
@ -15,12 +12,12 @@ KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT ${STORAGE_OPTS}"
@test "kpod ps default" { @test "kpod ps default" {
start_crio start_crio
[ "$status" -eq 0 ]
run crioctl pod run --config "$TESTDATA"/sandbox_config.json run crioctl pod run --config "$TESTDATA"/sandbox_config.json
echo "$output" echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
pod_id="$output" pod_id="$output"
run crioctl image pull "$IMAGE" run crioctl image pull "$IMAGE"
echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
run crioctl ctr create --config "$TESTDATA"/container_config.json --pod "$pod_id" run crioctl ctr create --config "$TESTDATA"/container_config.json --pod "$pod_id"
echo "$output" echo "$output"
@ -35,17 +32,16 @@ KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT ${STORAGE_OPTS}"
cleanup_ctrs cleanup_ctrs
cleanup_pods cleanup_pods
stop_crio stop_crio
[ "$status" -eq 0 ]
} }
@test "kpod ps all flag" { @test "kpod ps all flag" {
start_crio start_crio
[ "$status" -eq 0 ]
run crioctl pod run --config "$TESTDATA"/sandbox_config.json run crioctl pod run --config "$TESTDATA"/sandbox_config.json
echo "$output" echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
pod_id="$output" pod_id="$output"
run crioctl image pull "$IMAGE" run crioctl image pull "$IMAGE"
echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
run crioctl ctr create --config "$TESTDATA"/container_config.json --pod "$pod_id" run crioctl ctr create --config "$TESTDATA"/container_config.json --pod "$pod_id"
echo "$output" echo "$output"
@ -59,17 +55,16 @@ KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT ${STORAGE_OPTS}"
cleanup_ctrs cleanup_ctrs
cleanup_pods cleanup_pods
stop_crio stop_crio
[ "$status" -eq 0 ]
} }
@test "kpod ps size flag" { @test "kpod ps size flag" {
start_crio start_crio
[ "$status" -eq 0 ]
run crioctl pod run --config "$TESTDATA"/sandbox_config.json run crioctl pod run --config "$TESTDATA"/sandbox_config.json
echo "$output" echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
pod_id="$output" pod_id="$output"
run crioctl image pull "$IMAGE" run crioctl image pull "$IMAGE"
echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
run crioctl ctr create --config "$TESTDATA"/container_config.json --pod "$pod_id" run crioctl ctr create --config "$TESTDATA"/container_config.json --pod "$pod_id"
echo "$output" echo "$output"
@ -83,17 +78,16 @@ KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT ${STORAGE_OPTS}"
cleanup_ctrs cleanup_ctrs
cleanup_pods cleanup_pods
stop_crio stop_crio
[ "$status" -eq 0 ]
} }
@test "kpod ps quiet flag" { @test "kpod ps quiet flag" {
start_crio start_crio
[ "$status" -eq 0 ]
run crioctl pod run --config "$TESTDATA"/sandbox_config.json run crioctl pod run --config "$TESTDATA"/sandbox_config.json
echo "$output" echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
pod_id="$output" pod_id="$output"
run crioctl image pull "$IMAGE" run crioctl image pull "$IMAGE"
echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
run crioctl ctr create --config "$TESTDATA"/container_config.json --pod "$pod_id" run crioctl ctr create --config "$TESTDATA"/container_config.json --pod "$pod_id"
echo "$output" echo "$output"
@ -107,17 +101,16 @@ KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT ${STORAGE_OPTS}"
cleanup_ctrs cleanup_ctrs
cleanup_pods cleanup_pods
stop_crio stop_crio
[ "$status" -eq 0 ]
} }
@test "kpod ps latest flag" { @test "kpod ps latest flag" {
start_crio start_crio
[ "$status" -eq 0 ]
run crioctl pod run --config "$TESTDATA"/sandbox_config.json run crioctl pod run --config "$TESTDATA"/sandbox_config.json
echo "$output" echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
pod_id="$output" pod_id="$output"
run crioctl image pull "$IMAGE" run crioctl image pull "$IMAGE"
echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
run crioctl ctr create --config "$TESTDATA"/container_config.json --pod "$pod_id" run crioctl ctr create --config "$TESTDATA"/container_config.json --pod "$pod_id"
echo "$output" echo "$output"
@ -131,17 +124,16 @@ KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT ${STORAGE_OPTS}"
cleanup_ctrs cleanup_ctrs
cleanup_pods cleanup_pods
stop_crio stop_crio
[ "$status" -eq 0 ]
} }
@test "kpod ps last flag" { @test "kpod ps last flag" {
start_crio start_crio
[ "$status" -eq 0 ]
run crioctl pod run --config "$TESTDATA"/sandbox_config.json run crioctl pod run --config "$TESTDATA"/sandbox_config.json
echo "$output" echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
pod_id="$output" pod_id="$output"
run crioctl image pull "$IMAGE" run crioctl image pull "$IMAGE"
echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
run crioctl ctr create --config "$TESTDATA"/container_config.json --pod "$pod_id" run crioctl ctr create --config "$TESTDATA"/container_config.json --pod "$pod_id"
echo "$output" echo "$output"
@ -155,17 +147,16 @@ KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT ${STORAGE_OPTS}"
cleanup_ctrs cleanup_ctrs
cleanup_pods cleanup_pods
stop_crio stop_crio
[ "$status" -eq 0 ]
} }
@test "kpod ps no-trunc flag" { @test "kpod ps no-trunc flag" {
start_crio start_crio
[ "$status" -eq 0 ]
run crioctl pod run --config "$TESTDATA"/sandbox_config.json run crioctl pod run --config "$TESTDATA"/sandbox_config.json
echo "$output" echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
pod_id="$output" pod_id="$output"
run crioctl image pull "$IMAGE" run crioctl image pull "$IMAGE"
echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
run crioctl ctr create --config "$TESTDATA"/container_config.json --pod "$pod_id" run crioctl ctr create --config "$TESTDATA"/container_config.json --pod "$pod_id"
echo "$output" echo "$output"
@ -200,17 +191,16 @@ KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT ${STORAGE_OPTS}"
cleanup_ctrs cleanup_ctrs
cleanup_pods cleanup_pods
stop_crio stop_crio
[ "$status" -eq 0 ]
} }
@test "kpod ps namespace flag and format flag = json" { @test "kpod ps namespace flag and format flag = json" {
start_crio start_crio
[ "$status" -eq 0 ]
run crioctl pod run --config "$TESTDATA"/sandbox_config.json run crioctl pod run --config "$TESTDATA"/sandbox_config.json
echo "$output" echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
pod_id="$output" pod_id="$output"
run crioctl image pull "$IMAGE" run crioctl image pull "$IMAGE"
echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
run crioctl ctr create --config "$TESTDATA"/container_config.json --pod "$pod_id" run crioctl ctr create --config "$TESTDATA"/container_config.json --pod "$pod_id"
echo "$output" echo "$output"
@ -221,7 +211,6 @@ KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT ${STORAGE_OPTS}"
cleanup_ctrs cleanup_ctrs
cleanup_pods cleanup_pods
stop_crio stop_crio
[ "$status" -eq 0 ]
} }
@test "kpod ps without namespace flag and format flag = json" { @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" { @test "kpod ps format flag = go template" {
start_crio start_crio
[ "$status" -eq 0 ]
run crioctl pod run --config "$TESTDATA"/sandbox_config.json run crioctl pod run --config "$TESTDATA"/sandbox_config.json
echo "$output" echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
pod_id="$output" pod_id="$output"
run crioctl image pull "$IMAGE" run crioctl image pull "$IMAGE"
echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
run crioctl ctr create --config "$TESTDATA"/container_config.json --pod "$pod_id" run crioctl ctr create --config "$TESTDATA"/container_config.json --pod "$pod_id"
echo "$output" echo "$output"
@ -263,17 +252,16 @@ KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT ${STORAGE_OPTS}"
cleanup_ctrs cleanup_ctrs
cleanup_pods cleanup_pods
stop_crio stop_crio
[ "$status" -eq 0 ]
} }
@test "kpod ps filter flag - ancestor" { @test "kpod ps filter flag - ancestor" {
start_crio start_crio
[ "$status" -eq 0 ]
run crioctl pod run --config "$TESTDATA"/sandbox_config.json run crioctl pod run --config "$TESTDATA"/sandbox_config.json
echo "$output" echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
pod_id="$output" pod_id="$output"
run crioctl image pull "$IMAGE" run crioctl image pull "$IMAGE"
echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
run crioctl ctr create --config "$TESTDATA"/container_config.json --pod "$pod_id" run crioctl ctr create --config "$TESTDATA"/container_config.json --pod "$pod_id"
echo "$output" echo "$output"
@ -284,17 +272,16 @@ KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT ${STORAGE_OPTS}"
cleanup_ctrs cleanup_ctrs
cleanup_pods cleanup_pods
stop_crio stop_crio
[ "$status" -eq 0 ]
} }
@test "kpod ps filter flag - id" { @test "kpod ps filter flag - id" {
start_crio start_crio
[ "$status" -eq 0 ]
run crioctl pod run --config "$TESTDATA"/sandbox_config.json run crioctl pod run --config "$TESTDATA"/sandbox_config.json
echo "$output" echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
pod_id="$output" pod_id="$output"
run crioctl image pull "$IMAGE" run crioctl image pull "$IMAGE"
echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
run crioctl ctr create --config "$TESTDATA"/container_config.json --pod "$pod_id" run crioctl ctr create --config "$TESTDATA"/container_config.json --pod "$pod_id"
echo "$output" echo "$output"
@ -306,17 +293,16 @@ KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT ${STORAGE_OPTS}"
cleanup_ctrs cleanup_ctrs
cleanup_pods cleanup_pods
stop_crio stop_crio
[ "$status" -eq 0 ]
} }
@test "kpod ps filter flag - status" { @test "kpod ps filter flag - status" {
start_crio start_crio
[ "$status" -eq 0 ]
run crioctl pod run --config "$TESTDATA"/sandbox_config.json run crioctl pod run --config "$TESTDATA"/sandbox_config.json
echo "$output" echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
pod_id="$output" pod_id="$output"
run crioctl image pull "$IMAGE" run crioctl image pull "$IMAGE"
echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
run crioctl ctr create --config "$TESTDATA"/container_config.json --pod "$pod_id" run crioctl ctr create --config "$TESTDATA"/container_config.json --pod "$pod_id"
echo "$output" echo "$output"
@ -328,5 +314,4 @@ KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT ${STORAGE_OPTS}"
cleanup_ctrs cleanup_ctrs
cleanup_pods cleanup_pods
stop_crio stop_crio
[ "$status" -eq 0 ]
} }

View file

@ -3,9 +3,6 @@
load helpers load helpers
IMAGE="alpine:latest" IMAGE="alpine:latest"
ROOT="$TESTDIR/crio"
RUNROOT="$TESTDIR/crio-run"
KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT ${STORAGE_OPTS}"
function teardown() { function teardown() {
cleanup_test cleanup_test
@ -16,6 +13,7 @@ function teardown() {
echo "$output" echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
run ${KPOD_BINARY} $KPOD_OPTIONS rmi debian:6.0.10 run ${KPOD_BINARY} $KPOD_OPTIONS rmi debian:6.0.10
echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
} }
@ -24,6 +22,7 @@ function teardown() {
echo "$output" echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
run ${KPOD_BINARY} $KPOD_OPTIONS rmi debian run ${KPOD_BINARY} $KPOD_OPTIONS rmi debian
echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
} }
@ -32,6 +31,7 @@ function teardown() {
echo "$output" echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
run ${KPOD_BINARY} $KPOD_OPTIONS rmi registry.fedoraproject.org/fedora:rawhide run ${KPOD_BINARY} $KPOD_OPTIONS rmi registry.fedoraproject.org/fedora:rawhide
echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
} }
@ -40,6 +40,7 @@ function teardown() {
echo "$output" echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
run ${KPOD_BINARY} $KPOD_OPTIONS rmi registry.fedoraproject.org/fedora run ${KPOD_BINARY} $KPOD_OPTIONS rmi registry.fedoraproject.org/fedora
echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
} }
@ -48,6 +49,7 @@ function teardown() {
echo "$output" echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
run ${KPOD_BINARY} $KPOD_OPTIONS rmi alpine:latest run ${KPOD_BINARY} $KPOD_OPTIONS rmi alpine:latest
echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
} }
@ -62,6 +64,7 @@ function teardown() {
echo "$output" echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
run ${KPOD_BINARY} $KPOD_OPTIONS rmi docker.io/debian:latest run ${KPOD_BINARY} $KPOD_OPTIONS rmi docker.io/debian:latest
echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
} }
@ -70,5 +73,6 @@ function teardown() {
echo "$output" echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
run ${KPOD_BINARY} $KPOD_OPTIONS rmi docker.io/debian:6.0.10 run ${KPOD_BINARY} $KPOD_OPTIONS rmi docker.io/debian:6.0.10
echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
} }

82
test/kpod_push.bats Normal file
View file

@ -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 ]
}

View file

@ -3,10 +3,6 @@
load helpers load helpers
IMAGE="redis:alpine" IMAGE="redis:alpine"
ROOT="$TESTDIR/crio"
RUNROOT="$TESTDIR/crio-run"
KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT $STORAGE_OPTS"
NEW_NAME="rename-test"
function teardown() { function teardown() {
cleanup_test cleanup_test
@ -15,6 +11,7 @@ function teardown() {
@test "kpod rename successful" { @test "kpod rename successful" {
start_crio start_crio
run ${KPOD_BINARY} ${KPOD_OPTIONS} pull $IMAGE run ${KPOD_BINARY} ${KPOD_OPTIONS} pull $IMAGE
echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
run crioctl pod run --config "$TESTDATA"/sandbox_config.json run crioctl pod run --config "$TESTDATA"/sandbox_config.json
echo "$output" echo "$output"

View file

@ -3,9 +3,7 @@
load helpers load helpers
IMAGE="alpine:latest" IMAGE="alpine:latest"
ROOT="$TESTDIR/crio"
RUNROOT="$TESTDIR/crio-run"
KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT $STORAGE_OPTS --runtime $RUNTIME_BINARY"
function teardown() { function teardown() {
cleanup_test cleanup_test
} }

View file

@ -3,9 +3,6 @@
load helpers load helpers
IMAGE="alpine:latest" IMAGE="alpine:latest"
ROOT="$TESTDIR/crio"
RUNROOT="$TESTDIR/crio-run"
KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT $STORAGE_OPTS"
function teardown() { function teardown() {
cleanup_test cleanup_test
@ -13,14 +10,15 @@ function teardown() {
@test "kpod save output flag" { @test "kpod save output flag" {
run ${KPOD_BINARY} ${KPOD_OPTIONS} pull $IMAGE run ${KPOD_BINARY} ${KPOD_OPTIONS} pull $IMAGE
echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
run ${KPOD_BINARY} ${KPOD_OPTIONS} save -o alpine.tar $IMAGE run ${KPOD_BINARY} ${KPOD_OPTIONS} save -o alpine.tar $IMAGE
echo "$output" echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
run ${KPOD_BINARY} ${KPOD_OPTIONS} rmi $IMAGE run ${KPOD_BINARY} ${KPOD_OPTIONS} rmi $IMAGE
echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
rm -f alpine.tar rm -f alpine.tar
[ "$status" -eq 0 ]
} }
@test "kpod save oci flag" { @test "kpod save oci flag" {
@ -37,26 +35,28 @@ function teardown() {
@test "kpod save using stdout" { @test "kpod save using stdout" {
run ${KPOD_BINARY} ${KPOD_OPTIONS} pull $IMAGE run ${KPOD_BINARY} ${KPOD_OPTIONS} pull $IMAGE
echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
run ${KPOD_BINARY} ${KPOD_OPTIONS} save > alpine.tar $IMAGE run ${KPOD_BINARY} ${KPOD_OPTIONS} save > alpine.tar $IMAGE
echo "$output" echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
run ${KPOD_BINARY} ${KPOD_OPTIONS} rmi $IMAGE run ${KPOD_BINARY} ${KPOD_OPTIONS} rmi $IMAGE
echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
rm -f alpine.tar rm -f alpine.tar
[ "$status" -eq 0 ]
} }
@test "kpod save quiet flag" { @test "kpod save quiet flag" {
run ${KPOD_BINARY} ${KPOD_OPTIONS} pull $IMAGE run ${KPOD_BINARY} ${KPOD_OPTIONS} pull $IMAGE
echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
run ${KPOD_BINARY} ${KPOD_OPTIONS} save -q -o alpine.tar $IMAGE run ${KPOD_BINARY} ${KPOD_OPTIONS} save -q -o alpine.tar $IMAGE
echo "$output" echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
run ${KPOD_BINARY} ${KPOD_OPTIONS} rmi $IMAGE run ${KPOD_BINARY} ${KPOD_OPTIONS} rmi $IMAGE
echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
rm -f alpine.tar rm -f alpine.tar
[ "$status" -eq 0 ]
} }
@test "kpod save non-existent image" { @test "kpod save non-existent image" {

View file

@ -2,10 +2,6 @@
load helpers load helpers
ROOT="$TESTDIR/crio"
RUNROOT="$TESTDIR/crio-run"
KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT $STORAGE_OPTS"
function teardown() { function teardown() {
cleanup_test cleanup_test
} }
@ -23,7 +19,7 @@ function teardown() {
run crioctl ctr start --id "$ctr_id" run crioctl ctr start --id "$ctr_id"
echo "$output" echo "$output"
[ "$status" -eq 0 ] [ "$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" echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
cleanup_ctrs cleanup_ctrs
@ -41,7 +37,7 @@ function teardown() {
echo "$output" echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
ctr_id="$output" ctr_id="$output"
run ${KPOD_BINARY} $KPOD_OPTIONS stats --no-stream run ${KPOD_BINARY} ${KPOD_OPTIONS} stats --no-stream
echo "$output" echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
cleanup_ctrs cleanup_ctrs
@ -59,7 +55,7 @@ function teardown() {
echo "$output" echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
ctr_id="$output" ctr_id="$output"
run ${KPOD_BINARY} $KPOD_OPTIONS stats --no-stream --all run ${KPOD_BINARY} ${KPOD_OPTIONS} stats --no-stream --all
echo "$output" echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
cleanup_ctrs cleanup_ctrs
@ -80,7 +76,8 @@ function teardown() {
run crioctl ctr start --id "$ctr_id" run crioctl ctr start --id "$ctr_id"
echo "$output" echo "$output"
[ "$status" -eq 0 ] [ "$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 ] [ "$status" -eq 0 ]
# once ps is implemented, run ps -q and see if that equals the output from above # once ps is implemented, run ps -q and see if that equals the output from above
cleanup_ctrs cleanup_ctrs
@ -98,7 +95,7 @@ function teardown() {
echo "$output" echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
ctr_id="$output" 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" 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 [ "$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 cleanup_ctrs

View file

@ -2,9 +2,6 @@
load helpers load helpers
ROOT="$TESTDIR/crio"
RUNROOT="$TESTDIR/crio-run"
KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT --storage-driver vfs"
function teardown() { function teardown() {
cleanup_test cleanup_test
} }

13
test/kpod_version.bats Normal file
View file

@ -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 ]
}