Skip to content

Commit be3ad66

Browse files
[Monorepo]: Move catalogd upgrade e2e tests to operator-controller and cleanup makefile
1 parent 512f78f commit be3ad66

File tree

5 files changed

+22
-93
lines changed

5 files changed

+22
-93
lines changed

.github/workflows/catalogd-e2e.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,4 @@ jobs:
2626
with:
2727
go-version-file: "go.mod"
2828
- name: Run the upgrade e2e test
29-
working-directory: catalogd
30-
run: make test-upgrade-e2e
29+
run: make test-catalogd-upgrade-e2e

Makefile

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,22 @@ catalogd-e2e: ISSUER_NAME := selfsigned-issuer
227227
catalogd-e2e: CATALOGD_KUSTOMIZE_BUILD_DIR := catalogd/config/overlays/e2e
228228
catalogd-e2e: run catalogd-image-registry test-catalogd-e2e ## kind-clean Run e2e test suite on local kind cluster
229229

230+
## image-registry target has to come after run-latest-release,
231+
## because the image-registry depends on the olm-ca issuer.
232+
.PHONY: test-catalogd-upgrade-e2e
233+
test-catalogd-upgrade-e2e: export TEST_CLUSTER_CATALOG_NAME := test-catalog
234+
test-catalogd-upgrade-e2e: export TEST_CLUSTER_CATALOG_IMAGE := docker-registry.catalogd-e2e.svc:5000/test-catalog:e2e
235+
test-catalogd-upgrade-e2e: ISSUER_KIND=ClusterIssuer
236+
test-catalogd-upgrade-e2e: ISSUER_NAME=olmv1-ca
237+
test-catalogd-upgrade-e2e: kind-cluster docker-build kind-load run-latest-release catalogd-image-registry catalogd-pre-upgrade-setup kind-deploy catalogd-post-upgrade-checks kind-clean ## Run upgrade e2e tests on a local kind cluster
238+
239+
.PHONY: catalogd-post-upgrade-checks
240+
catalogd-post-upgrade-checks:
241+
$(GINKGO) $(E2E_FLAGS) -trace -vv $(FOCUS) test/catalogd-upgrade-e2e
242+
243+
catalogd-pre-upgrade-setup:
244+
./test/tools/imageregistry/pre-upgrade-setup.sh ${TEST_CLUSTER_CATALOG_IMAGE} ${TEST_CLUSTER_CATALOG_NAME}
245+
230246
catalogd-image-registry: ## Setup in-cluster image registry
231247
./test/tools/imageregistry/registry.sh $(ISSUER_KIND) $(ISSUER_NAME)
232248

@@ -329,7 +345,6 @@ wait:
329345
kubectl wait --for=condition=Available --namespace=$(CATALOGD_NAMESPACE) deployment/catalogd-controller-manager --timeout=60s
330346
kubectl wait --for=condition=Ready --namespace=$(CATALOGD_NAMESPACE) certificate/catalogd-service-cert # Avoid upgrade test flakes when reissuing cert
331347

332-
333348
.PHONY: docker-build
334349
docker-build: build-linux #EXHELP Build docker image for operator-controller and catalog with GOOS=linux and local GOARCH.
335350
$(CONTAINER_RUNTIME) build -t $(IMG) -f Dockerfile ./bin/linux

catalogd/Makefile

Lines changed: 2 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ else
2323
$(warning Could not find docker or podman in path! This may result in targets requiring a container runtime failing!)
2424
endif
2525

26-
# For standard development and release flows, we use the config/overlays/cert-manager overlay.
27-
KUSTOMIZE_OVERLAY := config/overlays/cert-manager
28-
2926
# bingo manages consistent tooling versions for things like kind, kustomize, etc.
3027
include ./../.bingo/Variables.mk
3128

@@ -38,14 +35,6 @@ ifeq ($(origin KIND_CLUSTER_NAME), undefined)
3835
KIND_CLUSTER_NAME := catalogd
3936
endif
4037

