2017-10-30 21:18:42 +00:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load helpers
|
|
|
|
|
|
|
|
IMAGE=docker.io/kubernetes/pause
|
|
|
|
|
|
|
|
function teardown() {
|
|
|
|
cleanup_test
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "image remove with multiple names, by name" {
|
|
|
|
start_crio "" "" --no-pause-image
|
|
|
|
# Pull the image, giving it one name.
|
2017-11-14 14:54:53 +00:00
|
|
|
run crictl pull "$IMAGE"
|
2017-10-30 21:18:42 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
# Add a second name to the image.
|
|
|
|
run "$COPYIMG_BINARY" --root "$TESTDIR/crio" $STORAGE_OPTIONS --runroot "$TESTDIR/crio-run" --image-name="$IMAGE":latest --add-name="$IMAGE":othertag --signature-policy="$INTEGRATION_ROOT"/policy.json
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
# Get the list of image names and IDs.
|
2017-11-14 14:54:53 +00:00
|
|
|
run crictl images -v
|
2017-10-30 21:18:42 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ "$output" != "" ]
|
|
|
|
# Cycle through each name, removing it by name. The image that we assigned a second
|
|
|
|
# name to should still be around when we get to removing its second name.
|
2017-11-14 14:54:53 +00:00
|
|
|
grep ^RepoTags: <<< "$output" | while read -r header tag ignored ; do
|
|
|
|
run crictl rmi "$tag"
|
2017-10-30 21:18:42 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
done
|
|
|
|
# List all images and their names. There should be none now.
|
2017-11-14 14:54:53 +00:00
|
|
|
run crictl images --quiet
|
2017-10-30 21:18:42 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ "$output" = "" ]
|
|
|
|
printf '%s\n' "$output" | while IFS= read -r id; do
|
|
|
|
echo "$id"
|
|
|
|
done
|
|
|
|
# All done.
|
|
|
|
cleanup_images
|
|
|
|
stop_crio
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "image remove with multiple names, by ID" {
|
|
|
|
start_crio "" "" --no-pause-image
|
|
|
|
# Pull the image, giving it one name.
|
2017-11-14 14:54:53 +00:00
|
|
|
run crictl pull "$IMAGE"
|
2017-10-30 21:18:42 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
# Add a second name to the image.
|
|
|
|
run "$COPYIMG_BINARY" --root "$TESTDIR/crio" $STORAGE_OPTIONS --runroot "$TESTDIR/crio-run" --image-name="$IMAGE":latest --add-name="$IMAGE":othertag --signature-policy="$INTEGRATION_ROOT"/policy.json
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-11-14 14:54:53 +00:00
|
|
|
# Get the list of the image's names and its ID.
|
|
|
|
run crictl images -v "$IMAGE":latest
|
2017-10-30 21:18:42 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ "$output" != "" ]
|
|
|
|
# Try to remove the image using its ID. That should succeed.
|
|
|
|
grep ^ID: <<< "$output" | while read -r header id ; do
|
2017-11-14 14:54:53 +00:00
|
|
|
run crictl rmi "$id"
|
2017-10-30 21:18:42 +00:00
|
|
|
echo "$output"
|
2017-11-14 14:54:53 +00:00
|
|
|
[ "$status" -eq 0 ]
|
2017-10-30 21:18:42 +00:00
|
|
|
done
|
|
|
|
# The image should be gone now.
|
2017-11-14 14:54:53 +00:00
|
|
|
run crictl images -v "$IMAGE"
|
2017-10-30 21:18:42 +00:00
|
|
|
echo "$output"
|
2017-11-14 14:54:53 +00:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ "$output" = "" ]
|
2017-10-30 21:18:42 +00:00
|
|
|
# All done.
|
|
|
|
cleanup_images
|
|
|
|
stop_crio
|
|
|
|
}
|