Skip to content

Commit 3a2a9d4

Browse files
authored
Fix & unify helm test setup as make rules (#2867)
* Fix & unify helm test setup as make rules * Allow to customize the test registry * Skip Ci kind to use makefile kind cluster instead Signed-off-by: jose.vazquez <jose.vazquez@mongodb.com> --------- Signed-off-by: jose.vazquez <jose.vazquez@mongodb.com>
1 parent 3c93dc2 commit 3a2a9d4

File tree

7 files changed

+51
-137
lines changed

7 files changed

+51
-137
lines changed

.github/workflows/test-e2e-gov.yml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,10 @@ jobs:
1414
uses: actions/checkout@v5
1515
with:
1616
submodules: true
17-
- name: Create k8s Kind Cluster
18-
if: ${{ !env.ACT }}
19-
uses: helm/kind-action@v1.13.0
20-
with:
21-
version: v0.29.0
22-
config: test/helper/e2e/config/kind.yaml
23-
cluster_name: "atlas-gov-e2e-test"
24-
wait: 180s
2517
- name: Install devbox
2618
uses: jetify-com/devbox-install-action@v0.14.0
2719
with:
2820
enable-cache: 'true'
29-
- name: Install CRDs
30-
run: devbox run -- 'make install'
3121
- name: Run e2e test
3222
env:
3323
MCLI_PUBLIC_API_KEY: ${{ secrets.ATLAS_GOV_PUBLIC_KEY }}
@@ -39,7 +29,8 @@ jobs:
3929
AWS_ACCOUNT_ARN_LIST: ${{ secrets.AWS_ACCOUNT_ARN_LIST }}
4030
PAGER_DUTY_SERVICE_KEY: ${{ secrets.PAGER_DUTY_SERVICE_KEY }}
4131
TEST_NAME: "atlas-gov"
42-
run: devbox run -- ./scripts/launch-ci-e2e.sh
32+
USE_NEXT_VERSION: "true"
33+
run: devbox run -- make e2e label=${{ env.TEST_NAME}}
4334
- name: Upload operator logs
4435
if: ${{ failure() }}
4536
uses: actions/upload-artifact@v5

.github/workflows/test-e2e.yml

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -133,31 +133,14 @@ jobs:
133133
run: |
134134
devbox run -- make bundle
135135
136-
137136
- name: Extract k8s version/platform
138137
id: extract
139138
run: |
140139
echo "k8s_version=$(echo '${{ matrix.k8s }}' | awk -F '-' '{print $1}')" >> $GITHUB_OUTPUT
141140
echo "k8s_platform=$(echo '${{ matrix.k8s }}' | awk -F '-' '{print $2}')" >> $GITHUB_OUTPUT
142141
143-
- name: Setup kind cluster
144-
if: ${{ steps.extract.outputs.k8s_platform == 'kind' }}
145-
uses: helm/kind-action@v1.13.0
146-
with:
147-
version: v0.29.0
148-
config: test/helper/e2e/config/kind.yaml
149-
node_image: kindest/node:${{ steps.extract.outputs.k8s_version }}
150-
cluster_name: ${{ matrix.test }}-${{ matrix.k8s }}
151-
wait: 180s
152-
153-
- name: Print Kubernetes version
154-
run: devbox run -- kubectl version
155-
156-
- name: Apply CRDs
157-
run: devbox run -- make install-crds
158-
159142
- name: Run CI E2E tests
160-
run: devbox run -- ./scripts/launch-ci-e2e.sh
143+
run: devbox run -- make e2e label=${{ env.TEST_NAME}}
161144
env:
162145
TEST_NAME: ${{ matrix.test }}
163146
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
@@ -210,21 +193,8 @@ jobs:
210193
echo "k8s_version=$(echo '${{ matrix.k8s }}' | awk -F '-' '{print $1}')" >> $GITHUB_OUTPUT
211194
echo "k8s_platform=$(echo '${{ matrix.k8s }}' | awk -F '-' '{print $2}')" >> $GITHUB_OUTPUT
212195
213-
- name: Setup kind cluster
214-
if: ${{ steps.extract.outputs.k8s_platform == 'kind' }}
215-
uses: helm/kind-action@v1.13.0
216-
with:
217-
version: v0.29.0
218-
config: test/helper/e2e/config/kind.yaml
219-
node_image: kindest/node:${{ steps.extract.outputs.k8s_version }}
220-
cluster_name: ${{ matrix.test }}-${{ matrix.k8s }}
221-
wait: 180s
222-
223-
- name: Print Kubernetes version
224-
run: devbox run -- kubectl version
225-
226196
- name: Run CI helm-E2E test with prepared image
227-
run: devbox run -- ./scripts/launch-ci-e2e.sh
197+
run: devbox run -- make e2e label=${{ env.TEST_NAME }}
228198
env:
229199
TEST_NAME: ${{ matrix.test }}
230200
IMAGE_PULL_SECRET_REGISTRY: ghcr.io

.github/workflows/tests-e2e2.yaml

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -150,37 +150,17 @@ jobs:
150150
echo "k8s_version=$version" >> $GITHUB_OUTPUT
151151
echo "k8s_platform=$platform" >> $GITHUB_OUTPUT
152152
153-
- name: Create k8s Kind Cluster
154-
if: ${{ steps.properties.outputs.k8s_platform == 'kind' && !env.ACT }}
155-
uses: helm/kind-action@v1.13.0
156-
with:
157-
version: v0.29.0
158-
config: test/helper/e2e/config/kind.yaml
159-
node_image: kindest/node:${{ steps.properties.outputs.k8s_version }}
160-
cluster_name: ${{ matrix.test }}
161-
wait: 180s
162-
163-
- name: Print kubectl version
164-
run: |
165-
devbox run -- 'kubectl version'
166-
167-
- name: Install CRDs if needed
168-
run: |
169-
devbox run -- 'make install-crds'
170-
devbox run -- 'make bundle'
171-
172153
- name: Run E2E2 test
173154
env:
174155
MCLI_PUBLIC_API_KEY: ${{ secrets.ATLAS_PUBLIC_KEY }}
175156
MCLI_PRIVATE_API_KEY: ${{ secrets.ATLAS_PRIVATE_KEY }}
176157
MCLI_ORG_ID: ${{ secrets.ATLAS_ORG_ID}}
177158
MCLI_OPS_MANAGER_URL: "https://cloud-qa.mongodb.com/"
178159
TEST_NAME: "${{ matrix.test }}"
179-
USE_KIND: false
160+
USE_CURRENT_VERSION: "true"
180161
run: |
181162
echo "Using ENV: ${{ steps.select-env.outputs.ENV }}"
182-
label=${TEST_NAME}
183-
devbox run -- make e2e2 label="${label}"
163+
devbox run -- make e2e2 label=${{ env.TEST_NAME }}
184164
185165
- name: Upload operator logs
186166
if: ${{ failure() }}

.github/workflows/tests-selectable.yaml

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -233,29 +233,12 @@ jobs:
233233
platform=$(echo ${{ matrix.k8s }} | awk -F "-" '{print $2}')
234234
echo "k8s_version=$version" >> $GITHUB_OUTPUT
235235
echo "k8s_platform=$platform" >> $GITHUB_OUTPUT
236-
- name: Create k8s Kind Cluster
237-
if: ${{ steps.properties.outputs.k8s_platform == 'kind' && !env.ACT }}
238-
uses: helm/kind-action@v1.13.0
239-
with:
240-
version: v0.29.0
241-
config: test/helper/e2e/config/kind.yaml
242-
node_image: kindest/node:${{ steps.properties.outputs.k8s_version }}
243-
cluster_name: ${{ matrix.test }}
244-
wait: 180s
245-
- name: Print kubectl version
246-
run: |
247-
devbox run -- 'kubectl version'
248-
- name: Install CRDs if needed
249-
if: ${{ !( matrix.test == 'helm-update' || matrix.test == 'helm-wide' || matrix.test == 'helm-ns' || matrix.test == 'bundle-test' ) }}
250-
run: |
251-
devbox run -- 'make install'
252236
- name: Run E2E test
253237
env:
254238
MCLI_OPS_MANAGER_URL: "https://cloud-qa.mongodb.com/"
255239
MCLI_ORG_ID: ${{ secrets.ATLAS_ORG_ID}}
256240
MCLI_PUBLIC_API_KEY: ${{ secrets.ATLAS_PUBLIC_KEY }}
257241
MCLI_PRIVATE_API_KEY: ${{ secrets.ATLAS_PRIVATE_KEY }}
258-
IMAGE_URL: "ghcr.io/mongodb/mongodb-atlas-kubernetes-operator-prerelease:${{ needs.detect-tests.outputs.image_tag }}"
259242
BUNDLE_IMAGE: "ghcr.io/mongodb/mongodb-atlas-kubernetes-bundles-prerelease:${{ needs.detect-tests.outputs.image_tag }}"
260243
IMAGE_PULL_SECRET_REGISTRY: ghcr.io
261244
IMAGE_PULL_SECRET_USERNAME: $
@@ -273,7 +256,7 @@ jobs:
273256
PAGER_DUTY_SERVICE_KEY: ${{ secrets.PAGER_DUTY_SERVICE_KEY }}
274257
run: |
275258
echo "Using ENV: ${{ steps.select-env.outputs.ENV }}"
276-
devbox run -- ./scripts/launch-ci-e2e.sh
259+
devbox run -- make e2e label=${{ env.TEST_NAME }}
277260
- name: Upload operator logs
278261
if: ${{ failure() }}
279262
uses: actions/upload-artifact@v5
@@ -305,20 +288,10 @@ jobs:
305288
ref: ${{github.event.pull_request.head.sha}}
306289
submodules: true
307290
fetch-depth: 0
308-
- name: Create k8s Kind Cluster
309-
if: ${{ !env.ACT }}
310-
uses: helm/kind-action@v1.13.0
311-
with:
312-
version: v0.29.0
313-
config: test/helper/e2e/config/kind.yaml
314-
cluster_name: "atlas-gov-e2e-test"
315-
wait: 180s
316291
- name: Install devbox
317292
uses: jetify-com/devbox-install-action@v0.14.0
318293
with:
319294
enable-cache: 'true'
320-
- name: Install CRDs
321-
run: devbox run -- 'make install'
322295
- name: Run e2e test
323296
env:
324297
MCLI_PUBLIC_API_KEY: ${{ secrets.ATLAS_GOV_PUBLIC_KEY }}
@@ -330,7 +303,7 @@ jobs:
330303
AWS_ACCOUNT_ARN_LIST: ${{ secrets.AWS_ACCOUNT_ARN_LIST }}
331304
PAGER_DUTY_SERVICE_KEY: ${{ secrets.PAGER_DUTY_SERVICE_KEY }}
332305
TEST_NAME: "${{ matrix.test }}"
333-
run: devbox run -- ./scripts/launch-ci-e2e.sh
306+
run: devbox run -- make e2e label=${{ env.TEST_NAME }}
334307
- name: Upload operator logs
335308
if: ${{ failure() }}
336309
uses: actions/upload-artifact@v5

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,6 @@ config/manifests/kustomization.yaml
6161
config/manager/kustomization.yaml
6262
config/generated/crd/bases/*.yaml
6363
config/generated/rbac/role.yaml
64+
65+
# ignore helm test artifacts
66+
helm-charts/atlas-operator/charts/

Makefile

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,21 @@ DOCKER_SBOM_PLUGIN_VERSION=0.6.1
1818
# - use environment variables to overwrite this value (e.g export VERSION=0.0.2)
1919
VERSION_FILE=version.json
2020
CURRENT_VERSION := $(shell $(JQ) -r .current $(VERSION_FILE))
21+
NEXT_VERSION := $(shell $(JQ) -r .next $(VERSION_FILE))
2122
VERSION ?= $(shell git describe --always --tags --dirty --broken | cut -c 2-)
2223
BUILDTIME ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
2324
GITCOMMIT ?= $(shell git rev-parse --short HEAD 2> /dev/null || true)
2425

26+
# Fix for e2e-gov tests not to use a bad semver version instead
27+
ifdef USE_NEXT_VERSION
28+
VERSION=$(NEXT_VERSION)
29+
endif
30+
31+
# Fix for e2e2 all-in-one test so that it uses an image that already exists in pre-release
32+
ifdef USE_CURRENT_VERSION
33+
VERSION=$(CURRENT_VERSION)
34+
endif
35+
2536
VERSION_PACKAGE = github.com/mongodb/mongodb-atlas-kubernetes/v2/internal/version
2637

2738
# LD_FLAGS
@@ -32,13 +43,6 @@ ifdef EXPERIMENTAL
3243
LD_FLAGS += -X $(VERSION_PACKAGE).Experimental=$(EXPERIMENTAL)
3344
endif
3445

35-
# NEXT_VERSION represents a version that is higher than anything released
36-
# VERSION default value does not play well with the run target which might end up failing
37-
# with errors such as:
38-
# "version of the resource $Resource is higher than the operator version $VERSION"
39-
# This happens if you use exported YAMLs from CLI and the dirty version is deemed a pre-release
40-
NEXT_VERSION = 99.99.99-next
41-
4246
# CHANNELS define the bundle channels used in the bundle.
4347
# Add a new line here if you would like to change its default config. (E.g CHANNELS = "preview,fast,stable")
4448
# To re-generate a bundle for other specific channels without changing the standard setup, you can:
@@ -188,6 +192,18 @@ SBOMS_DIR ?= template
188192

189193
SHELLCHECK_OPTIONS ?= -e SC2086
190194

195+
TEST_REGISTRY ?= localhost:5000
196+
DEFAULT_IMAGE_URL := $(TEST_REGISTRY)/mongodb-atlas-kubernetes-operator:$(NEXT_VERSION)-test
197+
export IMAGE_URL
198+
199+
ifndef IMAGE_URL
200+
IMAGE_URL := $(DEFAULT_IMAGE_URL)
201+
BUILD_DEPENDENCY := test-docker-image
202+
else
203+
$(info --- IMAGE_URL is set externally: $(IMAGE_URL))
204+
BUILD_DEPENDENCY :=
205+
endif
206+
191207
.DEFAULT_GOAL := help
192208
.PHONY: help
193209
help: ## Show this help screen
@@ -246,11 +262,11 @@ envtest-assets:
246262
mkdir -p $(ENVTEST_ASSETS_DIR)
247263

248264
.PHONY: e2e
249-
e2e: bundle manifests run-kind ## Run e2e test. Command `make e2e label=cluster-ns` run cluster-ns test
265+
e2e: bundle manifests run-kind install-crds $(BUILD_DEPENDENCY) ## Run e2e test. Command `make e2e label=cluster-ns` run cluster-ns test
250266
AKO_E2E_TEST=1 $(GINKGO) $(shell pwd)/test/$@
251267

252268
.PHONY: e2e2
253-
e2e2: run-kind manager install-credentials install-crds set-namespace ## Run e2e2 tests. Command `make e2e2 label=integrations-ctlr` run integrations-ctlr e2e2 test
269+
e2e2: bundle run-kind manager install-credentials install-crds set-namespace ## Run e2e2 tests. Command `make e2e2 label=integrations-ctlr` run integrations-ctlr e2e2 test
254270
NO_GORUN=1 \
255271
AKO_E2E2_TEST=1 \
256272
OPERATOR_NAMESPACE=$(OPERATOR_NAMESPACE) \
@@ -485,8 +501,21 @@ all-platforms:
485501

486502
.PHONY: all-platforms-docker
487503
all-platforms-docker: all-platforms
488-
docker build --build-arg BINARY_PATH=bin/linux/amd64 -f fast.Dockerfile -t manager-amd64 .
489-
docker build --build-arg BINARY_PATH=bin/linux/arm64 -f fast.Dockerfile -t manager-arm64 .
504+
docker build --build-arg TARGETOS=linux --build-arg TARGETARCH=amd64 \
505+
-f fast.Dockerfile -t manager-amd64 .
506+
docker build --build-arg TARGETOS=linux --build-arg TARGETARCH=arm64 \
507+
-f fast.Dockerfile -t manager-arm64 .
508+
509+
# docker-image builds the test image always for linux, even on MacOS.
510+
# This is because the Kubernetes cluster is always run within a Linux VM
511+
.PHONY: docker-image
512+
docker-image: all-platforms
513+
docker build --build-arg TARGETOS=linux --build-arg TARGETARCH=$(TARGET_ARCH) \
514+
-f fast.Dockerfile -t $(DEFAULT_IMAGE_URL) .
515+
516+
.PHONY: test-docker-image
517+
test-docker-image: docker-image run-kind
518+
docker push $(DEFAULT_IMAGE_URL)
490519

491520
.PHONY: check-major-version
492521
check-major-version: ## Check that VERSION starts with MAJOR_VERSION

scripts/launch-ci-e2e.sh

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)