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

regclient blackbox tests and regclient installation in Makefile

Signed-off-by: Lisca Ana-Roberta <ana.kagome@yahoo.com>
This commit is contained in:
Lisca Ana-Roberta 2022-07-22 14:34:12 +03:00 committed by Andrei Aaron
parent be93ece95e
commit a49692a22b
3 changed files with 98 additions and 7 deletions

View file

@ -11,6 +11,9 @@ STACKER := $(shell which stacker)
GOLINTER := $(TOOLSDIR)/bin/golangci-lint
GOLINTER_VERSION := v1.46.2
NOTATION := $(TOOLSDIR)/bin/notation
HELM := $(TOOLSDIR)/bin/helm
ORAS := $(TOOLSDIR)/bin/oras
REGCLIENT := $(TOOLSDIR)/bin/regctl
BATS := $(TOOLSDIR)/bin/bats
TESTDATA := $(TOP_LEVEL)/test/data
OS ?= linux
@ -101,6 +104,24 @@ $(NOTATION):
tar xvzf notation.tar.gz -C $(TOOLSDIR)/bin notation
rm notation.tar.gz
$(ORAS):
mkdir -p $(TOOLSDIR)/bin
curl -Lo oras.tar.gz https://github.com/oras-project/oras/releases/download/v0.13.0/oras_0.13.0_linux_amd64.tar.gz
tar xvzf oras.tar.gz -C $(TOOLSDIR)/bin oras
rm oras.tar.gz
$(HELM):
mkdir -p $(TOOLSDIR)/bin
curl -Lo helm.tar.gz https://get.helm.sh/helm-v3.9.1-linux-amd64.tar.gz
tar xvzf helm.tar.gz -C $(TOOLSDIR)/bin linux-amd64/helm --strip-components=1
rm helm.tar.gz
$(REGCLIENT):
mkdir -p $(TOOLSDIR)/bin
curl -Lo regctl https://github.com/regclient/regclient/releases/download/v0.4.4/regctl-linux-amd64
cp regctl $(TOOLSDIR)/bin/regctl
chmod +x $(TOOLSDIR)/bin/regctl
.PHONY: covhtml
covhtml:
go install github.com/wadey/gocovmerge@latest
@ -237,7 +258,7 @@ $(BATS):
rm -rf bats-core
.PHONY: push-pull
push-pull: binary check-skopeo $(BATS)
push-pull: binary check-skopeo $(BATS) $(REGCLIENT) $(ORAS) $(HELM)
$(BATS) --trace --print-output-on-failure test/blackbox/pushpull.bats
.PHONY: push-pull-verbose

View file

@ -36,6 +36,16 @@ function verify_prerequisites {
echo "you need to install oras as a prerequisite to running the tests" >&3
return 1
fi
if [ ! command -v helm ] &>/dev/null; then
echo "you need to install helm as a prerequisite to running the tests" >&3
return 1
fi
if [ ! command -v regctl ] &>/dev/null; then
echo "you need to install regclient as a prerequisite to running the tests" >&3
return 1
fi
return 0
}

View file

@ -69,23 +69,83 @@ function teardown_file() {
@test "push oras artifact" {
echo "{\"name\":\"foo\",\"value\":\"bar\"}" > config.json
echo "hello world" > artifact.txt
oras push --plain-http 127.0.0.1:8080/hello-artifact:v2 \
run oras push --plain-http 127.0.0.1:8080/hello-artifact:v2 \
--manifest-config config.json:application/vnd.acme.rocket.config.v1+json artifact.txt:text/plain -d -v
rm -f artifact.txt
[ "$status" -eq 0 ]
rm -f artifact.txt
rm -f config.json
}
@test "pull oras artifact" {
oras pull --plain-http 127.0.0.1:8080/hello-artifact:v2 -d -v
run oras pull --plain-http 127.0.0.1:8080/hello-artifact:v2 -d -v
[ "$status" -eq 0 ]
grep -q "hello world" artifact.txt
rm -f artifact.txt
}
@test "push helm chart" {
helm package ${BATS_FILE_TMPDIR}/helm-charts/charts/zot
helm push zot-0.1.0.tgz oci://localhost:8080/zot-chart
run helm package ${BATS_FILE_TMPDIR}/helm-charts/charts/zot
[ "$status" -eq 0 ]
run helm push zot-0.1.0.tgz oci://localhost:8080/zot-chart
[ "$status" -eq 0 ]
}
@test "pull helm chart" {
helm pull oci://localhost:8080/zot-chart/zot --version 0.1.0
run helm pull oci://localhost:8080/zot-chart/zot --version 0.1.0
[ "$status" -eq 0 ]
}
@test "copy image with regclient" {
run regctl registry set localhost:8080 --tls disabled
[ "$status" -eq 0 ]
run regctl image copy ocidir://${TEST_DATA_DIR}/golang:1.18 localhost:8080/test-regclient
[ "$status" -eq 0 ]
}
@test "list all images with regclient" {
run regctl repo ls localhost:8080
[ "$status" -eq 0 ]
found=0
for i in "${lines[@]}"
do
if [ "$i" = 'test-regclient' ]; then
found=1
fi
done
[ "$found" -eq 1 ]
}
@test "list tags with regclient" {
run regctl tag ls localhost:8080/test-regclient
[ "$status" -eq 0 ]
found=0
for i in "${lines[@]}"
do
if [ "$i" = 'latest' ]; then
found=1
fi
done
[ "$found" -eq 1 ]
}
@test "get and push manifest with regclient" {
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
$manifest
EOF
[ "$status" -eq 0 ]
}
@test "get manifest with regclient" {
run regctl manifest get localhost:8080/test-regclient
[ "$status" -eq 0 ]
}
@test "pull image with regclient" {
run regctl image copy localhost:8080/test-regclient ocidir://${TEST_DATA_DIR}/golang:1.18
[ "$status" -eq 0 ]
}