diff --git a/Makefile b/Makefile index 93c2e6e9..321c3e82 100644 --- a/Makefile +++ b/Makefile @@ -276,12 +276,12 @@ test-push-pull-verbose: binary check-skopeo $(BATS) .PHONY: test-bats-sync test-bats-sync: EXTENSIONS=sync -test-bats-sync: binary binary-minimal check-skopeo $(BATS) +test-bats-sync: binary binary-minimal check-skopeo $(BATS) $(NOTATION) $(COSIGN) $(BATS) --trace --print-output-on-failure test/blackbox/sync.bats .PHONY: test-bats-sync-verbose test-bats-sync-verbose: EXTENSIONS=sync -test-bats-sync-verbose: binary binary-minimal check-skopeo $(BATS) +test-bats-sync-verbose: binary binary-minimal check-skopeo $(BATS) $(NOTATION) $(COSIGN) $(BATS) --trace -t -x -p --verbose-run --print-output-on-failure --show-output-of-passing-tests test/blackbox/sync.bats .PHONY: test-bats-cve diff --git a/test/blackbox/sync.bats b/test/blackbox/sync.bats index 169e39f4..857b6207 100644 --- a/test/blackbox/sync.bats +++ b/test/blackbox/sync.bats @@ -7,25 +7,67 @@ function setup_file() { fi # Download test data to folder common for the entire suite, not just this file - skopeo --insecure-policy copy --format=oci docker://ghcr.io/project-zot/golang:1.17 oci:${TEST_DATA_DIR}/golang:1.17 + skopeo --insecure-policy copy --format=oci docker://ghcr.io/project-zot/golang:1.19 oci:${TEST_DATA_DIR}/golang:1.19 # Setup zot server - local zot_root_dir=${BATS_FILE_TMPDIR}/zot + local zot_sync_per_root_dir=${BATS_FILE_TMPDIR}/zot-per + local zot_sync_ondemand_root_dir=${BATS_FILE_TMPDIR}/zot-ondemand + + local zot_sync_per_config_file=${BATS_FILE_TMPDIR}/zot_sync_per_config.json + local zot_sync_ondemand_config_file=${BATS_FILE_TMPDIR}/zot_sync_ondemand_config.json + local zot_minimal_root_dir=${BATS_FILE_TMPDIR}/zot-minimal - local zot_config_file=${BATS_FILE_TMPDIR}/zot_config.json local zot_minimal_config_file=${BATS_FILE_TMPDIR}/zot_minimal_config.json + local oci_data_dir=${BATS_FILE_TMPDIR}/oci - mkdir -p ${zot_root_dir} + mkdir -p ${zot_sync_per_root_dir} + mkdir -p ${zot_sync_ondemand_root_dir} mkdir -p ${zot_minimal_root_dir} mkdir -p ${oci_data_dir} - cat >${zot_config_file} <${zot_sync_per_config_file} <${zot_sync_ondemand_config_file} < config.json + echo "hello world" > artifact.txt + run oras push --plain-http 127.0.0.1:9000/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 + rm -f config.json +} + +@test "sync oras artifact periodically" { +# # wait for oras artifact to be copied + run sleep 5s + run oras pull --plain-http 127.0.0.1:8081/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 + [ "$status" -eq 0 ] + grep -q "hello world" artifact.txt + rm -f artifact.txt +} + +# sync helm chart +@test "push helm chart" { + run helm package ${BATS_FILE_TMPDIR}/helm-charts/charts/zot + [ "$status" -eq 0 ] + local chart_version=$(awk '/version/{printf $2}' ${BATS_FILE_TMPDIR}/helm-charts/charts/zot/Chart.yaml) + run helm push zot-${chart_version}.tgz oci://localhost:9000/zot-chart + [ "$status" -eq 0 ] +} + +@test "sync helm chart periodically" { + # wait for helm chart to be copied + run sleep 5s + + 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} + [ "$status" -eq 0 ] +} + +@test "sync helm chart on demand" { + 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} + [ "$status" -eq 0 ] +} + +# sync OCI artifacts +@test "push OCI artifact 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 <