Skip to content

Commit 34bd607

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

15 files changed

+14579
-10
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: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ import (
1818
)
1919

2020
const (
21-
defaultTimeout = 30 * time.Second
22-
defaultPoll = 1 * time.Second
21+
defaultTimeout = 30 * time.Second
22+
defaultPoll = 1 * time.Second
23+
testCatalogRef = "localhost/testdata/catalogs/test-catalog:e2e"
24+
testCatalogName = "test-catalog"
2325
)
2426

2527
var _ = Describe("Operator Install", func() {
@@ -33,7 +35,7 @@ var _ = Describe("Operator Install", func() {
3335
When("An operator is installed from an operator catalog", func() {
3436
BeforeEach(func() {
3537
ctx = context.Background()
36-
pkgName = "argocd-operator"
38+
pkgName = "prometheus"
3739
operatorName = fmt.Sprintf("operator-%s", rand.String(8))
3840
operator = &operatorv1alpha1.Operator{
3941
ObjectMeta: metav1.ObjectMeta{
@@ -45,15 +47,13 @@ var _ = Describe("Operator Install", func() {
4547
}
4648
operatorCatalog = &catalogd.Catalog{
4749
ObjectMeta: metav1.ObjectMeta{
48-
Name: "test-catalog",
50+
Name: testCatalogName,
4951
},
5052
Spec: catalogd.CatalogSpec{
5153
Source: catalogd.CatalogSource{
5254
Type: catalogd.SourceTypeImage,
5355
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",
56+
Ref: testCatalogRef,
5757
},
5858
},
5959
},
@@ -63,15 +63,15 @@ var _ = Describe("Operator Install", func() {
6363
err := c.Create(ctx, operatorCatalog)
6464
Expect(err).ToNot(HaveOccurred())
6565
Eventually(func(g Gomega) {
66-
err = c.Get(ctx, types.NamespacedName{Name: "test-catalog"}, operatorCatalog)
66+
err = c.Get(ctx, types.NamespacedName{Name: testCatalogName}, operatorCatalog)
6767
g.Expect(err).ToNot(HaveOccurred())
6868
g.Expect(len(operatorCatalog.Status.Conditions)).To(Equal(1))
6969
cond := apimeta.FindStatusCondition(operatorCatalog.Status.Conditions, catalogd.TypeUnpacked)
7070
g.Expect(cond).ToNot(BeNil())
7171
g.Expect(cond.Status).To(Equal(metav1.ConditionTrue))
7272
g.Expect(cond.Reason).To(Equal(catalogd.ReasonUnpackSuccessful))
7373
g.Expect(cond.Message).To(ContainSubstring("successfully unpacked the catalog image"))
74-
}).WithTimeout(5 * time.Minute).WithPolling(defaultPoll).Should(Succeed())
74+
}).WithTimeout(defaultTimeout).WithPolling(defaultPoll).Should(Succeed())
7575

7676
By("creating the Operator resource")
7777
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

0 commit comments

Comments
 (0)