Skip to content

Commit 4a007b0

Browse files
🌱 [Monorepo]: Move e2e tests from catalogd to operator-controller (#1726)
* [Monorepo]: Move e2e tests from catalogd to operator-controller * [Monorepo]: Move catalogd upgrade e2e tests to operator-controller and cleanup makefile * [Monorepo]: Delete catalogd/scripts/install.tpl.sh since it is no longer used * Update Makefile
1 parent ce837d6 commit 4a007b0

File tree

13 files changed

+59
-158
lines changed

13 files changed

+59
-158
lines changed

‎.github/workflows/catalogd-e2e.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ jobs:
1717
with:
1818
go-version-file: "go.mod"
1919
- name: Run E2e
20-
working-directory: catalogd
21-
run: make e2e
20+
run: make test-catalogd-e2e
2221
upgrade-e2e:
2322
runs-on: ubuntu-latest
2423
steps:
@@ -27,5 +26,4 @@ jobs:
2726
with:
2827
go-version-file: "go.mod"
2928
- name: Run the upgrade e2e test
30-
working-directory: catalogd
31-
run: make test-upgrade-e2e
29+
run: make test-catalogd-upgrade-e2e

‎Makefile

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ endif
2525
export IMAGE_TAG
2626

2727
IMG := $(IMAGE_REPO):$(IMAGE_TAG)
28+
CATALOGD_IMG := $(CATALOG_IMAGE_REPO):$(IMAGE_TAG)
2829

2930
# Define dependency versions (use go.mod if we also use Go code from dependency)
3031
export CERT_MGR_VERSION := v1.15.3
@@ -64,12 +65,15 @@ $(warning Could not find docker or podman in path! This may result in targets re
6465
endif
6566

6667
KUSTOMIZE_BUILD_DIR := config/overlays/cert-manager
68+
CATALOGD_KUSTOMIZE_BUILD_DIR := catalogd/config/overlays/cert-manager
6769

6870
# Disable -j flag for make
6971
.NOTPARALLEL:
7072

7173
.DEFAULT_GOAL := build
7274

75+
GINKGO := go run github.com/onsi/ginkgo/v2/ginkgo
76+
7377
#SECTION General
7478

7579
# The help target prints out all targets with their descriptions organized
@@ -209,6 +213,39 @@ test-e2e: KUSTOMIZE_BUILD_DIR := config/overlays/e2e
209213
test-e2e: GO_BUILD_FLAGS := -cover
210214
test-e2e: run image-registry e2e e2e-coverage kind-clean #HELP Run e2e test suite on local kind cluster
211215

216+
# Catalogd e2e tests
217+
FOCUS := $(if $(TEST),-v -focus "$(TEST)")
218+
ifeq ($(origin E2E_FLAGS), undefined)
219+
E2E_FLAGS :=
220+
endif
221+
test-catalogd-e2e: ## Run the e2e tests on existing cluster
222+
$(GINKGO) $(E2E_FLAGS) -trace -vv $(FOCUS) test/catalogd-e2e
223+
224+
catalogd-e2e: KIND_CLUSTER_NAME := catalogd-e2e
225+
catalogd-e2e: ISSUER_KIND := Issuer
226+
catalogd-e2e: ISSUER_NAME := selfsigned-issuer
227+
catalogd-e2e: CATALOGD_KUSTOMIZE_BUILD_DIR := catalogd/config/overlays/e2e
228+
catalogd-e2e: run catalogd-image-registry test-catalogd-e2e ## kind-clean Run e2e test suite on local kind cluster
229+
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+
246+
catalogd-image-registry: ## Setup in-cluster image registry
247+
./test/tools/imageregistry/registry.sh $(ISSUER_KIND) $(ISSUER_NAME)
248+
212249
.PHONY: extension-developer-e2e
213250
extension-developer-e2e: KUSTOMIZE_BUILD_DIR := config/overlays/cert-manager
214251
extension-developer-e2e: KIND_CLUSTER_NAME := operator-controller-ext-dev-e2e #EXHELP Run extension-developer e2e on local kind cluster
@@ -246,10 +283,9 @@ kind-load: $(KIND) #EXHELP Loads the currently constructed images into the KIND
246283
kind-deploy: export MANIFEST := ./operator-controller.yaml
247284
kind-deploy: export DEFAULT_CATALOG := ./catalogd/config/base/default/clustercatalogs/default-catalogs.yaml
248285
kind-deploy: manifests $(KUSTOMIZE)
249-
($(KUSTOMIZE) build $(KUSTOMIZE_BUILD_DIR) && echo "---" && $(KUSTOMIZE) build catalogd/config/overlays/cert-manager | sed "s/cert-git-version/cert-$(VERSION)/g") > $(MANIFEST)
286+
($(KUSTOMIZE) build $(KUSTOMIZE_BUILD_DIR) && echo "---" && $(KUSTOMIZE) build $(CATALOGD_KUSTOMIZE_BUILD_DIR) | sed "s/cert-git-version/cert-$(VERSION)/g") > $(MANIFEST)
250287
envsubst '$$DEFAULT_CATALOG,$$CERT_MGR_VERSION,$$INSTALL_DEFAULT_CATALOGS,$$MANIFEST' < scripts/install.tpl.sh | bash -s
251288

252-
253289
.PHONY: kind-cluster
254290
kind-cluster: $(KIND) #EXHELP Standup a kind cluster.
255291
-$(KIND) delete cluster --name $(KIND_CLUSTER_NAME)
@@ -302,7 +338,12 @@ go-build-linux: export GOARCH=amd64
302338
go-build-linux: $(BINARIES)
303339

304340
.PHONY: run
305-
run: docker-build kind-cluster kind-load kind-deploy #HELP Build the operator-controller then deploy it into a new kind cluster.
341+
run: docker-build kind-cluster kind-load kind-deploy wait #HELP Build the operator-controller then deploy it into a new kind cluster.
342+
343+
CATALOGD_NAMESPACE := olmv1-system
344+
wait:
345+
kubectl wait --for=condition=Available --namespace=$(CATALOGD_NAMESPACE) deployment/catalogd-controller-manager --timeout=60s
346+
kubectl wait --for=condition=Ready --namespace=$(CATALOGD_NAMESPACE) certificate/catalogd-service-cert # Avoid upgrade test flakes when reissuing cert
306347

307348
.PHONY: docker-build
308349
docker-build: build-linux #EXHELP Build docker image for operator-controller and catalog with GOOS=linux and local GOARCH.

‎catalogd/Makefile

Lines changed: 2 additions & 95 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,42 +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-
test-e2e: ## Run the e2e tests on existing cluster
82-
$(GINKGO) $(E2E_FLAGS) -trace -vv $(FOCUS) test/e2e
83-
84-
e2e: KIND_CLUSTER_NAME := catalogd-e2e
85-
e2e: ISSUER_KIND := Issuer
86-
e2e: ISSUER_NAME := selfsigned-issuer
87-
e2e: KUSTOMIZE_OVERLAY := config/overlays/e2e
88-
e2e: run image-registry test-e2e kind-cluster-cleanup ## Run e2e test suite on local kind cluster
89-
90-
image-registry: ## Setup in-cluster image registry
91-
./test/tools/imageregistry/registry.sh $(ISSUER_KIND) $(ISSUER_NAME)
92-
93-
## image-registry target has to come after run-latest-release,
94-
## because the image-registry depends on the olm-ca issuer.
95-
.PHONY: test-upgrade-e2e
96-
test-upgrade-e2e: export TEST_CLUSTER_CATALOG_NAME := test-catalog
97-
test-upgrade-e2e: export TEST_CLUSTER_CATALOG_IMAGE := docker-registry.catalogd-e2e.svc:5000/test-catalog:e2e
98-
test-upgrade-e2e: ISSUER_KIND=ClusterIssuer
99-
test-upgrade-e2e: ISSUER_NAME=olmv1-ca
100-
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
101-
102-
pre-upgrade-setup:
103-
./test/tools/imageregistry/pre-upgrade-setup.sh ${TEST_CLUSTER_CATALOG_IMAGE} ${TEST_CLUSTER_CATALOG_NAME}
104-
105-
.PHONY: run-latest-release
106-
run-latest-release:
107-
cd ..; curl -L -s https://github.com/operator-framework/operator-controller/releases/latest/download/install.sh | bash -s
108-
109-
.PHONY: post-upgrade-checks
110-
post-upgrade-checks:
111-
$(GINKGO) $(E2E_FLAGS) -trace -vv $(FOCUS) test/upgrade
112-
11366
##@ Build
11467

11568
BINARIES=catalogd
@@ -157,63 +110,17 @@ $(LINUX_BINARIES): BUILDBIN = bin/linux
157110
$(LINUX_BINARIES):
158111
GOOS=linux $(BUILDCMD)
159112

160-
161-
.PHONY: run
162-
run: generate kind-cluster install ## Create a kind cluster and install a local build of catalogd
163-
164113
.PHONY: build-container
165114
build-container: build-linux ## Build docker image for catalogd.
166115
$(CONTAINER_RUNTIME) build -f Dockerfile -t $(IMAGE) ./bin/linux
167116

168-
##@ Deploy
169-
170-
.PHONY: kind-cluster
171-
kind-cluster: $(KIND) kind-cluster-cleanup ## Standup a kind cluster
172-
$(KIND) create cluster --name $(KIND_CLUSTER_NAME) --image $(KIND_CLUSTER_IMAGE)
173-
$(KIND) export kubeconfig --name $(KIND_CLUSTER_NAME)
174-
175-
.PHONY: kind-cluster-cleanup
176-
kind-cluster-cleanup: $(KIND) ## Delete the kind cluster
177-
$(KIND) delete cluster --name $(KIND_CLUSTER_NAME)
178-
179117
.PHONY: kind-load
180-
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
181119
$(CONTAINER_RUNTIME) save $(IMAGE) | $(KIND) load image-archive /dev/stdin --name $(KIND_CLUSTER_NAME)
182120

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

209123
# The demo script requires to install asciinema with: brew install asciinema to run on mac os envs.
210124
.PHONY: demo-update #HELP build demo
211125
demo-update:
212126
hack/scripts/generate-asciidemo.sh
213-
214-
.PHONY: check-cluster
215-
check-cluster:
216-
@kubectl config current-context >/dev/null 2>&1 || ( \
217-
echo "Error: Could not get current Kubernetes context. Maybe use 'run' or 'e2e' targets first?"; \
218-
exit 1; \
219-
)

‎catalogd/scripts/install.tpl.sh

Lines changed: 0 additions & 45 deletions
This file was deleted.

‎catalogd/test/e2e/e2e_suite_test.go renamed to ‎test/catalogd-e2e/e2e_suite_test.go

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

33
import (
44
"fmt"

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

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

33
import (
44
"context"
@@ -79,7 +79,7 @@ var _ = Describe("ClusterCatalog Unpacking", func() {
7979
actualFBC, err := ReadTestCatalogServerContents(ctx, catalog, c, kubeClient)
8080
Expect(err).To(Not(HaveOccurred()))
8181

82-
expectedFBC, err := os.ReadFile("../../testdata/catalogs/test-catalog/expected_all.json")
82+
expectedFBC, err := os.ReadFile("../../catalogd/testdata/catalogs/test-catalog/expected_all.json")
8383
Expect(err).To(Not(HaveOccurred()))
8484
Expect(cmp.Diff(expectedFBC, actualFBC)).To(BeEmpty())
8585

‎catalogd/test/e2e/util.go renamed to ‎test/catalogd-e2e/util.go

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

33
import (
44
"context"

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

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

33
import (
44
"bufio"
@@ -21,7 +21,7 @@ import (
2121
"sigs.k8s.io/controller-runtime/pkg/client"
2222

2323
catalogdv1 "github.com/operator-framework/operator-controller/catalogd/api/v1"
24-
"github.com/operator-framework/operator-controller/catalogd/test/e2e"
24+
catalogde2e "github.com/operator-framework/operator-controller/test/catalogd-e2e"
2525
)
2626

2727
var _ = Describe("ClusterCatalog Unpacking", func() {
@@ -87,12 +87,12 @@ 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")
9494
Eventually(func(g Gomega) {
95-
actualFBC, err := e2e.ReadTestCatalogServerContents(ctx, catalog, c, kubeClient)
95+
actualFBC, err := catalogde2e.ReadTestCatalogServerContents(ctx, catalog, c, kubeClient)
9696
g.Expect(err).To(Not(HaveOccurred()))
9797
g.Expect(cmp.Diff(expectedFBC, actualFBC)).To(BeEmpty())
9898
}).Should(Succeed())

‎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)