Skip to content

Commit fa691f6

Browse files
committed
Test Registry
Adds a bare-bones test registry and a folder tree for our test images. Signed-off-by: dtfranz <[email protected]>
1 parent 482a66d commit fa691f6

File tree

78 files changed

+117272
-172
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+117272
-172
lines changed

Makefile

+9-14
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,13 @@ test-unit: $(SETUP_ENVTEST) #HELP Run the unit tests
165165
$(UNIT_TEST_DIRS) \
166166
-test.gocoverdir=$(ROOT_DIR)/coverage/unit
167167

168-
image-registry: ## Setup in-cluster image registry
169-
./hack/test/image-registry.sh $(E2E_REGISTRY_NAMESPACE) $(E2E_REGISTRY_NAME)
170-
171-
build-push-e2e-catalog: ## Build the testdata catalog used for e2e tests and push it to the image registry
172-
./hack/test/build-push-e2e-catalog.sh $(E2E_REGISTRY_NAMESPACE) $(LOCAL_REGISTRY_HOST)/$(E2E_TEST_CATALOG_V1)
173-
./hack/test/build-push-e2e-catalog.sh $(E2E_REGISTRY_NAMESPACE) $(LOCAL_REGISTRY_HOST)/$(E2E_TEST_CATALOG_V2)
168+
E2E_REGISTRY_IMAGE=localhost/e2e-test-registry:devel
169+
image-registry: ## Build the testdata catalog used for e2e tests and push it to the image registry
170+
go build -o ./testdata/registry/bin/registry ./testdata/registry/registry.go
171+
go build -o ./testdata/push/bin/push ./testdata/push/push.go
172+
$(CONTAINER_RUNTIME) build -f ./testdata/Dockerfile -t $(E2E_REGISTRY_IMAGE) ./testdata
173+
$(CONTAINER_RUNTIME) save $(E2E_REGISTRY_IMAGE) | $(KIND) load image-archive /dev/stdin --name $(KIND_CLUSTER_NAME)
174+
./testdata/build-test-registry.sh $(E2E_REGISTRY_NAMESPACE) $(E2E_REGISTRY_NAME) $(E2E_REGISTRY_IMAGE)
174175

175176
# When running the e2e suite, you can set the ARTIFACT_PATH variable to the absolute path
176177
# of the directory for the operator-controller e2e tests to store the artifacts, which
@@ -181,7 +182,7 @@ build-push-e2e-catalog: ## Build the testdata catalog used for e2e tests and pus
181182
test-e2e: KIND_CLUSTER_NAME := operator-controller-e2e
182183
test-e2e: KUSTOMIZE_BUILD_DIR := config/overlays/e2e
183184
test-e2e: GO_BUILD_FLAGS := -cover
184-
test-e2e: run image-registry build-push-e2e-catalog registry-load-bundles e2e e2e-coverage kind-clean #HELP Run e2e test suite on local kind cluster
185+
test-e2e: run image-registry e2e e2e-coverage kind-clean #HELP Run e2e test suite on local kind cluster
185186

186187
.PHONY: extension-developer-e2e
187188
extension-developer-e2e: KUSTOMIZE_BUILD_DIR := config/overlays/cert-manager
@@ -205,7 +206,7 @@ post-upgrade-checks:
205206
test-upgrade-e2e: KIND_CLUSTER_NAME := operator-controller-upgrade-e2e
206207
test-upgrade-e2e: export TEST_CLUSTER_CATALOG_NAME := test-catalog
207208
test-upgrade-e2e: export TEST_CLUSTER_EXTENSION_NAME := test-package
208-
test-upgrade-e2e: kind-cluster run-latest-release image-registry build-push-e2e-catalog registry-load-bundles pre-upgrade-setup docker-build kind-load kind-deploy post-upgrade-checks kind-clean #HELP Run upgrade e2e tests on a local kind cluster
209+
test-upgrade-e2e: kind-cluster run-latest-release image-registry pre-upgrade-setup docker-build kind-load kind-deploy post-upgrade-checks kind-clean #HELP Run upgrade e2e tests on a local kind cluster
209210

