From 9333b7d896d5cd8c86d64040f93f33328805c655 Mon Sep 17 00:00:00 2001 From: Claudio Costa Date: Tue, 11 Aug 2020 10:41:23 +0200 Subject: [PATCH] Start required docker services before running tests (#15217) --- Makefile | 30 +++++++++++++++++++++++------- config.mk | 2 +- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 08edd37fc7..94d3284ac0 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: build package run stop run-client run-server stop-client stop-server restart restart-server restart-client start-docker clean-dist clean nuke check-style check-client-style check-server-style check-unit-tests test dist prepare-enteprise run-client-tests setup-run-client-tests cleanup-run-client-tests test-client build-linux build-osx build-windows internal-test-web-client vet run-server-for-web-client-tests diff-config prepackaged-plugins prepackaged-binaries test-server test-server-ee test-server-quick test-server-race +.PHONY: build package run stop run-client run-server stop-client stop-server restart restart-server restart-client start-docker clean-dist clean nuke check-style check-client-style check-server-style check-unit-tests test dist prepare-enteprise run-client-tests setup-run-client-tests cleanup-run-client-tests test-client build-linux build-osx build-windows internal-test-web-client vet run-server-for-web-client-tests diff-config prepackaged-plugins prepackaged-binaries test-server test-server-ee test-server-quick test-server-race start-docker-check ROOT := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) @@ -128,11 +128,19 @@ ifeq ($(RUN_SERVER_IN_BACKGROUND),true) RUN_IN_BACKGROUND := & endif -ifeq ($(BUILD_ENTERPRISE_READY),true) - ifeq (,$(findstring openldap,$(ENABLED_DOCKER_SERVICES))) - ENABLED_DOCKER_SERVICES:=$(ENABLED_DOCKER_SERVICES) openldap - endif +start-docker-check: +ifeq (,$(findstring minio,$(ENABLED_DOCKER_SERVICES))) + TEMP_DOCKER_SERVICES:=$(TEMP_DOCKER_SERVICES) minio endif +ifeq ($(BUILD_ENTERPRISE_READY),true) + ifeq (,$(findstring openldap,$(ENABLED_DOCKER_SERVICES))) + TEMP_DOCKER_SERVICES:=$(TEMP_DOCKER_SERVICES) openldap + endif + ifeq (,$(findstring elasticsearch,$(ENABLED_DOCKER_SERVICES))) + TEMP_DOCKER_SERVICES:=$(TEMP_DOCKER_SERVICES) elasticsearch + endif +endif +ENABLED_DOCKER_SERVICES:=$(ENABLED_DOCKER_SERVICES) $(TEMP_DOCKER_SERVICES) start-docker: ## Starts the docker containers for local development. ifneq ($(IS_CI),false) @@ -323,15 +331,23 @@ gomodtidy: fi; @rm go.*.orig; -test-server: check-prereqs-enterprise start-docker go-junit-report do-cover-file ## Runs tests. +test-server: check-prereqs-enterprise start-docker-check start-docker go-junit-report do-cover-file ## Runs tests. ifeq ($(BUILD_ENTERPRISE_READY),true) @echo Running all tests else @echo Running only TE tests endif ./scripts/test.sh "$(GO)" "$(GOFLAGS)" "$(ALL_PACKAGES)" "$(TESTS)" "$(TESTFLAGS)" "$(GOBIN)" + ifneq ($(IS_CI),true) + ifneq ($(MM_NO_DOCKER),true) + ifneq ($(TEMP_DOCKER_SERVICES),) + @echo Stopping temporary docker services + docker-compose stop $(TEMP_DOCKER_SERVICES) + endif + endif + endif -test-server-ee: check-prereqs-enterprise start-docker go-junit-report do-cover-file ## Runs EE tests. +test-server-ee: check-prereqs-enterprise start-docker-check start-docker go-junit-report do-cover-file ## Runs EE tests. @echo Running only EE tests ./scripts/test.sh "$(GO)" "$(GOFLAGS)" "$(EE_PACKAGES)" "$(TESTS)" "$(TESTFLAGS)" "$(GOBIN)" diff --git a/config.mk b/config.mk index 4417475072..f68f9d9c16 100644 --- a/config.mk +++ b/config.mk @@ -7,7 +7,7 @@ # Possible options: mysql, postgres, minio, inbucket, openldap, dejavu, # keycloak and elasticsearch # -# Must be space spearated names. +# Must be space separated names. # # Example: mysql postgres elasticsearch ENABLED_DOCKER_SERVICES ?= mysql postgres inbucket