2020-04-30 15:07:27 +08:00
|
|
|
SHELL := /bin/bash
|
|
|
|
PROJECT=tinykv
|
|
|
|
GOPATH ?= $(shell go env GOPATH)
|
|
|
|
|
|
|
|
# Ensure GOPATH is set before running build process.
|
|
|
|
ifeq "$(GOPATH)" ""
|
|
|
|
$(error Please set the environment variable GOPATH before running `make`)
|
|
|
|
endif
|
|
|
|
|
|
|
|
GO := GO111MODULE=on go
|
|
|
|
GOBUILD := $(GO) build $(BUILD_FLAG) -tags codes
|
2020-04-29 21:38:49 +08:00
|
|
|
GOTEST := $(GO) test -v --count=1 --parallel=1 -p=1
|
2021-12-22 17:32:57 +08:00
|
|
|
TEST_CLEAN := rm -rf /tmp/*test-raftstore*
|
2020-04-30 15:07:27 +08:00
|
|
|
|
|
|
|
TEST_LDFLAGS := ""
|
|
|
|
|
|
|
|
PACKAGE_LIST := go list ./...| grep -vE "cmd"
|
|
|
|
PACKAGES := $$($(PACKAGE_LIST))
|
|
|
|
|
|
|
|
# Targets
|
|
|
|
.PHONY: clean test proto kv scheduler dev
|
|
|
|
|
|
|
|
default: kv scheduler
|
|
|
|
|
|
|
|
dev: default test
|
|
|
|
|
|
|
|
test:
|
|
|
|
@echo "Running tests in native mode."
|
|
|
|
@export TZ='Asia/Shanghai'; \
|
2020-04-30 14:22:58 +08:00
|
|
|
LOG_LEVEL=fatal $(GOTEST) -cover $(PACKAGES)
|
2020-04-30 15:07:27 +08:00
|
|
|
|
|
|
|
CURDIR := $(shell pwd)
|
|
|
|
export PATH := $(CURDIR)/bin/:$(PATH)
|
|
|
|
proto:
|
|
|
|
mkdir -p $(CURDIR)/bin
|
|
|
|
(cd proto && ./generate_go.sh)
|
|
|
|
GO111MODULE=on go build ./proto/pkg/...
|
|
|
|
|
|
|
|
kv:
|
|
|
|
$(GOBUILD) -o bin/tinykv-server kv/main.go
|
|
|
|
|
|
|
|
scheduler:
|
|
|
|
$(GOBUILD) -o bin/tinyscheduler-server scheduler/main.go
|
|
|
|
|
2020-04-23 11:51:56 +08:00
|
|
|
ci: default
|
2020-04-30 15:07:27 +08:00
|
|
|
@echo "Checking formatting"
|
|
|
|
@test -z "$$(gofmt -s -l $$(find . -name '*.go' -type f -print) | tee /dev/stderr)"
|
|
|
|
@echo "Running Go vet"
|
|
|
|
@go vet ./...
|
|
|
|
|
|
|
|
format:
|
|
|
|
@gofmt -s -w `find . -name '*.go' -type f ! -path '*/_tools/*' -print`
|
|
|
|
|
2020-04-23 11:37:46 +08:00
|
|
|
project1:
|
2021-08-12 18:44:27 +08:00
|
|
|
$(GOTEST) ./kv/server -run 1
|
2020-04-30 15:07:27 +08:00
|
|
|
|
2020-04-23 11:37:46 +08:00
|
|
|
project2: project2a project2b project2c
|
2020-04-30 15:07:27 +08:00
|
|
|
|
2020-04-23 11:37:46 +08:00
|
|
|
project2a:
|
2020-04-30 14:22:58 +08:00
|
|
|
$(GOTEST) ./raft -run 2A
|
2020-04-30 15:07:27 +08:00
|
|
|
|
2020-04-23 11:37:46 +08:00
|
|
|
project2aa:
|
2020-04-30 14:22:58 +08:00
|
|
|
$(GOTEST) ./raft -run 2AA
|
2020-04-07 15:52:39 +08:00
|
|
|
|
2020-04-23 11:37:46 +08:00
|
|
|
project2ab:
|
2020-04-30 14:22:58 +08:00
|
|
|
$(GOTEST) ./raft -run 2AB
|
2020-04-07 15:52:39 +08:00
|
|
|
|
2020-04-23 11:37:46 +08:00
|
|
|
project2ac:
|
2020-04-30 14:22:58 +08:00
|
|
|
$(GOTEST) ./raft -run 2AC
|
2020-04-23 11:37:46 +08:00
|
|
|
|
|
|
|
project2b:
|
2021-12-22 17:32:57 +08:00
|
|
|
$(TEST_CLEAN)
|
2021-08-12 18:44:27 +08:00
|
|
|
$(GOTEST) ./kv/test_raftstore -run ^TestBasic2B$ || true
|
|
|
|
$(GOTEST) ./kv/test_raftstore -run ^TestConcurrent2B$ || true
|
|
|
|
$(GOTEST) ./kv/test_raftstore -run ^TestUnreliable2B$ || true
|
|
|
|
$(GOTEST) ./kv/test_raftstore -run ^TestOnePartition2B$ || true
|
|
|
|
$(GOTEST) ./kv/test_raftstore -run ^TestManyPartitionsOneClient2B$ || true
|
|
|
|
$(GOTEST) ./kv/test_raftstore -run ^TestManyPartitionsManyClients2B$ || true
|
|
|
|
$(GOTEST) ./kv/test_raftstore -run ^TestPersistOneClient2B$ || true
|
|
|
|
$(GOTEST) ./kv/test_raftstore -run ^TestPersistConcurrent2B$ || true
|
|
|
|
$(GOTEST) ./kv/test_raftstore -run ^TestPersistConcurrentUnreliable2B$ || true
|
|
|
|
$(GOTEST) ./kv/test_raftstore -run ^TestPersistPartition2B$ || true
|
|
|
|
$(GOTEST) ./kv/test_raftstore -run ^TestPersistPartitionUnreliable2B$ || true
|
2021-12-22 17:32:57 +08:00
|
|
|
$(TEST_CLEAN)
|
2020-04-30 15:07:27 +08:00
|
|
|
|
2020-04-23 11:37:46 +08:00
|
|
|
project2c:
|
2021-12-22 17:32:57 +08:00
|
|
|
$(TEST_CLEAN)
|
2022-01-05 13:06:11 +08:00
|
|
|
$(GOTEST) ./raft -run 2C || true
|
|
|
|
$(GOTEST) ./kv/test_raftstore -run ^TestOneSnapshot2C$ || true
|
|
|
|
$(GOTEST) ./kv/test_raftstore -run ^TestSnapshotRecover2C$ || true
|
|
|
|
$(GOTEST) ./kv/test_raftstore -run ^TestSnapshotRecoverManyClients2C$ || true
|
|
|
|
$(GOTEST) ./kv/test_raftstore -run ^TestSnapshotUnreliable2C$ || true
|
|
|
|
$(GOTEST) ./kv/test_raftstore -run ^TestSnapshotUnreliableRecover2C$ || true
|
|
|
|
$(GOTEST) ./kv/test_raftstore -run ^TestSnapshotUnreliableRecoverConcurrentPartition2C$ || true
|
2021-12-22 17:32:57 +08:00
|
|
|
$(TEST_CLEAN)
|
2020-04-23 11:37:46 +08:00
|
|
|
|
|
|
|
project3: project3a project3b project3c
|
|
|
|
|
|
|
|
project3a:
|
2020-04-30 14:22:58 +08:00
|
|
|
$(GOTEST) ./raft -run 3A
|
2020-04-23 11:37:46 +08:00
|
|
|
|
|
|
|
project3b:
|
2021-12-22 17:32:57 +08:00
|
|
|
$(TEST_CLEAN)
|
2021-08-12 18:44:27 +08:00
|
|
|
$(GOTEST) ./kv/test_raftstore -run ^TestTransferLeader3B$ || true
|
|
|
|
$(GOTEST) ./kv/test_raftstore -run ^TestBasicConfChange3B$ || true
|
2023-01-06 07:09:02 +08:00
|
|
|
$(GOTEST) ./kv/test_raftstore -run ^TestConfChangeRemoveLeader3B$ || true
|
2021-08-12 18:44:27 +08:00
|
|
|
$(GOTEST) ./kv/test_raftstore -run ^TestConfChangeRecover3B$ || true
|
|
|
|
$(GOTEST) ./kv/test_raftstore -run ^TestConfChangeRecoverManyClients3B$ || true
|
|
|
|
$(GOTEST) ./kv/test_raftstore -run ^TestConfChangeUnreliable3B$ || true
|
|
|
|
$(GOTEST) ./kv/test_raftstore -run ^TestConfChangeUnreliableRecover3B$ || true
|
|
|
|
$(GOTEST) ./kv/test_raftstore -run ^TestConfChangeSnapshotUnreliableRecover3B$ || true
|
|
|
|
$(GOTEST) ./kv/test_raftstore -run ^TestConfChangeSnapshotUnreliableRecoverConcurrentPartition3B$ || true
|
|
|
|
$(GOTEST) ./kv/test_raftstore -run ^TestOneSplit3B$ || true
|
|
|
|
$(GOTEST) ./kv/test_raftstore -run ^TestSplitRecover3B$ || true
|
|
|
|
$(GOTEST) ./kv/test_raftstore -run ^TestSplitRecoverManyClients3B$ || true
|
|
|
|
$(GOTEST) ./kv/test_raftstore -run ^TestSplitUnreliable3B$ || true
|
|
|
|
$(GOTEST) ./kv/test_raftstore -run ^TestSplitUnreliableRecover3B$ || true
|
|
|
|
$(GOTEST) ./kv/test_raftstore -run ^TestSplitConfChangeSnapshotUnreliableRecover3B$ || true
|
|
|
|
$(GOTEST) ./kv/test_raftstore -run ^TestSplitConfChangeSnapshotUnreliableRecoverConcurrentPartition3B$ || true
|
2021-12-22 17:32:57 +08:00
|
|
|
$(TEST_CLEAN)
|
2020-04-23 11:37:46 +08:00
|
|
|
|
|
|
|
project3c:
|
2020-05-26 11:16:41 +08:00
|
|
|
$(GOTEST) ./scheduler/server ./scheduler/server/schedulers -check.f="3C"
|
2020-04-23 11:37:46 +08:00
|
|
|
|
|
|
|
project4: project4a project4b project4c
|
|
|
|
|
|
|
|
project4a:
|
2020-04-30 14:22:58 +08:00
|
|
|
$(GOTEST) ./kv/transaction/... -run 4A
|
2020-04-23 11:37:46 +08:00
|
|
|
|
|
|
|
project4b:
|
2020-04-30 14:22:58 +08:00
|
|
|
$(GOTEST) ./kv/transaction/... -run 4B
|
2020-04-23 11:37:46 +08:00
|
|
|
|
|
|
|
project4c:
|
2021-12-22 17:32:57 +08:00
|
|
|
$(GOTEST) ./kv/transaction/... -run 4C
|