210211
.PHONY: e2e-coverage
211212
e2e-coverage:
@@ -231,12 +232,6 @@ kind-cluster: $(KIND) #EXHELP Standup a kind cluster.
231232
kind-clean: $(KIND) #EXHELP Delete the kind cluster.
232233
$(KIND) delete cluster --name $(KIND_CLUSTER_NAME)
233234

234-
registry-load-bundles: ## Load selected e2e testdata container images created in kind-load-bundles into registry
235-
testdata/bundles/registry-v1/build-push-e2e-bundle.sh ${E2E_REGISTRY_NAMESPACE} $(LOCAL_REGISTRY_HOST)/bundles/registry-v1/prometheus-operator:v1.0.0 prometheus-operator.v1.0.0 prometheus-operator.v1.0.0
236-
testdata/bundles/registry-v1/build-push-e2e-bundle.sh ${E2E_REGISTRY_NAMESPACE} $(LOCAL_REGISTRY_HOST)/bundles/registry-v1/prometheus-operator:v1.0.1 prometheus-operator.v1.0.1 prometheus-operator.v1.0.0
237-
testdata/bundles/registry-v1/build-push-e2e-bundle.sh ${E2E_REGISTRY_NAMESPACE} $(LOCAL_REGISTRY_HOST)/bundles/registry-v1/prometheus-operator:v1.2.0 prometheus-operator.v1.2.0 prometheus-operator.v1.0.0
238-
testdata/bundles/registry-v1/build-push-e2e-bundle.sh ${E2E_REGISTRY_NAMESPACE} $(LOCAL_REGISTRY_HOST)/bundles/registry-v1/prometheus-operator:v2.0.0 prometheus-operator.v2.0.0 prometheus-operator.v1.0.0
239-
240235
#SECTION Build
241236

242237
ifeq ($(origin VERSION), undefined)

hack/test/build-push-e2e-catalog.sh

-66
This file was deleted.

