Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(e2e) Use custom built test catalog for e2e testing #250

Merged
merged 1 commit into from
Jun 5, 2023
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
11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ export GORELEASER_VERSION ?= v1.16.2
export RUKPAK_VERSION=$(shell go list -mod=mod -m -f "{{.Version}}" github.com/operator-framework/rukpak)
export WAIT_TIMEOUT ?= 60s
IMG?=$(IMAGE_REPO):$(IMAGE_TAG)
TESTDATA_DIR := testdata

OPERATOR_CONTROLLER_NAMESPACE ?= operator-controller-system
KIND_CLUSTER_NAME ?= operator-controller

CONTAINER_RUNTIME ?= docker

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

e2e: KIND_CLUSTER_NAME=operator-controller-e2e
e2e: run test-e2e kind-cluster-cleanup ## Run e2e test suite on local kind cluster
e2e: run kind-load-test-artifacts test-e2e kind-cluster-cleanup ## Run e2e test suite on local kind cluster

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

kind-load-test-artifacts: kind ## Load the e2e testdata container images into a kind cluster
$(CONTAINER_RUNTIME) build $(TESTDATA_DIR)/bundles/registry-v1/prometheus-operator.v0.47.0 -t localhost/testdata/bundles/registry-v1/prometheus-operator:v0.47.0
everettraven marked this conversation as resolved.
Show resolved Hide resolved
$(CONTAINER_RUNTIME) build $(TESTDATA_DIR)/catalogs -f $(TESTDATA_DIR)/catalogs/test-catalog.Dockerfile -t localhost/testdata/catalogs/test-catalog:e2e
$(KIND) load docker-image localhost/testdata/bundles/registry-v1/prometheus-operator:v0.47.0 --name $(KIND_CLUSTER_NAME)
$(KIND) load docker-image localhost/testdata/catalogs/test-catalog:e2e --name $(KIND_CLUSTER_NAME)

##@ Build

BUILDCMD = sh -c 'mkdir -p $(BUILDBIN) && ${GORELEASER} build ${GORELEASER_ARGS} --single-target -o $(BUILDBIN)/manager'
Expand Down
18 changes: 9 additions & 9 deletions test/e2e/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ import (
)

const (
defaultTimeout = 30 * time.Second
defaultPoll = 1 * time.Second
defaultTimeout = 30 * time.Second
defaultPoll = 1 * time.Second
testCatalogRef = "localhost/testdata/catalogs/test-catalog:e2e"
testCatalogName = "test-catalog"
)

var _ = Describe("Operator Install", func() {
Expand All @@ -33,7 +35,7 @@ var _ = Describe("Operator Install", func() {
When("An operator is installed from an operator catalog", func() {
BeforeEach(func() {
ctx = context.Background()
pkgName = "argocd-operator"
pkgName = "prometheus"
operatorName = fmt.Sprintf("operator-%s", rand.String(8))
operator = &operatorv1alpha1.Operator{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -45,15 +47,13 @@ var _ = Describe("Operator Install", func() {
}
operatorCatalog = &catalogd.Catalog{
ObjectMeta: metav1.ObjectMeta{
Name: "test-catalog",
Name: testCatalogName,
},
Spec: catalogd.CatalogSpec{
Source: catalogd.CatalogSource{
Type: catalogd.SourceTypeImage,
Image: &catalogd.ImageSource{
// (TODO): Set up a local image registry, and build and store a test catalog in it
// to use in the test suite
Ref: "quay.io/olmtest/e2e-index:single-package-fbc", //generated from: "quay.io/operatorhubio/catalog:latest",
Ref: testCatalogRef,
},
},
},
Expand All @@ -63,15 +63,15 @@ var _ = Describe("Operator Install", func() {
err := c.Create(ctx, operatorCatalog)
Expect(err).ToNot(HaveOccurred())
Eventually(func(g Gomega) {
err = c.Get(ctx, types.NamespacedName{Name: "test-catalog"}, operatorCatalog)
err = c.Get(ctx, types.NamespacedName{Name: testCatalogName}, operatorCatalog)
g.Expect(err).ToNot(HaveOccurred())
g.Expect(len(operatorCatalog.Status.Conditions)).To(Equal(1))
cond := apimeta.FindStatusCondition(operatorCatalog.Status.Conditions, catalogd.TypeUnpacked)
g.Expect(cond).ToNot(BeNil())
g.Expect(cond.Status).To(Equal(metav1.ConditionTrue))
g.Expect(cond.Reason).To(Equal(catalogd.ReasonUnpackSuccessful))
g.Expect(cond.Message).To(ContainSubstring("successfully unpacked the catalog image"))
}).WithTimeout(5 * time.Minute).WithPolling(defaultPoll).Should(Succeed())
}).WithTimeout(defaultTimeout).WithPolling(defaultPoll).Should(Succeed())

By("creating the Operator resource")
err = c.Create(ctx, operator)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM scratch
COPY manifests /manifests
COPY metadata /metadata
Loading
Loading