Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sync): added tests for sync on demand with the most used upstrea… #1414

Merged
merged 1 commit into from
May 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 128 additions & 1 deletion test/blackbox/sync_docker.bats
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ function setup_file() {
"registries": [
{
"urls": [
"https://docker.io/library"
"https://docker.io/library",
andaaron marked this conversation as resolved.
Show resolved Hide resolved
"https://registry.k8s.io",
"https://aws.amazon.com/ecr",
"https://gcr.io",
"https://mcr.microsoft.com"
],
"onDemand": true,
"tlsVerify": true
Expand Down Expand Up @@ -80,3 +84,126 @@ function teardown_file() {
[ "$status" -eq 0 ]
[ $(echo "${lines[-1]}" | jq '.tags[]') = '"latest"' ]
}

@test "sync image on demand from registry.k8s.io" {
run skopeo copy docker://127.0.0.1:8090/kube-apiserver-amd64:v1.10.0 oci:${TEST_DATA_DIR} --src-tls-verify=false
[ "$status" -eq 0 ]

run curl http://127.0.0.1:8090/v2/_catalog
[ "$status" -eq 0 ]
[ $(echo "${lines[-1]}"| jq '.repositories | map(select(. == "kube-apiserver-amd64"))' | jq '.[]') = '"kube-apiserver-amd64"' ]
run curl http://127.0.0.1:8090/v2/kube-apiserver-amd64/tags/list
[ "$status" -eq 0 ]
[ $(echo "${lines[-1]}" | jq '.tags[]') = '"v1.10.0"' ]
}

@test "sync image on demand from aws.amazon.com/ecr" {
run skopeo copy docker://127.0.0.1:8090/amazonlinux:latest oci:${TEST_DATA_DIR} --src-tls-verify=false
[ "$status" -eq 0 ]

run curl http://127.0.0.1:8090/v2/_catalog
[ "$status" -eq 0 ]
[ $(echo "${lines[-1]}"| jq '.repositories | map(select(. == "amazonlinux"))' | jq '.[]') = '"amazonlinux"' ]
run curl http://127.0.0.1:8090/v2/amazonlinux/tags/list
[ "$status" -eq 0 ]
[ $(echo "${lines[-1]}" | jq '.tags[]') = '"latest"' ]
}

@test "sync image on demand from gcr.io" {
run skopeo copy docker://127.0.0.1:8090/google-containers/kube-proxy-amd64:v1.17.9 oci:${TEST_DATA_DIR} --src-tls-verify=false
[ "$status" -eq 0 ]

run curl http://127.0.0.1:8090/v2/_catalog
[ "$status" -eq 0 ]
[ $(echo "${lines[-1]}"| jq '.repositories | map(select(. == "google-containers/kube-proxy-amd64"))' | jq '.[]') = '"google-containers/kube-proxy-amd64"' ]
run curl http://127.0.0.1:8090/v2/google-containers/kube-proxy-amd64/tags/list
[ "$status" -eq 0 ]
[ $(echo "${lines[-1]}" | jq '.tags[]') = '"v1.17.9"' ]
}

@test "sync image on demand from mcr.microsoft.com" {
run skopeo copy docker://127.0.0.1:8090/azure-cognitive-services/vision/spatial-analysis/diagnostics:latest oci:${TEST_DATA_DIR} --src-tls-verify=false
[ "$status" -eq 0 ]

run curl http://127.0.0.1:8090/v2/_catalog
[ "$status" -eq 0 ]
[ $(echo "${lines[-1]}"| jq '.repositories | map(select(. == "azure-cognitive-services/vision/spatial-analysis/diagnostics"))' | jq '.[]') = '"azure-cognitive-services/vision/spatial-analysis/diagnostics"' ]
run curl http://127.0.0.1:8090/v2/azure-cognitive-services/vision/spatial-analysis/diagnostics/tags/list
[ "$status" -eq 0 ]
[ $(echo "${lines[-1]}" | jq '.tags[]') = '"latest"' ]
}

@test "run docker with image synced from docker.io/library" {
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
eusebiu-constantin-petu-dbk marked this conversation as resolved.
Show resolved Hide resolved
[ "$status" -eq 0 ]

run curl http://127.0.0.1:8090/v2/_catalog
[ "$status" -eq 0 ]
[ $(echo "${lines[-1]}"| jq '.repositories | map(select(. == "archlinux"))' | jq '.[]') = '"archlinux"' ]
run curl http://127.0.0.1:8090/v2/archlinux/tags/list
[ "$status" -eq 0 ]
[ $(echo "${lines[-1]}" | jq '.tags[]') = '"latest"' ]

run docker kill $(docker ps -q)
}

@test "run docker with image synced from registry.k8s.io" {
run docker run -d 127.0.0.1:8090/kube-apiserver-amd64:v1.10.0
[ "$status" -eq 0 ]

run curl http://127.0.0.1:8090/v2/_catalog
[ "$status" -eq 0 ]
[ $(echo "${lines[-1]}"| jq '.repositories | map(select(. == "kube-apiserver-amd64"))' | jq '.[]') = '"kube-apiserver-amd64"' ]
run curl http://127.0.0.1:8090/v2/kube-apiserver-amd64/tags/list
[ "$status" -eq 0 ]
[ $(echo "${lines[-1]}" | jq '.tags[]') = '"v1.10.0"' ]

run docker kill $(docker ps -q)
}

@test "run docker with image synced from aws.amazon.com/ecr" {
run docker run -d 127.0.0.1:8090/amazonlinux:latest
[ "$status" -eq 0 ]

run curl http://127.0.0.1:8090/v2/_catalog
[ "$status" -eq 0 ]
[ $(echo "${lines[-1]}"| jq '.repositories | map(select(. == "amazonlinux"))' | jq '.[]') = '"amazonlinux"' ]
run curl http://127.0.0.1:8090/v2/amazonlinux/tags/list
[ "$status" -eq 0 ]
[ $(echo "${lines[-1]}" | jq '.tags[]') = '"latest"' ]

run docker kill $(docker ps -q)
}

@test "run docker with image synced from gcr.io" {
run docker run -d 127.0.0.1:8090/google-containers/kube-proxy-amd64:v1.17.9
[ "$status" -eq 0 ]

run curl http://127.0.0.1:8090/v2/_catalog
[ "$status" -eq 0 ]
[ $(echo "${lines[-1]}"| jq '.repositories | map(select(. == "google-containers/kube-proxy-amd64"))' | jq '.[]') = '"google-containers/kube-proxy-amd64"' ]
run curl http://127.0.0.1:8090/v2/google-containers/kube-proxy-amd64/tags/list
[ "$status" -eq 0 ]
[ $(echo "${lines[-1]}" | jq '.tags[]') = '"v1.17.9"' ]

run docker kill $(docker ps -q)
}

@test "run docker with image synced from mcr.microsoft.com" {
run docker run -d 127.0.0.1:8090/azure-cognitive-services/vision/spatial-analysis/diagnostics:latest
[ "$status" -eq 0 ]

run curl http://127.0.0.1:8090/v2/_catalog
[ "$status" -eq 0 ]
[ $(echo "${lines[-1]}"| jq '.repositories | map(select(. == "azure-cognitive-services/vision/spatial-analysis/diagnostics"))' | jq '.[]') = '"azure-cognitive-services/vision/spatial-analysis/diagnostics"' ]
run curl http://127.0.0.1:8090/v2/azure-cognitive-services/vision/spatial-analysis/diagnostics/tags/list
[ "$status" -eq 0 ]
[ $(echo "${lines[-1]}" | jq '.tags[]') = '"latest"' ]

run docker kill $(docker ps -q)
}