0
Fork 0
mirror of https://github.com/project-zot/zot.git synced 2024-12-16 21:56:37 -05:00

test(bats): added regclient OCI artifact commands (#938)

Signed-off-by: Petu Eusebiu <peusebiu@cisco.com>
This commit is contained in:
peusebiu 2022-11-02 22:05:18 +02:00 committed by GitHub
parent 11ec261df6
commit e6539290d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 44 additions and 7 deletions

View file

@ -22,6 +22,7 @@ The following document refers on the **core dist-spec**, see also the [zot-speci
* Multi-arch support * Multi-arch support
* Clustering support * Clustering support
* Image linting support * Image linting support
* Supports push/pull OCI Artifacts
## [Demos](demos/README.md) ## [Demos](demos/README.md)

View file

@ -133,14 +133,19 @@ function teardown_file() {
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
} }
@test "copy image with regclient" { @test "push image with regclient" {
run regctl registry set localhost:8080 --tls disabled run regctl registry set localhost:8080 --tls disabled
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
run regctl image copy ocidir://${TEST_DATA_DIR}/golang:1.19 localhost:8080/test-regclient run regctl image copy ocidir://${TEST_DATA_DIR}/golang:1.19 localhost:8080/test-regclient
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
} }
@test "list all images with regclient" { @test "pull image with regclient" {
run regctl image copy localhost:8080/test-regclient ocidir://${TEST_DATA_DIR}/golang:1.19
[ "$status" -eq 0 ]
}
@test "list repositories with regclient" {
run regctl repo ls localhost:8080 run regctl repo ls localhost:8080
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
@ -155,7 +160,7 @@ function teardown_file() {
[ "$found" -eq 1 ] [ "$found" -eq 1 ]
} }
@test "list tags with regclient" { @test "list image tags with regclient" {
run regctl tag ls localhost:8080/test-regclient run regctl tag ls localhost:8080/test-regclient
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
@ -170,7 +175,7 @@ function teardown_file() {
[ "$found" -eq 1 ] [ "$found" -eq 1 ]
} }
@test "get and push manifest with regclient" { @test "push manifest with regclient" {
manifest=$(regctl manifest get localhost:8080/test-regclient --format=raw-body) manifest=$(regctl manifest get localhost:8080/test-regclient --format=raw-body)
run regctl manifest put localhost:8080/test-regclient:1.0.0 --format oci --content-type application/vnd.oci.image.manifest.v1+json --format oci <<EOF run regctl manifest put localhost:8080/test-regclient:1.0.0 --format oci --content-type application/vnd.oci.image.manifest.v1+json --format oci <<EOF
$manifest $manifest
@ -178,12 +183,43 @@ EOF
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
} }
@test "get manifest with regclient" { @test "pull manifest with regclient" {
run regctl manifest get localhost:8080/test-regclient run regctl manifest get localhost:8080/test-regclient
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
} }
@test "pull image with regclient" { @test "push OCI artifact with regclient" {
run regctl image copy localhost:8080/test-regclient ocidir://${TEST_DATA_DIR}/golang:1.19 run regctl artifact put localhost:8080/artifact:demo <<EOF
this is an artifact
EOF
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
} }
@test "pull OCI artifact with regclient" {
run regctl manifest get localhost:8080/artifact:demo
[ "$status" -eq 0 ]
run regctl artifact get localhost:8080/artifact:demo
[ "$status" -eq 0 ]
[ "${lines[-1]}" == "this is an artifact" ]
}
@test "list OCI artifacts with regclient" {
run regctl artifact list localhost:8080/test-regclient --format raw-body
[ "$status" -eq 0 ]
[ $(echo "${lines[-1]}" | jq '.manifests') == '[]' ]
# push OCI artifacts on an image
run regctl artifact put --refers localhost:8080/test-regclient <<EOF
first artifact with subject
EOF
[ "$status" -eq 0 ]
run regctl artifact put --refers localhost:8080/test-regclient <<EOF
second artifact with subject
EOF
[ "$status" -eq 0 ]
# list OCI artifacts of an image
run regctl artifact list localhost:8080/test-regclient --format raw-body
[ "$status" -eq 0 ]
[ $(echo "${lines[-1]}" | jq '.manifests | length') -eq 2 ]
}