Merge pull request #878 from umohnani8/refactor_tests

Refactor kpod tests
This commit is contained in:
Daniel J Walsh 2017-10-02 08:45:25 -04:00 committed by GitHub
commit f33b59861b
23 changed files with 345 additions and 311 deletions

View file

@ -90,6 +90,8 @@ CRIO_CNI_PLUGIN="/opt/cni/bin/"
POD_CIDR="10.88.0.0/16"
POD_CIDR_MASK="10.88.*.*"
KPOD_OPTIONS="--root $TESTDIR/crio $STORAGE_OPTS --runroot $TESTDIR/crio-run --runtime ${RUNTIME_BINARY}"
cp "$CONMON_BINARY" "$TESTDIR/conmon"
PATH=$PATH:$TESTDIR

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

View file

@ -3,19 +3,19 @@
load helpers
IMAGE="redis:alpine"
ROOT="$TESTDIR/crio"
RUNROOT="$TESTDIR/crio-run"
KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT ${STORAGE_OPTS}"
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 +25,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 ]
}

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

View file

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

View file

@ -1,15 +1,12 @@
#!/usr/bin/env bats
function teardown() {
cleanup_test
}
load helpers
IMAGE="redis:alpine"
ROOT="$TESTDIR/crio"
RUNROOT="$TESTDIR/crio-run"
KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT ${STORAGE_OPTS}"
function teardown() {
cleanup_test
}
@test "mount" {
start_crio
@ -42,7 +39,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

View file

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

View file

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

View file

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

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:[${TESTDIR}/crio]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
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"

View file

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

View file

@ -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" {

View file

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

View file

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

View file

@ -2,11 +2,7 @@
load helpers
IMAGE="docker.io/library/alpine:latest"
ROOT="$TESTDIR/crio"
RUNROOT="$TESTDIR/crio-run"
KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT --storage-driver vfs"
function teardown() {
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 ]
}

View file

@ -3,10 +3,6 @@
load helpers
IMAGE="redis:alpine"
ROOT="$TESTDIR/crio"
RUNROOT="$TESTDIR/crio-run"
KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT ${STORAGE_OPTS}"
# Returns the POD ID
function pod_run_from_template(){