2016-12-16 23:34:51 +00:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load helpers
|
|
|
|
|
|
|
|
IMAGE=kubernetes/pause
|
|
|
|
|
|
|
|
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-05-20 15:08:00 +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"
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2016-12-16 23:34:51 +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-04-06 17:28:55 +00:00
|
|
|
@test "image pull and list by digest" {
|
2017-05-12 13:36:15 +00:00
|
|
|
start_crio "" "" --no-pause-image
|
|
|
|
run crioctl image pull nginx@sha256:4aacdcf186934dcb02f642579314075910f1855590fd3039d8fa4c9f96e48315
|
2017-04-06 17:28:55 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl image list --quiet nginx@sha256:4aacdcf186934dcb02f642579314075910f1855590fd3039d8fa4c9f96e48315
|
2017-04-06 17:28:55 +00:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
echo "$output"
|
|
|
|
[ "$output" != "" ]
|
|
|
|
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl image list --quiet nginx@4aacdcf186934dcb02f642579314075910f1855590fd3039d8fa4c9f96e48315
|
2017-04-06 17:28:55 +00:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
echo "$output"
|
|
|
|
[ "$output" != "" ]
|
|
|
|
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl image list --quiet @4aacdcf186934dcb02f642579314075910f1855590fd3039d8fa4c9f96e48315
|
2017-04-06 17:28:55 +00:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
echo "$output"
|
|
|
|
[ "$output" != "" ]
|
|
|
|
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl image list --quiet 4aacdcf186934dcb02f642579314075910f1855590fd3039d8fa4c9f96e48315
|
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
|
|
|
}
|