Skip to content

Commit

Permalink
test: add zstd:chunked system tests
Browse files Browse the repository at this point in the history
Signed-off-by: Giuseppe Scrivano <[email protected]>
  • Loading branch information
giuseppe committed Oct 31, 2024
1 parent 998e9dc commit d9b1465
Showing 1 changed file with 100 additions and 0 deletions.
100 changes: 100 additions & 0 deletions test/system/150-login.bats
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,106 @@ EOF
assert "$output" =~ "--retry-delay .*pull failures \(default \"5s\"\)"
}

@test "push and pull zstd chunked image" {
image1=localhost:${PODMAN_LOGIN_REGISTRY_PORT}/img1-$(safename)

globalopts="--pull-option enable_partial_pulls=true"
pushpullargs="--cert-dir ${PODMAN_LOGIN_WORKDIR}/trusted-registry-cert-dir \
--creds ${PODMAN_LOGIN_USER}:${PODMAN_LOGIN_PASS}"

dockerfile1=$PODMAN_TMPDIR/Dockerfile.1
cat >$dockerfile1 <<EOF
FROM $IMAGE
RUN touch /
EOF

run_podman $globalopts build --squash-all -t $image1 -f $dockerfile1 .
run_podman $globalopts push \
--compression-format zstd:chunked \
$pushpullargs \
$image1

run_podman $globalopts rmi $image1

run_podman $globalopts pull \
$pushpullargs \
$image1

run -0 skopeo inspect containers-storage:$image1
assert "$output" =~ "application/vnd.oci.image.layer.v1.tar\+zstd" "pulled image must be zstd-compressed"

dockerfile2=$PODMAN_TMPDIR/Dockerfile.2
cat >$dockerfile2 <<EOF
FROM $image1
RUN touch /new-file
EOF

dockerfile3=$PODMAN_TMPDIR/Dockerfile.3
cat >$dockerfile3 <<EOF
FROM $image1
RUN touch /new-file-2
EOF

image2=localhost:${PODMAN_LOGIN_REGISTRY_PORT}/img2-$(safename)
image3=localhost:${PODMAN_LOGIN_REGISTRY_PORT}/img3-$(safename)

run_podman $globalopts build -t $image2 -f $dockerfile2 .
run_podman $globalopts build -t $image3 -f $dockerfile3 .

run_podman $globalopts push \
--compression-format zstd:chunked \
$pushpullargs \
$image2

run_podman $globalopts push \
--compression-format zstd:chunked \
$pushpullargs \
$image3

run_podman $globalopts diff $image3 $image2
sorted_output=$(sort <<< $output | tr -d '\n')
assert "$sorted_output" = "A /new-file-2D /new-file"

run_podman $globalopts rmi $image2 $image3

run_podman $globalopts pull \
$pushpullargs \
$image2

run -0 skopeo inspect containers-storage:$image2
assert "$output" =~ "application/vnd.oci.image.layer.v1.tar\+zstd" "pulled image must be zstd-compressed"

run_podman $globalopts pull \
$pushpullargs \
$image3

run -0 skopeo inspect containers-storage:$image3
assert "$output" =~ "application/vnd.oci.image.layer.v1.tar\+zstd" "pulled image must be zstd-compressed"

run_podman $globalopts diff $image3 $image2
sorted_output=$(sort <<< $output | tr -d '\n')
assert "$sorted_output" = "A /new-file-2D /new-file"

for image in $image1 $image2 $image3; do
push_dir=$PODMAN_TMPDIR/dir-image

# let's use the dir transport as it gives us directly the uncompressed tar
podman push $image dir:$push_dir

run_podman inspect $image
for layer in $(jq '.[].RootFS.Layers.[] | gsub("^sha256:"; "")' <<< $output | tr -d \"); do
layer_file=$push_dir/$layer
# the checksum for the layer is already validated, but for the sake
# of the test let's check it again
run -0 sha256sum < $layer_file
assert "$output" = "$layer -" "digest mismatch for layer $layer"
done
rm -rf $push_dir
done

run_podman $globalopts rmi $image1 $image2 $image3
}

# END cooperation with skopeo
# END actual tests
###############################################################################
Expand Down

0 comments on commit d9b1465

Please sign in to comment.