tests: add USE_CACHE variable to enable go packages cache

If the make variable USE_CACHE is set, the test container will mount
the /go directory from a named volume that is reused in following
test runs, so that go dependencies don't have to be installed again.

Signed-off-by: Sven Anderson <sven@redhat.com>
This commit is contained in:
Sven Anderson 2021-06-08 17:35:35 +02:00 committed by mergify[bot]
parent 5c49aab11e
commit 5cb1f79d74
2 changed files with 9 additions and 2 deletions

View File

@ -27,6 +27,10 @@ ifneq ($(USE_PTRGUARD),)
BUILD_TAGS := $(BUILD_TAGS),ptrguard
endif
ifneq ($(USE_CACHE),)
GOCACHE_VOLUME := -v test_ceph_go_cache:/go
endif
SELINUX := $(shell getenforce 2>/dev/null)
ifeq ($(SELINUX),Enforcing)
VOLUME_FLAGS = :z
@ -46,7 +50,9 @@ test:
.PHONY: test-docker test-container test-multi-container
test-docker: test-container
test-container: $(BUILDFILE) $(RESULTS_DIR)
$(CONTAINER_CMD) run $(CONTAINER_OPTS) --rm --hostname test_ceph_aio -v $(CURDIR):/go/src/github.com/ceph/go-ceph$(VOLUME_FLAGS) $(RESULTS_VOLUME) $(CI_IMAGE_TAG) $(ENTRYPOINT_ARGS)
$(CONTAINER_CMD) run $(CONTAINER_OPTS) --rm --hostname test_ceph_aio \
-v $(CURDIR):/go/src/github.com/ceph/go-ceph$(VOLUME_FLAGS) $(RESULTS_VOLUME) $(GOCACHE_VOLUME) \
$(CI_IMAGE_TAG) $(ENTRYPOINT_ARGS)
test-multi-container: $(BUILDFILE) $(RESULTS_DIR)
$(CONTAINER_CMD) kill test_ceph_a test_ceph_b 2>/dev/null || true
$(CONTAINER_CMD) volume remove test_ceph_a_data test_ceph_b_data 2>/dev/null || true
@ -57,7 +63,7 @@ test-multi-container: $(BUILDFILE) $(RESULTS_DIR)
-v test_ceph_b_data:/tmp/ceph $(CI_IMAGE_TAG) --test-run=NONE --pause
$(CONTAINER_CMD) run $(CONTAINER_OPTS) --rm \
--net test_ceph_net -v test_ceph_a_data:/ceph_a -v test_ceph_b_data:/ceph_b \
-v $(CURDIR):/go/src/github.com/ceph/go-ceph$(VOLUME_FLAGS) $(RESULTS_VOLUME) \
-v $(CURDIR):/go/src/github.com/ceph/go-ceph$(VOLUME_FLAGS) $(RESULTS_VOLUME) $(GOCACHE_VOLUME) \
$(CI_IMAGE_TAG) --wait-for=/ceph_a/.ready:/ceph_b/.ready --ceph-conf=/ceph_a/ceph.conf \
--mirror=/ceph_b/ceph.conf $(ENTRYPOINT_ARGS)
$(CONTAINER_CMD) kill test_ceph_a test_ceph_b

View File

@ -25,6 +25,7 @@ ENV GOROOT=/opt/go
ENV GO111MODULE=on
ENV GOPATH /go
ENV GODEBUG=cgocheck=2
ENV GOCACHE=/go/cache
WORKDIR /go/src/github.com/ceph/go-ceph
VOLUME /go/src/github.com/ceph/go-ceph