test/e2e/cluster_extension_install_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ func TestClusterExtensionInstallReResolvesWhenCatalogIsPatched(t *testing.T) {
550550

551551
// patch imageRef tag on test-catalog image with v2 image
552552
t.Log("By patching the catalog ImageRef to point to the v2 catalog")
553-
updatedCatalogImage := fmt.Sprintf("%s/e2e/test-catalog:v2", os.Getenv("LOCAL_REGISTRY_HOST"))
553+
updatedCatalogImage := fmt.Sprintf("%s/test-catalog:v2", os.Getenv("LOCAL_REGISTRY_HOST"))
554554
err := patchTestCatalog(context.Background(), testCatalogName, updatedCatalogImage)
555555
require.NoError(t, err)
556556
require.EventuallyWithT(t, func(ct *assert.CollectT) {
@@ -584,7 +584,7 @@ func TestClusterExtensionInstallReResolvesWhenNewCatalog(t *testing.T) {
584584
require.NoError(t, err)
585585

586586
// create a test-catalog with latest image tag
587-
latestCatalogImage := fmt.Sprintf("%s/e2e/test-catalog:latest", os.Getenv("LOCAL_REGISTRY_HOST"))
587+
latestCatalogImage := fmt.Sprintf("%s/test-catalog:latest", os.Getenv("LOCAL_REGISTRY_HOST"))
588588
extensionCatalog, err := createTestCatalog(context.Background(), testCatalogName, latestCatalogImage)
589589
require.NoError(t, err)
590590
clusterExtensionName := fmt.Sprintf("clusterextension-%s", rand.String(8))

testdata/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
push/bin
2+
registry/bin

testdata/Dockerfile

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from gcr.io/distroless/static:debug-nonroot
2+
3+
WORKDIR /
4+
5+
COPY registry/bin/registry registry
6+
COPY push/bin/push push
7+
8+
COPY images images
9+
10+
EXPOSE 5000
11+
12+
USER 65532:65532

hack/test/image-registry.sh renamed to testdata/build-test-registry.sh

+45-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#! /bin/bash
1+
#!/bin/bash
22

33
set -o errexit
44
set -o nounset
@@ -7,23 +7,23 @@ set -o pipefail
77
help="
88
image-registry.sh is a script to stand up an image registry within a cluster.
99
Usage:
10-
image-registry.sh [NAMESPACE] [NAME] [CERT_REF]
10+
image-registry.sh [NAMESPACE] [NAME] [IMAGE]
1111
1212
Argument Descriptions:
1313
- NAMESPACE is the namespace that should be created and is the namespace in which the image registry will be created
1414
- NAME is the name that should be used for the image registry Deployment and Service
15-
- CERT_REF is the reference to the CA certificate that should be used to serve the image registry over HTTPS, in the
16-
format of 'Issuer/<issuer-name>' or 'ClusterIssuer/<cluster-issuer-name>'
15+
- IMAGE is the name of the image that should be used to run the image registry
1716
"
1817

19-
if [[ "$#" -ne 2 ]]; then
18+
if [[ "$#" -ne 3 ]]; then
2019
echo "Illegal number of arguments passed"
2120
echo "${help}"
2221
exit 1
2322
fi
2423

2524
namespace=$1
2625
name=$2
26+
image=$3
2727

2828
kubectl apply -f - << EOF
2929
apiVersion: v1
@@ -69,7 +69,12 @@ spec:
6969
spec:
7070
containers:
7171
- name: registry
72-
image: registry:2
72+
image: ${image}
73+
imagePullPolicy: IfNotPresent
74+
command:
75+
- /registry
76+
args:
77+
- "--registry-address=:5000"
7378
volumeMounts:
7479
- name: certs-vol
7580
mountPath: "/certs"
@@ -100,3 +105,37 @@ spec:
100105
EOF
101106

102107
kubectl wait --for=condition=Available -n "${namespace}" "deploy/${name}" --timeout=60s
108+
109+
kubectl apply -f - << EOF
110+
apiVersion: batch/v1
111+
kind: Job
112+
metadata:
113+
name: ${name}-push
114+
namespace: "${namespace}"
115+
spec:
116+
template:
117+
spec:
118+
restartPolicy: Never
119+
containers:
120+
- name: push
121+
image: ${image}
122+
command:
123+
- /push
124+
args:
125+
- "--registry-address=${name}:5000"
126+
- "--images-path=/images"
127+
volumeMounts:
128+
- name: certs-vol
129+
mountPath: "/certs"
130+
env:
131+
- name: REGISTRY_HTTP_TLS_CERTIFICATE
132+
value: "/certs/tls.crt"
133+
- name: REGISTRY_HTTP_TLS_KEY
134+
value: "/certs/tls.key"
135+
volumes:
136+
- name: certs-vol
137+
secret:
138+
secretName: ${namespace}-registry
139+
EOF
140+
141+
kubectl wait --for=condition=Complete -n "${namespace}" "job/${name}-push" --timeout=60s

testdata/bundles/registry-v1/build-push-e2e-bundle.sh

-84
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM scratch
2+
3+
# Core bundle labels.
4+
LABEL operators.operatorframework.io.bundle.mediatype.v1=registry+v1
5+
LABEL operators.operatorframework.io.bundle.manifests.v1=manifests/
6+
LABEL operators.operatorframework.io.bundle.metadata.v1=metadata/
7+
LABEL operators.operatorframework.io.bundle.package.v1=prometheusoperator
8+
LABEL operators.operatorframework.io.bundle.channels.v1=beta
9+
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.28.0
10+
LABEL operators.operatorframework.io.metrics.mediatype.v1=metrics+v1
11+
LABEL operators.operatorframework.io.metrics.project_layout=unknown
12+
13+
# Copy files to locations specified by labels.
14+
COPY manifests /manifests/
15+
COPY metadata /metadata/

0 commit comments

Comments
 (0)