Skip to content

Commit 9fef81b

Browse files
committed
(e2e) Use custom built test catalog for e2e testing
closes #215 Signed-off-by: Anik <[email protected]>
1 parent 25cdc88 commit 9fef81b

15 files changed

+14649
-6
lines changed

Makefile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@ export GORELEASER_VERSION ?= v1.16.2
1111
export RUKPAK_VERSION=$(shell go list -mod=mod -m -f "{{.Version}}" github.com/operator-framework/rukpak)
1212
export WAIT_TIMEOUT ?= 60s
1313
IMG?=$(IMAGE_REPO):$(IMAGE_TAG)
14+
TESTDATA_DIR := testdata
1415

1516
OPERATOR_CONTROLLER_NAMESPACE ?= operator-controller-system
1617
KIND_CLUSTER_NAME ?= operator-controller
1718

19+
CONTAINER_RUNTIME ?= docker
20+
1821
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
1922
ifeq (,$(shell go env GOBIN))
2023
GOBIN=$(shell go env GOPATH)/bin
@@ -82,7 +85,7 @@ test-unit: envtest ## Run the unit tests
8285
eval $$($(ENVTEST) use -p env $(ENVTEST_VERSION)) && go test -tags $(GO_BUILD_TAGS) -count=1 -short $(UNIT_TEST_DIRS) -coverprofile cover.out
8386

8487
e2e: KIND_CLUSTER_NAME=operator-controller-e2e
85-
e2e: run test-e2e kind-cluster-cleanup ## Run e2e test suite on local kind cluster
88+
e2e: run kind-load-test-artifacts test-e2e kind-cluster-cleanup ## Run e2e test suite on local kind cluster
8689

8790
kind-load: kind ## Loads the currently constructed image onto the cluster
8891
$(KIND) load docker-image $(IMG) --name $(KIND_CLUSTER_NAME)
@@ -94,6 +97,12 @@ kind-cluster: kind kind-cluster-cleanup ## Standup a kind cluster
9497
kind-cluster-cleanup: kind ## Delete the kind cluster
9598
$(KIND) delete cluster --name ${KIND_CLUSTER_NAME}
9699

100+
kind-load-test-artifacts: kind ## Load the e2e testdata container images into a kind cluster
101+
$(CONTAINER_RUNTIME) build $(TESTDATA_DIR)/bundles/registry-v1/prometheus-operator.v0.47.0 -t localhost/testdata/bundles/registry-v1/prometheus-operator:v0.47.0
102+
$(CONTAINER_RUNTIME) build $(TESTDATA_DIR)/catalogs -f $(TESTDATA_DIR)/catalogs/test-catalog.Dockerfile -t localhost/testdata/catalogs/test-catalog:e2e
103+
$(KIND) load docker-image localhost/testdata/bundles/registry-v1/prometheus-operator:v0.47.0 --name $(KIND_CLUSTER_NAME)
104+
$(KIND) load docker-image localhost/testdata/catalogs/test-catalog:e2e --name $(KIND_CLUSTER_NAME)
105+
97106
##@ Build
98107

99108
BUILDCMD = sh -c 'mkdir -p $(BUILDBIN) && ${GORELEASER} build ${GORELEASER_ARGS} --single-target -o $(BUILDBIN)/manager'

test/e2e/install_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
const (
2121
defaultTimeout = 30 * time.Second
2222
defaultPoll = 1 * time.Second
23+
testCatalogRef = "localhost/testdata/catalogs/test-catalog:e2e"
2324
)
2425

2526
var _ = Describe("Operator Install", func() {
@@ -33,7 +34,7 @@ var _ = Describe("Operator Install", func() {
3334
When("An operator is installed from an operator catalog", func() {
3435
BeforeEach(func() {
3536
ctx = context.Background()
36-
pkgName = "argocd-operator"
37+
pkgName = "prometheus"
3738
operatorName = fmt.Sprintf("operator-%s", rand.String(8))
3839
operator = &operatorv1alpha1.Operator{
3940
ObjectMeta: metav1.ObjectMeta{
@@ -51,9 +52,7 @@ var _ = Describe("Operator Install", func() {
5152
Source: catalogd.CatalogSource{
5253
Type: catalogd.SourceTypeImage,
5354
Image: &catalogd.ImageSource{
54-
// (TODO): Set up a local image registry, and build and store a test catalog in it
55-
// to use in the test suite
56-
Ref: "quay.io/olmtest/e2e-index:single-package-fbc", //generated from: "quay.io/operatorhubio/catalog:latest",
55+
Ref: testCatalogRef,
5756
},
5857
},
5958
},
@@ -71,7 +70,7 @@ var _ = Describe("Operator Install", func() {
7170
g.Expect(cond.Status).To(Equal(metav1.ConditionTrue))
7271
g.Expect(cond.Reason).To(Equal(catalogd.ReasonUnpackSuccessful))
7372
g.Expect(cond.Message).To(ContainSubstring("successfully unpacked the catalog image"))
74-
}).WithTimeout(5 * time.Minute).WithPolling(defaultPoll).Should(Succeed())
73+
}).WithTimeout(defaultTimeout).WithPolling(defaultPoll).Should(Succeed())
7574

7675
By("creating the Operator resource")
7776
err = c.Create(ctx, operator)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM scratch
2+
COPY manifests /manifests
3+
COPY metadata /metadata

testdata/bundles/registry-v1/prometheus-operator.v0.47.0/manifests/alertmanagerconfigs.monitoring.coreos.com.crd.yaml

Lines changed: 1866 additions & 0 deletions
Large diffs are not rendered by default.

testdata/bundles/registry-v1/prometheus-operator.v0.47.0/manifests/alertmanagers.monitoring.coreos.com.crd.yaml

Lines changed: 3215 additions & 0 deletions
Large diffs are not rendered by default.

testdata/bundles/registry-v1/prometheus-operator.v0.47.0/manifests/podmonitors.monitoring.coreos.com.crd.yaml

Lines changed: 355 additions & 0 deletions
Large diffs are not rendered by default.

testdata/bundles/registry-v1/prometheus-operator.v0.47.0/manifests/probes.monitoring.coreos.com.crd.yaml

Lines changed: 341 additions & 0 deletions
Large diffs are not rendered by default.

testdata/bundles/registry-v1/prometheus-operator.v0.47.0/manifests/prometheuses.monitoring.coreos.com.crd.yaml

Lines changed: 4444 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)