mirror of
https://github.com/containers/podman.git
synced 2026-07-29 08:26:45 -04:00
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 <msimek@redhat.com>
This commit is contained in:
@@ -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
|
||||
|
||||
2
test/apiv2/storage.partial-pull.conf
Normal file
2
test/apiv2/storage.partial-pull.conf
Normal file
@@ -0,0 +1,2 @@
|
||||
[storage.options.pull_options]
|
||||
enable_partial_images = "true"
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user