2022-12-16 12:33:46 -05:00
|
|
|
load helpers_sync
|
|
|
|
|
|
|
|
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_sync_ondemand_config_file=${BATS_FILE_TMPDIR}/zot_sync_ondemand_config.json
|
|
|
|
|
|
|
|
mkdir -p ${zot_root_dir}
|
|
|
|
|
|
|
|
cat >${zot_sync_ondemand_config_file} <<EOF
|
|
|
|
{
|
2023-01-31 12:35:33 -05:00
|
|
|
"distSpecVersion": "1.1.0",
|
2022-12-16 12:33:46 -05:00
|
|
|
"storage": {
|
|
|
|
"rootDirectory": "${zot_root_dir}"
|
|
|
|
},
|
|
|
|
"http": {
|
|
|
|
"address": "0.0.0.0",
|
|
|
|
"port": "8090"
|
|
|
|
},
|
|
|
|
"log": {
|
|
|
|
"level": "debug"
|
|
|
|
},
|
|
|
|
"extensions": {
|
|
|
|
"sync": {
|
|
|
|
"registries": [
|
|
|
|
{
|
|
|
|
"urls": [
|
|
|
|
"https://docker.io/library"
|
|
|
|
],
|
|
|
|
"onDemand": true,
|
|
|
|
"tlsVerify": true
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
|
|
|
setup_zot_file_level ${zot_sync_ondemand_config_file}
|
|
|
|
wait_zot_reachable "http://127.0.0.1:8090/v2/_catalog"
|
|
|
|
}
|
|
|
|
|
|
|
|
function teardown_file() {
|
|
|
|
local zot_root_dir=${BATS_FILE_TMPDIR}/zot
|
|
|
|
|
|
|
|
teardown_zot_file_level
|
|
|
|
rm -rf ${zot_root_dir}
|
|
|
|
}
|
|
|
|
|
|
|
|
# sync image
|
2022-12-22 12:23:49 -05:00
|
|
|
@test "sync docker image list on demand" {
|
|
|
|
run skopeo --insecure-policy copy --multi-arch=all --src-tls-verify=false \
|
2022-12-16 12:33:46 -05:00
|
|
|
docker://127.0.0.1:8090/registry \
|
|
|
|
oci:${TEST_DATA_DIR}
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
|
|
|
run curl http://127.0.0.1:8090/v2/_catalog
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ $(echo "${lines[-1]}" | jq '.repositories[]') = '"registry"' ]
|
|
|
|
run curl http://127.0.0.1:8090/v2/registry/tags/list
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ $(echo "${lines[-1]}" | jq '.tags[]') = '"latest"' ]
|
|
|
|
}
|
2022-12-22 12:23:49 -05:00
|
|
|
|
|
|
|
@test "sync docker image on demand" {
|
|
|
|
run skopeo --insecure-policy copy --src-tls-verify=false \
|
|
|
|
docker://127.0.0.1:8090/archlinux \
|
|
|
|
oci:${TEST_DATA_DIR}
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
|
|
|
run curl http://127.0.0.1:8090/v2/_catalog
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ $(echo "${lines[-1]}" | jq '.repositories[0]') = '"archlinux"' ]
|
|
|
|
run curl http://127.0.0.1:8090/v2/registry/tags/list
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ $(echo "${lines[-1]}" | jq '.tags[]') = '"latest"' ]
|
|
|
|
}
|