2016-12-16 23:34:51 +00:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load helpers
|
|
|
|
|
|
|
|
IMAGE=kubernetes/pause
|
2017-08-10 13:49:07 +00:00
|
|
|
SIGNED_IMAGE=registry.access.redhat.com/rhel7-atomic:latest
|
|
|
|
UNSIGNED_IMAGE=docker.io/library/hello-world:latest
|
2016-12-16 23:34:51 +00:00
|
|
|
|
|
|
|
function teardown() {
|
|
|
|
cleanup_test
|
|
|
|
}
|
|
|
|
|
2017-01-31 15:32:27 +00:00
|
|
|
@test "run container in pod with image ID" {
|
2017-05-12 13:36:15 +00:00
|
|
|
start_crio
|
2017-11-15 15:24:20 +00:00
|
|
|
run crictl runs "$TESTDATA"/sandbox_config.json
|
2017-01-31 15:32:27 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
pod_id="$output"
|
|
|
|
sed -e "s/%VALUE%/$REDIS_IMAGEID/g" "$TESTDATA"/container_config_by_imageid.json > "$TESTDIR"/ctr_by_imageid.json
|
2017-11-15 15:24:20 +00:00
|
|
|
run crictl create "$pod_id" "$TESTDIR"/ctr_by_imageid.json "$TESTDATA"/sandbox_config.json
|
2017-01-31 15:32:27 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
cleanup_ctrs
|
|
|
|
cleanup_pods
|
2017-05-12 13:36:15 +00:00
|
|
|
stop_crio
|
2017-01-31 15:32:27 +00:00
|
|
|
}
|
|
|
|
|
2017-05-20 13:16:58 +00:00
|
|
|
@test "container status return image:tag if created by image ID" {
|
|
|
|
start_crio
|
|
|
|
|
2017-11-15 15:24:20 +00:00
|
|
|
run crictl runs "$TESTDATA"/sandbox_config.json
|
2017-05-20 13:16:58 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
pod_id="$output"
|
|
|
|
|
|
|
|
sed -e "s/%VALUE%/$REDIS_IMAGEID/g" "$TESTDATA"/container_config_by_imageid.json > "$TESTDIR"/ctr_by_imageid.json
|
|
|
|
|
2017-11-15 15:24:20 +00:00
|
|
|
run crictl create "$pod_id" "$TESTDIR"/ctr_by_imageid.json "$TESTDATA"/sandbox_config.json
|
2017-05-20 13:16:58 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
ctr_id="$output"
|
|
|
|
|
2017-11-15 15:24:20 +00:00
|
|
|
run crictl inspect "$ctr_id" --output yaml
|
2017-05-20 13:16:58 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-11-15 15:24:20 +00:00
|
|
|
[[ "$output" =~ "image: redis:alpine" ]]
|
2017-05-20 13:16:58 +00:00
|
|
|
|
|
|
|
cleanup_ctrs
|
|
|
|
cleanup_pods
|
|
|
|
stop_crio
|
|
|
|
}
|
|
|
|
|
2017-11-11 10:55:55 +00:00
|
|
|
@test "container status return image@digest if created by image ID and digest available" {
|
|
|
|
skip "depends on https://github.com/kubernetes-incubator/cri-o/issues/531"
|
|
|
|
|
2017-05-20 15:08:00 +00:00
|
|
|
start_crio
|
|
|
|
|
2017-11-15 15:24:20 +00:00
|
|
|
run crictl runs "$TESTDATA"/sandbox_config.json
|
2017-05-20 15:08:00 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
pod_id="$output"
|
|
|
|
|
|
|
|
sed -e "s/%VALUE%/$REDIS_IMAGEID_DIGESTED/g" "$TESTDATA"/container_config_by_imageid.json > "$TESTDIR"/ctr_by_imageid.json
|
|
|
|
|
2017-11-15 15:24:20 +00:00
|
|
|
run crictl create "$pod_id" "$TESTDIR"/ctr_by_imageid.json "$TESTDATA"/sandbox_config.json
|
2017-05-20 15:08:00 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
ctr_id="$output"
|
|
|
|
|
2017-11-15 15:24:20 +00:00
|
|
|
run crictl inspect "$ctr_id" --output yaml
|
2017-05-20 15:08:00 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-11-15 15:24:20 +00:00
|
|
|
[[ "$output" =~ "image_ref: redis@sha256:03789f402b2ecfb98184bf128d180f398f81c63364948ff1454583b02442f73b" ]]
|
2017-05-20 15:08:00 +00:00
|
|
|
|
|
|
|
cleanup_ctrs
|
|
|
|
cleanup_pods
|
|
|
|
stop_crio
|
|
|
|
}
|
|
|
|
|
2017-11-11 10:55:55 +00:00
|
|
|
@test "image pull" {
|
2017-05-12 13:36:15 +00:00
|
|
|
start_crio "" "" --no-pause-image
|
2017-11-15 15:24:20 +00:00
|
|
|
run crictl pull "$IMAGE"
|
2016-12-16 23:34:51 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-11-15 15:24:20 +00:00
|
|
|
run crictl inspecti "$IMAGE"
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ "$output" =~ "$IMAGE" ]]
|
2016-12-16 23:34:51 +00:00
|
|
|
cleanup_images
|
2017-05-12 13:36:15 +00:00
|
|
|
stop_crio
|
2016-12-16 23:34:51 +00:00
|
|
|
}
|
|
|
|
|
2017-08-10 13:49:07 +00:00
|
|
|
@test "image pull with signature" {
|
|
|
|
start_crio "" "" --no-pause-image
|
2017-11-15 15:24:20 +00:00
|
|
|
run crictl pull "$SIGNED_IMAGE"
|
2017-08-10 13:49:07 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
cleanup_images
|
|
|
|
stop_crio
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "image pull without signature" {
|
|
|
|
start_crio "" "" --no-pause-image
|
2017-11-15 15:24:20 +00:00
|
|
|
run crictl image pull "$UNSIGNED_IMAGE"
|
2017-08-10 13:49:07 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -ne 0 ]
|
|
|
|
cleanup_images
|
|
|
|
stop_crio
|
|
|
|
}
|
|
|
|
|
2017-11-11 10:55:55 +00:00
|
|
|
@test "image pull and list by digest" {
|
2017-05-12 13:36:15 +00:00
|
|
|
start_crio "" "" --no-pause-image
|
2017-11-15 15:24:20 +00:00
|
|
|
run crictl pull nginx@sha256:33eb1ed1e802d4f71e52421f56af028cdf12bb3bfff5affeaf5bf0e328ffa1bc
|
2017-04-06 17:28:55 +00:00
|
|
|
echo "$output"
|
2017-07-12 16:41:38 +00:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
2017-11-15 15:24:20 +00:00
|
|
|
run crictl images --quiet nginx@sha256:33eb1ed1e802d4f71e52421f56af028cdf12bb3bfff5affeaf5bf0e328ffa1bc
|
2017-07-12 16:41:38 +00:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
echo "$output"
|
|
|
|
[ "$output" != "" ]
|
|
|
|
|
2017-11-15 15:24:20 +00:00
|
|
|
run crictl images --quiet nginx@33eb1ed1e802d4f71e52421f56af028cdf12bb3bfff5affeaf5bf0e328ffa1bc
|
2017-04-06 17:28:55 +00:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
echo "$output"
|
|
|
|
[ "$output" != "" ]
|
|
|
|
|
2017-11-15 15:24:20 +00:00
|
|
|
run crictl images --quiet @33eb1ed1e802d4f71e52421f56af028cdf12bb3bfff5affeaf5bf0e328ffa1bc
|
2017-04-06 17:28:55 +00:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
echo "$output"
|
|
|
|
[ "$output" != "" ]
|
|
|
|
|
2017-11-15 15:24:20 +00:00
|
|
|
run crictl images --quiet 33eb1ed1e802d4f71e52421f56af028cdf12bb3bfff5affeaf5bf0e328ffa1bc
|
2017-04-06 17:28:55 +00:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
echo "$output"
|
|
|
|
[ "$output" != "" ]
|
|
|
|
|
|
|
|
cleanup_images
|
2017-05-12 13:36:15 +00:00
|
|
|
stop_crio
|
2017-04-06 17:28:55 +00:00
|
|
|
}
|
|
|
|
|
2016-12-16 23:34:51 +00:00
|
|
|
@test "image list with filter" {
|
2017-05-12 13:36:15 +00:00
|
|
|
start_crio "" "" --no-pause-image
|
2017-11-15 15:24:20 +00:00
|
|
|
run crictl pull "$IMAGE"
|
2016-12-16 23:34:51 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-11-15 15:24:20 +00:00
|
|
|
run crictl images --quiet "$IMAGE"
|
2016-12-16 23:34:51 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
printf '%s\n' "$output" | while IFS= read -r id; do
|
2017-11-15 15:24:20 +00:00
|
|
|
run crictl rmi "$id"
|
2016-12-16 23:34:51 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
done
|
2017-11-15 15:24:20 +00:00
|
|
|
run crictl images --quiet
|
2016-12-16 23:34:51 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
printf '%s\n' "$output" | while IFS= read -r id; do
|
|
|
|
echo "$id"
|
|
|
|
status=1
|
|
|
|
done
|
|
|
|
cleanup_images
|
2017-05-12 13:36:15 +00:00
|
|
|
stop_crio
|
2016-12-16 23:34:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "image list/remove" {
|
2017-05-12 13:36:15 +00:00
|
|
|
start_crio "" "" --no-pause-image
|
2017-11-15 15:24:20 +00:00
|
|
|
run crictl pull "$IMAGE"
|
2016-12-16 23:34:51 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-11-15 15:24:20 +00:00
|
|
|
run crictl images --quiet
|
2016-12-16 23:34:51 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-04-06 17:28:55 +00:00
|
|
|
[ "$output" != "" ]
|
2016-12-16 23:34:51 +00:00
|
|
|
printf '%s\n' "$output" | while IFS= read -r id; do
|
2017-11-15 15:24:20 +00:00
|
|
|
run crictl rmi "$id"
|
2016-12-16 23:34:51 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
done
|
2017-11-15 15:24:20 +00:00
|
|
|
run crictl images --quiet
|
2016-12-16 23:34:51 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-04-06 17:28:55 +00:00
|
|
|
[ "$output" = "" ]
|
2016-12-16 23:34:51 +00:00
|
|
|
printf '%s\n' "$output" | while IFS= read -r id; do
|
|
|
|
echo "$id"
|
|
|
|
status=1
|
|
|
|
done
|
|
|
|
cleanup_images
|
2017-05-12 13:36:15 +00:00
|
|
|
stop_crio
|
2016-12-16 23:34:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "image status/remove" {
|
2017-05-12 13:36:15 +00:00
|
|
|
start_crio "" "" --no-pause-image
|
2017-11-15 15:24:20 +00:00
|
|
|
run crictl pull "$IMAGE"
|
2016-12-16 23:34:51 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-11-15 15:24:20 +00:00
|
|
|
run crictl images --quiet
|
2016-12-16 23:34:51 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-04-06 17:28:55 +00:00
|
|
|
[ "$output" != "" ]
|
2016-12-16 23:34:51 +00:00
|
|
|
printf '%s\n' "$output" | while IFS= read -r id; do
|
2017-11-15 15:24:20 +00:00
|
|
|
run crictl inspecti "$id"
|
2016-12-16 23:34:51 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-04-06 17:28:55 +00:00
|
|
|
[ "$output" != "" ]
|
2017-11-15 15:24:20 +00:00
|
|
|
run crictl rmi "$id"
|
2016-12-16 23:34:51 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
done
|
2017-11-15 15:24:20 +00:00
|
|
|
run crictl images --quiet
|
2016-12-16 23:34:51 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-04-06 17:28:55 +00:00
|
|
|
[ "$output" = "" ]
|
2016-12-16 23:34:51 +00:00
|
|
|
printf '%s\n' "$output" | while IFS= read -r id; do
|
|
|
|
echo "$id"
|
|
|
|
status=1
|
|
|
|
done
|
|
|
|
cleanup_images
|
2017-05-12 13:36:15 +00:00
|
|
|
stop_crio
|
2016-12-16 23:34:51 +00:00
|
|
|
}
|