2020-06-05 15:36:40 +00:00
|
|
|
CI_IMAGE_NAME = go-ceph-ci
|
2020-06-09 20:13:10 +00:00
|
|
|
CONTAINER_CMD ?=
|
2020-12-20 08:53:56 +00:00
|
|
|
CONTAINER_OPTS := --security-opt $(shell grep -q selinux /sys/kernel/security/lsm 2>/dev/null && echo "label=disable" || echo "apparmor:unconfined")
|
2020-03-11 18:57:27 +00:00
|
|
|
CONTAINER_CONFIG_DIR := testing/containers/ceph
|
2020-06-09 20:15:57 +00:00
|
|
|
VOLUME_FLAGS :=
|
2021-04-30 14:17:54 +00:00
|
|
|
CEPH_VERSION := octopus
|
2020-04-17 15:29:30 +00:00
|
|
|
RESULTS_DIR :=
|
2020-05-13 21:01:32 +00:00
|
|
|
CHECK_GOFMT_FLAGS := -e -s -l
|
2020-05-06 15:20:09 +00:00
|
|
|
IMPLEMENTS_OPTS :=
|
2021-01-18 22:29:06 +00:00
|
|
|
BUILD_TAGS := $(CEPH_VERSION)
|
2019-11-04 14:22:35 +00:00
|
|
|
|
2020-06-09 20:13:10 +00:00
|
|
|
ifeq ($(CONTAINER_CMD),)
|
|
|
|
CONTAINER_CMD:=$(shell docker version >/dev/null 2>&1 && echo docker)
|
|
|
|
endif
|
|
|
|
ifeq ($(CONTAINER_CMD),)
|
|
|
|
CONTAINER_CMD:=$(shell podman version >/dev/null 2>&1 && echo podman)
|
|
|
|
endif
|
|
|
|
|
2020-06-05 15:36:40 +00:00
|
|
|
# the full name of the marker file including the ceph version
|
|
|
|
BUILDFILE=.build.$(CEPH_VERSION)
|
|
|
|
|
|
|
|
# the name of the image plus ceph version as tag
|
|
|
|
CI_IMAGE_TAG=$(CI_IMAGE_NAME):$(CEPH_VERSION)
|
|
|
|
|
2021-01-18 22:29:06 +00:00
|
|
|
ifneq ($(USE_PTRGUARD),)
|
|
|
|
CONTAINER_OPTS += -e USE_PTRGUARD=true
|
|
|
|
BUILD_TAGS := $(BUILD_TAGS),ptrguard
|
|
|
|
endif
|
|
|
|
|
2019-11-04 14:22:35 +00:00
|
|
|
SELINUX := $(shell getenforce 2>/dev/null)
|
|
|
|
ifeq ($(SELINUX),Enforcing)
|
|
|
|
VOLUME_FLAGS = :z
|
|
|
|
endif
|
2019-10-21 23:04:22 +00:00
|
|
|
|
2020-04-17 15:29:30 +00:00
|
|
|
ifdef RESULTS_DIR
|
|
|
|
RESULTS_VOLUME := -v $(RESULTS_DIR):/results$(VOLUME_FLAGS)
|
|
|
|
endif
|
|
|
|
|
2015-05-24 08:13:05 +00:00
|
|
|
build:
|
2021-01-18 22:29:06 +00:00
|
|
|
go build -v -tags $(BUILD_TAGS) $(shell go list ./... | grep -v /contrib)
|
2015-05-24 08:13:05 +00:00
|
|
|
fmt:
|
|
|
|
go fmt ./...
|
|
|
|
test:
|
2021-01-18 22:29:06 +00:00
|
|
|
go test -v -tags $(BUILD_TAGS) ./...
|
2015-05-24 08:13:05 +00:00
|
|
|
|
2021-03-03 21:18:05 +00:00
|
|
|
.PHONY: test-docker test-container test-multi-container
|
2020-03-11 17:50:23 +00:00
|
|
|
test-docker: test-container
|
2020-06-10 14:46:28 +00:00
|
|
|
test-container: $(BUILDFILE) $(RESULTS_DIR)
|
2021-05-26 09:05:46 +00:00
|
|
|
$(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)
|
2021-03-03 21:18:05 +00:00
|
|
|
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
|
|
|
|
$(CONTAINER_CMD) network create test_ceph_net 2>/dev/null || true
|
2021-04-06 17:36:41 +00:00
|
|
|
$(CONTAINER_CMD) run $(CONTAINER_OPTS) --rm -d --name test_ceph_a --hostname test_ceph_a --net test_ceph_net \
|
2021-03-03 21:18:05 +00:00
|
|
|
-v test_ceph_a_data:/tmp/ceph $(CI_IMAGE_TAG) --test-run=NONE --pause
|
2021-04-06 17:36:41 +00:00
|
|
|
$(CONTAINER_CMD) run $(CONTAINER_OPTS) --rm -d --name test_ceph_b --hostname test_ceph_b --net test_ceph_net \
|
2021-03-03 21:18:05 +00:00
|
|
|
-v test_ceph_b_data:/tmp/ceph $(CI_IMAGE_TAG) --test-run=NONE --pause
|
2021-04-12 13:09:19 +00:00
|
|
|
$(CONTAINER_CMD) run $(CONTAINER_OPTS) --rm \
|
2021-03-03 21:18:05 +00:00
|
|
|
--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) \
|
2021-03-03 22:31:49 +00:00
|
|
|
$(CI_IMAGE_TAG) --wait-for=/ceph_a/.ready:/ceph_b/.ready --ceph-conf=/ceph_a/ceph.conf \
|
2021-04-06 17:36:52 +00:00
|
|
|
--mirror=/ceph_b/ceph.conf $(ENTRYPOINT_ARGS)
|
2021-03-03 21:18:05 +00:00
|
|
|
$(CONTAINER_CMD) kill test_ceph_a test_ceph_b
|
2020-04-17 15:29:30 +00:00
|
|
|
|
|
|
|
ifdef RESULTS_DIR
|
|
|
|
$(RESULTS_DIR):
|
|
|
|
mkdir -p $(RESULTS_DIR)
|
|
|
|
endif
|
2015-05-24 08:13:05 +00:00
|
|
|
|
2020-03-11 17:50:23 +00:00
|
|
|
.PHONY: ci-image
|
2020-06-05 15:36:40 +00:00
|
|
|
ci-image: $(BUILDFILE)
|
2020-07-26 19:32:12 +00:00
|
|
|
$(BUILDFILE): $(CONTAINER_CONFIG_DIR)/Dockerfile entrypoint.sh micro-osd.sh
|
2020-06-05 15:36:40 +00:00
|
|
|
$(CONTAINER_CMD) build --build-arg CEPH_VERSION=$(CEPH_VERSION) -t $(CI_IMAGE_TAG) -f $(CONTAINER_CONFIG_DIR)/Dockerfile .
|
|
|
|
@$(CONTAINER_CMD) inspect -f '{{.Id}}' $(CI_IMAGE_TAG) > $(BUILDFILE)
|
|
|
|
echo $(CEPH_VERSION) >> $(BUILDFILE)
|
2019-12-17 15:50:58 +00:00
|
|
|
|
2020-05-13 21:01:32 +00:00
|
|
|
check: check-revive check-format
|
|
|
|
|
|
|
|
check-format:
|
|
|
|
! gofmt $(CHECK_GOFMT_FLAGS) . | sed 's,^,formatting error: ,' | grep 'go$$'
|
|
|
|
|
|
|
|
check-revive:
|
2019-12-12 02:04:19 +00:00
|
|
|
# Configure project's revive checks using .revive.toml
|
|
|
|
# See: https://github.com/mgechev/revive
|
2020-03-28 17:20:13 +00:00
|
|
|
revive -config .revive.toml $$(go list ./... | grep -v /vendor/)
|
2020-02-04 19:46:17 +00:00
|
|
|
|
|
|
|
# Do a quick compile only check of the tests and impliclity the
|
|
|
|
# library code as well.
|
2020-04-13 15:22:39 +00:00
|
|
|
test-binaries: \
|
|
|
|
cephfs.test \
|
2020-08-04 21:00:16 +00:00
|
|
|
cephfs/admin.test \
|
2020-04-13 15:22:39 +00:00
|
|
|
internal/callbacks.test \
|
|
|
|
internal/cutil.test \
|
|
|
|
internal/errutil.test \
|
|
|
|
internal/retry.test \
|
|
|
|
rados.test \
|
2021-03-03 19:44:17 +00:00
|
|
|
rbd.test \
|
|
|
|
rbd/admin.test
|
2020-02-04 19:46:17 +00:00
|
|
|
test-bins: test-binaries
|
|
|
|
|
|
|
|
%.test: % force_go_build
|
2021-01-18 22:29:06 +00:00
|
|
|
go test -c -tags $(BUILD_TAGS) ./$<
|
2020-02-04 19:46:17 +00:00
|
|
|
|
2020-05-04 21:39:22 +00:00
|
|
|
implements:
|
|
|
|
go build -o implements ./contrib/implements
|
|
|
|
|
2020-05-06 15:20:09 +00:00
|
|
|
check-implements: implements
|
|
|
|
./implements $(IMPLEMENTS_OPTS) ./cephfs ./rados ./rbd
|
|
|
|
|
2020-02-04 19:46:17 +00:00
|
|
|
# force_go_build is phony and builds nothing, can be used for forcing
|
|
|
|
# go toolchain commands to always run
|
2020-05-06 15:20:09 +00:00
|
|
|
.PHONY: build fmt test test-docker check test-binaries test-bins force_go_build check-implements
|