diff --git a/Makefile b/Makefile index 1c72c8b..3f868d6 100644 --- a/Makefile +++ b/Makefile @@ -163,6 +163,7 @@ test-olm: operator-sdk opm-index ./config/operatorhub/flux-operator/testdata/003-catalog-source.yaml export OLM_VERSION=${OLM_VERSION} && \ export FLUX_OPERATOR_VERSION=${FLUX_OPERATOR_VERSION} && \ + export OPERATOR_SDK_BIN=$(OPERATOR_SDK) && \ go test ./test/olm/ -v -ginkgo.v .PHONY: deploy-olm-data @@ -186,7 +187,7 @@ KUSTOMIZE ?= $(LOCALBIN)/kustomize-$(KUSTOMIZE_VERSION) CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen-$(CONTROLLER_TOOLS_VERSION) ENVTEST ?= $(LOCALBIN)/setup-envtest-$(ENVTEST_VERSION) GOLANGCI_LINT = $(LOCALBIN)/golangci-lint-$(GOLANGCI_LINT_VERSION) -OPERATOR_SDK ?= $(LOCALBIN)/operator-sdk +OPERATOR_SDK ?= $(LOCALBIN)/operator-sdk-$(OPERATOR_SDK_VERSION) ## Tool Versions KUSTOMIZE_VERSION ?= v5.4.1 diff --git a/test/olm/e2e_test.go b/test/olm/e2e_test.go index 1d736dc..bd0bee7 100644 --- a/test/olm/e2e_test.go +++ b/test/olm/e2e_test.go @@ -13,14 +13,16 @@ import ( ) const ( - namespace = "flux-system" - defaultVersion = "v0.3.0" - defaultOLMVersion = "v0.28.0" + namespace = "flux-system" + defaultVersion = "v0.3.0" + defaultOLMVersion = "v0.28.0" + defaultOperatorsdkBin = "bin/operator-sdk" ) var ( - version string - img string + version string + img string + operatorsdkBin string ) // Build the flux-operator image and deploy it to the Kind cluster. @@ -34,6 +36,11 @@ var _ = BeforeSuite(func() { olmVersion = defaultOLMVersion } + operatorsdkBin = os.Getenv("OPERATOR_SDK_BIN") + if operatorsdkBin == "" { + operatorsdkBin = defaultOperatorsdkBin + } + img = fmt.Sprintf("ghcr.io/controlplaneio-fluxcd/openshift-flux-operator-catalog:bundle-%s", version) opm := fmt.Sprintf("ghcr.io/controlplaneio-fluxcd/openshift-flux-operator-index:%s", version) @@ -44,9 +51,9 @@ var _ = BeforeSuite(func() { ExpectWithOffset(1, err).NotTo(HaveOccurred()) By("installing OLM") - cmd := exec.Command("bin/operator-sdk", "olm", "install", "--version", olmVersion) + cmd := exec.Command(operatorsdkBin, "olm", "install", "--version", olmVersion) _, err = utils.Run(cmd, "/test/olm") - ExpectWithOffset(1, err).NotTo(HaveOccurred()) + ExpectWithOffset(3, err).NotTo(HaveOccurred()) By("deploying flux-operator olm kubernetes resources") cmd = exec.Command("make", "deploy-olm-data") diff --git a/test/olm/scorecard_test.go b/test/olm/scorecard_test.go index dc7fab2..15c4f86 100644 --- a/test/olm/scorecard_test.go +++ b/test/olm/scorecard_test.go @@ -12,7 +12,7 @@ var _ = Describe("Scorecard", Ordered, func() { Context("test", func() { It("should run successfully", func() { By("run scorecard tests") - cmd := exec.Command("bin/operator-sdk", "scorecard", + cmd := exec.Command(operatorsdkBin, "scorecard", img, "-c", "config/operatorhub/flux-operator/"+version+"/tests/scorecard/config.yaml", "-w", "60s", "-o", "json") _, err := utils.Run(cmd, "/test/olm")