kuma

Форк
0
/
e2e.new.mk 
159 строк · 6.6 Кб
1
K8SCLUSTERS = kuma-1 kuma-2
2
K8SCLUSTERS_START_TARGETS = $(addprefix test/e2e/k8s/start/cluster/, $(K8SCLUSTERS))
3
K8SCLUSTERS_STOP_TARGETS  = $(addprefix test/e2e/k8s/stop/cluster/, $(K8SCLUSTERS))
4
K8SCLUSTERS_LOAD_IMAGES_TARGETS  = $(addprefix test/e2e/k8s/load/images/, $(K8SCLUSTERS))
5
K8SCLUSTERS_WAIT_TARGETS  = $(addprefix test/e2e/k8s/wait/, $(K8SCLUSTERS))
6
# export `IPV6=true` to enable IPv6 testing
7

8
# Targets to run prior to running the tests
9
E2E_DEPS_TARGETS ?=
10
# Environment veriables the tests should run with
11
E2E_ENV_VARS ?=
12

13
E2E_K8S_BIN_DEPS = images/test
14
E2E_UNIVERSAL_BIN_DEPS = images/test
15
ifdef CI
16
# In circleCI all this was built from previous targets let's reuse them!
17
E2E_K8S_BIN_DEPS+= docker/load
18
E2E_UNIVERSAL_BIN_DEPS+= docker/load
19
E2E_ENV_VARS+= CLEANUP_LOGS_ON_SUCCESS=true
20
else
21
E2E_K8S_BIN_DEPS+= build/kumactl images
22
E2E_UNIVERSAL_BIN_DEPS+= build/kumactl
23
E2E_ENV_VARS+= GINKGO_EDITOR_INTEGRATION=true
24
endif
25

26
# We don't use `go list` here because Ginkgo requires disk path names,
27
# not Go packages names.
28
TEST_NAMES = $(shell ls -1 ./test/e2e)
29
ALL_TESTS = $(addprefix ./test/e2e/, $(addsuffix /..., $(TEST_NAMES)))
30
E2E_PKG_LIST ?= $(ALL_TESTS)
31
KUBE_E2E_PKG_LIST ?= ./test/e2e_env/kubernetes
32
UNIVERSAL_E2E_PKG_LIST ?= ./test/e2e_env/universal
33
MULTIZONE_E2E_PKG_LIST ?= ./test/e2e_env/multizone
34
GINKGO_E2E_TEST_FLAGS ?=
35
GINKGO_E2E_LABEL_FILTERS ?=
36

37
GINKGO_TEST_E2E=$(GOENV) $(GINKGO_TEST) -v $(GINKGO_E2E_TEST_FLAGS) --label-filter="$(GINKGO_E2E_LABEL_FILTERS)"
38
ifdef DEBUG
39
GINKGO_TEST_E2E+=--procs 1 --keep-going=false --fail-fast
40
endif
41

42
define append_label_filter
43
$(if $(GINKGO_E2E_LABEL_FILTERS),$(GINKGO_E2E_LABEL_FILTERS) && $(1),$(1))
44
endef
45

46
K8S_CLUSTER_TOOL ?= k3d
47
ifeq ($(K8S_CLUSTER_TOOL),k3d)
48
	ifeq ($(K3D_NETWORK_CNI),calico)
49
		E2E_ENV_VARS += KUMA_K8S_TYPE=k3d-calico
50
	else
51
		E2E_ENV_VARS += KUMA_K8S_TYPE=k3d
52
	endif
53
endif
54
ifeq ($(K8S_CLUSTER_TOOL),kind)
55
	GINKGO_E2E_LABEL_FILTERS := $(call append_label_filter,!kind-not-supported)
56
endif
57
ifdef IPV6
58
	GINKGO_E2E_LABEL_FILTERS := $(call append_label_filter,!ipv6-not-supported)
59
endif
60

61
ifeq ($(shell uname -m | sed -e s/aarch.*/arm64/),arm64)
62
	GINKGO_E2E_LABEL_FILTERS := $(call append_label_filter,!arm-not-supported)
63
endif
64

65
define gen-k8sclusters
66
.PHONY: test/e2e/k8s/start/cluster/$1
67
test/e2e/k8s/start/cluster/$1:
68
	KIND_CLUSTER_NAME=$1 $(MAKE) $(K8S_CLUSTER_TOOL)/start
69

70
.PHONY: test/e2e/k8s/load/images/$1
71
test/e2e/k8s/load/images/$1:
72
	KIND_CLUSTER_NAME=$1 $(MAKE) $(K8S_CLUSTER_TOOL)/load/images
73

74
.PHONY: test/e2e/k8s/wait/$1
75
test/e2e/k8s/wait/$1:
76
	KIND_CLUSTER_NAME=$1 $(MAKE) $(K8S_CLUSTER_TOOL)/wait
77

78
.PHONY: test/e2e/k8s/stop/cluster/$1
79
test/e2e/k8s/stop/cluster/$1:
80
	KIND_CLUSTER_NAME=$1 $(MAKE) $(K8S_CLUSTER_TOOL)/stop
81
endef
82

83
$(foreach cluster, $(K8SCLUSTERS), $(eval $(call gen-k8sclusters,$(cluster))))
84

85
ifdef K8SCLUSTERS
86
E2E_ENV_VARS += K8SCLUSTERS="$(K8SCLUSTERS)"
87
endif
88
E2E_ENV_VARS += KUMACTLBIN=${BUILD_ARTIFACTS_DIR}/kumactl/kumactl
89
E2E_ENV_VARS += PATH=$(CI_TOOLS_BIN_DIR):$$PATH
90
.PHONY: test/e2e/list
91
test/e2e/list:
92
	@echo $(ALL_TESTS)
93

