Skip to content

Commit

Permalink
feat(sync): added tests for sync on demand with the most used upstrea…
Browse files Browse the repository at this point in the history
…m registry services

Signed-off-by: Ana-Roberta Lisca <ana.kagome@yahoo.com>
  • Loading branch information
aokirisaki committed May 3, 2023
1 parent 5fcf01d commit a65afc6
Showing 1 changed file with 127 additions and 1 deletion.
128 changes: 127 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",
"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,125 @@ function teardown_file() {
[ "$status" -eq 0 ]
[ $(echo "${lines[-1]}" | jq '.tags[]') = '"latest"' ]
}

@test "sync image on demand for kubernetes" {
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[1]') = '"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 for Amazon 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[0]') = '"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 for Google Container Registry" {
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[2]') = '"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 for Azure Container Registry" {
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[2]') = '"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 "sync docker image on demand - docker" {
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

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/archlinux/tags/list
[ "$status" -eq 0 ]
[ $(echo "${lines[-1]}" | jq '.tags[]') = '"latest"' ]

run docker kill $(docker ps -q)
}

@test "sync docker image on demand for Kubernetes - docker" {
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[1]') = '"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 "sync docker image on demand for for Amazon ECR - docker" {
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[0]') = '"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 "sync docker image on demand for for Google Container Registry - docker" {
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[2]') = '"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 "sync docker image on demand for for Azure Container Registry - docker" {
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[2]') = '"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)
}

0 comments on commit a65afc6

Please sign in to comment.