Skip to content

Commit 512f78f

Browse files
[Monorepo]: Move e2e tests from catalogd to operator-controller
1 parent ae41bfc commit 512f78f

File tree

11 files changed

+39
-22
lines changed

11 files changed

+39
-22
lines changed

.github/workflows/catalogd-e2e.yaml

Lines changed: 1 addition & 2 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:

Makefile

Lines changed: 29 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,23 @@ 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+
catalogd-image-registry: ## Setup in-cluster image registry
231+
./test/tools/imageregistry/registry.sh $(ISSUER_KIND) $(ISSUER_NAME)
232+
212233
.PHONY: extension-developer-e2e
213234
extension-developer-e2e: KUSTOMIZE_BUILD_DIR := config/overlays/cert-manager
214235
extension-developer-e2e: KIND_CLUSTER_NAME := operator-controller-ext-dev-e2e #EXHELP Run extension-developer e2e on local kind cluster
@@ -246,10 +267,9 @@ kind-load: $(KIND) #EXHELP Loads the currently constructed images into the KIND
246267
kind-deploy: export MANIFEST := ./operator-controller.yaml
247268
kind-deploy: export DEFAULT_CATALOG := ./catalogd/config/base/default/clustercatalogs/default-catalogs.yaml
248269
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)
270+
($(KUSTOMIZE) build $(KUSTOMIZE_BUILD_DIR) && echo "---" && $(KUSTOMIZE) build $(CATALOGD_KUSTOMIZE_BUILD_DIR) | sed "s/cert-git-version/cert-$(VERSION)/g") > $(MANIFEST)
250271
envsubst '$$DEFAULT_CATALOG,$$CERT_MGR_VERSION,$$INSTALL_DEFAULT_CATALOGS,$$MANIFEST' < scripts/install.tpl.sh | bash -s
251272

252-
253273
.PHONY: kind-cluster
254274
kind-cluster: $(KIND) #EXHELP Standup a kind cluster.
255275
-$(KIND) delete cluster --name $(KIND_CLUSTER_NAME)
@@ -302,7 +322,13 @@ go-build-linux: export GOARCH=amd64
302322
go-build-linux: $(BINARIES)
303323

304324
.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.
325+
run: generate docker-build kind-cluster kind-load kind-deploy wait #HELP Build the operator-controller then deploy it into a new kind cluster.
326+
327+
CATALOGD_NAMESPACE := olmv1-system
328+
wait:
329+
kubectl wait --for=condition=Available --namespace=$(CATALOGD_NAMESPACE) deployment/catalogd-controller-manager --timeout=60s
330+
kubectl wait --for=condition=Ready --namespace=$(CATALOGD_NAMESPACE) certificate/catalogd-service-cert # Avoid upgrade test flakes when reissuing cert
331+
306332

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

catalogd/Makefile

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,9 @@ FOCUS := $(if $(TEST),-v -focus "$(TEST)")
7878
ifeq ($(origin E2E_FLAGS), undefined)
7979
E2E_FLAGS :=
8080
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
8981

9082
image-registry: ## Setup in-cluster image registry
91-
./test/tools/imageregistry/registry.sh $(ISSUER_KIND) $(ISSUER_NAME)
83+
./../test/tools/imageregistry/registry.sh $(ISSUER_KIND) $(ISSUER_NAME)
9284

9385
## image-registry target has to come after run-latest-release,
9486
## because the image-registry depends on the olm-ca issuer.

catalogd/test/upgrade/unpack_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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() {
@@ -92,7 +92,7 @@ var _ = Describe("ClusterCatalog Unpacking", func() {
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/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/tools/imageregistry/registry.sh renamed to test/tools/imageregistry/registry.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ envsubst '${ISSUER_KIND},${ISSUER_NAME}' < test/tools/imageregistry/imgreg.yaml
2626
kubectl wait -n catalogd-e2e --for=condition=Available deployment/docker-registry --timeout=60s
2727

2828
# Load the testdata onto the cluster as a configmap so it can be used with kaniko
29-
kubectl create configmap -n catalogd-e2e --from-file=testdata/catalogs/test-catalog.Dockerfile catalogd-e2e.dockerfile
30-
kubectl create configmap -n catalogd-e2e --from-file=testdata/catalogs/test-catalog catalogd-e2e.build-contents
29+
kubectl create configmap -n catalogd-e2e --from-file=catalogd/testdata/catalogs/test-catalog.Dockerfile catalogd-e2e.dockerfile
30+
kubectl create configmap -n catalogd-e2e --from-file=catalogd/testdata/catalogs/test-catalog catalogd-e2e.build-contents
3131

3232
# Create the kaniko pod to build the test image and push it to the test registry.
3333
kubectl apply -f test/tools/imageregistry/imagebuilder.yaml

0 commit comments

Comments
 (0)