Skip to content

Commit

Permalink
fix(e2e): not using up to date koperator image for e2e test (#1052)
Browse files Browse the repository at this point in the history
  • Loading branch information
bartam1 authored Aug 31, 2023
1 parent aa018ad commit 2feac63
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 16 deletions.
16 changes: 14 additions & 2 deletions .github/workflows/e2e-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
- master
pull_request:

env:
REPOSITORY: koperator_e2e_test

jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -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
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
47 changes: 35 additions & 12 deletions tests/e2e/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ package e2e

import (
"errors"
"os"
"strings"
)

// HelmDescriptors.
Expand All @@ -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.
Expand Down

0 comments on commit 2feac63

Please sign in to comment.