From d164324c3929b16d3b33678c82a7624f997cb6a0 Mon Sep 17 00:00:00 2001 From: Stefan Prodan Date: Tue, 11 Jun 2024 12:36:43 +0300 Subject: [PATCH] Improve OPM build for e2e testing Signed-off-by: Stefan Prodan --- Makefile | 2 +- .../flux-operator/{Dockerfile.opm => opm.Dockerfile} | 0 config/operatorhub/flux-operator/scripts/opm-index.sh | 5 ++--- test/olm/e2e_test.go | 11 ++++++++++- test/olm/scorecard_test.go | 5 +++-- 5 files changed, 16 insertions(+), 7 deletions(-) rename config/operatorhub/flux-operator/{Dockerfile.opm => opm.Dockerfile} (100%) diff --git a/Makefile b/Makefile index 3f868d6..e425748 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ IMG ?= ghcr.io/controlplaneio-fluxcd/flux-operator:latest # FLUX_OPERATOR_VERSION refers to the version of the operator to be tested # under ./config/operatorhub/flux-operator/ directory. -FLUX_OPERATOR_VERSION ?= v0.1.0 +FLUX_OPERATOR_VERSION ?= $(shell gh release view --json tagName -q '.tagName') # OLM_VERSION refers to the version of the Operator Lifecycle Manager to be used. OLM_VERSION ?= 0.28.0 diff --git a/config/operatorhub/flux-operator/Dockerfile.opm b/config/operatorhub/flux-operator/opm.Dockerfile similarity index 100% rename from config/operatorhub/flux-operator/Dockerfile.opm rename to config/operatorhub/flux-operator/opm.Dockerfile diff --git a/config/operatorhub/flux-operator/scripts/opm-index.sh b/config/operatorhub/flux-operator/scripts/opm-index.sh index d7bc8b4..510096e 100755 --- a/config/operatorhub/flux-operator/scripts/opm-index.sh +++ b/config/operatorhub/flux-operator/scripts/opm-index.sh @@ -27,10 +27,9 @@ docker build -t ghcr.io/controlplaneio-fluxcd/openshift-flux-operator-catalog:bu -f "${DIR}/bundle.Dockerfile" "${DIR}/${VERSION}" docker push ghcr.io/controlplaneio-fluxcd/openshift-flux-operator-catalog:bundle-"${VERSION}" -docker build -t opm --build-arg ARCH=$ARCH -f "${DIR}/Dockerfile.opm" . +docker build -t opm --build-arg ARCH=$ARCH -f "${DIR}/opm.Dockerfile" . -docker run --rm -it \ - --privileged \ +docker run --rm --privileged \ -v /var/lib/docker:/var/lib/docker \ -v /var/run/docker.sock:/var/run/docker.sock \ opm:latest index add \ diff --git a/test/olm/e2e_test.go b/test/olm/e2e_test.go index bd0bee7..1381137 100644 --- a/test/olm/e2e_test.go +++ b/test/olm/e2e_test.go @@ -7,9 +7,10 @@ import ( "strings" "time" - utils "github.com/controlplaneio-fluxcd/flux-operator/test/e2e" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" + + utils "github.com/controlplaneio-fluxcd/flux-operator/test/e2e" ) const ( @@ -97,4 +98,12 @@ var _ = AfterSuite(func() { cmd := exec.Command("make", "undeploy-olm-data") _, err := utils.Run(cmd, "/test/olm") Expect(err).NotTo(HaveOccurred()) + + operatorsdkBin = os.Getenv("OPERATOR_SDK_BIN") + if operatorsdkBin == "" { + operatorsdkBin = defaultOperatorsdkBin + } + cmd = exec.Command(operatorsdkBin, "olm", "uninstall") + _, err = utils.Run(cmd, "/test/olm") + Expect(err).NotTo(HaveOccurred()) }) diff --git a/test/olm/scorecard_test.go b/test/olm/scorecard_test.go index 15c4f86..674d003 100644 --- a/test/olm/scorecard_test.go +++ b/test/olm/scorecard_test.go @@ -3,9 +3,10 @@ package e2eolm import ( "os/exec" - utils "github.com/controlplaneio-fluxcd/flux-operator/test/e2e" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" + + utils "github.com/controlplaneio-fluxcd/flux-operator/test/e2e" ) var _ = Describe("Scorecard", Ordered, func() { @@ -14,7 +15,7 @@ var _ = Describe("Scorecard", Ordered, func() { By("run scorecard tests") cmd := exec.Command(operatorsdkBin, "scorecard", img, "-c", "config/operatorhub/flux-operator/"+version+"/tests/scorecard/config.yaml", - "-w", "60s", "-o", "json") + "-w", "5m", "-o", "json") _, err := utils.Run(cmd, "/test/olm") ExpectWithOffset(2, err).NotTo(HaveOccurred()) })