From ca4e8c665deeffb8c1dbbd8042cf921baa3be831 Mon Sep 17 00:00:00 2001 From: Ryotaro Banno Date: Thu, 16 Jan 2025 08:38:32 +0000 Subject: [PATCH] test/e2e: retry `minikube start` at most three times Signed-off-by: Ryotaro Banno --- test/e2e/Makefile | 43 ++++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/test/e2e/Makefile b/test/e2e/Makefile index 87364559..323c3486 100644 --- a/test/e2e/Makefile +++ b/test/e2e/Makefile @@ -115,20 +115,8 @@ $(HELM): | $(BINDIR) | tar xvz -C $(BINDIR) --strip-components 1 linux-amd64/helm .PHONY: launch-minikube -launch-minikube: MINIKUBE_PROFILE= launch-minikube: - # TODO: Is there any better way to verify whether k8s cluster is available or not? - if $(MINIKUBE) profile $(MINIKUBE_PROFILE) |& grep "not found" > /dev/null; then \ - $(MINIKUBE) start \ - --kubernetes-version="v$(KUBERNETES_VERSION)" \ - --driver=kvm2 \ - --memory 6g \ - --cpus=2 \ - --extra-config=kubeadm.node-name=$(NODE_NAME) \ - --extra-config=kubelet.hostname-override=$(NODE_NAME) \ - --network mantle-test \ - -p $(MINIKUBE_PROFILE) ; \ - fi + $(MAKE) do-minikube-start $(MINIKUBE) profile $(MINIKUBE_PROFILE) $(MAKE) image-build $(MAKE) create-loop-dev @@ -140,6 +128,35 @@ launch-minikube: > testdata/persistentvolumes.yaml $(KUBECTL) apply -f testdata/persistentvolumes.yaml +.PHONY: do-minikube-start +do-minikube-start: + # TODO: Is there any better way to verify whether k8s cluster is available or not? + if $(MINIKUBE) profile $(MINIKUBE_PROFILE) |& grep "not found" > /dev/null; then \ + ok=0; \ + for i in $(shell seq 1 3) ; do \ + if [ "$$ok" -eq 0 ]; then \ + if [ "$$i" -ne 1 ]; then \ + $(MINIKUBE) delete -p $(MINIKUBE_PROFILE) || true; \ + fi; \ + $(MINIKUBE) start \ + --kubernetes-version="v$(KUBERNETES_VERSION)" \ + --driver=kvm2 \ + --memory 6g \ + --cpus=2 \ + --extra-config=kubeadm.node-name=$(NODE_NAME) \ + --extra-config=kubelet.hostname-override=$(NODE_NAME) \ + --network mantle-test \ + -p $(MINIKUBE_PROFILE) ; \ + if [ "$$?" -eq 0 ]; then \ + ok=1; \ + fi; \ + fi; \ + done; \ + if [ $$ok -eq 0 ]; then \ + exit 1; \ + fi \ + fi + .PHONY: create-loop-dev create-loop-dev: $(MINIKUBE) ssh -- $(DD) if=/dev/zero of=$(LOOP_FILE) bs=1G seek=32 count=0