diff --git a/.github/workflows/e2e-test.yaml b/.github/workflows/e2e-test.yaml index 30b7a6b3c..484d36248 100644 --- a/.github/workflows/e2e-test.yaml +++ b/.github/workflows/e2e-test.yaml @@ -6,6 +6,9 @@ on: - master pull_request: +env: + REPOSITORY: koperator_e2e_test + jobs: build: runs-on: ubuntu-latest @@ -18,15 +21,24 @@ jobs: - name: Checkout code uses: actions/checkout@v3 + + - name: Build docker image + run: | + IMG=$REPOSITORY:$GITHUB_SHA make docker-build - name: Setup Kind cluster id: setup-kind uses: ./.github/actions/kind-create - - name: run tests + - name: Load image into kind cluster + run: | + kind load docker-image $REPOSITORY:$GITHUB_SHA --name e2e-kind + + + - name: Run E2E tests env: KUBECONFIG: ${{ steps.setup-kind.outputs.kubeconfig }} run: | go work init go work use -r . - make test-e2e + IMG_E2E=$REPOSITORY:$GITHUB_SHA make test-e2e diff --git a/Makefile b/Makefile index 52c993e0f..ef78467e8 100644 --- a/Makefile +++ b/Makefile @@ -97,8 +97,9 @@ test: generate fmt vet manifests bin/setup-envtest ## Run unit and integration ( -timeout 1h cd properties && go test -coverprofile cover.out -cover -failfast -v -covermode=count ./pkg/... ./internal/... -test-e2e: # Run e2e tests. - go test github.com/banzaicloud/koperator/tests/e2e \ +# Run e2e tests +test-e2e: + IMG_E2E=${IMG_E2E} go test github.com/banzaicloud/koperator/tests/e2e \ -v \ -timeout 20m \ -tags e2e \ diff --git a/tests/e2e/global.go b/tests/e2e/global.go index 3935a19e6..6baa274f4 100644 --- a/tests/e2e/global.go +++ b/tests/e2e/global.go @@ -16,6 +16,8 @@ package e2e import ( "errors" + "os" + "strings" ) // HelmDescriptors. @@ -35,18 +37,39 @@ var ( // koperatorLocalHelmDescriptor describes the Koperator Helm component with // a local chart and version. - koperatorLocalHelmDescriptor = helmDescriptor{ - Repository: "../../charts/kafka-operator", - ChartVersion: LocalVersion, - ReleaseName: "kafka-operator", - Namespace: "kafka", - LocalCRDSubpaths: []string{ - "crds/cruisecontroloperations.yaml", - "crds/kafkaclusters.yaml", - "crds/kafkatopics.yaml", - "crds/kafkausers.yaml", - }, - } + koperatorLocalHelmDescriptor = func() helmDescriptor { + koperatorLocalHelmDescriptor := helmDescriptor{ + Repository: "../../charts/kafka-operator", + ChartVersion: LocalVersion, + ReleaseName: "kafka-operator", + Namespace: "kafka", + LocalCRDSubpaths: []string{ + "crds/cruisecontroloperations.yaml", + "crds/kafkaclusters.yaml", + "crds/kafkatopics.yaml", + "crds/kafkausers.yaml", + }, + } + // Set helm chart values for Koperator to be able to use custom image + koperatorImagePath := os.Getenv("IMG_E2E") + if koperatorImagePath != "" { + koperatorImagePathSplit := strings.Split(koperatorImagePath, ":") + + koperatorImageRepository := koperatorImagePathSplit[0] + koperatorImageTag := "latest" + + if len(koperatorImagePathSplit) == 2 { + koperatorImageTag = koperatorImagePathSplit[1] + } + + koperatorLocalHelmDescriptor.SetValues = map[string]string{ + "operator.image.repository": koperatorImageRepository, + "operator.image.tag": koperatorImageTag, + } + } + + return koperatorLocalHelmDescriptor + }() // koperatorLocalHelmDescriptor describes the Koperator Helm component with // a remote latest chart and version.