mirror of
https://github.com/project-zot/zot.git
synced 2025-03-11 02:17:43 -05:00
test(blackbox): add multi-arch index creation and image attributes modification (#2306)
* test: add multi-arch index creation and image modification tests Signed-off-by: ossfellow <masoud@operatik.io> * chore: update regclient version to the latest Signed-off-by: ossfellow <masoud@operatik.io> --------- Signed-off-by: ossfellow <masoud@operatik.io>
This commit is contained in:
parent
2dd1fc9316
commit
dc0e41ad53
3 changed files with 112 additions and 3 deletions
2
Makefile
2
Makefile
|
@ -19,7 +19,7 @@ HELM := $(TOOLSDIR)/bin/helm
|
||||||
ORAS := $(TOOLSDIR)/bin/oras
|
ORAS := $(TOOLSDIR)/bin/oras
|
||||||
ORAS_VERSION := 1.0.0-rc.1
|
ORAS_VERSION := 1.0.0-rc.1
|
||||||
REGCLIENT := $(TOOLSDIR)/bin/regctl
|
REGCLIENT := $(TOOLSDIR)/bin/regctl
|
||||||
REGCLIENT_VERSION := v0.4.5
|
REGCLIENT_VERSION := v0.5.7
|
||||||
CRICTL := $(TOOLSDIR)/bin/crictl
|
CRICTL := $(TOOLSDIR)/bin/crictl
|
||||||
CRICTL_VERSION := v1.26.1
|
CRICTL_VERSION := v1.26.1
|
||||||
ACTION_VALIDATOR := $(TOOLSDIR)/bin/action-validator
|
ACTION_VALIDATOR := $(TOOLSDIR)/bin/action-validator
|
||||||
|
|
|
@ -8,8 +8,8 @@ BATS=${SCRIPTPATH}/../../hack/tools/bin/bats
|
||||||
PATH=$PATH:${SCRIPTPATH}/../../hack/tools/bin
|
PATH=$PATH:${SCRIPTPATH}/../../hack/tools/bin
|
||||||
|
|
||||||
tests=("pushpull" "pushpull_authn" "delete_images" "referrers" "metadata" "anonymous_policy"
|
tests=("pushpull" "pushpull_authn" "delete_images" "referrers" "metadata" "anonymous_policy"
|
||||||
"annotations" "detect_manifest_collision" "cve" "sync" "sync_docker" "sync_replica_cluster"
|
"annotations" "detect_manifest_collision" "cve" "sync" "sync_docker" "sync_replica_cluster"
|
||||||
"scrub" "garbage_collect" "metrics" "metrics_minimal")
|
"scrub" "garbage_collect" "metrics" "metrics_minimal" "multiarch_index")
|
||||||
|
|
||||||
for test in ${tests[*]}; do
|
for test in ${tests[*]}; do
|
||||||
${BATS} ${BATS_FLAGS} ${SCRIPTPATH}/${test}.bats > ${test}.log & pids+=($!)
|
${BATS} ${BATS_FLAGS} ${SCRIPTPATH}/${test}.bats > ${test}.log & pids+=($!)
|
||||||
|
|
109
test/blackbox/multiarch_index.bats
Normal file
109
test/blackbox/multiarch_index.bats
Normal file
|
@ -0,0 +1,109 @@
|
||||||
|
# Note: Intended to be run as "make run-blackbox-tests" or "make run-blackbox-ci"
|
||||||
|
# Makefile target installs & checks all necessary tooling
|
||||||
|
# Extra tools that are not covered in Makefile target needs to be added in verify_prerequisites()
|
||||||
|
|
||||||
|
load helpers_zot
|
||||||
|
|
||||||
|
function verify_prerequisites {
|
||||||
|
if [ ! $(command -v regctl) ]; then
|
||||||
|
echo "you need to install regctl as a prerequisite to running the tests" >&3
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
function setup_file() {
|
||||||
|
# Verify prerequisites are available
|
||||||
|
if ! $(verify_prerequisites); then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
# Setup zot server
|
||||||
|
local zot_root_dir=${BATS_FILE_TMPDIR}/zot
|
||||||
|
local zot_config_file=${BATS_FILE_TMPDIR}/zot_config.json
|
||||||
|
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}<<EOF
|
||||||
|
{
|
||||||
|
"distSpecVersion": "1.1.0",
|
||||||
|
"storage": {
|
||||||
|
"rootDirectory": "${zot_root_dir}"
|
||||||
|
},
|
||||||
|
"http": {
|
||||||
|
"address": "0.0.0.0",
|
||||||
|
"port": "${zot_port}"
|
||||||
|
},
|
||||||
|
"log": {
|
||||||
|
"level": "debug",
|
||||||
|
"output": "${BATS_FILE_TMPDIR}/zot.log"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
zot_serve ${ZOT_PATH} ${zot_config_file}
|
||||||
|
wait_zot_reachable ${zot_port}
|
||||||
|
}
|
||||||
|
|
||||||
|
function teardown() {
|
||||||
|
# conditionally printing on failure is possible from teardown but not from from teardown_file
|
||||||
|
cat ${BATS_FILE_TMPDIR}/zot.log
|
||||||
|
}
|
||||||
|
|
||||||
|
function teardown_file() {
|
||||||
|
zot_stop_all
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "push linux/amd64 image" {
|
||||||
|
zot_port=`cat ${BATS_FILE_TMPDIR}/zot.port`
|
||||||
|
run regctl registry set localhost:${zot_port} --tls disabled
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
echo "Pushing ghcr.io/project-zot/zot-minimal:latest image to local zot registry, for linux/amd64 platform"
|
||||||
|
run regctl image copy \
|
||||||
|
ghcr.io/project-zot/zot-minimal:latest \
|
||||||
|
localhost:${zot_port}/test-index/zot-minimal-amd64:latest \
|
||||||
|
--platform=linux/amd64
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "push linux/arm64 image" {
|
||||||
|
zot_port=`cat ${BATS_FILE_TMPDIR}/zot.port`
|
||||||
|
echo "Pushing ghcr.io/project-zot/zot-minimal:latest image to local zot registry, for linux/arm64 platform"
|
||||||
|
run regctl image copy \
|
||||||
|
ghcr.io/project-zot/zot-minimal:latest \
|
||||||
|
localhost:${zot_port}/test-index/zot-minimal-arm64:latest \
|
||||||
|
--platform=linux/arm64
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "create multi-arch index" {
|
||||||
|
zot_port=`cat ${BATS_FILE_TMPDIR}/zot.port`
|
||||||
|
echo "Creating the multi-arch zot-minimal:latest index using linux/amd64 and linux/arm64 images, in local zot registry"
|
||||||
|
run regctl index create \
|
||||||
|
localhost:${zot_port}/test-index/zot-minimal:latest \
|
||||||
|
--ref=localhost:${zot_port}/test-index/zot-minimal-amd64:latest \
|
||||||
|
--ref=localhost:${zot_port}/test-index/zot-minimal-arm64:latest \
|
||||||
|
--digest-tags --referrers
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "modify multi-arch image" {
|
||||||
|
zot_port=`cat ${BATS_FILE_TMPDIR}/zot.port`
|
||||||
|
echo "Modifying the multi-arch zot-minimal:latest image attributes in local zot registry (suitable for Docker to OCI format conversion, or better conformance, scenarios)"
|
||||||
|
run regctl image mod \
|
||||||
|
localhost:${zot_port}/test-index/zot-minimal:latest \
|
||||||
|
--replace \
|
||||||
|
--to-oci \
|
||||||
|
--to-oci-referrers \
|
||||||
|
--label-to-annotation \
|
||||||
|
--annotation="[*]org.opencontainers.image.title=zot-minimal" \
|
||||||
|
--annotation="[*]org.opencontainers.image.description=Zot OCI registry" \
|
||||||
|
--annotation="[*]org.opencontainers.image.authors=authors@zotregistry.dev" \
|
||||||
|
--annotation="[*]org.opencontainers.image.licenses=Apache-2.0" \
|
||||||
|
--annotation="[*]org.opencontainers.image.url=localhost:${zot_port}/test-index/zot-minimal:latest" \
|
||||||
|
--annotation="[*]org.opencontainers.image.source=https://github.com/project-zot/zot" \
|
||||||
|
--annotation="[*]org.opencontainers.image.version=latest" \
|
||||||
|
--annotation="[*]org.opencontainers.image.created=$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue