Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .github/workflows/catalogd-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ jobs:
with:
go-version-file: "go.mod"
- name: Run E2e
working-directory: catalogd
run: make e2e
run: make test-catalogd-e2e
upgrade-e2e:
runs-on: ubuntu-latest
steps:
Expand All @@ -27,5 +26,4 @@ jobs:
with:
go-version-file: "go.mod"
- name: Run the upgrade e2e test
working-directory: catalogd
run: make test-upgrade-e2e
run: make test-catalogd-upgrade-e2e
47 changes: 44 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ endif
export IMAGE_TAG

IMG := $(IMAGE_REPO):$(IMAGE_TAG)
CATALOGD_IMG := $(CATALOG_IMAGE_REPO):$(IMAGE_TAG)

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

KUSTOMIZE_BUILD_DIR := config/overlays/cert-manager
CATALOGD_KUSTOMIZE_BUILD_DIR := catalogd/config/overlays/cert-manager

# Disable -j flag for make
.NOTPARALLEL:

.DEFAULT_GOAL := build

GINKGO := go run github.com/onsi/ginkgo/v2/ginkgo

#SECTION General

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm reading the Makefile correctly, we have:
test-e2e - runs operator-controller e2e only
catalogd-e2e - runs catalogd e2e only

I think we need some more clear separation between the e2e for the two components. I'd prefer this as a follow-up if we do change it, but IMO we should have:
test-e2e - runs both operator-controller and catalogd e2e
catalogd-e2e - runscatalogd e2e only
operator-controller-e2e - runs operator-controller e2e only

We could then have the github actions run the catalogd-e2e and operator-controller-e2e in two separate jobs as it does now, but with slightly more clear job names. WDYT?

Again though, don't do that on this PR if you agree, I think this one is big enough already :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HI @dtfranz

I also want :-) That is what I expected we have at some point:

test-e2e - runs both operator-controller and catalogd e2e
upgrade-e2e runs for both

But that needs to be follow ups.
We need to do step by step

  • We need change the tests to no longer use Omega Ginkgo
  • Then, we can start to began to combine
  • We will need to combine as well the image registry and going on

We need to split. Otherwise, it is too much for a single go


# Catalogd e2e tests
FOCUS := $(if $(TEST),-v -focus "$(TEST)")
ifeq ($(origin E2E_FLAGS), undefined)
E2E_FLAGS :=
endif
test-catalogd-e2e: ## Run the e2e tests on existing cluster
$(GINKGO) $(E2E_FLAGS) -trace -vv $(FOCUS) test/catalogd-e2e

catalogd-e2e: KIND_CLUSTER_NAME := catalogd-e2e
catalogd-e2e: ISSUER_KIND := Issuer
catalogd-e2e: ISSUER_NAME := selfsigned-issuer
catalogd-e2e: CATALOGD_KUSTOMIZE_BUILD_DIR := catalogd/config/overlays/e2e
catalogd-e2e: run catalogd-image-registry test-catalogd-e2e ## kind-clean Run e2e test suite on local kind cluster

## image-registry target has to come after run-latest-release,
## because the image-registry depends on the olm-ca issuer.
.PHONY: test-catalogd-upgrade-e2e
test-catalogd-upgrade-e2e: export TEST_CLUSTER_CATALOG_NAME := test-catalog
test-catalogd-upgrade-e2e: export TEST_CLUSTER_CATALOG_IMAGE := docker-registry.catalogd-e2e.svc:5000/test-catalog:e2e
test-catalogd-upgrade-e2e: ISSUER_KIND=ClusterIssuer
test-catalogd-upgrade-e2e: ISSUER_NAME=olmv1-ca
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

.PHONY: catalogd-post-upgrade-checks
catalogd-post-upgrade-checks:
$(GINKGO) $(E2E_FLAGS) -trace -vv $(FOCUS) test/catalogd-upgrade-e2e

catalogd-pre-upgrade-setup:
./test/tools/imageregistry/pre-upgrade-setup.sh ${TEST_CLUSTER_CATALOG_IMAGE} ${TEST_CLUSTER_CATALOG_NAME}

catalogd-image-registry: ## Setup in-cluster image registry
./test/tools/imageregistry/registry.sh $(ISSUER_KIND) $(ISSUER_NAME)

.PHONY: extension-developer-e2e
extension-developer-e2e: KUSTOMIZE_BUILD_DIR := config/overlays/cert-manager
extension-developer-e2e: KIND_CLUSTER_NAME := operator-controller-ext-dev-e2e #EXHELP Run extension-developer e2e on local kind cluster
Expand Down Expand Up @@ -246,10 +283,9 @@ kind-load: $(KIND) #EXHELP Loads the currently constructed images into the KIND
kind-deploy: export MANIFEST := ./operator-controller.yaml
kind-deploy: export DEFAULT_CATALOG := ./catalogd/config/base/default/clustercatalogs/default-catalogs.yaml
kind-deploy: manifests $(KUSTOMIZE)
($(KUSTOMIZE) build $(KUSTOMIZE_BUILD_DIR) && echo "---" && $(KUSTOMIZE) build catalogd/config/overlays/cert-manager | sed "s/cert-git-version/cert-$(VERSION)/g") > $(MANIFEST)
($(KUSTOMIZE) build $(KUSTOMIZE_BUILD_DIR) && echo "---" && $(KUSTOMIZE) build $(CATALOGD_KUSTOMIZE_BUILD_DIR) | sed "s/cert-git-version/cert-$(VERSION)/g") > $(MANIFEST)
envsubst '$$DEFAULT_CATALOG,$$CERT_MGR_VERSION,$$INSTALL_DEFAULT_CATALOGS,$$MANIFEST' < scripts/install.tpl.sh | bash -s


.PHONY: kind-cluster
kind-cluster: $(KIND) #EXHELP Standup a kind cluster.
-$(KIND) delete cluster --name $(KIND_CLUSTER_NAME)
Expand Down Expand Up @@ -302,7 +338,12 @@ go-build-linux: export GOARCH=amd64
go-build-linux: $(BINARIES)

.PHONY: run
run: docker-build kind-cluster kind-load kind-deploy #HELP Build the operator-controller then deploy it into a new kind cluster.
run: generate docker-build kind-cluster kind-load kind-deploy wait #HELP Build the operator-controller then deploy it into a new kind cluster.

CATALOGD_NAMESPACE := olmv1-system
wait:
kubectl wait --for=condition=Available --namespace=$(CATALOGD_NAMESPACE) deployment/catalogd-controller-manager --timeout=60s
kubectl wait --for=condition=Ready --namespace=$(CATALOGD_NAMESPACE) certificate/catalogd-service-cert # Avoid upgrade test flakes when reissuing cert

.PHONY: docker-build
docker-build: build-linux #EXHELP Build docker image for operator-controller and catalog with GOOS=linux and local GOARCH.
Expand Down
97 changes: 2 additions & 95 deletions catalogd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ else
$(warning Could not find docker or podman in path! This may result in targets requiring a container runtime failing!)
endif

# For standard development and release flows, we use the config/overlays/cert-manager overlay.
KUSTOMIZE_OVERLAY := config/overlays/cert-manager

# bingo manages consistent tooling versions for things like kind, kustomize, etc.
include ./../.bingo/Variables.mk

Expand All @@ -38,14 +35,6 @@ ifeq ($(origin KIND_CLUSTER_NAME), undefined)
KIND_CLUSTER_NAME := catalogd
endif

# E2E configuration
TESTDATA_DIR := testdata

CATALOGD_NAMESPACE := olmv1-system
KIND_CLUSTER_IMAGE := kindest/node:v1.30.0@sha256:047357ac0cfea04663786a612ba1eaba9702bef25227a794b52890dd8bcd692e

GINKGO := go run github.com/onsi/ginkgo/v2/ginkgo

##@ General

# The help target prints out all targets with their descriptions organized
Expand Down Expand Up @@ -74,42 +63,6 @@ generate: $(CONTROLLER_GEN) ## Generate code and manifests.
$(CONTROLLER_GEN) object:headerFile="../hack/boilerplate.go.txt" paths="./..."
$(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/

FOCUS := $(if $(TEST),-v -focus "$(TEST)")
ifeq ($(origin E2E_FLAGS), undefined)
E2E_FLAGS :=
endif
test-e2e: ## Run the e2e tests on existing cluster
$(GINKGO) $(E2E_FLAGS) -trace -vv $(FOCUS) test/e2e

e2e: KIND_CLUSTER_NAME := catalogd-e2e
e2e: ISSUER_KIND := Issuer
e2e: ISSUER_NAME := selfsigned-issuer
e2e: KUSTOMIZE_OVERLAY := config/overlays/e2e
e2e: run image-registry test-e2e kind-cluster-cleanup ## Run e2e test suite on local kind cluster

image-registry: ## Setup in-cluster image registry
./test/tools/imageregistry/registry.sh $(ISSUER_KIND) $(ISSUER_NAME)

## image-registry target has to come after run-latest-release,
## because the image-registry depends on the olm-ca issuer.
.PHONY: test-upgrade-e2e
test-upgrade-e2e: export TEST_CLUSTER_CATALOG_NAME := test-catalog
test-upgrade-e2e: export TEST_CLUSTER_CATALOG_IMAGE := docker-registry.catalogd-e2e.svc:5000/test-catalog:e2e
test-upgrade-e2e: ISSUER_KIND=ClusterIssuer
test-upgrade-e2e: ISSUER_NAME=olmv1-ca
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

pre-upgrade-setup:
./test/tools/imageregistry/pre-upgrade-setup.sh ${TEST_CLUSTER_CATALOG_IMAGE} ${TEST_CLUSTER_CATALOG_NAME}

.PHONY: run-latest-release
run-latest-release:
cd ..; curl -L -s https://github.com/operator-framework/operator-controller/releases/latest/download/install.sh | bash -s

.PHONY: post-upgrade-checks
post-upgrade-checks:
$(GINKGO) $(E2E_FLAGS) -trace -vv $(FOCUS) test/upgrade

##@ Build

BINARIES=catalogd
Expand Down Expand Up @@ -157,62 +110,16 @@ $(LINUX_BINARIES): BUILDBIN = bin/linux
$(LINUX_BINARIES):
GOOS=linux $(BUILDCMD)


.PHONY: run
run: generate kind-cluster install ## Create a kind cluster and install a local build of catalogd

.PHONY: build-container
build-container: build-linux ## Build docker image for catalogd.
$(CONTAINER_RUNTIME) build -f Dockerfile -t $(IMAGE) ./bin/linux

##@ Deploy

.PHONY: kind-cluster
kind-cluster: $(KIND) kind-cluster-cleanup ## Standup a kind cluster
$(KIND) create cluster --name $(KIND_CLUSTER_NAME) --image $(KIND_CLUSTER_IMAGE)
$(KIND) export kubeconfig --name $(KIND_CLUSTER_NAME)

.PHONY: kind-cluster-cleanup
kind-cluster-cleanup: $(KIND) ## Delete the kind cluster
$(KIND) delete cluster --name $(KIND_CLUSTER_NAME)

.PHONY: kind-load
kind-load: check-cluster $(KIND) ## Load the built images onto the local cluster
kind-load: $(KIND) ## Load the built images onto the local cluster
$(CONTAINER_RUNTIME) save $(IMAGE) | $(KIND) load image-archive /dev/stdin --name $(KIND_CLUSTER_NAME)

.PHONY: install
install: check-cluster build-container kind-load deploy wait ## Install local catalogd to an existing cluster

.PHONY: deploy
deploy: export MANIFEST="./catalogd.yaml"
deploy: export DEFAULT_CATALOGS="./config/base/default/clustercatalogs/default-catalogs.yaml"
deploy: $(KUSTOMIZE) ## Deploy Catalogd to the K8s cluster specified in ~/.kube/config with cert-manager and default clustercatalogs
cd config/base/manager && $(KUSTOMIZE) edit set image controller=$(IMAGE) && cd ../../..
$(KUSTOMIZE) build $(KUSTOMIZE_OVERLAY) | sed "s/cert-git-version/cert-$(GIT_VERSION)/g" > catalogd.yaml
envsubst '$$CERT_MGR_VERSION,$$MANIFEST,$$DEFAULT_CATALOGS' < scripts/install.tpl.sh | bash -s

.PHONY: only-deploy-manifest
only-deploy-manifest: $(KUSTOMIZE) ## Deploy just the Catalogd manifest--used in e2e testing where cert-manager is installed in a separate step
cd config/base/manager && $(KUSTOMIZE) edit set image controller=$(IMAGE)
$(KUSTOMIZE) build $(KUSTOMIZE_OVERLAY) | kubectl apply -f -

wait:
kubectl wait --for=condition=Available --namespace=$(CATALOGD_NAMESPACE) deployment/catalogd-controller-manager --timeout=60s
kubectl wait --for=condition=Ready --namespace=$(CATALOGD_NAMESPACE) certificate/catalogd-service-cert # Avoid upgrade test flakes when reissuing cert


.PHONY: cert-manager
cert-manager:
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/${CERT_MGR_VERSION}/cert-manager.yaml
kubectl wait --for=condition=Available --namespace=cert-manager deployment/cert-manager-webhook --timeout=60s
##@ Deploy

.PHONY: demo-update
demo-update:
hack/scripts/generate-asciidemo.sh

.PHONY: check-cluster
check-cluster:
@kubectl config current-context >/dev/null 2>&1 || ( \
echo "Error: Could not get current Kubernetes context. Maybe use 'run' or 'e2e' targets first?"; \
exit 1; \
)
45 changes: 0 additions & 45 deletions catalogd/scripts/install.tpl.sh

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package e2e
package catalogde2e

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package e2e
package catalogde2e

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

expectedFBC, err := os.ReadFile("../../testdata/catalogs/test-catalog/expected_all.json")
expectedFBC, err := os.ReadFile("../../catalogd/testdata/catalogs/test-catalog/expected_all.json")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expect(err).To(Not(HaveOccurred()))
Expect(cmp.Diff(expectedFBC, actualFBC)).To(BeEmpty())

Expand Down
2 changes: 1 addition & 1 deletion catalogd/test/e2e/util.go → test/catalogd-e2e/util.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package e2e
package catalogde2e

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package upgradee2e
package catalogdupgradee2e

import (
"bufio"
Expand All @@ -21,7 +21,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"

catalogdv1 "github.com/operator-framework/operator-controller/catalogd/api/v1"
"github.com/operator-framework/operator-controller/catalogd/test/e2e"
catalogde2e "github.com/operator-framework/operator-controller/test/catalogd-e2e"
)

var _ = Describe("ClusterCatalog Unpacking", func() {
Expand Down Expand Up @@ -87,12 +87,12 @@ var _ = Describe("ClusterCatalog Unpacking", func() {
g.Expect(cond.Reason).To(Equal(catalogdv1.ReasonSucceeded))
}).Should(Succeed())

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

By("Making sure the catalog content is available via the http server")
Eventually(func(g Gomega) {
actualFBC, err := e2e.ReadTestCatalogServerContents(ctx, catalog, c, kubeClient)
actualFBC, err := catalogde2e.ReadTestCatalogServerContents(ctx, catalog, c, kubeClient)
g.Expect(err).To(Not(HaveOccurred()))
g.Expect(cmp.Diff(expectedFBC, actualFBC)).To(BeEmpty())
}).Should(Succeed())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package upgradee2e
package catalogdupgradee2e

import (
"os"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ envsubst '${ISSUER_KIND},${ISSUER_NAME}' < test/tools/imageregistry/imgreg.yaml
kubectl wait -n catalogd-e2e --for=condition=Available deployment/docker-registry --timeout=60s

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

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