@@ -55,7 +55,6 @@ MEMBER_CLUSTER_COUNT ?= 3
5555ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST ) ) ) )
5656TOOLS_DIR := hack/tools
5757TOOLS_BIN_DIR := $(abspath $(TOOLS_DIR ) /bin)
58- CLUSTER_CONFIG := $(abspath test/e2e/v1alpha1/kind-config.yaml)
5958
6059# Binaries
6160# Note: Need to use abspath so we can invoke these from subdirectories
@@ -174,25 +173,6 @@ fmt: $(GOIMPORTS) ## Run go fmt against code.
174173vet : # # Run go vet against code.
175174 go vet ./...
176175
177- # # --------------------------------------
178- # # Kind
179- # # --------------------------------------
180-
181- # Note that these targets are only used for E2E tests of the v1alpha1 API.
182-
183- create-hub-kind-cluster :
184- kind create cluster --name $(HUB_KIND_CLUSTER_NAME ) --image=$(KIND_IMAGE ) --config=$(CLUSTER_CONFIG ) --kubeconfig=$(KUBECONFIG )
185-
186- create-member-kind-cluster :
187- kind create cluster --name $(MEMBER_KIND_CLUSTER_NAME ) --image=$(KIND_IMAGE ) --config=$(CLUSTER_CONFIG ) --kubeconfig=$(KUBECONFIG )
188-
189- load-hub-docker-image :
190- kind load docker-image --name $(HUB_KIND_CLUSTER_NAME ) $(REGISTRY ) /$(HUB_AGENT_IMAGE_NAME ) :$(HUB_AGENT_IMAGE_VERSION )
191-
192- load-member-docker-image :
193- kind load docker-image --name $(MEMBER_KIND_CLUSTER_NAME ) $(REGISTRY ) /$(REFRESH_TOKEN_IMAGE_NAME ) :$(REFRESH_TOKEN_IMAGE_VERSION )
194- kind load docker-image --name $(MEMBER_KIND_CLUSTER_NAME ) $(REGISTRY ) /$(MEMBER_AGENT_IMAGE_NAME ) :$(MEMBER_AGENT_IMAGE_VERSION )
195-
196176# # --------------------------------------
197177# # test
198178# # --------------------------------------
@@ -201,87 +181,23 @@ load-member-docker-image:
201181test : manifests generate fmt vet local-unit-test integration-test # # Run tests.
202182
203183# #
204- # # workaround to bypass the pkg/controllers/workv1alpha1 tests failure
205- # # rollout controller tests need a bit longer to complete, so we increase the timeout
206- # #
207- # Set up the timeout parameters as some of the test lengths have exceeded the default 10 minute mark.
184+ # Set up the timeout parameters as some of the tests (rollout controller) lengths have exceeded the default 10 minute mark.
208185# TO-DO (chenyu1): enable parallelization for single package integration tests.
209186.PHONY : local-unit-test
210187local-unit-test : $(ENVTEST ) # # Run tests.
211188 export CGO_ENABLED=1 && \
212189 export KUBEBUILDER_ASSETS=" $( shell $( ENVTEST) use $( ENVTEST_K8S_VERSION) -p path) " && \
213- go test ./pkg/controllers/workv1alpha1 -race -coverprofile=ut-coverage.xml -covermode=atomic -v && \
214- go test ` go list ./pkg/... ./cmd/... | grep -v pkg/controllers/workv1alpha1` -race -coverpkg=./... -coverprofile=ut-coverage.xml -covermode=atomic -v -timeout=20m
190+ go test ` go list ./pkg/... ./cmd/...` -race -coverpkg=./... -coverprofile=ut-coverage.xml -covermode=atomic -v -timeout=20m
215191
216192.PHONY : integration-test
217193integration-test : $(ENVTEST ) # # Run tests.
218194 export CGO_ENABLED=1 && \
219195 export KUBEBUILDER_ASSETS=" $( shell $( ENVTEST) use $( ENVTEST_K8S_VERSION) -p path) " && \
220196 ginkgo -v -p --race --cover --coverpkg=./pkg/scheduler/... ./test/scheduler && \
221- ginkgo -v -p --race --cover --coverpkg=./... ./test/apis/... ./test/crdinstaller && \
222- go test ./test/integration/... -coverpkg=./... -race -coverprofile=it-coverage.xml -v
197+ ginkgo -v -p --race --cover --coverpkg=./... ./test/apis/...
223198
224199# # local tests & e2e tests
225200
226- install-hub-agent-helm :
227- kind export kubeconfig --name $(HUB_KIND_CLUSTER_NAME )
228- helm install hub-agent ./charts/hub-agent/ \
229- --set image.pullPolicy=Never \
230- --set image.repository=$(REGISTRY ) /$(HUB_AGENT_IMAGE_NAME ) \
231- --set image.tag=$(HUB_AGENT_IMAGE_VERSION ) \
232- --set logVerbosity=5 \
233- --set namespace=fleet-system \
234- --set enableWebhook=true \
235- --set webhookServiceName=fleetwebhook \
236- --set webhookClientConnectionType=service \
237- --set enableV1Alpha1APIs=true \
238- --set enableV1Beta1APIs=false \
239- --set enableClusterInventoryAPI=true \
240- --set logFileMaxSize=1000000
241-
242- .PHONY : e2e-v1alpha1-hub-kubeconfig-secret
243- e2e-v1alpha1-hub-kubeconfig-secret :
244- kind export kubeconfig --name $(HUB_KIND_CLUSTER_NAME )
245- kubectl apply -f test/e2e/v1alpha1/hub-agent-sa-secret.yaml
246- TOKEN=$$(kubectl get secret hub-kubeconfig-secret -n fleet-system -o jsonpath='{.data.token}' | base64 -d ) ; \
247- kind export kubeconfig --name $(MEMBER_KIND_CLUSTER_NAME ) ; \
248- kubectl delete secret hub-kubeconfig-secret --ignore-not-found ; \
249- kubectl create secret generic hub-kubeconfig-secret --from-literal=token=$$ TOKEN
250-
251- install-member-agent-helm : install-hub-agent-helm e2e-v1alpha1-hub-kubeconfig-secret
252- kind export kubeconfig --name $(HUB_KIND_CLUSTER_NAME )
253- # # Get kind cluster IP that docker uses internally so we can talk to the other cluster. the port is the default one.
254- HUB_SERVER_URL=" https://$$ (docker inspect $( HUB_KIND_CLUSTER_NAME) -control-plane --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}'):6443" ; \
255- kind export kubeconfig --name $(MEMBER_KIND_CLUSTER_NAME ) ; \
256- helm install member-agent ./charts/member-agent/ \
257- --set config.hubURL=$$ HUB_SERVER_URL \
258- --set image.repository=$(REGISTRY ) /$(MEMBER_AGENT_IMAGE_NAME ) \
259- --set image.tag=$(MEMBER_AGENT_IMAGE_VERSION ) \
260- --set refreshtoken.repository=$(REGISTRY ) /$(REFRESH_TOKEN_IMAGE_NAME ) \
261- --set refreshtoken.tag=$(REFRESH_TOKEN_IMAGE_VERSION ) \
262- --set image.pullPolicy=Never \
263- --set refreshtoken.pullPolicy=Never \
264- --set config.memberClusterName=" kind-$( MEMBER_KIND_CLUSTER_NAME) " \
265- --set logVerbosity=5 \
266- --set namespace=fleet-system
267- # to make sure member-agent reads the token file.
268- kubectl delete pod --all -n fleet-system
269-
270- build-e2e-v1alpha1 :
271- go test -c ./test/e2e/v1alpha1
272-
273- run-e2e-v1alpha1 : build-e2e-v1alpha1
274- KUBECONFIG=$(KUBECONFIG ) HUB_SERVER_URL=" https://$$ (docker inspect $( HUB_KIND_CLUSTER_NAME) -control-plane --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}'):6443" ./v1alpha1.test -test.v -ginkgo.v
275-
276- .PHONY : create-kind-cluster
277- create-kind-cluster : create-hub-kind-cluster create-member-kind-cluster install-helm
278-
279- .PHONY : install-helm
280- install-helm : load-hub-docker-image load-member-docker-image install-member-agent-helm
281-
282- .PHONY : e2e-tests-v1alpha1
283- e2e-tests-v1alpha1 : create-kind-cluster run-e2e-v1alpha1
284-
285201# E2E test label filter (can be overridden)
286202LABEL_FILTER ?= !custom
287203
@@ -462,30 +378,6 @@ clean-bin: ## Remove all generated binaries
462378 rm -rf $(TOOLS_BIN_DIR )
463379 rm -rf ./bin
464380
465- # Note that these targets are only used for E2E tests of the v1alpha1 API.
466-
467- .PHONY : uninstall-helm
468- uninstall-helm : clean-testing-resources
469- kind export kubeconfig --name $(HUB_KIND_CLUSTER_NAME )
470- helm uninstall hub-agent
471-
472- kind export kubeconfig --name $(MEMBER_KIND_CLUSTER_NAME)
473- helm uninstall member-agent
474-
475- .PHONY : clean-testing-resources
476- clean-testing-resources :
477- kind export kubeconfig --name $(HUB_KIND_CLUSTER_NAME )
478- kubectl delete ns fleet-member-kind-member-testing --ignore-not-found
479- kubectl delete memberclusters.fleet.azure.com kind-$(MEMBER_KIND_CLUSTER_NAME ) --ignore-not-found
480-
481- kind export kubeconfig --name $(MEMBER_KIND_CLUSTER_NAME)
482- kubectl delete ns fleet-member-kind-member-testing --ignore-not-found
483-
484- .PHONY : clean-e2e-tests-v1alpha1
485- clean-e2e-tests-v1alpha1 :
486- kind delete cluster --name $(HUB_KIND_CLUSTER_NAME )
487- kind delete cluster --name $(MEMBER_KIND_CLUSTER_NAME )
488-
489381.PHONY : clean-e2e-tests
490382clean-e2e-tests :
491383 cd ./test/e2e && chmod +x ./stop.sh && ./stop.sh $(MEMBER_CLUSTER_COUNT )
0 commit comments