mirror of
https://github.com/project-zot/zot.git
synced 2026-06-16 04:17:55 +08:00
fix: bats test refactoring (#1731)
Signed-off-by: Alexei Dodon <adodon@cisco.com>
This commit is contained in:
@@ -1,8 +1,31 @@
|
||||
load helpers_sync
|
||||
# Note: Intended to be run as "make test-bats-sync" or "make test-bats-sync-verbose"
|
||||
# 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 curl) ]; then
|
||||
echo "you need to install curl as a prerequisite to running the tests" >&3
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ ! $(command -v jq) ]; then
|
||||
echo "you need to install jq as a prerequisite to running the tests" >&3
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ ! $(command -v docker) ]; then
|
||||
echo "you need to install docker as a prerequisite to running the tests" >&3
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
function setup_file() {
|
||||
# Verify prerequisites are available
|
||||
if ! verify_prerequisites; then
|
||||
if ! $(verify_prerequisites); then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -14,7 +37,7 @@ function setup_file() {
|
||||
|
||||
cat >${zot_sync_ondemand_config_file} <<EOF
|
||||
{
|
||||
"distSpecVersion": "1.1.0",
|
||||
"distSpecVersion": "1.1.0-dev",
|
||||
"storage": {
|
||||
"rootDirectory": "${zot_root_dir}"
|
||||
},
|
||||
@@ -34,13 +57,13 @@ function setup_file() {
|
||||
"https://docker.io/library"
|
||||
],
|
||||
"content": [
|
||||
{
|
||||
"prefix": "registry"
|
||||
},
|
||||
{
|
||||
"prefix": "archlinux"
|
||||
}
|
||||
],
|
||||
"prefix": "registry"
|
||||
},
|
||||
{
|
||||
"prefix": "archlinux"
|
||||
}
|
||||
],
|
||||
"onDemand": true,
|
||||
"tlsVerify": true
|
||||
},
|
||||
@@ -49,16 +72,16 @@ function setup_file() {
|
||||
"https://registry.k8s.io"
|
||||
],
|
||||
"content": [
|
||||
{
|
||||
"prefix": "kube-apiserver"
|
||||
},
|
||||
{
|
||||
"prefix": "pause"
|
||||
},
|
||||
"prefix": "kube-apiserver"
|
||||
},
|
||||
{
|
||||
"prefix": "pause"
|
||||
},
|
||||
{
|
||||
"prefix": "kube-apiserver-amd64"
|
||||
}
|
||||
],
|
||||
],
|
||||
"onDemand": true,
|
||||
"tlsVerify": true
|
||||
},
|
||||
@@ -67,23 +90,22 @@ function setup_file() {
|
||||
"https://public.ecr.aws"
|
||||
],
|
||||
"content": [
|
||||
{
|
||||
"prefix": "amazonlinux/amazonlinux"
|
||||
}
|
||||
],
|
||||
{
|
||||
"prefix": "amazonlinux/amazonlinux"
|
||||
}
|
||||
],
|
||||
"onDemand": true,
|
||||
"tlsVerify": true
|
||||
},
|
||||
{
|
||||
"urls": [
|
||||
"https://gcr.io"
|
||||
|
||||
],
|
||||
"content": [
|
||||
{
|
||||
"prefix": "google-containers/kube-proxy-amd64"
|
||||
}
|
||||
],
|
||||
{
|
||||
"prefix": "google-containers/kube-proxy-amd64"
|
||||
}
|
||||
],
|
||||
"onDemand": true,
|
||||
"tlsVerify": true
|
||||
},
|
||||
@@ -92,10 +114,10 @@ function setup_file() {
|
||||
"https://mcr.microsoft.com"
|
||||
],
|
||||
"content": [
|
||||
{
|
||||
"prefix": "azure-cognitive-services/vision/spatial-analysis/diagnostics"
|
||||
}
|
||||
],
|
||||
{
|
||||
"prefix": "azure-cognitive-services/vision/spatial-analysis/diagnostics"
|
||||
}
|
||||
],
|
||||
"onDemand": true,
|
||||
"tlsVerify": true
|
||||
},
|
||||
@@ -141,15 +163,12 @@ function setup_file() {
|
||||
}
|
||||
EOF
|
||||
|
||||
setup_zot_file_level ${zot_sync_ondemand_config_file}
|
||||
wait_zot_reachable "http://127.0.0.1:8090/v2/_catalog"
|
||||
zot_serve ${ZOT_PATH} ${zot_sync_ondemand_config_file}
|
||||
wait_zot_reachable 8090
|
||||
}
|
||||
|
||||
function teardown_file() {
|
||||
local zot_root_dir=${BATS_FILE_TMPDIR}/zot
|
||||
|
||||
teardown_zot_file_level
|
||||
rm -rf ${zot_root_dir}
|
||||
zot_stop_all
|
||||
}
|
||||
|
||||
# sync image
|
||||
@@ -312,10 +331,10 @@ function teardown_file() {
|
||||
}
|
||||
|
||||
@test "run docker with image synced from docker.io/library" {
|
||||
local zot_root_dir=${BATS_FILE_TMPDIR}/zot
|
||||
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
|
||||
[ "$status" -eq 0 ]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user