@@ -9,6 +9,8 @@ VERSION ?= 0.1.0
99IMG ?= cr.yandex/yc/ydb-operator:latest
1010# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
1111ENVTEST_K8S_VERSION = 1.26
12+ # Image URL which uses in tests
13+ YDB_IMAGE ?= $(shell grep "anchor_for_fetching_image_from_workflow" ./tests/** /* .go | grep -o -E '"cr\.yandex.* "' | tr -d '"')
1214
1315# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
1416ifeq (,$(shell go env GOBIN) )
@@ -66,32 +68,28 @@ vet: ## Run go vet against code.
6668kind-init :
6769 if kind get clusters | grep " kind-ydb-operator" ; then exit 0; fi ; \
6870 kind create cluster \
69- --config e2e /kind-cluster-config.yaml \
71+ --config tests/cfg /kind-cluster-config.yaml \
7072 --image=kindest/node:v1.31.2@sha256:18fbefc20a7113353c7b75b5c869d7145a6abd6269154825872dc59c1329912e \
71- --name kind-ydb-operator; \
72- docker pull k8s.gcr.io/ingress-nginx/kube-webhook-certgen :v1.0; \
73- kind load docker-image k8s.gcr.io/ingress-nginx/kube-webhook-certgen:v1.0 --nodes kind-worker,kind-worker2,kind-worker3 --name kind-ydb-operator; \
74- YDB_IMAGE=$(grep "anchor_for_fetching_image_from_workflow" ./tests/**/*.go | grep -o -E '"cr\.yandex.*"' ) ; \
75- YDB_IMAGE=${YDB_IMAGE: 1:- 1} ; \
76- docker pull ${YDB_IMAGE} ; \
77- kind load docker-image ${YDB_IMAGE} --nodes kind-worker,kind-worker2,kind-worker3 --name kind-ydb-operator;
73+ --name kind-ydb-operator
74+ docker pull k8s.gcr.io/ingress-nginx/kube-webhook-certgen:v1.0
75+ kind load docker-image k8s.gcr.io/ingress-nginx/kube-webhook-certgen:v1.0 --name kind-ydb-operator
76+ docker pull ${YDB_IMAGE}
77+ kind load docker-image ${YDB_IMAGE} --name kind-ydb-operator
7878
7979kind-load :
80- docker tag cr.yandex/yc/ydb-operator:latest kind/ydb-operator:current
81- kind load docker-image kind/ydb-operator:current --nodes kind-worker,kind-worker2,kind-worker3 -- name kind-ydb-operator
80+ docker tag ${IMG} kind/ydb-operator:current
81+ kind load docker-image kind/ydb-operator:current --name kind-ydb-operator
8282
8383opts ?= ''
8484
8585.PHONY : unit-test
86- unit-test : manifests generate fmt vet gotestsum envtest # # Run unit tests
86+ unit-test : manifests generate fmt vet envtest # # Run unit tests
8787 KUBEBUILDER_ASSETS=" $( shell $( ENVTEST) use --arch=amd64 $( ENVTEST_K8S_VERSION) -p path) " \
88- $(GOTESTSUM ) --format testname --jsonfile log.json -- -v -timeout 900s -p 1 ./internal/... -ginkgo.vv -coverprofile cover.out $(opts )
89- jq -r ' .Output| gsub("[\\n]"; "")' log.json 2> /dev/null 1> log.txt || true
88+ go test -v -timeout 900s -p 1 ./internal/... -ginkgo.vv -coverprofile cover.out $(opts )
9089
9190.PHONY : e2e-test
92- e2e-test : manifests generate fmt vet gotestsum docker-build kind-init kind-load # # Run e2e tests
93- $(GOTESTSUM ) --format testname --jsonfile log.json -- -v -timeout 3600s -p 1 ./tests/e2e/... -ginkgo.vv $(opts )
94- jq -r ' .Output| gsub("[\\n]"; "")' log.json 2> /dev/null 1> log.txt || true
91+ e2e-test : manifests generate fmt vet docker-build kind-init kind-load # # Run e2e tests
92+ go test -v -timeout 3600s -p 1 ./tests/e2e/... -ginkgo.vv $(opts )
9593
9694.PHONY : test
9795test : unit-test e2e-test # # Run all tests
@@ -124,11 +122,6 @@ ENVTEST_VERSION ?= release-0.17
124122envtest : # # Download envtest-setup locally if necessary.
125123 $(call go-get-tool,$(ENVTEST ) ,sigs.k8s.io/controller-runtime/tools/setup-envtest@$(ENVTEST_VERSION ) )
126124
127- GOTESTSUM = $(shell pwd) /bin/gotestsum
128- GOTESTSUM_VERSION ?= v1.12.0
129- gotestsum : # # Download gotestsum locally if necessary.
130- $(call go-get-tool,$(ENVTEST ) ,gotest.tools/gotestsum@$(GOTESTSUM_VERSION ) )
131-
132125# go-get-tool will 'go install' any package $2 and install it to $1.
133126PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST ) ) ) )
134127define go-get-tool
0 commit comments