41-
# E2E configuration
42-
TESTDATA_DIR := testdata
43-
44-
CATALOGD_NAMESPACE := olmv1-system
45-
KIND_CLUSTER_IMAGE := kindest/node:v1.30.0@sha256:047357ac0cfea04663786a612ba1eaba9702bef25227a794b52890dd8bcd692e
46-
47-
GINKGO := go run github.com/onsi/ginkgo/v2/ginkgo
48-
4938
##@ General
5039

5140
# The help target prints out all targets with their descriptions organized
@@ -74,34 +63,6 @@ generate: $(CONTROLLER_GEN) ## Generate code and manifests.
7463
$(CONTROLLER_GEN) object:headerFile="../hack/boilerplate.go.txt" paths="./..."
7564
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/base/crd/bases output:rbac:artifacts:config=config/base/rbac output:webhook:artifacts:config=config/base/manager/webhook/
7665

77-
FOCUS := $(if $(TEST),-v -focus "$(TEST)")
78-
ifeq ($(origin E2E_FLAGS), undefined)
79-
E2E_FLAGS :=
80-
endif
81-
82-
image-registry: ## Setup in-cluster image registry
83-
./../test/tools/imageregistry/registry.sh $(ISSUER_KIND) $(ISSUER_NAME)
84-
85-
## image-registry target has to come after run-latest-release,
86-
## because the image-registry depends on the olm-ca issuer.
87-
.PHONY: test-upgrade-e2e
88-
test-upgrade-e2e: export TEST_CLUSTER_CATALOG_NAME := test-catalog
89-
test-upgrade-e2e: export TEST_CLUSTER_CATALOG_IMAGE := docker-registry.catalogd-e2e.svc:5000/test-catalog:e2e
90-
test-upgrade-e2e: ISSUER_KIND=ClusterIssuer
91-
test-upgrade-e2e: ISSUER_NAME=olmv1-ca
92-
test-upgrade-e2e: kind-cluster cert-manager build-container kind-load run-latest-release image-registry pre-upgrade-setup only-deploy-manifest wait post-upgrade-checks kind-cluster-cleanup ## Run upgrade e2e tests on a local kind cluster
93-
94-
pre-upgrade-setup:
95-
./test/tools/imageregistry/pre-upgrade-setup.sh ${TEST_CLUSTER_CATALOG_IMAGE} ${TEST_CLUSTER_CATALOG_NAME}
96-
97-
.PHONY: run-latest-release
98-
run-latest-release:
99-
cd ..; curl -L -s https://github.com/operator-framework/operator-controller/releases/latest/download/install.sh | bash -s
100-
101-
.PHONY: post-upgrade-checks
102-
post-upgrade-checks:
103-
$(GINKGO) $(E2E_FLAGS) -trace -vv $(FOCUS) test/upgrade
104-
10566
##@ Build
10667

10768
BINARIES=catalogd
@@ -149,62 +110,16 @@ $(LINUX_BINARIES): BUILDBIN = bin/linux
149110
$(LINUX_BINARIES):
150111
GOOS=linux $(BUILDCMD)
151112

152-
153-
.PHONY: run
154-
run: generate kind-cluster install ## Create a kind cluster and install a local build of catalogd
155-
156113
.PHONY: build-container
157114
build-container: build-linux ## Build docker image for catalogd.
158115
$(CONTAINER_RUNTIME) build -f Dockerfile -t $(IMAGE) ./bin/linux
159116

160-
##@ Deploy
161-
162-
.PHONY: kind-cluster
163-
kind-cluster: $(KIND) kind-cluster-cleanup ## Standup a kind cluster
164-
$(KIND) create cluster --name $(KIND_CLUSTER_NAME) --image $(KIND_CLUSTER_IMAGE)
165-
$(KIND) export kubeconfig --name $(KIND_CLUSTER_NAME)
166-
167-
.PHONY: kind-cluster-cleanup
168-
kind-cluster-cleanup: $(KIND) ## Delete the kind cluster
169-
$(KIND) delete cluster --name $(KIND_CLUSTER_NAME)
170-
171117
.PHONY: kind-load
172-
kind-load: check-cluster $(KIND) ## Load the built images onto the local cluster
118+
kind-load: $(KIND) ## Load the built images onto the local cluster
173119
$(CONTAINER_RUNTIME) save $(IMAGE) | $(KIND) load image-archive /dev/stdin --name $(KIND_CLUSTER_NAME)
174120

