From 1ef74a3056bac569986d07827b1a1a0f4285c362 Mon Sep 17 00:00:00 2001 From: Ivan Fernandez Calvo Date: Mon, 9 Mar 2020 10:22:41 +0100 Subject: [PATCH] test: add flag to disable pull on docker-compose build --- dev-tools/mage/integtest.go | 6 +++++- libbeat/scripts/Makefile | 7 ++++++- metricbeat/Makefile | 6 +----- x-pack/metricbeat/Makefile | 6 +----- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/dev-tools/mage/integtest.go b/dev-tools/mage/integtest.go index 41219d58d6c..7e6f98ce9f9 100644 --- a/dev-tools/mage/integtest.go +++ b/dev-tools/mage/integtest.go @@ -326,11 +326,15 @@ func dockerComposeBuildImages() error { return err } - args := []string{"-p", dockerComposeProjectName(), "build", "--pull", "--force-rm"} + args := []string{"-p", dockerComposeProjectName(), "build", "--force-rm"} if _, noCache := os.LookupEnv("DOCKER_NOCACHE"); noCache { args = append(args, "--no-cache") } + if _, forcePull := os.LookupEnv("DOCKER_PULL"); forcePull { + args = append(args, "--pull") + } + out := ioutil.Discard if mg.Verbose() { out = os.Stderr diff --git a/libbeat/scripts/Makefile b/libbeat/scripts/Makefile index e1bcca4a728..1131447d0a7 100755 --- a/libbeat/scripts/Makefile +++ b/libbeat/scripts/Makefile @@ -98,6 +98,7 @@ COMMIT_ID=$(shell git rev-parse HEAD) DOCKER_COMPOSE_PROJECT_NAME?=${BEAT_NAME}${TESTING_ENVIRONMENT//-}${BEAT_VERSION//-}${COMMIT_ID} ## @testing The name of the docker-compose project used by the integration and system tests DOCKER_COMPOSE?=TESTING_ENVIRONMENT=${TESTING_ENVIRONMENT} ES_BEATS=${ES_BEATS} docker-compose -p ${DOCKER_COMPOSE_PROJECT_NAME} -f docker-compose.yml DOCKER_CACHE?=1 ## @miscellaneous If set to 0, all docker images are created without cache +DOCKER_PULL?=1 ## @miscellaneous If set to 0, disable the force pull on docker-compose build GOPACKAGES_COMMA_SEP=$(subst $(space),$(comma),$(strip ${GOPACKAGES})) PYTHON_EXE?=python3 PYTHON_ENV?=${BUILD_DIR}/python-env @@ -115,6 +116,10 @@ ifeq ($(DOCKER_CACHE),0) DOCKER_NOCACHE=--no-cache endif +ifeq ($(DOCKER_PULL),1) + DOCKER_FORCE_PULL=--pull +endif + # Conditionally enable the race detector when RACE_DETECTOR=1. ifeq ($(RACE_DETECTOR),1) RACE=-race @@ -404,7 +409,7 @@ $(.OVER)import-dashboards: update ${BEAT_NAME} # Builds the environment to test beat .PHONY: build-image build-image: write-environment - ${DOCKER_COMPOSE} build ${DOCKER_NOCACHE} --pull --force-rm + ${DOCKER_COMPOSE} build ${DOCKER_NOCACHE} ${DOCKER_FORCE_PULL} --force-rm # Runs the environment so the redis and elasticsearch can also be used for local development # To use it for running the test, set ES_HOST and REDIS_HOST environment variable to the ip of your docker-machine. diff --git a/metricbeat/Makefile b/metricbeat/Makefile index 6c92cb855f9..96f0330bf5d 100644 --- a/metricbeat/Makefile +++ b/metricbeat/Makefile @@ -5,6 +5,7 @@ SYSTEM_TESTS?=true TEST_ENVIRONMENT?=true BEATS_DOCKER_INTEGRATION_TEST_ENV?=true ES_BEATS?=.. +DOCKER_PULL=0 # Metricbeat can only be cross-compiled on platforms not requiring CGO. GOX_OS=netbsd linux windows @@ -83,8 +84,3 @@ integration-tests: ## @testing Run golang integration tests. integration-tests: prepare-tests mage rm -f docker-compose.yml.lock mage goIntegTest - -# Builds the environment to test beat -.PHONY: build-image -build-image: write-environment - ${DOCKER_COMPOSE} build ${DOCKER_NOCACHE} --force-rm diff --git a/x-pack/metricbeat/Makefile b/x-pack/metricbeat/Makefile index f52006cf70d..0ed9384ddd7 100644 --- a/x-pack/metricbeat/Makefile +++ b/x-pack/metricbeat/Makefile @@ -1,8 +1,4 @@ ES_BEATS ?= ../.. +DOCKER_PULL=0 include $(ES_BEATS)/dev-tools/make/xpack.mk - -# Builds the environment to test beat -.PHONY: build-image -build-image: write-environment - ${DOCKER_COMPOSE} build ${DOCKER_NOCACHE} --force-rm