mirror of
https://github.com/project-zot/zot.git
synced 2026-06-15 20:07:55 +08:00
Manage builds with different combinations of extensions
Files were added to be built whether an extension is on or off. New build tags were added for each extension, while minimal and extended disappeared. added custom binary naming depending on extensions used and changed references from binary to binary-extended added automated blackbox tests for sync, search, scrub, metrics added contributor guidelines Signed-off-by: Alex Stan <alexandrustan96@yahoo.ro>
This commit is contained in:
committed by
Ramkumar Chinchani
parent
616d5f8a6d
commit
ada21ed842
@@ -0,0 +1,68 @@
|
||||
load helpers_cve
|
||||
|
||||
function setup_file() {
|
||||
|
||||
# Verify prerequisites are available
|
||||
if ! verify_prerequisites; then
|
||||
exit 1
|
||||
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
|
||||
# Setup zot server
|
||||
local zot_root_dir=${BATS_FILE_TMPDIR}/zot
|
||||
local zot_config_file=${BATS_FILE_TMPDIR}/zot_config.json
|
||||
mkdir -p ${zot_root_dir}
|
||||
cat >${zot_config_file} <<EOF
|
||||
{
|
||||
"distSpecVersion": "1.0.1",
|
||||
"storage": {
|
||||
"rootDirectory": "${zot_root_dir}"
|
||||
},
|
||||
"http": {
|
||||
"address": "0.0.0.0",
|
||||
"port": "8080",
|
||||
"ReadOnly": false
|
||||
},
|
||||
"log": {
|
||||
"level": "debug"
|
||||
},
|
||||
"extensions": {
|
||||
"search": {
|
||||
"enable": true,
|
||||
"cve": {
|
||||
"updateInterval": "24h"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
setup_zot_file_level ${zot_config_file}
|
||||
wait_zot_reachable "http://127.0.0.1:8080/v2/_catalog"
|
||||
|
||||
# setup zli to add zot registry to configs
|
||||
local registry_name=main
|
||||
local registry_url="http://127.0.0.1:8080/"
|
||||
zli_add_config ${registry_name} ${registry_url}
|
||||
}
|
||||
|
||||
function teardown_file() {
|
||||
local zot_root_dir=${BATS_FILE_TMPDIR}/zot
|
||||
teardown_zot_file_level
|
||||
rm -rf ${zot_root_dir}
|
||||
}
|
||||
|
||||
@test "cve by image name and tag" {
|
||||
run skopeo --insecure-policy copy --dest-tls-verify=false \
|
||||
oci:${TEST_DATA_DIR}/golang:1.17 \
|
||||
docker://127.0.0.1:8080/golang:1.17
|
||||
[ "$status" -eq 0 ]
|
||||
run curl http://127.0.0.1:8080/v2/_catalog
|
||||
[ "$status" -eq 0 ]
|
||||
[ $(echo "${lines[-1]}" | jq '.repositories[]') = '"golang"' ]
|
||||
run curl http://127.0.0.1:8080/v2/golang/tags/list
|
||||
[ "$status" -eq 0 ]
|
||||
[ $(echo "${lines[-1]}" | jq '.tags[]') = '"1.17"' ]
|
||||
run ${ZLI_PATH} cve ${REGISTRY_NAME} -I golang:1.17
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
ROOT_DIR=$(git rev-parse --show-toplevel)
|
||||
TEST_DATA_DIR=${ROOT_DIR}/test/data/
|
||||
OS="${OS:-linux}"
|
||||
ARCH="${ARCH:-amd64}"
|
||||
ZOT_PATH=${ROOT_DIR}/bin/zot-${OS}-${ARCH}
|
||||
ZLI_PATH=${ROOT_DIR}/bin/zli-${OS}-${ARCH}
|
||||
REGISTRY_NAME=main
|
||||
|
||||
function verify_prerequisites {
|
||||
if [ ! -f ${BATS_RUN_TMPDIR}/.firstrun ]; then
|
||||
env | grep proxy >&3
|
||||
touch ${BATS_RUN_TMPDIR}/.firstrun
|
||||
fi
|
||||
|
||||
if [ ! -f ${ZOT_PATH} ]; then
|
||||
echo "you need to build ${ZOT_PATH} before running the tests" >&3
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ ! -f ${ZLI_PATH} ]; then
|
||||
echo "you need to build ${ZLI} before running tests" >&3
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ ! command -v curl ] &>/dev/null; then
|
||||
echo "you need to install curl as a prerequisite to running the tests" >&3
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ ! command -v jq ] &>/dev/null; then
|
||||
echo "you need to install jq as a prerequisite to running the tests" >&3
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ ! command -v skopeo ] &>/dev/null; then
|
||||
echo "you need to install skopeo as a prerequisite to running the tests" >&3
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
function zot_serve() {
|
||||
local zot_path=${1}
|
||||
local config_file=${2}
|
||||
local pid_dir=${3}
|
||||
${zot_path} serve ${config_file} &
|
||||
echo $! >>${pid_dir}/zot.pid
|
||||
}
|
||||
|
||||
function zot_stop() {
|
||||
local pid_dir=${1}
|
||||
cat ${pid_dir}/zot.pid
|
||||
kill $(cat ${pid_dir}/zot.pid)
|
||||
rm ${pid_dir}/zot.pid
|
||||
}
|
||||
|
||||
function setup_zot_file_level() {
|
||||
local config_file=${1}
|
||||
zot_serve ${ZOT_PATH} ${config_file} ${BATS_FILE_TMPDIR}
|
||||
}
|
||||
|
||||
function teardown_zot_file_level() {
|
||||
zot_stop ${BATS_FILE_TMPDIR}
|
||||
}
|
||||
|
||||
function wait_zot_reachable() {
|
||||
zot_url=${1}
|
||||
curl --connect-timeout 3 \
|
||||
--max-time 3 \
|
||||
--retry 10 \
|
||||
--retry-delay 0 \
|
||||
--retry-max-time 60 \
|
||||
--retry-connrefused \
|
||||
${zot_url}
|
||||
}
|
||||
|
||||
function zli_add_config() {
|
||||
local registry_name=${1}
|
||||
local registry_url=${2}
|
||||
if ! ${ZLI_PATH} config --list | grep -q main; then
|
||||
${ZLI_PATH} config add ${registry_name} ${registry_url}
|
||||
fi
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
ROOT_DIR=$(git rev-parse --show-toplevel)
|
||||
TEST_DATA_DIR=${ROOT_DIR}/test/data/
|
||||
OS="${OS:-linux}"
|
||||
ARCH="${ARCH:-amd64}"
|
||||
ZOT_PATH=${ROOT_DIR}/bin/zot-${OS}-${ARCH}
|
||||
|
||||
function verify_prerequisites() {
|
||||
if [ ! -f ${BATS_RUN_TMPDIR}/.firstrun ]; then
|
||||
env | grep proxy >&3
|
||||
touch ${BATS_RUN_TMPDIR}/.firstrun
|
||||
fi
|
||||
|
||||
if [ ! command -v curl ] &>/dev/null; then
|
||||
echo "you need to install curl as a prerequisite to running the tests" >&3
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ ! command -v jq ] &>/dev/null; then
|
||||
echo "you need to install jq as a prerequisite to running the tests" >&3
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ ! command -v skopeo ] &>/dev/null; then
|
||||
echo "you need to install skopeo as a prerequisite to running the tests" >&3
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
function zot_serve() {
|
||||
local zot_path=${1}
|
||||
local config_file=${2}
|
||||
local pid_dir=${3}
|
||||
${zot_path} serve ${config_file} &
|
||||
echo $! >>${pid_dir}/zot.pid
|
||||
}
|
||||
|
||||
function zot_stop() {
|
||||
local pid_dir=${1}
|
||||
cat ${pid_dir}/zot.pid
|
||||
kill $(cat ${pid_dir}/zot.pid)
|
||||
rm ${pid_dir}/zot.pid
|
||||
}
|
||||
|
||||
function setup_zot_file_level() {
|
||||
local config_file=${1}
|
||||
zot_serve ${ZOT_PATH} ${config_file} ${BATS_FILE_TMPDIR}
|
||||
}
|
||||
|
||||
function teardown_zot_file_level() {
|
||||
zot_stop ${BATS_FILE_TMPDIR}
|
||||
}
|
||||
|
||||
function wait_zot_reachable() {
|
||||
zot_url=${1}
|
||||
curl --connect-timeout 3 \
|
||||
--max-time 3 \
|
||||
--retry 10 \
|
||||
--retry-delay 0 \
|
||||
--retry-max-time 60 \
|
||||
--retry-connrefused \
|
||||
${zot_url}
|
||||
}
|
||||
@@ -22,17 +22,17 @@ function verify_prerequisites {
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ ! command -v jq &> /dev/null ]; then
|
||||
if [ ! command -v jq ] &>/dev/null; then
|
||||
echo "you need to install jq as a prerequisite to running the tests" >&3
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ ! command -v skopeo &> /dev/null ]; then
|
||||
if [ ! command -v skopeo ] &>/dev/null; then
|
||||
echo "you need to install skopeo as a prerequisite to running the tests" >&3
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ ! command -v oras &> /dev/null ]; then
|
||||
if [ ! command -v oras ] &>/dev/null; then
|
||||
echo "you need to install oras as a prerequisite to running the tests" >&3
|
||||
return 1
|
||||
fi
|
||||
@@ -0,0 +1,99 @@
|
||||
ROOT_DIR=$(git rev-parse --show-toplevel)
|
||||
TEST_DATA_DIR=${ROOT_DIR}/test/data/
|
||||
OS="${OS:-linux}"
|
||||
ARCH="${ARCH:-amd64}"
|
||||
ZOT_PATH=${ROOT_DIR}/bin/zot-${OS}-${ARCH}
|
||||
ZOT_ROOT_DIR=?
|
||||
ZOT_LOG_FILE=?
|
||||
ZOT_CONFIG_FILE=
|
||||
|
||||
function verify_prerequisites() {
|
||||
if [ ! -f ${BATS_RUN_TMPDIR}/.firstrun ]; then
|
||||
env | grep proxy >&3
|
||||
touch ${BATS_RUN_TMPDIR}/.firstrun
|
||||
fi
|
||||
|
||||
if [ ! -f ${ZOT_PATH} ]; then
|
||||
echo "you need to build ${ZOT_PATH} before running tests" >&3
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ ! command -v curl ] &>/dev/null; then
|
||||
echo "you need to install curl as a prerequisite to running the tests" >&3
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ ! command -v jq ] &>/dev/null; then
|
||||
echo "you need to install jq as a prerequisite to running the tests" >&3
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ ! command -v skopeo ] &>/dev/null; then
|
||||
echo "you need to install skopeo as a prerequisite to running the tests" >&3
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
function zot_serve() {
|
||||
local zot_path=${1}
|
||||
local config_file=${2}
|
||||
local pid_dir=${3}
|
||||
${zot_path} serve ${config_file} &
|
||||
echo $! >>${pid_dir}/zot.pid
|
||||
}
|
||||
|
||||
function zot_stop() {
|
||||
local pid_dir=${1}
|
||||
cat ${pid_dir}/zot.pid
|
||||
kill $(cat ${pid_dir}/zot.pid)
|
||||
rm ${pid_dir}/zot.pid
|
||||
}
|
||||
|
||||
function setup_zot_file_level() {
|
||||
local config_file=${1}
|
||||
zot_serve ${ZOT_PATH} ${config_file} ${BATS_FILE_TMPDIR}
|
||||
}
|
||||
|
||||
function teardown_zot_file_level() {
|
||||
zot_stop ${BATS_FILE_TMPDIR}
|
||||
}
|
||||
|
||||
function wait_zot_reachable() {
|
||||
zot_url=${1}
|
||||
curl --connect-timeout 3 \
|
||||
--max-time 3 \
|
||||
--retry 10 \
|
||||
--retry-delay 0 \
|
||||
--retry-max-time 60 \
|
||||
--retry-connrefused \
|
||||
${zot_url}
|
||||
}
|
||||
|
||||
function add_test_files() {
|
||||
local zot_root_dir=${BATS_FILE_TMPDIR}/zot
|
||||
echo ${zot_root_dir}
|
||||
cp -r ${TEST_DATA_DIR}golang ${zot_root_dir}
|
||||
ls -al ${zot_root_dir}/golang
|
||||
}
|
||||
|
||||
function delete_blob() {
|
||||
local zot_test_files=${BATS_FILE_TMPDIR}/zot/golang
|
||||
find ${zot_test_files}/blobs/sha256 -maxdepth 1 -type f -name "*" -print0 |
|
||||
sort -z -R |
|
||||
head -z -n 1 | xargs -0 rm
|
||||
ls -al ${zot_test_files}/blobs/sha256/
|
||||
}
|
||||
|
||||
function log_output() {
|
||||
local zot_log_file=${BATS_FILE_TMPDIR}/zot/zot-log.json
|
||||
cat ${zot_log_file} | jq ' .["message"] '
|
||||
}
|
||||
|
||||
function affected() {
|
||||
log_output | jq 'contains("blobs/manifest affected")?' | grep true
|
||||
}
|
||||
|
||||
function not_affected() {
|
||||
log_output | jq 'contains("blobs/manifest ok")?' | grep true
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
ROOT_DIR=$(git rev-parse --show-toplevel)
|
||||
TEST_DATA_DIR=${ROOT_DIR}/test/data/
|
||||
OS="${OS:-linux}"
|
||||
ARCH="${ARCH:-amd64}"
|
||||
ZOT_PATH=${ROOT_DIR}/bin/zot-${OS}-${ARCH}
|
||||
ZOT_MINIMAL_PATH=${ROOT_DIR}/bin/zot-${OS}-${ARCH}-minimal
|
||||
|
||||
mkdir -p ${TEST_DATA_DIR}
|
||||
|
||||
function verify_prerequisites {
|
||||
if [ ! -f ${BATS_RUN_TMPDIR}/.firstrun ]; then
|
||||
env | grep proxy >&3
|
||||
touch ${BATS_RUN_TMPDIR}/.firstrun
|
||||
fi
|
||||
|
||||
if [ ! -f ${ZOT_PATH} ]; then
|
||||
echo "you need to build ${ZOT_PATH} before running the tests" >&3
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ ! -f ${ZOT_MINIMAL_PATH} ]; then
|
||||
echo "you need to build ${ZOT_MINIMAL_PATH} before running tests" >&3
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ ! command -v curl ] &>/dev/null; then
|
||||
echo "you need to install curl as a prerequisite to running the tests" >&3
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ ! command -v jq ] &>/dev/null; then
|
||||
echo "you need to install jq as a prerequisite to running the tests" >&3
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ ! command -v skopeo ] &>/dev/null; then
|
||||
echo "you need to install skopeo as a prerequisite to running the tests" >&3
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
function zot_serve() {
|
||||
local zot_path=${1}
|
||||
local config_file=${2}
|
||||
local pid_dir=${3}
|
||||
${zot_path} serve ${config_file} &
|
||||
echo $! >>${pid_dir}/zot.pid
|
||||
}
|
||||
|
||||
function zot_stop() {
|
||||
local pid_dir=${1}
|
||||
cat ${pid_dir}/zot.pid
|
||||
kill $(cat ${pid_dir}/zot.pid)
|
||||
rm ${pid_dir}/zot.pid
|
||||
}
|
||||
|
||||
function zot_minimal_stop() {
|
||||
local pid_dir=${1}
|
||||
kill $(cat ${pid_dir}/zot-minimal.pid)
|
||||
rm ${pid_dir}/zot-minimal.pid
|
||||
}
|
||||
|
||||
function setup_zot_file_level() {
|
||||
local config_file=${1}
|
||||
zot_serve ${ZOT_PATH} ${config_file} ${BATS_FILE_TMPDIR}
|
||||
}
|
||||
|
||||
function setup_zot_minimal_file_level() {
|
||||
local config_file=${1}
|
||||
zot_serve ${ZOT_MINIMAL_PATH} ${config_file} ${BATS_FILE_TMPDIR}
|
||||
}
|
||||
|
||||
function teardown_zot_file_level() {
|
||||
zot_stop ${BATS_FILE_TMPDIR}
|
||||
}
|
||||
|
||||
function wait_zot_reachable() {
|
||||
zot_url=${1}
|
||||
curl --connect-timeout 3 \
|
||||
--max-time 3 \
|
||||
--retry 10 \
|
||||
--retry-delay 0 \
|
||||
--retry-max-time 60 \
|
||||
--retry-connrefused \
|
||||
${zot_url}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
load helpers_metrics
|
||||
|
||||
function setup_file() {
|
||||
# verify prerequisites are available
|
||||
if ! verify_prerequisites; then
|
||||
echo "oh noooooo"
|
||||
exit 1
|
||||
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
|
||||
|
||||
# Setup zot server
|
||||
zot_root_dir=${BATS_FILE_TMPDIR}/zot
|
||||
echo ${zot_root_dir}
|
||||
zot_log_file=${zot_root_dir}/zot-log.json
|
||||
zot_config_file=${BATS_FILE_TMPDIR}/zot_config.json
|
||||
mkdir -p ${zot_root_dir}
|
||||
touch ${zot_log_file}
|
||||
cat >${zot_config_file} <<EOF
|
||||
{
|
||||
"distSpecVersion": "1.0.1",
|
||||
"storage": {
|
||||
"rootDirectory": "${zot_root_dir}"
|
||||
},
|
||||
"http": {
|
||||
"address": "0.0.0.0",
|
||||
"port": "8080",
|
||||
"ReadOnly": false
|
||||
},
|
||||
"log": {
|
||||
"level": "debug",
|
||||
"output": "${zot_log_file}"
|
||||
},
|
||||
"extensions": {
|
||||
"metrics": {
|
||||
"enable": true,
|
||||
"prometheus": {
|
||||
"path": "/metrics"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
setup_zot_file_level ${zot_config_file}
|
||||
wait_zot_reachable "http://127.0.0.1:8080/v2/_catalog"
|
||||
|
||||
}
|
||||
|
||||
function teardown_file() {
|
||||
local zot_root_dir=${BATS_FILE_TMPDIR}/zot
|
||||
teardown_zot_file_level
|
||||
rm -rf ${zot_root_dir}
|
||||
}
|
||||
|
||||
@test "metric enabled" {
|
||||
local servername="http://127.0.0.1:8080/metrics"
|
||||
status_code=$(curl --write-out '%{http_code}' --silent --output /dev/null ${servername})
|
||||
[ "$status_code" -eq 200 ]
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
load helpers
|
||||
load helpers_pushpull
|
||||
|
||||
function setup_file() {
|
||||
# Verify prerequisites are available
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
load helpers_scrub
|
||||
|
||||
function setup_file(){
|
||||
skopeo --insecure-policy copy --format=oci docker://ghcr.io/project-zot/golang:1.17 oci:${TEST_DATA_DIR}/golang:1.17
|
||||
}
|
||||
|
||||
function setup() {
|
||||
|
||||
# verify prerequisites are available
|
||||
if ! verify_prerequisites; then
|
||||
echo "oh noooooo"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Setup zot server
|
||||
ZOT_ROOT_DIR=${BATS_FILE_TMPDIR}/zot
|
||||
echo ${ZOT_ROOT_DIR}
|
||||
ZOT_LOG_FILE=${ZOT_ROOT_DIR}/zot-log.json
|
||||
ZOT_CONFIG_FILE=${BATS_FILE_TMPDIR}/zot_config.json
|
||||
mkdir -p ${ZOT_ROOT_DIR}
|
||||
touch ${ZOT_LOG_FILE}
|
||||
cat >${ZOT_CONFIG_FILE} <<EOF
|
||||
{
|
||||
"distSpecVersion": "1.0.1",
|
||||
"storage": {
|
||||
"rootDirectory": "${ZOT_ROOT_DIR}"
|
||||
},
|
||||
"http": {
|
||||
"address": "0.0.0.0",
|
||||
"port": "8080",
|
||||
"ReadOnly": false
|
||||
},
|
||||
"log": {
|
||||
"level": "debug",
|
||||
"output": "${ZOT_LOG_FILE}"
|
||||
},
|
||||
"extensions": {
|
||||
"scrub": {
|
||||
"interval": "2h"
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
}
|
||||
|
||||
function teardown() {
|
||||
local zot_root_dir=${BATS_FILE_TMPDIR}/zot
|
||||
teardown_zot_file_level
|
||||
rm -rf ${zot_root_dir}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@test "blobs/manifest integrity not affected" {
|
||||
|
||||
add_test_files
|
||||
echo ${ZOT_CONFIG_FILE}
|
||||
setup_zot_file_level ${ZOT_CONFIG_FILE}
|
||||
wait_zot_reachable "http://127.0.0.1:8080/v2/_catalog"
|
||||
|
||||
# wait for scrub to be done and logs to get populated
|
||||
run sleep 5s
|
||||
run not_affected
|
||||
[ "$status" -eq 0 ]
|
||||
[ $(echo "${lines[0]}" ) = 'true' ]
|
||||
}
|
||||
|
||||
@test "blobs/manifest integrity affected" {
|
||||
|
||||
add_test_files
|
||||
delete_blob
|
||||
echo ${ZOT_CONFIG_FILE}
|
||||
setup_zot_file_level ${ZOT_CONFIG_FILE}
|
||||
wait_zot_reachable "http://127.0.0.1:8080/v2/_catalog"
|
||||
|
||||
# wait for scrub to be done and logs to get populated
|
||||
run sleep 5s
|
||||
run affected
|
||||
[ "$status" -eq 0 ]
|
||||
[ $(echo "${lines[0]}" ) = 'true' ]
|
||||
# [ $(echo "${lines[-1]}" | jq .) ]
|
||||
}
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
load helpers_sync
|
||||
|
||||
function setup_file() {
|
||||
# Verify prerequisites are available
|
||||
if ! verify_prerequisites; then
|
||||
exit 1
|
||||
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
|
||||
# Setup zot server
|
||||
local zot_root_dir=${BATS_FILE_TMPDIR}/zot
|
||||
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_minimal_root_dir}
|
||||
mkdir -p ${oci_data_dir}
|
||||
cat >${zot_config_file} <<EOF
|
||||
{
|
||||
"distSpecVersion": "1.0.1",
|
||||
"storage": {
|
||||
"rootDirectory": "${zot_root_dir}"
|
||||
},
|
||||
"http": {
|
||||
"address": "0.0.0.0",
|
||||
"port": "8080",
|
||||
"ReadOnly": false
|
||||
},
|
||||
"log": {
|
||||
"level": "debug"
|
||||
},
|
||||
"extensions": {
|
||||
"sync": {
|
||||
"registries": [
|
||||
{
|
||||
"urls": [
|
||||
"http://localhost:9000"
|
||||
],
|
||||
"onDemand": true,
|
||||
"tlsVerify": false,
|
||||
"PollInterval": "30s",
|
||||
"content": [
|
||||
{
|
||||
"prefix": "**"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
cat >${zot_minimal_config_file} <<EOF
|
||||
{
|
||||
"distSpecVersion": "1.0.1",
|
||||
"storage": {
|
||||
"rootDirectory": "${zot_minimal_root_dir}"
|
||||
},
|
||||
"http": {
|
||||
"address": "0.0.0.0",
|
||||
"port": "9000",
|
||||
"ReadOnly": false
|
||||
},
|
||||
"log": {
|
||||
"level": "debug"
|
||||
}
|
||||
}
|
||||
EOF
|
||||
setup_zot_file_level ${zot_config_file}
|
||||
wait_zot_reachable "http://127.0.0.1:8080/v2/_catalog"
|
||||
|
||||
setup_zot_minimal_file_level ${zot_minimal_config_file}
|
||||
wait_zot_reachable "http://127.0.0.1:9000/v2/_catalog"
|
||||
}
|
||||
|
||||
function teardown_file() {
|
||||
local zot_root_dir=${BATS_FILE_TMPDIR}/zot
|
||||
local oci_data_dir=${BATS_FILE_TMPDIR}/oci
|
||||
local zot_minimal_root_dir=${BATS_FILE_TMPDIR}/zot-minimal
|
||||
teardown_zot_file_level
|
||||
rm -rf ${zot_root_dir}
|
||||
rm -rf ${zot_minimal_root_dir}
|
||||
rm -rf ${oci_data_dir}
|
||||
}
|
||||
|
||||
@test "sync registry" {
|
||||
run skopeo --insecure-policy copy --dest-tls-verify=false \
|
||||
oci:${TEST_DATA_DIR}/golang:1.17 \
|
||||
docker://127.0.0.1:9000/golang:1.17
|
||||
[ "$status" -eq 0 ]
|
||||
run curl http://127.0.0.1:9000/v2/_catalog
|
||||
[ "$status" -eq 0 ]
|
||||
[ $(echo "${lines[-1]}" | jq '.repositories[]') = '"golang"' ]
|
||||
run curl http://127.0.0.1:8080/v2/_catalog
|
||||
run curl http://127.0.0.1:9000/v2/golang/tags/list
|
||||
[ "$status" -eq 0 ]
|
||||
[ $(echo "${lines[-1]}" | jq '.tags[]') = '"1.17"' ]
|
||||
run sleep 30s
|
||||
run curl http://127.0.0.1:8080/v2/_catalog
|
||||
[ "$status" -eq 0 ]
|
||||
[ $(echo "${lines[-1]}" | jq '.repositories[]') = '"golang"' ]
|
||||
}
|
||||
Reference in New Issue
Block a user