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")
|
2021-08-26 15:09:06 +00:00
|
|
|
CONTAINER_BUILD_OPTS :=
|
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
|
|
|
|
|
2021-08-26 15:12:57 +00:00
|
|
|
ifeq ($(CEPH_VERSION),nautilus)
|
|
|
|
CEPH_TAG := v14
|
|
|
|
endif
|
|
|
|
ifeq ($(CEPH_VERSION),octopus)
|
|
|
|
CEPH_TAG := v15
|
|
|
|
endif
|
|
|
|
ifeq ($(CEPH_VERSION),pacific)
|
|
|
|
CEPH_TAG := v16
|
|
|
|
endif
|
2022-02-28 18:15:02 +00:00
|
|
|
ifeq ($(CEPH_VERSION),quincy)
|
|
|
|
CEPH_TAG := v17
|
|
|
|
endif
|
2021-08-26 15:12:57 +00:00
|
|
|
|
2021-06-19 16:40:13 +00:00
|
|
|
GO_CMD:=go
|
|
|
|
GOFMT_CMD:=gofmt
|
|
|
|
|
2020-06-05 15:36:40 +00:00
|
|
|
# the full name of the marker file including the ceph version
|
|
|
|
BUILDFILE=.build.$(CEPH_VERSION)
|
|
|
|
|
2021-08-16 18:48:34 +00:00
|
|
|
# files marking daemon containers supporting the tests
|
|
|
|
TEST_CTR_A=.run.test_ceph_a
|
|
|
|
TEST_CTR_B=.run.test_ceph_b
|
|
|
|
TEST_CTR_NET=.run.test_ceph_net
|
|
|
|
|
2020-06-05 15:36:40 +00:00
|
|
|
# the name of the image plus ceph version as tag
|
|
|
|
CI_IMAGE_TAG=$(CI_IMAGE_NAME):$(CEPH_VERSION)
|
|
|
|
|
2022-04-26 22:22:02 +00:00
|
|
|
ifneq ($(NO_PTRGUARD),)
|
|
|
|
CONTAINER_OPTS += -e NO_PTRGUARD=true
|
|
|
|
BUILD_TAGS := $(BUILD_TAGS),no_ptrguard
|
2021-01-18 22:29:06 +00:00
|
|
|
endif
|
|
|
|
|
2021-09-21 13:57:24 +00:00
|
|
|
ifneq ($(NO_PREVIEW),)
|
|
|
|
CONTAINER_OPTS += -e NO_PREVIEW=true
|
|
|
|
else
|
|
|
|
BUILD_TAGS := $(BUILD_TAGS),ceph_preview
|
|
|
|
endif
|
|
|
|
|
2021-06-08 15:35:35 +00:00
|
|
|
ifneq ($(USE_CACHE),)
|
|
|
|
GOCACHE_VOLUME := -v test_ceph_go_cache:/go
|
|
|
|
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
|
|
|
|
|
2021-06-19 16:47:11 +00:00
|
|
|
ifneq ($(USE_GOCO),)
|
|
|
|
GO_CMD:=$(CONTAINER_CMD) run $(CONTAINER_OPTS) --rm $(GOCACHE_VOLUME) -v $(CURDIR):/go/src/github.com/ceph/go-ceph$(VOLUME_FLAGS) --entrypoint $(GO_CMD) $(CI_IMAGE_TAG)
|
|
|
|
GOFMT_CMD:=$(CONTAINER_CMD) run $(CONTAINER_OPTS) --rm $(GOCACHE_VOLUME) -v $(CURDIR):/go/src/github.com/ceph/go-ceph$(VOLUME_FLAGS) --entrypoint $(GOFMT_CMD) $(CI_IMAGE_TAG)
|
|
|
|
endif
|
|
|
|
|
2015-05-24 08:13:05 +00:00
|
|
|
build:
|
2021-06-19 16:40:13 +00:00
|
|
|
$(GO_CMD) build -v -tags $(BUILD_TAGS) $(shell $(GO_CMD) list ./... | grep -v /contrib)
|
2015-05-24 08:13:05 +00:00
|
|
|
fmt:
|
2021-06-19 16:40:13 +00:00
|
|
|
$(GO_CMD) fmt ./...
|
2015-05-24 08:13:05 +00:00
|
|
|
test:
|
2021-06-19 16:40:13 +00:00
|
|
|
$(GO_CMD) 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-06-08 15:35:35 +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) $(GOCACHE_VOLUME) \
|
|
|
|
$(CI_IMAGE_TAG) $(ENTRYPOINT_ARGS)
|
2021-03-03 21:18:05 +00:00
|
|
|
test-multi-container: $(BUILDFILE) $(RESULTS_DIR)
|
2021-08-16 18:48:34 +00:00
|
|
|
-$(MAKE) test-containers-kill
|
|
|
|
-$(MAKE) test-containers-rm-volumes
|
|
|
|
-$(MAKE) test-containers-rm-network
|
|
|
|
$(MAKE) test-containers-test
|
|
|
|
$(MAKE) test-containers-kill
|
|
|
|
$(MAKE) test-containers-rm-volumes
|
|
|
|
$(MAKE) test-containers-rm-network
|
|
|
|
|
|
|
|
# The test-containers-* cleanup rules:
|
|
|
|
.PHONY: test-containers-clean \
|
|
|
|
test-containers-kill \
|
|
|
|
test-containers-rm-volumes \
|
|
|
|
test-containers-rm-network
|
|
|
|
|
|
|
|
test-containers-clean: test-containers-kill
|
|
|
|
-$(MAKE) test-containers-rm-volumes
|
|
|
|
-$(MAKE) test-containers-rm-network
|
|
|
|
|
|
|
|
test-containers-kill:
|
|
|
|
-$(CONTAINER_CMD) kill test_ceph_a || $(CONTAINER_CMD) rm test_ceph_a
|
|
|
|
-$(CONTAINER_CMD) kill test_ceph_b || $(CONTAINER_CMD) rm test_ceph_b
|
|
|
|
$(RM) $(TEST_CTR_A) $(TEST_CTR_B)
|
|
|
|
sleep 0.3
|
|
|
|
# sometimes the container runtime fails to remove things immediately after
|
|
|
|
# killing the containers. The short sleep helps avoid hitting that condition.
|
|
|
|
|
|
|
|
test-containers-rm-volumes:
|
|
|
|
$(CONTAINER_CMD) volume remove test_ceph_a_data test_ceph_b_data
|
|
|
|
|
|
|
|
test-containers-rm-network:
|
|
|
|
$(CONTAINER_CMD) network rm test_ceph_net
|
|
|
|
$(RM) $(TEST_CTR_NET)
|
|
|
|
|
|
|
|
# Thest test-containers-* setup rules:
|
|
|
|
.PHONY: test-containers-network \
|
|
|
|
test-containers-test_ceph_a \
|
|
|
|
test-containers-test_ceph_b \
|
|
|
|
test-containers-test
|
|
|
|
|
|
|
|
test-containers-network: $(TEST_CTR_NET)
|
|
|
|
$(TEST_CTR_NET):
|
|
|
|
($(CONTAINER_CMD) network ls -q | grep -q test_ceph_net) \
|
|
|
|
|| $(CONTAINER_CMD) network create test_ceph_net
|
|
|
|
@echo "test_ceph_net" > $(TEST_CTR_NET)
|
|
|
|
|
|
|
|
test-containers-test_ceph_a: $(TEST_CTR_A)
|
|
|
|
$(TEST_CTR_A): $(TEST_CTR_NET) $(BUILDFILE)
|
|
|
|
$(CONTAINER_CMD) run $(CONTAINER_OPTS) \
|
|
|
|
--cidfile=$(TEST_CTR_A) --rm -d --name test_ceph_a \
|
|
|
|
--hostname test_ceph_a \
|
|
|
|
--net test_ceph_net \
|
|
|
|
-v test_ceph_a_data:/tmp/ceph $(CI_IMAGE_TAG) \
|
|
|
|
--test-run=NONE --pause
|
|
|
|
|
|
|
|
test-containers-test_ceph_b: $(TEST_CTR_B)
|
|
|
|
$(TEST_CTR_B): $(TEST_CTR_NET) $(BUILDFILE)
|
|
|
|
$(CONTAINER_CMD) run $(CONTAINER_OPTS) \
|
|
|
|
--cidfile=$(TEST_CTR_B) --rm -d --name test_ceph_b \
|
|
|
|
--hostname test_ceph_b \
|
|
|
|
--net test_ceph_net \
|
|
|
|
-v test_ceph_b_data:/tmp/ceph $(CI_IMAGE_TAG) \
|
|
|
|
--test-run=NONE --pause
|
|
|
|
|
|
|
|
test-containers-test: $(BUILDFILE) $(TEST_CTR_A) $(TEST_CTR_B)
|
2021-04-12 13:09:19 +00:00
|
|
|
$(CONTAINER_CMD) run $(CONTAINER_OPTS) --rm \
|
2021-08-16 18:48:34 +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) $(GOCACHE_VOLUME) \
|
|
|
|
$(CI_IMAGE_TAG) \
|
|
|
|
--wait-for=/ceph_a/.ready:/ceph_b/.ready \
|
|
|
|
--mirror-state=/ceph_b/.mstate \
|
|
|
|
--ceph-conf=/ceph_a/ceph.conf \
|
2021-04-06 17:36:52 +00:00
|
|
|
--mirror=/ceph_b/ceph.conf $(ENTRYPOINT_ARGS)
|
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
|
2021-08-26 15:12:57 +00:00
|
|
|
$(CONTAINER_CMD) build \
|
|
|
|
--build-arg GO_CEPH_VERSION=$(CEPH_VERSION) \
|
|
|
|
--build-arg CEPH_TAG=$(CEPH_TAG) \
|
2021-08-26 15:09:06 +00:00
|
|
|
$(CONTAINER_BUILD_OPTS) \
|
2021-08-26 15:12:57 +00:00
|
|
|
-t $(CI_IMAGE_TAG) \
|
|
|
|
-f $(CONTAINER_CONFIG_DIR)/Dockerfile .
|
2020-06-05 15:36:40 +00:00
|
|
|
@$(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:
|
2021-06-19 16:40:13 +00:00
|
|
|
! $(GOFMT_CMD) $(CHECK_GOFMT_FLAGS) . | sed 's,^,formatting error: ,' | grep 'go$$'
|
2020-05-13 21:01:32 +00:00
|
|
|
|
|
|
|
check-revive:
|
2019-12-12 02:04:19 +00:00
|
|
|
# Configure project's revive checks using .revive.toml
|
|
|
|
# See: https://github.com/mgechev/revive
|
2022-02-07 22:58:05 +00:00
|
|
|
revive -config .revive.toml $$(find . -name '*.go')
|
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 \
|
2021-12-13 21:49:33 +00:00
|
|
|
common/admin/manager.test \
|
2022-02-22 17:01:25 +00:00
|
|
|
common/admin/nfs.test \
|
2020-04-13 15:22:39 +00:00
|
|
|
internal/callbacks.test \
|
2022-02-22 19:03:32 +00:00
|
|
|
internal/commands.test \
|
2020-04-13 15:22:39 +00:00
|
|
|
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-06-19 16:40:13 +00:00
|
|
|
$(GO_CMD) test -c -tags $(BUILD_TAGS) ./$<
|
2020-02-04 19:46:17 +00:00
|
|
|
|
2020-05-04 21:39:22 +00:00
|
|
|
implements:
|
2022-02-14 20:50:25 +00:00
|
|
|
cd contrib/implements && $(GO_CMD) build -o ../../implements
|
2020-05-04 21:39:22 +00:00
|
|
|
|
2020-05-06 15:20:09 +00:00
|
|
|
check-implements: implements
|
2021-11-16 03:03:22 +00:00
|
|
|
./implements $(IMPLEMENTS_OPTS) cephfs rados rbd
|
2020-05-06 15:20:09 +00:00
|
|
|
|
2021-10-18 17:43:28 +00:00
|
|
|
clean-implements:
|
|
|
|
$(RM) ./implements
|
|
|
|
|
2021-10-04 16:15:09 +00:00
|
|
|
|
2021-10-11 17:04:03 +00:00
|
|
|
api-check: implements-json
|
2021-10-04 16:15:09 +00:00
|
|
|
./contrib/apiage.py
|
|
|
|
|
2021-10-11 17:04:03 +00:00
|
|
|
api-update: implements-json
|
2021-10-04 16:15:09 +00:00
|
|
|
./contrib/apiage.py --mode=update \
|
|
|
|
--current-tag="$$(git describe --tags --abbrev=0)"
|
|
|
|
|
|
|
|
api-doc:
|
|
|
|
./contrib/apiage.py --mode=write-doc
|
|
|
|
|
2021-10-11 17:04:03 +00:00
|
|
|
ifeq ($(RESULTS_DIR),)
|
|
|
|
IMPLEMENTS_DIR:=$(PWD)/_results
|
|
|
|
else
|
|
|
|
IMPLEMENTS_DIR:=$(RESULTS_DIR)
|
|
|
|
endif
|
|
|
|
|
2022-01-31 15:11:22 +00:00
|
|
|
implements-json: $(BUILDFILE)
|
2021-10-11 17:04:03 +00:00
|
|
|
$(MAKE) RESULTS_DIR="$(IMPLEMENTS_DIR)" ENTRYPOINT_ARGS="--test-run=IMPLEMENTS --micro-osd=/bin/true $(ENTRYPOINT_ARGS)" test-container
|
2021-10-04 16:15:09 +00:00
|
|
|
|
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
|
2021-10-18 17:43:28 +00:00
|
|
|
.PHONY: build fmt test test-docker check test-binaries test-bins force_go_build check-implements clean-implements api-check api-update api-doc implements-json
|