From b0f917a44472aa43066f4f0db38c4615e9b83602 Mon Sep 17 00:00:00 2001 From: Andrei Aaron Date: Mon, 13 Oct 2025 10:41:30 +0300 Subject: [PATCH] ci: pre download docker images used in bats tests (#3452) Should help with issues such as https://github.com/project-zot/zot/actions/runs/18457240003/job/52580780359 Signed-off-by: Andrei Aaron --- test/blackbox/ci.sh | 4 ++++ test/blackbox/setup_images.sh | 41 +++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100755 test/blackbox/setup_images.sh diff --git a/test/blackbox/ci.sh b/test/blackbox/ci.sh index 12aff31c..1cf532d7 100755 --- a/test/blackbox/ci.sh +++ b/test/blackbox/ci.sh @@ -7,6 +7,10 @@ SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" BATS=${SCRIPTPATH}/../../hack/tools/bin/bats PATH=$PATH:${SCRIPTPATH}/../../hack/tools/bin +# Pre-download Docker images before running tests +echo "Setting up Docker images..." +${SCRIPTPATH}/setup_images.sh + tests=("pushpull" "pushpull_authn" "delete_images" "referrers" "metadata" "anonymous_policy" "annotations" "detect_manifest_collision" "cve" "sync" "sync_docker" "sync_replica_cluster" "scrub" "garbage_collect" "metrics" "metrics_minimal" "multiarch_index" "docker_compat" "redis_local" "redis_session_store" diff --git a/test/blackbox/setup_images.sh b/test/blackbox/setup_images.sh new file mode 100755 index 00000000..97ae1ef4 --- /dev/null +++ b/test/blackbox/setup_images.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +# Pre-download Docker images used in blackbox tests +# This script ensures all required images are available before tests start + +set -e + +echo "Pre-downloading Docker images for blackbox tests..." + +# List of images used in the tests +IMAGES=( + "nats:2.11.1" + "natsio/nats-box:latest" + "python:3" + "redis:latest" +) + +# Function to download an image if not already present +download_image() { + local image="$1" + echo "Checking for image: $image" + + if docker image inspect "$image" >/dev/null 2>&1; then + echo "✓ Image $image already exists" + else + echo "Downloading image: $image" + if docker pull "$image"; then + echo "✓ Successfully downloaded $image" + else + echo "✗ Failed to download $image" + return 1 + fi + fi +} + +# Download all images +for image in "${IMAGES[@]}"; do + download_image "$image" +done + +echo "All Docker images are ready for testing!"