Merge pull request #19861 from edsantiago/manifest_test_cleanup

systests: manifest zstd test: lots of tiny cleanups
This commit is contained in:
OpenShift Merge Robot
2023-09-06 01:04:35 +02:00
committed by GitHub

View File

@ -4,6 +4,15 @@ load helpers
load helpers.network load helpers.network
load helpers.registry load helpers.registry
function teardown() {
# Enumerate every one of the manifest names used everywhere below
echo "[ teardown - ignore 'image not known' errors below ]"
run_podman '?' manifest rm test:1.0 \
localhost:${PODMAN_LOGIN_REGISTRY_PORT}/test:1.0
basic_teardown
}
# Helper function for several of the tests which verifies compression. # Helper function for several of the tests which verifies compression.
# #
# Usage: validate_instance_compression INDEX MANIFEST ARCH COMPRESSION # Usage: validate_instance_compression INDEX MANIFEST ARCH COMPRESSION
@ -90,17 +99,15 @@ function validate_instance_compression {
} }
@test "manifest list --add-compression with zstd" { @test "manifest list --add-compression with zstd" {
if ! type -p skopeo; then
skip "skopeo not available"
fi
skip_if_remote "running a local registry doesn't work with podman-remote" skip_if_remote "running a local registry doesn't work with podman-remote"
start_registry start_registry
tmpdir=$PODMAN_TMPDIR/build-test # Using TARGETARCH gives us distinct images for each arch
mkdir -p $tmpdir dockerfile=$PODMAN_TMPDIR/Dockerfile
dockerfile=$tmpdir/Dockerfile
cat >$dockerfile <<EOF cat >$dockerfile <<EOF
FROM alpine FROM scratch
ARG TARGETARCH
COPY Dockerfile /i-am-\${TARGETARCH}
EOF EOF
authfile=${PODMAN_LOGIN_WORKDIR}/auth-$(random_string 10).json authfile=${PODMAN_LOGIN_WORKDIR}/auth-$(random_string 10).json
run_podman login --tls-verify=false \ run_podman login --tls-verify=false \
@ -110,25 +117,34 @@ EOF
localhost:${PODMAN_LOGIN_REGISTRY_PORT} <<<"${PODMAN_LOGIN_PASS}" localhost:${PODMAN_LOGIN_REGISTRY_PORT} <<<"${PODMAN_LOGIN_PASS}"
is "$output" "Login Succeeded!" "output from podman login" is "$output" "Login Succeeded!" "output from podman login"
manifest1="localhost:${PODMAN_LOGIN_REGISTRY_PORT}/test:1.0" # Build two images, different arches, and add each to one manifest list
run_podman build -t image1 --platform linux/amd64 -f $dockerfile local manifestlocal="test:1.0"
run_podman build -t image2 --platform linux/arm64 -f $dockerfile run_podman manifest create $manifestlocal
for arch in amd arm;do
# FIXME: --layers=false needed to work around #19860
run_podman build --layers=false -t image_$arch --platform linux/${arch}64 -f $dockerfile
run_podman manifest add $manifestlocal containers-storage:localhost/image_$arch:latest
done
run_podman manifest create foo # (for debugging)
run_podman images -a run_podman images -a
run_podman manifest add foo containers-storage:localhost/image1:latest
run_podman manifest add foo containers-storage:localhost/image2:latest
run_podman manifest push --authfile=$authfile --all --add-compression zstd --tls-verify=false foo $manifest1 # Push to local registry; the magic key here is --add-compression...
local manifestpushed="localhost:${PODMAN_LOGIN_REGISTRY_PORT}/test:1.0"
run_podman manifest push --authfile=$authfile --all --add-compression zstd --tls-verify=false $manifestlocal $manifestpushed
run skopeo inspect --authfile=$authfile --tls-verify=false --raw docker://$manifest1 # ...and use skopeo to confirm that each component has the right settings
echo $output echo "$_LOG_PROMPT skopeo inspect ... $manifestpushed"
list="$output" list=$(skopeo inspect --authfile=$authfile --tls-verify=false --raw docker://$manifestpushed)
jq . <<<"$list"
validate_instance_compression "0" "$list" "amd64" "gzip" validate_instance_compression "0" "$list" "amd64" "gzip"
validate_instance_compression "1" "$list" "arm64" "gzip" validate_instance_compression "1" "$list" "arm64" "gzip"
validate_instance_compression "2" "$list" "amd64" "zstd" validate_instance_compression "2" "$list" "amd64" "zstd"
validate_instance_compression "3" "$list" "arm64" "zstd" validate_instance_compression "3" "$list" "arm64" "zstd"
run_podman rmi image_amd image_arm
run_podman manifest rm $manifestlocal
} }
# vim: filetype=sh # vim: filetype=sh