@@ -82,6 +82,21 @@ OPERATOR_NAMESPACE = mongodb-atlas-system
8282ATLAS_DOMAIN = https://cloud-qa.mongodb.com/
8383ATLAS_KEY_SECRET_NAME = mongodb-atlas-operator-api-key
8484
85+ # Envtest configuration params
86+ ENVTEST_ASSETS_DIR ?= $(shell pwd) /bin
87+ ENVTEST_K8S_VERSION ?= 1.30.0
88+ KUBEBUILDER_ASSETS ?= $(ENVTEST_ASSETS_DIR ) /k8s/$(ENVTEST_K8S_VERSION ) -$(TARGET_OS ) -$(TARGET_ARCH )
89+
90+ # Ginkgo configuration
91+ GINKGO_NODES ?= 12
92+ GINKGO_EDITOR_INTEGRATION ?= true
93+ GINKGO_OPTS = -vv --randomize-all --output-interceptor-mode=none --trace --timeout 90m --flake-attempts=1 --race --nodes=$(GINKGO_NODES ) --cover --coverpkg=github.com/mongodb/mongodb-atlas-kubernetes/v2/pkg/...
94+ GINKGO_FILTER_LABEL ?=
95+ ifneq ($(GINKGO_FILTER_LABEL ) ,)
96+ GINKGO_FILTER_LABEL_OPT := --label-filter="$(GINKGO_FILTER_LABEL ) "
97+ endif
98+ GINKGO =ginkgo run $(GINKGO_OPTS ) $(GINKGO_FILTER_LABEL_OPT ) $(shell pwd) /$@
99+
85100BASE_GO_PACKAGE = github.com/mongodb/mongodb-atlas-kubernetes/v2
86101GO_LICENSES = go-licenses
87102GO_LICENSES_VERSION = 1.6.0
@@ -157,16 +172,18 @@ check-licenses: licenses-up-to-date ## Check licenses are compliant with our res
157172unit-test :
158173 go test -race -cover $(GO_UNIT_TEST_FOLDERS )
159174
160- .PHONY : int-test
161- int-test : ENVTEST_ASSETS_DIR = $(shell pwd) /testbin
162- int-test : ENVTEST_K8S_VERSION = 1.26.1
163- # magical env that if specified makes the test output 0 on successful runs
164- # https://github.com/onsi/ginkgo/blob/master/ginkgo/run_command.go#L130
165- int-test : export GINKGO_EDITOR_INTEGRATION="true"
166- int-test : generate manifests # # Run integration tests. Sample with labels: `make int-test label=AtlasProject` or `make int-test label='AtlasDeployment && !slow'`
175+ # # Run integration tests. Sample with labels: `make test/int GINKGO_FILTER_LABEL=AtlasProject`
176+ test/int : envtest
177+ AKO_INT_TEST=1 KUBEBUILDER_ASSETS=$(KUBEBUILDER_ASSETS ) $(GINKGO )
178+
179+ test/int/clusterwide : envtest
180+ AKO_INT_TEST=1 KUBEBUILDER_ASSETS=$(KUBEBUILDER_ASSETS ) $(GINKGO )
181+
182+ envtest : envtest-assets
183+ KUBEBUILDER_ASSETS=$(shell setup-envtest use $(ENVTEST_K8S_VERSION ) --bin-dir $(ENVTEST_ASSETS_DIR ) -p path)
184+
185+ envtest-assets :
167186 mkdir -p $(ENVTEST_ASSETS_DIR )
168- test -f $(ENVTEST_ASSETS_DIR ) /setup-envtest.sh || curl -sSLo $(ENVTEST_ASSETS_DIR ) /setup-envtest.sh https://raw.githubusercontent.com/kubernetes-sigs/controller-runtime/v0.8.0/hack/setup-envtest.sh
169- export ENVTEST_K8S_VERSION=$(ENVTEST_K8S_VERSION ) && source $(ENVTEST_ASSETS_DIR ) /setup-envtest.sh; fetch_envtest_tools $(ENVTEST_ASSETS_DIR ) ; setup_envtest_env $(ENVTEST_ASSETS_DIR ) ; ./scripts/int_local.sh $(label )
170187
171188.PHONY : e2e
172189e2e : run-kind # # Run e2e test. Command `make e2e label=cluster-ns` run cluster-ns test
0 commit comments