Skip to content

Commit

Permalink
test: add flag to disable pull on docker-compose build
Browse files Browse the repository at this point in the history
  • Loading branch information
kuisathaverat committed Mar 9, 2020
1 parent 37b5d1c commit 1ef74a3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
6 changes: 5 additions & 1 deletion dev-tools/mage/integtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion libbeat/scripts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 1 addition & 5 deletions metricbeat/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
6 changes: 1 addition & 5 deletions x-pack/metricbeat/Makefile
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 1ef74a3

Please sign in to comment.