From 4cb705bfe92a2ea4b50aa1efa9f7c71ccf938b11 Mon Sep 17 00:00:00 2001 From: Marek Simek Date: Fri, 15 May 2026 13:38:26 +0200 Subject: [PATCH] test: Add API test for partial pull with pullProgress flag Progress reporting in container-libs/image did not update the progress channel for chunked layers. Add test that builds a new image with chunked layers, pull it using the REST API and verify that the progress stream contains events for partial pulls too. Depends-on: https://github.com/containers/container-libs/issues/469 Signed-off-by: Marek Simek --- test/apiv2/10-images.at | 54 ++++++++++++++++++++++++++++ test/apiv2/storage.partial-pull.conf | 2 ++ test/apiv2/test-apiv2 | 4 ++- 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 test/apiv2/storage.partial-pull.conf diff --git a/test/apiv2/10-images.at b/test/apiv2/10-images.at index 7112852a21..2a24348f9a 100644 --- a/test/apiv2/10-images.at +++ b/test/apiv2/10-images.at @@ -550,4 +550,58 @@ done # Clean up podman rmi -f quay.io/libpod/alpine:latest >/dev/null 2>&1 || true +# Test pullProgress=true with zstd:chunked image from local registry +# Restart service with a custom storage.conf (enable_partial_images = "true") +stop_service +CONTAINERS_STORAGE_CONF=$TESTS_DIR/storage.partial-pull.conf start_service +start_registry + +# Build the image +CHUNKED_TMPD=$(mktemp -d podman-apiv2-test.chunked.XXXXXXXX) +echo "$(random_string 256)" > $CHUNKED_TMPD/content1 +echo "$(random_string 256)" > $CHUNKED_TMPD/content2 +echo "$(random_string 256)" > $CHUNKED_TMPD/content3 +cat > $CHUNKED_TMPD/Containerfile << EOF +FROM scratch +ADD content1 /content1 +ADD content2 /content2 +ADD content3 /content3 +EOF +podman image build -t chunked-test:latest $CHUNKED_TMPD + +# Push it to the local registry +podman push --tls-verify=false --force-compression \ + --compression-format=zstd:chunked \ + chunked-test:latest docker://localhost:$REGISTRY_PORT/chunked-test:latest + +# Remove the local image to force a fresh pull +podman rmi -f chunked-test:latest >/dev/null 2>&1 || true + +# Pull via API with pullProgress=true +t POST "libpod/images/pull?reference=localhost:$REGISTRY_PORT/chunked-test:latest&pullProgress=true&tlsVerify=false" 200 \ + .status~".*success.*" \ + .stream~".*Starting to pull artifact.*" \ + .stream~".*Artifact pulled successfully.*" + +# Get layer digests (output has the 'sha256:' prefix) for verification +layer_digests=$(skopeo inspect --tls-verify=false \ + docker://localhost:$REGISTRY_PORT/chunked-test:latest | jq -r '.Layers[]') + +# Verify each layer digest appears as a progressComponentID in the pullProgress stream +for layer_id in $layer_digests; do + like "$output" ".*\"total\":[1-9][0-9]*,\"progressComponentID\":\"${layer_id}\".*" \ + "pullProgress reports total for layer $layer_id" + like "$output" ".*\"current\":[1-9][0-9]*,\"total\":[1-9][0-9]*,\"progressComponentID\":\"${layer_id}\".*" \ + "pullProgress reports current for layer $layer_id" +done + +# Clean up +podman rmi -f localhost:$REGISTRY_PORT/chunked-test:latest >/dev/null 2>&1 || true +rm -rf $CHUNKED_TMPD +stop_registry + +# Restart service without modified storage.conf +stop_service +start_service + # vim: filetype=sh diff --git a/test/apiv2/storage.partial-pull.conf b/test/apiv2/storage.partial-pull.conf new file mode 100644 index 0000000000..87144f67db --- /dev/null +++ b/test/apiv2/storage.partial-pull.conf @@ -0,0 +1,2 @@ +[storage.options.pull_options] +enable_partial_images = "true" diff --git a/test/apiv2/test-apiv2 b/test/apiv2/test-apiv2 index d1a78c58c4..6d7857d212 100755 --- a/test/apiv2/test-apiv2 +++ b/test/apiv2/test-apiv2 @@ -482,7 +482,8 @@ function start_service() { $PODMAN_BIN unshare true fi - CONTAINERS_REGISTRIES_CONF=$registries_conf_path \ + env CONTAINERS_REGISTRIES_CONF=$registries_conf_path \ + ${CONTAINERS_STORAGE_CONF:+CONTAINERS_STORAGE_CONF=$CONTAINERS_STORAGE_CONF} \ $PODMAN_BIN \ --root $WORKDIR/server_root --syslog=true \ system service \ @@ -655,6 +656,7 @@ function wait_for_port() { function podman() { echo "\$ $PODMAN_BIN $*" >>$WORKDIR/output.log env CONTAINERS_REGISTRIES_CONF=$registries_conf_path \ + ${CONTAINERS_STORAGE_CONF:+CONTAINERS_STORAGE_CONF=$CONTAINERS_STORAGE_CONF} \ $PODMAN_BIN --root $WORKDIR/server_root "$@" >>$WORKDIR/output.log 2>&1 }