2017-06-16 16:27:06 +00:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load helpers
|
|
|
|
|
2017-06-16 17:24:00 +00:00
|
|
|
IMAGE="alpine:latest"
|
2017-06-30 19:10:57 +00:00
|
|
|
ROOT="$TESTDIR/crio"
|
|
|
|
RUNROOT="$TESTDIR/crio-run"
|
|
|
|
KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT --storage-driver vfs"
|
|
|
|
|
2017-06-16 17:24:00 +00:00
|
|
|
function teardown() {
|
|
|
|
cleanup_test
|
|
|
|
}
|
|
|
|
|
2017-06-16 16:27:06 +00:00
|
|
|
@test "kpod version test" {
|
|
|
|
run ${KPOD_BINARY} version
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
}
|
2017-06-30 19:10:57 +00:00
|
|
|
|
2017-07-10 00:33:50 +00:00
|
|
|
@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 ]
|
|
|
|
}
|
|
|
|
|
2017-08-14 19:32:00 +00:00
|
|
|
@test "kpod history with Go template format" {
|
2017-07-10 00:33:50 +00:00
|
|
|
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
|
2017-07-14 14:31:02 +00:00
|
|
|
[ "$status" -eq 0 ]
|
2017-08-14 19:32:00 +00:00
|
|
|
run bash -c "${KPOD_BINARY} ${KPOD_OPTIONS} history --format json $IMAGE | python -m json.tool"
|
2017-07-10 00:33:50 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
run ${KPOD_BINARY} $KPOD_OPTIONS rmi $IMAGE
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
}
|
2017-06-16 17:24:00 +00:00
|
|
|
|
|
|
|
@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 ]
|
2017-08-31 19:57:03 +00:00
|
|
|
run ${KPOD_BINARY} $KPOD_OPTIONS push "$IMAGE" oci:/tmp/oci-busybox:"$IMAGE"
|
2017-06-16 17:24:00 +00:00
|
|
|
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
|
|
|
|
}
|
2017-06-29 19:16:06 +00:00
|
|
|
|
|
|
|
@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
|
2017-08-17 16:45:08 +00:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
}
|
2017-06-29 19:16:06 +00:00
|
|
|
|
2017-07-31 18:02:57 +00:00
|
|
|
|
2017-06-29 19:16:06 +00:00
|
|
|
@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 ]
|
2017-08-17 16:45:08 +00:00
|
|
|
run ${KPOD_BINARY} $KPOD_OPTIONS inspect --format {{.ID}} redis:alpine
|
|
|
|
[ "$status" -eq 0 ]
|
2017-06-29 19:16:06 +00:00
|
|
|
inspectOutput="$output"
|
|
|
|
run ${KPOD_BINARY} $KPOD_OPTIONS images --quiet redis:alpine
|
2017-08-17 16:45:08 +00:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ "$output" = "$inspectOutput" ]
|
2017-06-29 19:16:06 +00:00
|
|
|
run ${KPOD_BINARY} $KPOD_OPTIONS rmi redis:alpine
|
2017-08-17 16:45:08 +00:00
|
|
|
[ "$status" -eq 0 ]
|
2017-06-29 19:16:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@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"
|
2017-08-17 16:45:08 +00:00
|
|
|
[ "$status" -eq 0 ]
|
2017-06-29 19:16:06 +00:00
|
|
|
run ${KPOD_BINARY} $KPOD_OPTIONS rmi redis:alpine
|
2017-08-17 16:45:08 +00:00
|
|
|
[ "$status" -eq 0 ]
|
2017-06-29 19:16:06 +00:00
|
|
|
}
|
2017-07-31 18:02:57 +00:00
|
|
|
|
|
|
|
@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
|
2017-08-17 16:45:08 +00:00
|
|
|
echo "$output"
|
2017-07-31 18:02:57 +00:00
|
|
|
name=$(echo $output | python -c 'import sys; import json; print(json.loads(sys.stdin.read())[0])["names"][0]')
|
2017-08-17 16:45:08 +00:00
|
|
|
[ "$name" = "docker.io/library/debian:6.0.10" ]
|
2017-07-31 18:02:57 +00:00
|
|
|
}
|