From 88afd0dd31c28d230fa6a0583e4873cb512572f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles-Edouard=20Br=C3=A9t=C3=A9ch=C3=A9?= Date: Fri, 25 Mar 2022 17:08:38 +0100 Subject: [PATCH] refactor: create e2e infra using make to speed up e2e tests (#3470) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Charles-Edouard Brétéché Co-authored-by: Prateek Pandey --- Makefile | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index a543c58ed5..c768ad7f4c 100644 --- a/Makefile +++ b/Makefile @@ -31,6 +31,9 @@ K8S_VERSION ?= $(shell kubectl version --short | grep -i server | cut -d" " -f3 export K8S_VERSION TEST_GIT_BRANCH ?= main +KIND_VERSION=v0.11.1 +KIND_IMAGE?=kindest/node:v1.23.3 + ################################## # KYVERNO ################################## @@ -208,9 +211,33 @@ docker-build-all-amd64: docker-buildx-builder docker-build-initContainer-amd64 d # Create e2e Infrastruture ################################## -create-e2e-infrastruture: docker-build-initContainer-local docker-build-kyverno-local - chmod a+x $(PWD)/scripts/create-e2e-infrastruture.sh - $(PWD)/scripts/create-e2e-infrastruture.sh +.PHONY: kind-install +kind-install: ## Install kind +ifeq (, $(shell which kind)) + go install sigs.k8s.io/kind@$(KIND_VERSION) +endif + +.PHONY: kind-e2e-cluster +kind-e2e-cluster: kind-install ## Create kind cluster for e2e tests + kind create cluster --image=$(KIND_IMAGE) + +.PHONY: e2e-kustomize +e2e-kustomize: kustomize ## Build kustomize manifests for e2e tests + cd config && \ + kustomize edit set image $(REPO)/$(KYVERNO_IMAGE):$(IMAGE_TAG_DEV) && \ + kustomize edit set image $(REPO)/$(INITC_IMAGE):$(IMAGE_TAG_DEV) + kustomize build config/ -o config/install.yaml + +.PHONY: e2e-init-container +e2e-init-container: kind-e2e-cluster docker-build-initContainer-local + kind load docker-image $(REPO)/$(INITC_IMAGE):$(IMAGE_TAG_DEV) + +.PHONY: e2e-kyverno-container +e2e-kyverno-container: kind-e2e-cluster docker-build-kyverno-local + kind load docker-image $(REPO)/$(KYVERNO_IMAGE):$(IMAGE_TAG_DEV) + +.PHONY: create-e2e-infrastruture +create-e2e-infrastruture: e2e-init-container e2e-kyverno-container e2e-kustomize ## Setup infrastructure for e2e tests ################################## # Testing & Code-Coverage @@ -305,7 +332,9 @@ godownloader: .PHONY: kustomize kustomize: ## Install kustomize +ifeq (, $(shell which kustomize)) go install sigs.k8s.io/kustomize/kustomize/v4@latest +endif .PHONY: kustomize-crd kustomize-crd: kustomize ## Create install.yaml