175-
.PHONY: install
176-
install: check-cluster build-container kind-load deploy wait ## Install local catalogd to an existing cluster
177-
178-
.PHONY: deploy
179-
deploy: export MANIFEST="./catalogd.yaml"
180-
deploy: export DEFAULT_CATALOGS="./config/base/default/clustercatalogs/default-catalogs.yaml"
181-
deploy: $(KUSTOMIZE) ## Deploy Catalogd to the K8s cluster specified in ~/.kube/config with cert-manager and default clustercatalogs
182-
cd config/base/manager && $(KUSTOMIZE) edit set image controller=$(IMAGE) && cd ../../..
183-
$(KUSTOMIZE) build $(KUSTOMIZE_OVERLAY) | sed "s/cert-git-version/cert-$(GIT_VERSION)/g" > catalogd.yaml
184-
envsubst '$$CERT_MGR_VERSION,$$MANIFEST,$$DEFAULT_CATALOGS' < scripts/install.tpl.sh | bash -s
185-
186-
.PHONY: only-deploy-manifest
187-
only-deploy-manifest: $(KUSTOMIZE) ## Deploy just the Catalogd manifest--used in e2e testing where cert-manager is installed in a separate step
188-
cd config/base/manager && $(KUSTOMIZE) edit set image controller=$(IMAGE)
189-
$(KUSTOMIZE) build $(KUSTOMIZE_OVERLAY) | kubectl apply -f -
190-
191-
wait:
192-
kubectl wait --for=condition=Available --namespace=$(CATALOGD_NAMESPACE) deployment/catalogd-controller-manager --timeout=60s
193-
kubectl wait --for=condition=Ready --namespace=$(CATALOGD_NAMESPACE) certificate/catalogd-service-cert # Avoid upgrade test flakes when reissuing cert
194-
195-
196-
.PHONY: cert-manager
197-
cert-manager:
198-
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/${CERT_MGR_VERSION}/cert-manager.yaml
199-
kubectl wait --for=condition=Available --namespace=cert-manager deployment/cert-manager-webhook --timeout=60s
121+
##@ Deploy
200122

201123
.PHONY: demo-update
202124
demo-update:
203125
hack/scripts/generate-asciidemo.sh
204-
205-
.PHONY: check-cluster
206-
check-cluster:
207-
@kubectl config current-context >/dev/null 2>&1 || ( \
208-
echo "Error: Could not get current Kubernetes context. Maybe use 'run' or 'e2e' targets first?"; \
209-
exit 1; \
210-
)

catalogd/test/upgrade/unpack_test.go renamed to test/catalogd-upgrade-e2e/unpack_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package upgradee2e
1+
package catalogdupgradee2e
22

33
import (
44
"bufio"
@@ -87,7 +87,7 @@ var _ = Describe("ClusterCatalog Unpacking", func() {
8787
g.Expect(cond.Reason).To(Equal(catalogdv1.ReasonSucceeded))
8888
}).Should(Succeed())
8989

90-
expectedFBC, err := os.ReadFile("../../testdata/catalogs/test-catalog/expected_all.json")
90+
expectedFBC, err := os.ReadFile("../../catalogd/testdata/catalogs/test-catalog/expected_all.json")
9191
Expect(err).To(Not(HaveOccurred()))
9292

9393
By("Making sure the catalog content is available via the http server")

catalogd/test/upgrade/upgrade_suite_test.go renamed to test/catalogd-upgrade-e2e/upgrade_suite_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package upgradee2e
1+
package catalogdupgradee2e
22

33
import (
44
"os"

0 commit comments

Comments
 (0)