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
|
|
|
|
run crioctl pod run --config "$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-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr create --config "$TESTDIR"/ctr_by_imageid.json --pod "$pod_id"
|
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
|
|
|
|
|
|
|
|
run crioctl pod run --config "$TESTDATA"/sandbox_config.json
|
|
|
|
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
|
|
|
|
|
|
|
|
run crioctl ctr create --config "$TESTDIR"/ctr_by_imageid.json --pod "$pod_id"
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
ctr_id="$output"
|
|
|
|
|
|
|
|
run crioctl ctr status --id "$ctr_id"
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ "$output" =~ "Image: redis:alpine" ]]
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
run crioctl pod run --config "$TESTDATA"/sandbox_config.json
|
|
|
|
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
|
|
|
|
|
|
|
|
run crioctl ctr create --config "$TESTDIR"/ctr_by_imageid.json --pod "$pod_id"
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
ctr_id="$output"
|
|
|
|
|
|
|
|
run crioctl ctr status --id "$ctr_id"
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ "$output" =~ "ImageRef: redis@sha256:03789f402b2ecfb98184bf128d180f398f81c63364948ff1454583b02442f73b" ]]
|
|
|
|
|
|
|
|
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
|
|
|
|
run crioctl image pull "$IMAGE"
|
2016-12-16 23:34:51 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
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
|
|
|
|
run crioctl image pull "$SIGNED_IMAGE"
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
cleanup_images
|
|
|
|
stop_crio
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "image pull without signature" {
|
|
|
|
start_crio "" "" --no-pause-image
|
|
|
|
run crioctl image pull "$UNSIGNED_IMAGE"
|
|
|
|
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-11 10:55:55 +00:00
|
|
|
run crioctl image 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-11 10:55:55 +00:00
|
|
|
run crioctl image list --quiet nginx@sha256:33eb1ed1e802d4f71e52421f56af028cdf12bb3bfff5affeaf5bf0e328ffa1bc
|
2017-07-12 16:41:38 +00:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
echo "$output"
|
|
|
|
[ "$output" != "" ]
|
|
|
|
|
2017-11-11 10:55:55 +00:00
|
|
|
run crioctl image list --quiet nginx@33eb1ed1e802d4f71e52421f56af028cdf12bb3bfff5affeaf5bf0e328ffa1bc
|
2017-04-06 17:28:55 +00:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
echo "$output"
|
|
|
|
[ "$output" != "" ]
|
|
|
|
|
2017-11-11 10:55:55 +00:00
|
|
|
run crioctl image list --quiet @33eb1ed1e802d4f71e52421f56af028cdf12bb3bfff5affeaf5bf0e328ffa1bc
|
2017-04-06 17:28:55 +00:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
echo "$output"
|
|
|
|
[ "$output" != "" ]
|
|
|
|
|
2017-11-11 10:55:55 +00:00
|
|
|
run crioctl image list --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
|
|
|
|
run crioctl image pull "$IMAGE"
|
2016-12-16 23:34:51 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl image list --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-05-12 13:36:15 +00:00
|
|
|
run crioctl image remove --id "$id"
|
2016-12-16 23:34:51 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
done
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl image list --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
|
|
|
|
run crioctl image pull "$IMAGE"
|
2016-12-16 23:34:51 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl image list --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-05-12 13:36:15 +00:00
|
|
|
run crioctl image remove --id "$id"
|
2016-12-16 23:34:51 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
done
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl image list --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
|
|
|
|
run crioctl image pull "$IMAGE"
|
2016-12-16 23:34:51 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl image list --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-05-12 13:36:15 +00:00
|
|
|
run crioctl image status --id "$id"
|
2016-12-16 23:34:51 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-04-06 17:28:55 +00:00
|
|
|
[ "$output" != "" ]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl image remove --id "$id"
|
2016-12-16 23:34:51 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
done
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl image list --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
|
|
|
}
|