94
.PHONY: test/e2e/k8s/start
95
test/e2e/k8s/start: $(K8SCLUSTERS_START_TARGETS)
96
	$(MAKE) $(K8SCLUSTERS_LOAD_IMAGES_TARGETS) # execute after start targets
97

98
.PHONY: test/e2e/k8s/stop
99
test/e2e/k8s/stop: $(K8SCLUSTERS_STOP_TARGETS)
100

101
# test/e2e/debug is used for quicker feedback of E2E tests (ex. debugging flaky tests)
102
# It runs tests with fail fast which means you don't have to wait for all tests to get information that something failed
103
# Clusters are deleted only if all tests passes, otherwise clusters are live and running current test deployment
104
# GINKGO_EDITOR_INTEGRATION is required to work with focused test. Normally they exit with non 0 code which prevents clusters to be cleaned up.
105
# We run ginkgo instead of "go test" to fail fast (builtin "go test" fail fast does not seem to work with individual ginkgo tests)
106
# Run only with -j and K8S_CLUSTER_TOOL=k3d (which is the default value)
107
.PHONY: test/e2e/debug
108
test/e2e/debug: $(E2E_DEPS_TARGETS)
109
	$(MAKE) -j $(K8SCLUSTERS_START_TARGETS) build/kumactl images
110
	$(MAKE) docker/tag
111
	$(MAKE) $(K8SCLUSTERS_LOAD_IMAGES_TARGETS) # K3D is able to load images before the cluster is ready. It retries if cluster is not able to handle images yet.
112
	$(MAKE) $(K8SCLUSTERS_WAIT_TARGETS) # there is no easy way of waiting for processes in the background so just wait for K8S clusters
113
	$(E2E_ENV_VARS) \
114
	$(GINKGO_TEST_E2E) --procs 1 --keep-going=false --fail-fast $(E2E_PKG_LIST)
115
	$(MAKE) test/e2e/k8s/stop
116

117
# test/e2e/debug-universal is the same target as 'test/e2e/debug' but builds only 'kuma-universal' image
118
# and doesn't start Kind clusters
119
.PHONY: test/e2e/debug-universal
120
test/e2e/debug-universal:
121
	@echo "Stop using this target use `make test/e2e-universal DEBUG=1`"
122
	$(MAKE) test/e2e-universal DEBUG=1
123

124
.PHONY: test/e2e
125
test/e2e: $(E2E_DEPS_TARGETS) $(E2E_K8S_BIN_DEPS) ## Run slower e2e tests (slower as they start and stop Kuma for each tests). Use DEBUG=1 to more easily find issues
126
	$(MAKE) docker/tag
127
	$(MAKE) test/e2e/k8s/start
128
	$(E2E_ENV_VARS) $(GINKGO_TEST_E2E) --procs 1 $(E2E_PKG_LIST) || (ret=$$?; $(MAKE) test/e2e/k8s/stop && exit $$ret)
129
	$(MAKE) test/e2e/k8s/stop
130

131
.PHONY: test/e2e-kubernetes
132
test/e2e-kubernetes: $(E2E_DEPS_TARGETS) $(E2E_K8S_BIN_DEPS) ## Run kubernetes e2e tests. Use DEBUG=1 to more easily find issues
133
	$(MAKE) docker/tag
134
	$(MAKE) test/e2e/k8s/start/cluster/kuma-1
135
	$(MAKE) test/e2e/k8s/wait/kuma-1
136
	$(MAKE) test/e2e/k8s/load/images/kuma-1
137
	$(E2E_ENV_VARS) $(GINKGO_TEST_E2E) $(KUBE_E2E_PKG_LIST) || (ret=$$?; $(MAKE) test/e2e/k8s/stop/cluster/kuma-1 && exit $$ret)
138
	$(MAKE) test/e2e/k8s/stop/cluster/kuma-1
139

140
.PHONY: test/e2e-gatewayapi
141
test/e2e-gatewayapi: $(E2E_DEPS_TARGETS) $(E2E_K8S_BIN_DEPS) ## Run kubernetes e2e tests. Use DEBUG=1 to more easily find issues
142
	$(MAKE) docker/tag
143
	$(MAKE) test/e2e/k8s/start/cluster/kuma-1
144
	$(MAKE) test/e2e/k8s/wait/kuma-1
145
	$(MAKE) test/e2e/k8s/load/images/kuma-1
146
	$(E2E_ENV_VARS) $(GINKGO_TEST_E2E) ./test/e2e_env/gatewayapi || (ret=$$?; $(MAKE) test/e2e/k8s/stop/cluster/kuma-1 && exit $$ret)
147
	$(MAKE) test/e2e/k8s/stop/cluster/kuma-1
148

149
.PHONY: test/e2e-universal
150
test/e2e-universal: $(E2E_DEPS_TARGETS) $(E2E_UNIVERSAL_BIN_DEPS) k3d/network/create ## Run universal e2e tests. Use DEBUG=1 to more easily find issues
151
	$(MAKE) docker/tag/test
152
	$(E2E_ENV_VARS) $(GINKGO_TEST_E2E) $(UNIVERSAL_E2E_PKG_LIST)
153

154
.PHONY: test/e2e-multizone
155
test/e2e-multizone: $(E2E_DEPS_TARGETS) $(E2E_K8S_BIN_DEPS) ## Run multizone e2e tests. Use DEBUG=1 to more easily find issues
156
	$(MAKE) docker/tag
157
	$(MAKE) test/e2e/k8s/start
158
	$(E2E_ENV_VARS) $(GINKGO_TEST_E2E) $(MULTIZONE_E2E_PKG_LIST) || (ret=$$?; $(MAKE) test/e2e/k8s/stop && exit $$ret)
159
	$(MAKE) test/e2e/k8s/stop
160

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.