From 0949202ee56283a5219fd1fe6f6273dc4991c989 Mon Sep 17 00:00:00 2001 From: Alexei Dodon Date: Thu, 26 Oct 2023 18:16:25 +0300 Subject: [PATCH] ci: resource tuning for faster runs Signed-off-by: Alexei Dodon --- .github/workflows/benchmark.yaml | 2 +- .github/workflows/build.yaml | 7 +- .github/workflows/cluster.yaml | 2 +- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/ecosystem-tools.yaml | 5 +- .github/workflows/gc-stress-test.yaml | 12 +- .github/workflows/golangci-lint.yaml | 2 +- .github/workflows/gqlgen.yaml | 2 +- .github/workflows/nightly.yaml | 11 +- .github/workflows/test.yaml | 8 - .github/workflows/web-scan.yaml | 2 +- Makefile | 20 +- test/blackbox/annotations.bats | 43 ++-- test/blackbox/anonymous_policy.bats | 15 +- test/blackbox/ci.sh | 37 ++++ test/blackbox/delete_images.bats | 21 +- test/blackbox/detect_manifest_collision.bats | 22 +- test/blackbox/garbage_collect.bats | 61 +++--- test/blackbox/helpers_zot.bash | 14 ++ test/blackbox/metadata.bats | 35 ++-- test/blackbox/metrics.bats | 16 +- test/blackbox/metrics_minimal.bats | 16 +- test/blackbox/pushpull.bats | 129 +++++++----- test/blackbox/pushpull_authn.bats | 50 +++-- test/blackbox/referrers.bats | 22 +- test/blackbox/scrub.bats | 10 +- test/blackbox/sync.bats | 203 +++++++++++-------- test/blackbox/sync_docker.bats | 143 +++++++------ test/blackbox/sync_replica_cluster.bats | 45 ++-- 29 files changed, 557 insertions(+), 400 deletions(-) create mode 100755 test/blackbox/ci.sh diff --git a/.github/workflows/benchmark.yaml b/.github/workflows/benchmark.yaml index c4a0226ef5..031c64f166 100644 --- a/.github/workflows/benchmark.yaml +++ b/.github/workflows/benchmark.yaml @@ -12,7 +12,7 @@ permissions: read-all jobs: benchmark: name: Performance regression check - runs-on: ubuntu-latest + runs-on: ubuntu-latest-8-cores steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v4 diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index e265dc0462..60e427ad80 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -18,7 +18,7 @@ jobs: permissions: contents: write packages: write - runs-on: ubuntu-latest-16-cores + runs-on: ubuntu-latest strategy: matrix: os: [linux, darwin, freebsd] @@ -26,7 +26,6 @@ jobs: steps: - name: Check out source code uses: actions/checkout@v4 - - uses: ./.github/actions/clean-runner - name: Install go uses: actions/setup-go@v4 with: @@ -72,9 +71,8 @@ jobs: curl -Lo notation.tar.gz https://github.com/notaryproject/notation/releases/download/v1.0.0-rc.4/notation_1.0.0-rc.4_linux_amd64.tar.gz sudo tar xvzf notation.tar.gz -C /usr/bin notation rm -f notation.tar.gz - - uses: ./.github/actions/check-diskspace - name: Run build - timeout-minutes: 80 + timeout-minutes: 10 run: | echo "Building for $OS:$ARCH" cd $GITHUB_WORKSPACE @@ -82,7 +80,6 @@ jobs: env: OS: ${{ matrix.os }} ARCH: ${{ matrix.arch }} - - uses: ./.github/actions/check-diskspace - name: Generate GraphQL Introspection JSON on Release if: github.event_name == 'release' && github.event.action == 'published' && matrix.os == 'linux' && matrix.arch == 'amd64' diff --git a/.github/workflows/cluster.yaml b/.github/workflows/cluster.yaml index 22c5266dc1..3a15389e3c 100644 --- a/.github/workflows/cluster.yaml +++ b/.github/workflows/cluster.yaml @@ -14,7 +14,7 @@ permissions: read-all jobs: client-tools: name: Stateless zot with shared reliable storage - runs-on: ubuntu-latest + runs-on: ubuntu-latest-4-cores # services: # minio: # image: minio/minio:edge-cicd diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 1adc7e5490..32808ce45f 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -25,7 +25,7 @@ permissions: read-all jobs: analyze: name: Analyze - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest-4-cores permissions: actions: read contents: read diff --git a/.github/workflows/ecosystem-tools.yaml b/.github/workflows/ecosystem-tools.yaml index c27183a52c..18988a3d1f 100644 --- a/.github/workflows/ecosystem-tools.yaml +++ b/.github/workflows/ecosystem-tools.yaml @@ -14,10 +14,9 @@ permissions: read-all jobs: client-tools: name: Check client tools - runs-on: ubuntu-latest + runs-on: ubuntu-latest-16-cores steps: - uses: actions/checkout@v4 - - uses: ./.github/actions/clean-runner - uses: actions/setup-go@v4 with: cache: false @@ -53,7 +52,6 @@ jobs: make bin/dex ./bin/dex serve $GITHUB_WORKSPACE/test/dex/config-dev.yaml & cd $GITHUB_WORKSPACE - - uses: ./.github/actions/check-diskspace - name: Run CI tests run: | make run-blackbox-ci @@ -79,5 +77,4 @@ jobs: env: AWS_ACCESS_KEY_ID: fake AWS_SECRET_ACCESS_KEY: fake - - uses: ./.github/actions/check-diskspace - uses: ./.github/actions/teardown-localstack diff --git a/.github/workflows/gc-stress-test.yaml b/.github/workflows/gc-stress-test.yaml index d0d62af637..582e3d2a38 100644 --- a/.github/workflows/gc-stress-test.yaml +++ b/.github/workflows/gc-stress-test.yaml @@ -14,10 +14,9 @@ permissions: read-all jobs: gc-referrers-stress-local: name: GC(with referrers) on filesystem with short interval - runs-on: ubuntu-latest + runs-on: ubuntu-latest-8-cores steps: - uses: actions/checkout@v4 - - uses: ./.github/actions/clean-runner - uses: actions/setup-go@v4 with: cache: false @@ -46,10 +45,9 @@ jobs: gc-stress-local: name: GC(without referrers) on filesystem with short interval - runs-on: ubuntu-latest + runs-on: ubuntu-latest-8-cores steps: - uses: actions/checkout@v4 - - uses: ./.github/actions/clean-runner - uses: actions/setup-go@v4 with: cache: false @@ -78,10 +76,9 @@ jobs: gc-referrers-stress-s3: name: GC(with referrers) on S3(minio) with short interval - runs-on: ubuntu-latest + runs-on: ubuntu-latest-8-cores steps: - uses: actions/checkout@v4 - - uses: ./.github/actions/clean-runner - uses: actions/setup-go@v4 with: cache: false @@ -154,10 +151,9 @@ jobs: gc-stress-s3: name: GC(without referrers) on S3(minio) with short interval - runs-on: ubuntu-latest + runs-on: ubuntu-latest-8-cores steps: - uses: actions/checkout@v4 - - uses: ./.github/actions/clean-runner - uses: actions/setup-go@v4 with: cache: false diff --git a/.github/workflows/golangci-lint.yaml b/.github/workflows/golangci-lint.yaml index 10bf0d4523..5e27731e8b 100644 --- a/.github/workflows/golangci-lint.yaml +++ b/.github/workflows/golangci-lint.yaml @@ -13,7 +13,7 @@ permissions: jobs: golangci: name: lint - runs-on: ubuntu-latest + runs-on: ubuntu-latest-8-cores steps: - uses: actions/setup-go@v4 with: diff --git a/.github/workflows/gqlgen.yaml b/.github/workflows/gqlgen.yaml index 2273c192f2..5536adece9 100644 --- a/.github/workflows/gqlgen.yaml +++ b/.github/workflows/gqlgen.yaml @@ -19,7 +19,7 @@ permissions: read-all jobs: gqlgen: name: Check GQL generation - runs-on: ubuntu-latest + runs-on: ubuntu-latest-4-cores steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v4 diff --git a/.github/workflows/nightly.yaml b/.github/workflows/nightly.yaml index 6a936f908b..835d1bbc2c 100644 --- a/.github/workflows/nightly.yaml +++ b/.github/workflows/nightly.yaml @@ -14,10 +14,9 @@ permissions: read-all jobs: dedupe: name: Dedupe/restore blobs - runs-on: ubuntu-latest-16-cores + runs-on: ubuntu-latest-4-cores steps: - uses: actions/checkout@v4 - - uses: ./.github/actions/clean-runner - uses: actions/setup-go@v3 with: go-version: 1.20.x @@ -62,11 +61,10 @@ jobs: sync: name: Sync harness - runs-on: ubuntu-latest-16-cores + runs-on: ubuntu-latest-4-cores steps: - name: Check out source code uses: actions/checkout@v4 - - uses: ./.github/actions/clean-runner - uses: actions/setup-go@v3 with: go-version: 1.20.x @@ -84,7 +82,6 @@ jobs: runs-on: ubuntu-latest-16-cores steps: - uses: actions/checkout@v4 - - uses: ./.github/actions/clean-runner - uses: actions/setup-go@v4 with: cache: false @@ -121,7 +118,6 @@ jobs: runs-on: ubuntu-latest-16-cores steps: - uses: actions/checkout@v4 - - uses: ./.github/actions/clean-runner - uses: actions/setup-go@v4 with: cache: false @@ -155,10 +151,9 @@ jobs: docker-image: name: Build docker image (for users still using Docker environments) - runs-on: ubuntu-latest-16-cores + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: ./.github/actions/clean-runner - name: Check out source code uses: actions/checkout@v4 - name: Build image diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 5cef588526..c810044419 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -17,7 +17,6 @@ jobs: runs-on: ubuntu-latest-16-cores steps: - uses: actions/checkout@v4 - - uses: ./.github/actions/clean-runner - name: Install go uses: actions/setup-go@v4 with: @@ -38,7 +37,6 @@ jobs: cd $GITHUB_WORKSPACE go mod download - uses: ./.github/actions/setup-localstack - - uses: ./.github/actions/check-diskspace - name: run zot minimal tests run: | cd $GITHUB_WORKSPACE @@ -53,14 +51,12 @@ jobs: with: name: coverage-minimal path: coverage-minimal.txt - - uses: ./.github/actions/check-diskspace - uses: ./.github/actions/teardown-localstack test-run-extensions: name: Run zot with extensions tests runs-on: ubuntu-latest-16-cores steps: - uses: actions/checkout@v4 - - uses: ./.github/actions/clean-runner - uses: actions/setup-go@v4 with: cache: false @@ -94,14 +90,12 @@ jobs: with: name: coverage-extended path: coverage-extended.txt - - uses: ./.github/actions/check-diskspace - uses: ./.github/actions/teardown-localstack test-run-devmode: name: Running privileged tests on Linux runs-on: ubuntu-latest-16-cores steps: - uses: actions/checkout@v4 - - uses: ./.github/actions/clean-runner - uses: actions/setup-go@v4 with: cache: false @@ -120,7 +114,6 @@ jobs: run: | cd $GITHUB_WORKSPACE go mod download - - uses: ./.github/actions/check-diskspace - name: run zot development-mode unit tests (possibly using failure injection) run: make test-devmode - name: run zot privileged tests @@ -130,7 +123,6 @@ jobs: with: name: coverage-devmode path: coverage-dev-*.txt - - uses: ./.github/actions/check-diskspace test-coverage: name: Collect all test coverage runs-on: ubuntu-latest diff --git a/.github/workflows/web-scan.yaml b/.github/workflows/web-scan.yaml index b703f6c550..8800f6ab3e 100644 --- a/.github/workflows/web-scan.yaml +++ b/.github/workflows/web-scan.yaml @@ -15,7 +15,7 @@ permissions: jobs: zap_scan: - runs-on: ubuntu-latest + runs-on: ubuntu-latest-4-cores name: Scan ZOT using ZAP strategy: matrix: diff --git a/Makefile b/Makefile index 01fc1be79c..2618da5b83 100644 --- a/Makefile +++ b/Makefile @@ -485,24 +485,8 @@ run-blackbox-tests: $(BATS_TEST_FILE_PATH) check-blackbox-prerequisites binary b .PHONY: run-blackbox-ci run-blackbox-ci: check-blackbox-prerequisites binary binary-minimal cli - # ideally we would run a single bats command but too much disk space would be used at once - echo running CI bats tests; \ - $(BATS) $(BATS_FLAGS) test/blackbox/pushpull.bats && \ - $(BATS) $(BATS_FLAGS) test/blackbox/pushpull_authn.bats && \ - $(BATS) $(BATS_FLAGS) test/blackbox/delete_images.bats && \ - $(BATS) $(BATS_FLAGS) test/blackbox/referrers.bats && \ - $(BATS) $(BATS_FLAGS) test/blackbox/metadata.bats && \ - $(BATS) $(BATS_FLAGS) test/blackbox/anonymous_policy.bats && \ - $(BATS) $(BATS_FLAGS) test/blackbox/annotations.bats && \ - $(BATS) $(BATS_FLAGS) test/blackbox/detect_manifest_collision.bats && \ - $(BATS) $(BATS_FLAGS) test/blackbox/cve.bats && \ - $(BATS) $(BATS_FLAGS) test/blackbox/sync.bats && \ - $(BATS) $(BATS_FLAGS) test/blackbox/sync_docker.bats && \ - $(BATS) $(BATS_FLAGS) test/blackbox/sync_replica_cluster.bats && \ - $(BATS) $(BATS_FLAGS) test/blackbox/scrub.bats && \ - $(BATS) $(BATS_FLAGS) test/blackbox/garbage_collect.bats && \ - $(BATS) $(BATS_FLAGS) test/blackbox/metrics.bats && \ - $(BATS) $(BATS_FLAGS) test/blackbox/metrics_minimal.bats + echo running CI bats tests concurently + BATS_FLAGS="$(BATS_FLAGS)" test/blackbox/ci.sh .PHONY: run-blackbox-cloud-ci run-blackbox-cloud-ci: check-blackbox-prerequisites check-awslocal binary $(BATS) diff --git a/test/blackbox/annotations.bats b/test/blackbox/annotations.bats index bfada64b0a..d2a5c08385 100644 --- a/test/blackbox/annotations.bats +++ b/test/blackbox/annotations.bats @@ -35,6 +35,8 @@ function setup_file() { local zot_root_dir=${BATS_FILE_TMPDIR}/zot local zot_config_file=${BATS_FILE_TMPDIR}/zot_config.json mkdir -p ${zot_root_dir} + zot_port=$(get_free_port) + echo ${zot_port} > ${BATS_FILE_TMPDIR}/zot.port cat > ${zot_config_file}< ${BATS_FILE_TMPDIR}/zot.port htpasswd -Bbn ${AUTH_USER} ${AUTH_PASS} >> ${zot_htpasswd_file} cat > ${zot_config_file}</dev/null 2>&1 ; pwd -P )" +BATS=${SCRIPTPATH}/../../hack/tools/bin/bats +PATH=$PATH:${SCRIPTPATH}/../../hack/tools/bin + +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") + +for test in ${tests[*]}; do + ${BATS} ${BATS_FLAGS} ${SCRIPTPATH}/${test}.bats > ${test}.log & pids+=($!) +done + +i=0 +success="true" +for pid in ${pids[*]}; do + if ! wait $pid; then + echo "${tests[$i]} test returns an error !!!" + cat ${tests[$i]}.log + success="false" + # we still need to wait for other PIDs to finish for the script to return properly + else + echo "${tests[$i]} test completed successfully." + fi + rm ${tests[$i]}.log + i=$((i+1)) +done + +if [ "$success" == "false" ]; then + exit 1 +fi + +echo "Successfully run all tests" diff --git a/test/blackbox/delete_images.bats b/test/blackbox/delete_images.bats index e099fabaf9..29f7c1f54c 100644 --- a/test/blackbox/delete_images.bats +++ b/test/blackbox/delete_images.bats @@ -32,6 +32,8 @@ function setup_file() { local zot_config_file=${BATS_FILE_TMPDIR}/zot_config.json mkdir -p ${ZOT_ROOT_DIR} touch ${zot_log_file} + zot_port=$(get_free_port) + echo ${zot_port} > ${BATS_FILE_TMPDIR}/zot.port cat >${zot_config_file} < ${BATS_FILE_TMPDIR}/zot.port htpasswd -Bbn ${AUTH_USER} ${AUTH_PASS} >> ${zot_htpasswd_file} cat > ${zot_config_file}< ${BATS_FILE_TMPDIR}/zot.port mkdir -p ${zot_root_dir} mkdir -p ${oci_data_dir} cat > ${zot_config_file}< signature.json - run oras attach --plain-http 127.0.0.1:8080/golang:1.20 --image-spec v1.1-image --artifact-type 'signature/example' ./signature.json:application/json + run oras attach --plain-http 127.0.0.1:${zot_port}/golang:1.20 --image-spec v1.1-image --artifact-type 'signature/example' ./signature.json:application/json [ "$status" -eq 0 ] # attach sbom to image - echo "{\"version\": \"0.0.0.0\", \"artifact\": \"'127.0.0.1:8080/golang:1.20'\", \"contents\": \"good\"}" > sbom.json - run oras attach --plain-http 127.0.0.1:8080/golang:1.20 --image-spec v1.1-image --artifact-type 'sbom/example' ./sbom.json:application/json + echo "{\"version\": \"0.0.0.0\", \"artifact\": \"'127.0.0.1:${zot_port}/golang:1.20'\", \"contents\": \"good\"}" > sbom.json + run oras attach --plain-http 127.0.0.1:${zot_port}/golang:1.20 --image-spec v1.1-image --artifact-type 'sbom/example' ./sbom.json:application/json [ "$status" -eq 0 ] # attach signature to index image - run oras attach --plain-http 127.0.0.1:8080/busybox:latest --image-spec v1.1-image --artifact-type 'signature/example' ./signature.json:application/json + run oras attach --plain-http 127.0.0.1:${zot_port}/busybox:latest --image-spec v1.1-image --artifact-type 'signature/example' ./signature.json:application/json [ "$status" -eq 0 ] # attach sbom to index image - echo "{\"version\": \"0.0.0.0\", \"artifact\": \"'127.0.0.1:8080/golang:1.20'\", \"contents\": \"good\"}" > sbom.json - run oras attach --plain-http 127.0.0.1:8080/busybox:latest --image-spec v1.1-image --artifact-type 'sbom/example' ./sbom.json:application/json + echo "{\"version\": \"0.0.0.0\", \"artifact\": \"'127.0.0.1:${zot_port}/golang:1.20'\", \"contents\": \"good\"}" > sbom.json + run oras attach --plain-http 127.0.0.1:${zot_port}/busybox:latest --image-spec v1.1-image --artifact-type 'sbom/example' ./sbom.json:application/json [ "$status" -eq 0 ] } @test "push OCI artifact with regclient" { - run regctl registry set 127.0.0.1:8080 --tls disabled + zot_port=`cat ${BATS_FILE_TMPDIR}/zot.port` + run regctl registry set 127.0.0.1:${zot_port} --tls disabled [ "$status" -eq 0 ] - run regctl artifact put --artifact-type application/vnd.example.artifact --subject 127.0.0.1:8080/golang:1.20 < ${BATS_FILE_TMPDIR}/zot.port htpasswd -Bbn ${AUTH_USER} ${AUTH_PASS} >> ${zot_htpasswd_file} cat > ${zot_config_file}< ${BATS_FILE_TMPDIR}/zot.port htpasswd -Bbn ${AUTH_USER} ${AUTH_PASS} >> ${zot_htpasswd_file} htpasswd -Bbn ${METRICS_USER} ${METRICS_PASS} >> ${zot_htpasswd_file} @@ -44,7 +46,7 @@ function setup_file() { }, "http": { "address": "0.0.0.0", - "port": "8080", + "port": "${zot_port}", "auth": { "htpasswd": { "path": "${zot_htpasswd_file}" @@ -80,7 +82,7 @@ function setup_file() { EOF zot_serve ${ZOT_PATH} ${zot_config_file} - wait_zot_reachable 8080 + wait_zot_reachable ${zot_port} } @@ -96,18 +98,20 @@ function teardown_file() { @test "unauthorized request to metrics" { # anonymous policy: metrics endpoint should not be available # 401 - http.StatusUnauthorized - run metrics_route_check 8080 "" 401 + zot_port=`cat ${BATS_FILE_TMPDIR}/zot.port` + run metrics_route_check ${zot_port} "" 401 [ "$status" -eq 0 ] # user is not in htpasswd - run metrics_route_check 8080 "-u unlucky:wrongpass" 401 + run metrics_route_check ${zot_port} "-u unlucky:wrongpass" 401 [ "$status" -eq 0 ] # proper user/pass tuple from htpasswd, but user not allowed to access metrics # 403 - http.StatusForbidden - run metrics_route_check 8080 "-u ${AUTH_USER}:${AUTH_PASS}" 403 + run metrics_route_check ${zot_port} "-u ${AUTH_USER}:${AUTH_PASS}" 403 [ "$status" -eq 0 ] } @test "authorized request: metrics enabled" { - run metrics_route_check 8080 "-u ${METRICS_USER}:${METRICS_PASS}" 200 + zot_port=`cat ${BATS_FILE_TMPDIR}/zot.port` + run metrics_route_check ${zot_port} "-u ${METRICS_USER}:${METRICS_PASS}" 200 [ "$status" -eq 0 ] } diff --git a/test/blackbox/metrics_minimal.bats b/test/blackbox/metrics_minimal.bats index 352498840f..1fa2f13416 100644 --- a/test/blackbox/metrics_minimal.bats +++ b/test/blackbox/metrics_minimal.bats @@ -31,6 +31,8 @@ function setup_file() { zot_log_file=${zot_root_dir}/zot-log.json zot_config_file=${BATS_FILE_TMPDIR}/zot_config.json zot_htpasswd_file=${BATS_FILE_TMPDIR}/zot_htpasswd + zot_port=$(get_free_port) + echo ${zot_port} > ${BATS_FILE_TMPDIR}/zot.port htpasswd -Bbn ${AUTH_USER} ${AUTH_PASS} >> ${zot_htpasswd_file} htpasswd -Bbn ${METRICS_USER} ${METRICS_PASS} >> ${zot_htpasswd_file} @@ -44,7 +46,7 @@ function setup_file() { }, "http": { "address": "0.0.0.0", - "port": "8080", + "port": "${zot_port}", "auth": { "htpasswd": { "path": "${zot_htpasswd_file}" @@ -73,7 +75,7 @@ function setup_file() { EOF zot_serve ${ZOT_MINIMAL_PATH} ${zot_config_file} - wait_zot_reachable 8080 + wait_zot_reachable ${zot_port} } @@ -89,18 +91,20 @@ function teardown_file() { @test "unauthorized request to metrics" { # anonymous policy: metrics endpoint should not be available # 401 - http.StatusUnauthorized - run metrics_route_check 8080 "" 401 + zot_port=`cat ${BATS_FILE_TMPDIR}/zot.port` + run metrics_route_check ${zot_port} "" 401 [ "$status" -eq 0 ] # user is not in htpasswd - run metrics_route_check 8080 "-u test:wrongpass" 401 + run metrics_route_check ${zot_port} "-u test:wrongpass" 401 [ "$status" -eq 0 ] # proper user/pass tuple from htpasswd, but user not allowed to access metrics # 403 - http.StatusForbidden - run metrics_route_check 8080 "-u ${AUTH_USER}:${AUTH_PASS}" 403 + run metrics_route_check ${zot_port} "-u ${AUTH_USER}:${AUTH_PASS}" 403 [ "$status" -eq 0 ] } @test "authorized request: metrics enabled" { - run metrics_route_check 8080 "-u ${METRICS_USER}:${METRICS_PASS}" 200 + zot_port=`cat ${BATS_FILE_TMPDIR}/zot.port` + run metrics_route_check ${zot_port} "-u ${METRICS_USER}:${METRICS_PASS}" 200 [ "$status" -eq 0 ] } diff --git a/test/blackbox/pushpull.bats b/test/blackbox/pushpull.bats index 03d7c6d1df..8e83f50e9c 100644 --- a/test/blackbox/pushpull.bats +++ b/test/blackbox/pushpull.bats @@ -31,6 +31,8 @@ function setup_file() { local oci_data_dir=${BATS_FILE_TMPDIR}/oci mkdir -p ${zot_root_dir} mkdir -p ${oci_data_dir} + zot_port=$(get_free_port) + echo ${zot_port} > ${BATS_FILE_TMPDIR}/zot.port cat > ${zot_config_file}< config.json echo "hello world" > artifact.txt - run oras push --plain-http 127.0.0.1:8080/hello-artifact:v2 \ + run oras push --plain-http 127.0.0.1:${zot_port}/hello-artifact:v2 \ --config config.json:application/vnd.acme.rocket.config.v1+json artifact.txt:text/plain -d -v [ "$status" -eq 0 ] rm -f artifact.txt @@ -131,37 +138,41 @@ function teardown_file() { } @test "pull oras artifact" { - run oras pull --plain-http 127.0.0.1:8080/hello-artifact:v2 -d -v + zot_port=`cat ${BATS_FILE_TMPDIR}/zot.port` + run oras pull --plain-http 127.0.0.1:${zot_port}/hello-artifact:v2 -d -v [ "$status" -eq 0 ] grep -q "hello world" artifact.txt rm -f artifact.txt } @test "attach oras artifacts" { + zot_port=`cat ${BATS_FILE_TMPDIR}/zot.port` # attach signature echo "{\"artifact\": \"\", \"signature\": \"pat hancock\"}" > ${BATS_FILE_TMPDIR}/signature.json - run oras attach --plain-http 127.0.0.1:8080/golang:1.20 --image-spec v1.1-image --artifact-type 'signature/example' ${BATS_FILE_TMPDIR}/signature.json:application/json + run oras attach --plain-http 127.0.0.1:${zot_port}/golang:1.20 --image-spec v1.1-image --artifact-type 'signature/example' ${BATS_FILE_TMPDIR}/signature.json:application/json [ "$status" -eq 0 ] # attach sbom - echo "{\"version\": \"0.0.0.0\", \"artifact\": \"'127.0.0.1:8080/golang:1.20'\", \"contents\": \"good\"}" > ${BATS_FILE_TMPDIR}/sbom.json - run oras attach --plain-http 127.0.0.1:8080/golang:1.20 --image-spec v1.1-image --artifact-type 'sbom/example' ${BATS_FILE_TMPDIR}/sbom.json:application/json + echo "{\"version\": \"0.0.0.0\", \"artifact\": \"'127.0.0.1:${zot_port}/golang:1.20'\", \"contents\": \"good\"}" > ${BATS_FILE_TMPDIR}/sbom.json + run oras attach --plain-http 127.0.0.1:${zot_port}/golang:1.20 --image-spec v1.1-image --artifact-type 'sbom/example' ${BATS_FILE_TMPDIR}/sbom.json:application/json [ "$status" -eq 0 ] } @test "discover oras artifacts" { - run oras discover --plain-http -o json 127.0.0.1:8080/golang:1.20 + zot_port=`cat ${BATS_FILE_TMPDIR}/zot.port` + run oras discover --plain-http -o json 127.0.0.1:${zot_port}/golang:1.20 [ "$status" -eq 0 ] [ $(echo "$output" | jq -r ".manifests | length") -eq 2 ] } @test "add and list tags using oras" { + zot_port=`cat ${BATS_FILE_TMPDIR}/zot.port` run skopeo --insecure-policy copy --dest-tls-verify=false \ oci:${TEST_DATA_DIR}/golang:1.20 \ - docker://127.0.0.1:8080/oras-tags:1.20 + docker://127.0.0.1:${zot_port}/oras-tags:1.20 [ "$status" -eq 0 ] - run oras tag --plain-http 127.0.0.1:8080/oras-tags:1.20 1 new latest + run oras tag --plain-http 127.0.0.1:${zot_port}/oras-tags:1.20 1 new latest [ "$status" -eq 0 ] - run oras repo tags --plain-http 127.0.0.1:8080/oras-tags + run oras repo tags --plain-http 127.0.0.1:${zot_port}/oras-tags [ "$status" -eq 0 ] echo "$output" [ $(echo "$output" | wc -l) -eq 4 ] @@ -169,22 +180,22 @@ function teardown_file() { [ "${lines[-2]}" == "latest" ] [ "${lines[-3]}" == "1.20" ] [ "${lines[-4]}" == "1" ] - run oras repo tags --plain-http --last new 127.0.0.1:8080/oras-tags + run oras repo tags --plain-http --last new 127.0.0.1:${zot_port}/oras-tags [ "$status" -eq 0 ] echo "$output" [ -z $output ] - run oras repo tags --plain-http --last latest 127.0.0.1:8080/oras-tags + run oras repo tags --plain-http --last latest 127.0.0.1:${zot_port}/oras-tags [ "$status" -eq 0 ] echo "$output" [ $(echo "$output" | wc -l) -eq 1 ] [ "${lines[-1]}" == "new" ] - run oras repo tags --plain-http --last "1.20" 127.0.0.1:8080/oras-tags + run oras repo tags --plain-http --last "1.20" 127.0.0.1:${zot_port}/oras-tags [ "$status" -eq 0 ] echo "$output" [ $(echo "$output" | wc -l) -eq 2 ] [ "${lines[-2]}" == "latest" ] [ "${lines[-1]}" == "new" ] - run oras repo tags --plain-http --last "1" 127.0.0.1:8080/oras-tags + run oras repo tags --plain-http --last "1" 127.0.0.1:${zot_port}/oras-tags [ "$status" -eq 0 ] echo "$output" [ $(echo "$output" | wc -l) -eq 3 ] @@ -194,33 +205,38 @@ function teardown_file() { } @test "push helm chart" { + zot_port=`cat ${BATS_FILE_TMPDIR}/zot.port` run helm package ${BATS_FILE_TMPDIR}/helm-charts/charts/zot -d ${BATS_FILE_TMPDIR} [ "$status" -eq 0 ] local chart_version=$(awk '/version/{printf $2}' ${BATS_FILE_TMPDIR}/helm-charts/charts/zot/Chart.yaml) - run helm push ${BATS_FILE_TMPDIR}/zot-${chart_version}.tgz oci://localhost:8080/zot-chart + run helm push ${BATS_FILE_TMPDIR}/zot-${chart_version}.tgz oci://localhost:${zot_port}/zot-chart [ "$status" -eq 0 ] } @test "pull helm chart" { + zot_port=`cat ${BATS_FILE_TMPDIR}/zot.port` local chart_version=$(awk '/version/{printf $2}' ${BATS_FILE_TMPDIR}/helm-charts/charts/zot/Chart.yaml) - run helm pull oci://localhost:8080/zot-chart/zot --version ${chart_version} -d ${BATS_FILE_TMPDIR} + run helm pull oci://localhost:${zot_port}/zot-chart/zot --version ${chart_version} -d ${BATS_FILE_TMPDIR} [ "$status" -eq 0 ] } @test "push image with regclient" { - run regctl registry set localhost:8080 --tls disabled + zot_port=`cat ${BATS_FILE_TMPDIR}/zot.port` + run regctl registry set localhost:${zot_port} --tls disabled [ "$status" -eq 0 ] - run regctl image copy ocidir://${TEST_DATA_DIR}/golang:1.20 localhost:8080/test-regclient + run regctl image copy ocidir://${TEST_DATA_DIR}/golang:1.20 localhost:${zot_port}/test-regclient [ "$status" -eq 0 ] } @test "pull image with regclient" { - run regctl image copy localhost:8080/test-regclient ocidir://${TEST_DATA_DIR}/golang:1.20 + zot_port=`cat ${BATS_FILE_TMPDIR}/zot.port` + run regctl image copy localhost:${zot_port}/test-regclient ocidir://${TEST_DATA_DIR}/golang:1.20 [ "$status" -eq 0 ] } @test "list repositories with regclient" { - run regctl repo ls localhost:8080 + zot_port=`cat ${BATS_FILE_TMPDIR}/zot.port` + run regctl repo ls localhost:${zot_port} [ "$status" -eq 0 ] found=0 @@ -235,7 +251,8 @@ function teardown_file() { } @test "list image tags with regclient" { - run regctl tag ls localhost:8080/test-regclient + zot_port=`cat ${BATS_FILE_TMPDIR}/zot.port` + run regctl tag ls localhost:${zot_port}/test-regclient [ "$status" -eq 0 ] found=0 @@ -250,87 +267,95 @@ function teardown_file() { } @test "push manifest with regclient" { - manifest=$(regctl manifest get localhost:8080/test-regclient --format=raw-body) - run regctl manifest put localhost:8080/test-regclient:1.0.0 --format oci --content-type application/vnd.oci.image.manifest.v1+json --format oci < ${BATS_FILE_TMPDIR}/zot.port htpasswd -Bbn ${AUTH_USER} ${AUTH_PASS} >> ${zot_htpasswd_file} echo ${zot_root_dir} >&3 @@ -50,7 +52,7 @@ function setup_file() { }, "http": { "address": "127.0.0.1", - "port": "8080", + "port": "${zot_port}", "realm":"zot", "auth": { "htpasswd": { @@ -78,7 +80,7 @@ function setup_file() { } EOF zot_serve ${ZOT_PATH} ${zot_config_file} - wait_zot_reachable 8080 + wait_zot_reachable ${zot_port} } function teardown() { @@ -91,77 +93,83 @@ function teardown_file() { } @test "push image with regclient" { - run regctl registry set localhost:8080 --tls disabled - run regctl registry login localhost:8080 -u ${AUTH_USER} -p ${AUTH_PASS} + zot_port=`cat ${BATS_FILE_TMPDIR}/zot.port` + run regctl registry set localhost:${zot_port} --tls disabled + run regctl registry login localhost:${zot_port} -u ${AUTH_USER} -p ${AUTH_PASS} [ "$status" -eq 0 ] - run regctl image copy ocidir://${TEST_DATA_DIR}/busybox:1.36 localhost:8080/test-regclient + run regctl image copy ocidir://${TEST_DATA_DIR}/busybox:1.36 localhost:${zot_port}/test-regclient [ "$status" -eq 0 ] } @test "pull image with regclient" { - run regctl image copy localhost:8080/test-regclient ocidir://${TEST_DATA_DIR}/busybox:latest + zot_port=`cat ${BATS_FILE_TMPDIR}/zot.port` + run regctl image copy localhost:${zot_port}/test-regclient ocidir://${TEST_DATA_DIR}/busybox:latest [ "$status" -eq 0 ] } @test "push OCI artifact with regclient" { - run regctl artifact put localhost:8080/artifact:demo < ${BATS_FILE_TMPDIR}/zot.port cat >${ZOT_CONFIG_FILE} < ${BATS_FILE_TMPDIR}/zot.port mkdir -p ${ZOT_ROOT_DIR} touch ${ZOT_LOG_FILE} cat >${ZOT_CONFIG_FILE} < ${BATS_FILE_TMPDIR}/zot.port1 + zot_port2=$(get_free_port) + echo ${zot_port2} > ${BATS_FILE_TMPDIR}/zot.port2 + zot_port3=$(get_free_port) + echo ${zot_port3} > ${BATS_FILE_TMPDIR}/zot.port3 cat >${zot_sync_per_config_file} < config.json echo "hello world" > artifact.txt - run oras push --plain-http 127.0.0.1:9000/hello-artifact:v2 \ + run oras push --plain-http 127.0.0.1:${zot_port3}/hello-artifact:v2 \ --config config.json:application/vnd.acme.rocket.config.v1+json artifact.txt:text/plain -d -v [ "$status" -eq 0 ] rm -f artifact.txt @@ -330,16 +349,18 @@ EOF } @test "sync oras artifact periodically" { -# # wait for oras artifact to be copied + zot_port1=`cat ${BATS_FILE_TMPDIR}/zot.port1` + # wait for oras artifact to be copied run sleep 15s - run oras pull --plain-http 127.0.0.1:8081/hello-artifact:v2 -d -v + run oras pull --plain-http 127.0.0.1:${zot_port1}/hello-artifact:v2 -d -v [ "$status" -eq 0 ] grep -q "hello world" artifact.txt rm -f artifact.txt } @test "sync oras artifact on demand" { - run oras pull --plain-http 127.0.0.1:8082/hello-artifact:v2 -d -v + zot_port2=`cat ${BATS_FILE_TMPDIR}/zot.port2` + run oras pull --plain-http 127.0.0.1:${zot_port2}/hello-artifact:v2 -d -v [ "$status" -eq 0 ] grep -q "hello world" artifact.txt rm -f artifact.txt @@ -347,163 +368,177 @@ EOF # sync helm chart @test "push helm chart" { + zot_port3=`cat ${BATS_FILE_TMPDIR}/zot.port3` run helm package ${BATS_FILE_TMPDIR}/helm-charts/charts/zot -d ${BATS_FILE_TMPDIR} [ "$status" -eq 0 ] local chart_version=$(awk '/version/{printf $2}' ${BATS_FILE_TMPDIR}/helm-charts/charts/zot/Chart.yaml) - run helm push ${BATS_FILE_TMPDIR}/zot-${chart_version}.tgz oci://localhost:9000/zot-chart + run helm push ${BATS_FILE_TMPDIR}/zot-${chart_version}.tgz oci://localhost:${zot_port3}/zot-chart [ "$status" -eq 0 ] } @test "sync helm chart periodically" { + zot_port1=`cat ${BATS_FILE_TMPDIR}/zot.port1` # wait for helm chart to be copied run sleep 15s local chart_version=$(awk '/version/{printf $2}' ${BATS_FILE_TMPDIR}/helm-charts/charts/zot/Chart.yaml) - run helm pull oci://localhost:8081/zot-chart/zot --version ${chart_version} -d ${BATS_FILE_TMPDIR} + run helm pull oci://localhost:${zot_port1}/zot-chart/zot --version ${chart_version} -d ${BATS_FILE_TMPDIR} [ "$status" -eq 0 ] } @test "sync helm chart on demand" { + zot_port2=`cat ${BATS_FILE_TMPDIR}/zot.port2` local chart_version=$(awk '/version/{printf $2}' ${BATS_FILE_TMPDIR}/helm-charts/charts/zot/Chart.yaml) - run helm pull oci://localhost:8082/zot-chart/zot --version ${chart_version} -d ${BATS_FILE_TMPDIR} + run helm pull oci://localhost:${zot_port2}/zot-chart/zot --version ${chart_version} -d ${BATS_FILE_TMPDIR} [ "$status" -eq 0 ] } # sync OCI artifacts @test "push OCI artifact (oci image mediatype) with regclient" { - run regctl registry set localhost:9000 --tls disabled - run regctl registry set localhost:8081 --tls disabled - run regctl registry set localhost:8082 --tls disabled - - run regctl artifact put localhost:9000/artifact:demo < ${BATS_FILE_TMPDIR}/zot.port mkdir -p ${zot_root_dir} @@ -43,7 +45,7 @@ function setup_file() { }, "http": { "address": "0.0.0.0", - "port": "8090" + "port": "${zot_port}" }, "log": { "level": "debug", @@ -164,7 +166,7 @@ function setup_file() { EOF zot_serve ${ZOT_PATH} ${zot_sync_ondemand_config_file} - wait_zot_reachable 8090 + wait_zot_reachable ${zot_port} } function teardown_file() { @@ -173,21 +175,22 @@ function teardown_file() { # sync image @test "sync docker image list on demand" { + zot_port=`cat ${BATS_FILE_TMPDIR}/zot.port` run skopeo --insecure-policy copy --multi-arch=all --src-tls-verify=false \ - docker://127.0.0.1:8090/registry \ + docker://127.0.0.1:${zot_port}/registry \ oci:${TEST_DATA_DIR} [ "$status" -eq 0 ] - run curl http://127.0.0.1:8090/v2/_catalog + run curl http://127.0.0.1:${zot_port}/v2/_catalog [ "$status" -eq 0 ] [ $(echo "${lines[-1]}" | jq '.repositories[]') = '"registry"' ] - run curl http://127.0.0.1:8090/v2/registry/tags/list + run curl http://127.0.0.1:${zot_port}/v2/registry/tags/list [ "$status" -eq 0 ] [ $(echo "${lines[-1]}" | jq '.tags[]') = '"latest"' ] # make sure image is skipped when synced again run skopeo --insecure-policy copy --multi-arch=all --src-tls-verify=false \ - docker://127.0.0.1:8090/registry \ + docker://127.0.0.1:${zot_port}/registry \ oci:${TEST_DATA_DIR} [ "$status" -eq 0 ] @@ -196,21 +199,22 @@ function teardown_file() { } @test "sync docker image on demand" { + zot_port=`cat ${BATS_FILE_TMPDIR}/zot.port` run skopeo --insecure-policy copy --src-tls-verify=false \ - docker://127.0.0.1:8090/archlinux \ + docker://127.0.0.1:${zot_port}/archlinux \ oci:${TEST_DATA_DIR} [ "$status" -eq 0 ] - run curl http://127.0.0.1:8090/v2/_catalog + run curl http://127.0.0.1:${zot_port}/v2/_catalog [ "$status" -eq 0 ] [ $(echo "${lines[-1]}" | jq '.repositories[0]') = '"archlinux"' ] - run curl http://127.0.0.1:8090/v2/archlinux/tags/list + run curl http://127.0.0.1:${zot_port}/v2/archlinux/tags/list [ "$status" -eq 0 ] [ $(echo "${lines[-1]}" | jq '.tags[]') = '"latest"' ] # make sure image is skipped when synced again run skopeo --insecure-policy copy --src-tls-verify=false \ - docker://127.0.0.1:8090/archlinux \ + docker://127.0.0.1:${zot_port}/archlinux \ oci:${TEST_DATA_DIR} [ "$status" -eq 0 ] @@ -219,129 +223,139 @@ function teardown_file() { } @test "sync k8s image list on demand" { + zot_port=`cat ${BATS_FILE_TMPDIR}/zot.port` run skopeo --insecure-policy copy --multi-arch=all --src-tls-verify=false \ - docker://127.0.0.1:8090/kube-apiserver:v1.26.0 \ + docker://127.0.0.1:${zot_port}/kube-apiserver:v1.26.0 \ oci:${TEST_DATA_DIR} [ "$status" -eq 0 ] - run curl http://127.0.0.1:8090/v2/_catalog + run curl http://127.0.0.1:${zot_port}/v2/_catalog [ "$status" -eq 0 ] [ $(echo "${lines[-1]}" | jq '.repositories[1]') = '"kube-apiserver"' ] - run curl http://127.0.0.1:8090/v2/kube-apiserver/tags/list + run curl http://127.0.0.1:${zot_port}/v2/kube-apiserver/tags/list [ "$status" -eq 0 ] [ $(echo "${lines[-1]}" | jq '.tags[]') = '"v1.26.0"' ] } @test "sync k8s image on demand" { + zot_port=`cat ${BATS_FILE_TMPDIR}/zot.port` run skopeo --insecure-policy copy --src-tls-verify=false \ - docker://127.0.0.1:8090/pause \ + docker://127.0.0.1:${zot_port}/pause \ oci:${TEST_DATA_DIR} [ "$status" -eq 0 ] - run curl http://127.0.0.1:8090/v2/_catalog + run curl http://127.0.0.1:${zot_port}/v2/_catalog [ "$status" -eq 0 ] [ $(echo "${lines[-1]}" | jq '.repositories[2]') = '"pause"' ] - run curl http://127.0.0.1:8090/v2/pause/tags/list + run curl http://127.0.0.1:${zot_port}/v2/pause/tags/list [ "$status" -eq 0 ] [ $(echo "${lines[-1]}" | jq '.tags[]') = '"latest"' ] } @test "sync image on demand from registry.k8s.io" { - run skopeo copy docker://127.0.0.1:8090/kube-apiserver-amd64:v1.10.0 oci:${TEST_DATA_DIR} --src-tls-verify=false + zot_port=`cat ${BATS_FILE_TMPDIR}/zot.port` + run skopeo copy docker://127.0.0.1:${zot_port}/kube-apiserver-amd64:v1.10.0 oci:${TEST_DATA_DIR} --src-tls-verify=false [ "$status" -eq 0 ] - run curl http://127.0.0.1:8090/v2/_catalog + run curl http://127.0.0.1:${zot_port}/v2/_catalog [ "$status" -eq 0 ] [ $(echo "${lines[-1]}"| jq '.repositories | map(select(. == "kube-apiserver-amd64"))' | jq '.[]') = '"kube-apiserver-amd64"' ] - run curl http://127.0.0.1:8090/v2/kube-apiserver-amd64/tags/list + run curl http://127.0.0.1:${zot_port}/v2/kube-apiserver-amd64/tags/list [ "$status" -eq 0 ] [ $(echo "${lines[-1]}" | jq '.tags[]') = '"v1.10.0"' ] } @test "sync image on demand from aws.amazon.com/ecr" { - run skopeo copy docker://127.0.0.1:8090/amazonlinux/amazonlinux:latest oci:${TEST_DATA_DIR} --src-tls-verify=false + zot_port=`cat ${BATS_FILE_TMPDIR}/zot.port` + run skopeo copy docker://127.0.0.1:${zot_port}/amazonlinux/amazonlinux:latest oci:${TEST_DATA_DIR} --src-tls-verify=false [ "$status" -eq 0 ] - run curl http://127.0.0.1:8090/v2/_catalog + run curl http://127.0.0.1:${zot_port}/v2/_catalog [ "$status" -eq 0 ] [ $(echo "${lines[-1]}"| jq '.repositories | map(select(. == "amazonlinux/amazonlinux"))' | jq '.[]') = '"amazonlinux/amazonlinux"' ] - run curl http://127.0.0.1:8090/v2/amazonlinux/amazonlinux/tags/list + run curl http://127.0.0.1:${zot_port}/v2/amazonlinux/amazonlinux/tags/list [ "$status" -eq 0 ] [ $(echo "${lines[-1]}" | jq '.tags[]') = '"latest"' ] } @test "sync image on demand from gcr.io" { - run skopeo copy docker://127.0.0.1:8090/google-containers/kube-proxy-amd64:v1.17.9 oci:${TEST_DATA_DIR} --src-tls-verify=false + zot_port=`cat ${BATS_FILE_TMPDIR}/zot.port` + run skopeo copy docker://127.0.0.1:${zot_port}/google-containers/kube-proxy-amd64:v1.17.9 oci:${TEST_DATA_DIR} --src-tls-verify=false [ "$status" -eq 0 ] - run curl http://127.0.0.1:8090/v2/_catalog + run curl http://127.0.0.1:${zot_port}/v2/_catalog [ "$status" -eq 0 ] [ $(echo "${lines[-1]}"| jq '.repositories | map(select(. == "google-containers/kube-proxy-amd64"))' | jq '.[]') = '"google-containers/kube-proxy-amd64"' ] - run curl http://127.0.0.1:8090/v2/google-containers/kube-proxy-amd64/tags/list + run curl http://127.0.0.1:${zot_port}/v2/google-containers/kube-proxy-amd64/tags/list [ "$status" -eq 0 ] [ $(echo "${lines[-1]}" | jq '.tags[]') = '"v1.17.9"' ] } @test "sync image on demand from mcr.microsoft.com" { - run skopeo copy docker://127.0.0.1:8090/azure-cognitive-services/vision/spatial-analysis/diagnostics:latest oci:${TEST_DATA_DIR} --src-tls-verify=false + zot_port=`cat ${BATS_FILE_TMPDIR}/zot.port` + run skopeo copy docker://127.0.0.1:${zot_port}/azure-cognitive-services/vision/spatial-analysis/diagnostics:latest oci:${TEST_DATA_DIR} --src-tls-verify=false [ "$status" -eq 0 ] - run curl http://127.0.0.1:8090/v2/_catalog + run curl http://127.0.0.1:${zot_port}/v2/_catalog [ "$status" -eq 0 ] [ $(echo "${lines[-1]}"| jq '.repositories | map(select(. == "azure-cognitive-services/vision/spatial-analysis/diagnostics"))' | jq '.[]') = '"azure-cognitive-services/vision/spatial-analysis/diagnostics"' ] - run curl http://127.0.0.1:8090/v2/azure-cognitive-services/vision/spatial-analysis/diagnostics/tags/list + run curl http://127.0.0.1:${zot_port}/v2/azure-cognitive-services/vision/spatial-analysis/diagnostics/tags/list [ "$status" -eq 0 ] [ $(echo "${lines[-1]}" | jq '.tags[]') = '"latest"' ] } @test "sync image on demand from registry.gitlab.com" { - run skopeo copy docker://127.0.0.1:8090/gitlab-org/public-image-archive/gitlab-ee:15.11.6-ee.0 oci:${TEST_DATA_DIR} --src-tls-verify=false + zot_port=`cat ${BATS_FILE_TMPDIR}/zot.port` + run skopeo copy docker://127.0.0.1:${zot_port}/gitlab-org/public-image-archive/gitlab-ee:15.11.6-ee.0 oci:${TEST_DATA_DIR} --src-tls-verify=false [ "$status" -eq 0 ] - run curl http://127.0.0.1:8090/v2/_catalog + run curl http://127.0.0.1:${zot_port}/v2/_catalog [ "$status" -eq 0 ] [ $(echo "${lines[-1]}"| jq '.repositories | map(select(. == "gitlab-org/public-image-archive/gitlab-ee"))' | jq '.[]') = '"gitlab-org/public-image-archive/gitlab-ee"' ] - run curl http://127.0.0.1:8090/v2/gitlab-org/public-image-archive/gitlab-ee/tags/list + run curl http://127.0.0.1:${zot_port}/v2/gitlab-org/public-image-archive/gitlab-ee/tags/list [ "$status" -eq 0 ] [ $(echo "${lines[-1]}" | jq '.tags[]') = '"15.11.6-ee.0"' ] } @test "sync image on demand from quay.io" { - run skopeo copy docker://127.0.0.1:8090/coreos/etcd:v3.4.26 oci:${TEST_DATA_DIR} --src-tls-verify=false + zot_port=`cat ${BATS_FILE_TMPDIR}/zot.port` + run skopeo copy docker://127.0.0.1:${zot_port}/coreos/etcd:v3.4.26 oci:${TEST_DATA_DIR} --src-tls-verify=false [ "$status" -eq 0 ] - run curl http://127.0.0.1:8090/v2/_catalog + run curl http://127.0.0.1:${zot_port}/v2/_catalog [ "$status" -eq 0 ] [ $(echo "${lines[-1]}"| jq '.repositories | map(select(. == "coreos/etcd"))' | jq '.[]') = '"coreos/etcd"' ] - run curl http://127.0.0.1:8090/v2/coreos/etcd/tags/list + run curl http://127.0.0.1:${zot_port}/v2/coreos/etcd/tags/list [ "$status" -eq 0 ] [ $(echo "${lines[-1]}" | jq '.tags[]') = '"v3.4.26"' ] } @test "sync image on demand from ghcr.io" { - run skopeo copy docker://127.0.0.1:8090/project-zot/zot-linux-amd64:v2.0.0-rc5 oci:${TEST_DATA_DIR} --src-tls-verify=false + zot_port=`cat ${BATS_FILE_TMPDIR}/zot.port` + run skopeo copy docker://127.0.0.1:${zot_port}/project-zot/zot-linux-amd64:v2.0.0-rc5 oci:${TEST_DATA_DIR} --src-tls-verify=false [ "$status" -eq 0 ] - run curl http://127.0.0.1:8090/v2/_catalog + run curl http://127.0.0.1:${zot_port}/v2/_catalog [ "$status" -eq 0 ] [ $(echo "${lines[-1]}"| jq '.repositories | map(select(. == "project-zot/zot-linux-amd64"))' | jq '.[]') = '"project-zot/zot-linux-amd64"' ] - run curl http://127.0.0.1:8090/v2/project-zot/zot-linux-amd64/tags/list + run curl http://127.0.0.1:${zot_port}/v2/project-zot/zot-linux-amd64/tags/list [ "$status" -eq 0 ] [ $(echo "${lines[-1]}" | jq '.tags[]') = '"v2.0.0-rc5"' ] } @test "run docker with image synced from docker.io" { + zot_port=`cat ${BATS_FILE_TMPDIR}/zot.port` local zot_root_dir=${BATS_FILE_TMPDIR}/zot run rm -rf ${zot_root_dir} [ "$status" -eq 0 ] - run docker run -d 127.0.0.1:8090/archlinux:latest + run docker run -d 127.0.0.1:${zot_port}/archlinux:latest [ "$status" -eq 0 ] - run curl http://127.0.0.1:8090/v2/_catalog + run curl http://127.0.0.1:${zot_port}/v2/_catalog [ "$status" -eq 0 ] [ $(echo "${lines[-1]}"| jq '.repositories | map(select(. == "archlinux"))' | jq '.[]') = '"archlinux"' ] - run curl http://127.0.0.1:8090/v2/archlinux/tags/list + run curl http://127.0.0.1:${zot_port}/v2/archlinux/tags/list [ "$status" -eq 0 ] [ $(echo "${lines[-1]}" | jq '.tags[]') = '"latest"' ] @@ -349,13 +363,14 @@ function teardown_file() { } @test "run docker with image synced from registry.k8s.io" { - run docker run -d 127.0.0.1:8090/kube-apiserver-amd64:v1.10.0 + zot_port=`cat ${BATS_FILE_TMPDIR}/zot.port` + run docker run -d 127.0.0.1:${zot_port}/kube-apiserver-amd64:v1.10.0 [ "$status" -eq 0 ] - run curl http://127.0.0.1:8090/v2/_catalog + run curl http://127.0.0.1:${zot_port}/v2/_catalog [ "$status" -eq 0 ] [ $(echo "${lines[-1]}"| jq '.repositories | map(select(. == "kube-apiserver-amd64"))' | jq '.[]') = '"kube-apiserver-amd64"' ] - run curl http://127.0.0.1:8090/v2/kube-apiserver-amd64/tags/list + run curl http://127.0.0.1:${zot_port}/v2/kube-apiserver-amd64/tags/list [ "$status" -eq 0 ] [ $(echo "${lines[-1]}" | jq '.tags[]') = '"v1.10.0"' ] @@ -363,13 +378,14 @@ function teardown_file() { } @test "run docker with image synced from aws.amazon.com/ecr" { - run docker run -d 127.0.0.1:8090/amazonlinux/amazonlinux:latest + zot_port=`cat ${BATS_FILE_TMPDIR}/zot.port` + run docker run -d 127.0.0.1:${zot_port}/amazonlinux/amazonlinux:latest [ "$status" -eq 0 ] - run curl http://127.0.0.1:8090/v2/_catalog + run curl http://127.0.0.1:${zot_port}/v2/_catalog [ "$status" -eq 0 ] [ $(echo "${lines[-1]}"| jq '.repositories | map(select(. == "amazonlinux/amazonlinux"))' | jq '.[]') = '"amazonlinux/amazonlinux"' ] - run curl http://127.0.0.1:8090/v2/amazonlinux/amazonlinux/tags/list + run curl http://127.0.0.1:${zot_port}/v2/amazonlinux/amazonlinux/tags/list [ "$status" -eq 0 ] [ $(echo "${lines[-1]}" | jq '.tags[]') = '"latest"' ] @@ -377,13 +393,14 @@ function teardown_file() { } @test "run docker with image synced from gcr.io" { - run docker run -d 127.0.0.1:8090/google-containers/kube-proxy-amd64:v1.17.9 + zot_port=`cat ${BATS_FILE_TMPDIR}/zot.port` + run docker run -d 127.0.0.1:${zot_port}/google-containers/kube-proxy-amd64:v1.17.9 [ "$status" -eq 0 ] - run curl http://127.0.0.1:8090/v2/_catalog + run curl http://127.0.0.1:${zot_port}/v2/_catalog [ "$status" -eq 0 ] [ $(echo "${lines[-1]}"| jq '.repositories | map(select(. == "google-containers/kube-proxy-amd64"))' | jq '.[]') = '"google-containers/kube-proxy-amd64"' ] - run curl http://127.0.0.1:8090/v2/google-containers/kube-proxy-amd64/tags/list + run curl http://127.0.0.1:${zot_port}/v2/google-containers/kube-proxy-amd64/tags/list [ "$status" -eq 0 ] [ $(echo "${lines[-1]}" | jq '.tags[]') = '"v1.17.9"' ] @@ -391,13 +408,14 @@ function teardown_file() { } @test "run docker with image synced from mcr.microsoft.com" { - run docker run -d 127.0.0.1:8090/azure-cognitive-services/vision/spatial-analysis/diagnostics:latest + zot_port=`cat ${BATS_FILE_TMPDIR}/zot.port` + run docker run -d 127.0.0.1:${zot_port}/azure-cognitive-services/vision/spatial-analysis/diagnostics:latest [ "$status" -eq 0 ] - run curl http://127.0.0.1:8090/v2/_catalog + run curl http://127.0.0.1:${zot_port}/v2/_catalog [ "$status" -eq 0 ] [ $(echo "${lines[-1]}"| jq '.repositories | map(select(. == "azure-cognitive-services/vision/spatial-analysis/diagnostics"))' | jq '.[]') = '"azure-cognitive-services/vision/spatial-analysis/diagnostics"' ] - run curl http://127.0.0.1:8090/v2/azure-cognitive-services/vision/spatial-analysis/diagnostics/tags/list + run curl http://127.0.0.1:${zot_port}/v2/azure-cognitive-services/vision/spatial-analysis/diagnostics/tags/list [ "$status" -eq 0 ] [ $(echo "${lines[-1]}" | jq '.tags[]') = '"latest"' ] @@ -405,37 +423,40 @@ function teardown_file() { } @test "run docker with image synced from registry.gitlab.com" { - run docker run -d 127.0.0.1:8090/gitlab-org/public-image-archive/gitlab-ee:15.11.6-ee.0 + zot_port=`cat ${BATS_FILE_TMPDIR}/zot.port` + run docker run -d 127.0.0.1:${zot_port}/gitlab-org/public-image-archive/gitlab-ee:15.11.6-ee.0 [ "$status" -eq 0 ] - run curl http://127.0.0.1:8090/v2/_catalog + run curl http://127.0.0.1:${zot_port}/v2/_catalog [ "$status" -eq 0 ] [ $(echo "${lines[-1]}"| jq '.repositories | map(select(. == "gitlab-org/public-image-archive/gitlab-ee"))' | jq '.[]') = '"gitlab-org/public-image-archive/gitlab-ee"' ] - run curl http://127.0.0.1:8090/v2/gitlab-org/public-image-archive/gitlab-ee/tags/list + run curl http://127.0.0.1:${zot_port}/v2/gitlab-org/public-image-archive/gitlab-ee/tags/list [ "$status" -eq 0 ] [ $(echo "${lines[-1]}" | jq '.tags[]') = '"15.11.6-ee.0"' ] } @test "run docker with image synced from quay.io" { - run docker run -d 127.0.0.1:8090/coreos/etcd:v3.4.26 + zot_port=`cat ${BATS_FILE_TMPDIR}/zot.port` + run docker run -d 127.0.0.1:${zot_port}/coreos/etcd:v3.4.26 [ "$status" -eq 0 ] - run curl http://127.0.0.1:8090/v2/_catalog + run curl http://127.0.0.1:${zot_port}/v2/_catalog [ "$status" -eq 0 ] [ $(echo "${lines[-1]}"| jq '.repositories | map(select(. == "coreos/etcd"))' | jq '.[]') = '"coreos/etcd"' ] - run curl http://127.0.0.1:8090/v2/coreos/etcd/tags/list + run curl http://127.0.0.1:${zot_port}/v2/coreos/etcd/tags/list [ "$status" -eq 0 ] [ $(echo "${lines[-1]}" | jq '.tags[]') = '"v3.4.26"' ] } @test "run docker with image synced from ghcr.io" { - run docker run -d 127.0.0.1:8090/project-zot/zot-linux-amd64:v2.0.0-rc5 + zot_port=`cat ${BATS_FILE_TMPDIR}/zot.port` + run docker run -d 127.0.0.1:${zot_port}/project-zot/zot-linux-amd64:v2.0.0-rc5 [ "$status" -eq 0 ] - run curl http://127.0.0.1:8090/v2/_catalog + run curl http://127.0.0.1:${zot_port}/v2/_catalog [ "$status" -eq 0 ] [ $(echo "${lines[-1]}"| jq '.repositories | map(select(. == "project-zot/zot-linux-amd64"))' | jq '.[]') = '"project-zot/zot-linux-amd64"' ] - run curl http://127.0.0.1:8090/v2/project-zot/zot-linux-amd64/tags/list + run curl http://127.0.0.1:${zot_port}/v2/project-zot/zot-linux-amd64/tags/list [ "$status" -eq 0 ] [ $(echo "${lines[-1]}" | jq '.tags[]') = '"v2.0.0-rc5"' ] } diff --git a/test/blackbox/sync_replica_cluster.bats b/test/blackbox/sync_replica_cluster.bats index cc96596a30..37291d044c 100644 --- a/test/blackbox/sync_replica_cluster.bats +++ b/test/blackbox/sync_replica_cluster.bats @@ -41,6 +41,11 @@ function setup_file() { mkdir -p ${zot_sync_one_root_dir} mkdir -p ${zot_sync_two_root_dir} + zot_port1=$(get_free_port) + echo ${zot_port1} > ${BATS_FILE_TMPDIR}/zot.port1 + zot_port2=$(get_free_port) + echo ${zot_port2} > ${BATS_FILE_TMPDIR}/zot.port2 + cat >${zot_sync_one_config_file} <