From 74ba85f87b1526e615f1643d3475316137a18264 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Thu, 30 Jul 2020 15:48:42 +0200 Subject: [PATCH] ci: add "make run-e2e" The keeps the standard arguments for e2e testing in a single location instead of spread over multiple files and CI jobs. Signed-off-by: Niels de Vos --- Makefile | 16 ++++++++++++++++ scripts/travis-functest.sh | 2 +- scripts/travis-helmtest.sh | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 013b5fe8d..45bacd659 100644 --- a/Makefile +++ b/Makefile @@ -130,6 +130,22 @@ cephcsi: check-env e2e.test: check-env go test $(GO_TAGS) -mod=vendor -c ./e2e +# +# e2e testing by compiling e2e.test in case it does not exist and running the +# executable. The e2e.test executable is not checked as a dependency in the +# make rule, as the phony check-env causes rebuilds for each run. +# +# Usage: make run-e2e E2E_ARGS="--test-cephfs=false --test-rbd=true" +# +.PHONY: run-e2e +run-e2e: E2E_TIMEOUT ?= $(shell . $(CURDIR)/build.env ; echo $${E2E_TIMEOUT}) +run-e2e: DEPLOY_TIMEOUT ?= $(shell . $(CURDIR)/build.env ; echo $${DEPLOY_TIMEOUT}) +run-e2e: NAMESPACE ?= cephcsi-e2e-$(shell uuidgen | cut -d- -f1) +run-e2e: + @test -e e2e.test || $(MAKE) e2e.test + cd e2e && \ + ../e2e.test -test.v -test.timeout="${E2E_TIMEOUT}" --deploy-timeout="${DEPLOY_TIMEOUT}" --cephcsi-namespace=$(NAMESPACE) $(E2E_ARGS) + need-container-cmd: @test -n "$(shell which $(CONTAINER_CMD) 2>/dev/null)" || { echo "Missing container support, install Podman or Docker"; exit 1; } diff --git a/scripts/travis-functest.sh b/scripts/travis-functest.sh index e06037cbf..d4bedc1f5 100755 --- a/scripts/travis-functest.sh +++ b/scripts/travis-functest.sh @@ -39,7 +39,7 @@ if [[ "${KUBE_MAJOR}" -ge 1 ]] && [[ "${KUBE_MINOR}" -ge 17 ]]; then fi # functional tests -go test "${GO_TAGS}" github.com/ceph/ceph-csi/e2e --deploy-timeout="${DEPLOY_TIMEOUT}" -timeout="${E2E_TIMEOUT}" --cephcsi-namespace=cephcsi-e2e-$RANDOM -v -mod=vendor "${@}" +make run-e2e E2E_ARGS="${*}" if [[ "${KUBE_MAJOR}" -ge 1 ]] && [[ "${KUBE_MINOR}" -ge 17 ]]; then # delete snapshot CRD diff --git a/scripts/travis-helmtest.sh b/scripts/travis-helmtest.sh index 9db7b4dc1..9fbb7839c 100755 --- a/scripts/travis-helmtest.sh +++ b/scripts/travis-helmtest.sh @@ -50,7 +50,7 @@ scripts/install-helm.sh up # install cephcsi helm charts scripts/install-helm.sh install-cephcsi ${NAMESPACE} # functional tests -go test "${GO_TAGS}" github.com/ceph/ceph-csi/e2e -mod=vendor --deploy-timeout="${DEPLOY_TIMEOUT}" -timeout="${E2E_TIMEOUT}" --cephcsi-namespace=${NAMESPACE} --deploy-cephfs=false --deploy-rbd=false -v "${@}" +make run-e2e NAMESPACE="${NAMESPACE}" E2E_ARGS="--deploy-cephfs=false --deploy-rbd=false ${*}" #cleanup # skip snapshot operation if kube version is less than 1.17.0