forked from talent-plan/tinykv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
299 lines (262 loc) · 13.2 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
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
GOTEST := $(GO) test -v --count=1 --parallel=1 -p=1
TEST_CLEAN := rm -rf /tmp/*test-raftstore*
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'; \
LOG_LEVEL=fatal $(GOTEST) -cover $(PACKAGES)
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
ci: default
@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`
project1:
$(GOTEST) ./kv/server -run 1
project2: project2a project2b project2c
project2a:
$(GOTEST) ./raft -run 2A
project2aa:
$(GOTEST) ./raft -run 2AA
project2ab:
$(GOTEST) ./raft -run 2AB
project2ac:
$(GOTEST) ./raft -run 2AC
project2b:
$(TEST_CLEAN)
$(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
$(TEST_CLEAN)
#project2b:
# $(TEST_CLEAN)
# $(GOTEST) -v ./kv/test_raftstore -run ^TestBasic2B$ | grep PASS || true
# $(GOTEST) -v ./kv/test_raftstore -run ^TestConcurrent2B$ | grep PASS || true
# $(GOTEST) -v ./kv/test_raftstore -run ^TestUnreliable2B$ | grep PASS || true
# $(GOTEST) -v ./kv/test_raftstore -run ^TestOnePartition2B$ | grep PASS || true
# $(GOTEST) -v ./kv/test_raftstore -run ^TestManyPartitionsOneClient2B$ | grep PASS || true
# $(GOTEST) -v ./kv/test_raftstore -run ^TestManyPartitionsManyClients2B$ | grep PASS || true
# $(GOTEST) -v ./kv/test_raftstore -run ^TestPersistOneClient2B$ | grep PASS || true
# $(GOTEST) -v ./kv/test_raftstore -run ^TestPersistConcurrent2B$ | grep PASS || true
# $(GOTEST) -v ./kv/test_raftstore -run ^TestPersistConcurrentUnreliable2B$ | grep PASS || true
# $(GOTEST) -v ./kv/test_raftstore -run ^TestPersistPartition2B$ | grep PASS || true
# $(GOTEST) -v ./kv/test_raftstore -run ^TestPersistPartitionUnreliable2B$ | grep PASS || true
# $(TEST_CLEAN)
#project2b:
# $(TEST_CLEAN)
# $(GOTEST) -v ./kv/test_raftstore -run ^TestBasic2B$ | grep -E "PASS|ok|FAIL" || true
# $(GOTEST) -v ./kv/test_raftstore -run ^TestConcurrent2B$ | grep -E "PASS|ok|FAIL" || true
# $(GOTEST) -v ./kv/test_raftstore -run ^TestUnreliable2B$ | grep -E "PASS|ok|FAIL" || true
# $(GOTEST) -v ./kv/test_raftstore -run ^TestOnePartition2B$ | grep -E "PASS|ok|FAIL" || true
# $(GOTEST) -v ./kv/test_raftstore -run ^TestManyPartitionsOneClient2B$ | grep -E "PASS|ok|FAIL" || true
# $(GOTEST) -v ./kv/test_raftstore -run ^TestManyPartitionsManyClients2B$ | grep -E "PASS|ok|FAIL" || true
# $(GOTEST) -v ./kv/test_raftstore -run ^TestPersistOneClient2B$ | grep -E "PASS|ok|FAIL" || true
# $(GOTEST) -v ./kv/test_raftstore -run ^TestPersistConcurrent2B$ | grep -E "PASS|ok|FAIL" || true
# $(GOTEST) -v ./kv/test_raftstore -run ^TestPersistConcurrentUnreliable2B$ | grep -E "PASS|ok|FAIL" || true
# $(GOTEST) -v ./kv/test_raftstore -run ^TestPersistPartition2B$ | grep -E "PASS|ok|FAIL" || true
# $(GOTEST) -v ./kv/test_raftstore -run ^TestPersistPartitionUnreliable2B$ | grep -E "PASS|ok|FAIL" || true
# $(TEST_CLEAN)
project2_multiTestsWithErrors:
$(TEST_CLEAN)
PASS_COUNT=0; \
for i in {1..30}; do \
RESULT=$$($(GOTEST) ./kv/test_raftstore -run ^$(TEST_NAME)$$ | grep -v "info" || true); \
echo "$$RESULT"; \
PASS_COUNT=$$(($$PASS_COUNT + $$(echo "$$RESULT" | grep -c "PASS"))); \
done; \
HALF_PASS_COUNT=$$(($$PASS_COUNT / 2)); \
GREEN='\033[0;32m'; \
NC='\033[0m'; \
echo -e "$$GREEN TOTAL tests: 30 $$NC"; \
echo -e "$$GREEN PASS tests: $$HALF_PASS_COUNT $$NC"
$(TEST_CLEAN)
project2c:
$(TEST_CLEAN)
$(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
$(TEST_CLEAN)
project2c_SnapshotRecover:
$(TEST_CLEAN)
$(GOTEST) ./kv/test_raftstore -run ^TestSnapshotRecover2C$ || true
$(TEST_CLEAN)
project2c_TestSnapshotUnreliable5Times:
$(TEST_CLEAN)
$(GOTEST) ./kv/test_raftstore -run ^TestSnapshotUnreliable2C$ || true
$(GOTEST) ./kv/test_raftstore -run ^TestSnapshotUnreliable2C$ || true
$(GOTEST) ./kv/test_raftstore -run ^TestSnapshotUnreliable2C$ || true
$(GOTEST) ./kv/test_raftstore -run ^TestSnapshotUnreliable2C$ || true
$(GOTEST) ./kv/test_raftstore -run ^TestSnapshotUnreliable2C$ || true
$(TEST_CLEAN)
project3: project3a project3b project3c
project3a:
$(GOTEST) ./raft -run 3A
project3b:
$(TEST_CLEAN)
$(GOTEST) ./kv/test_raftstore -run ^$ || true
$(GOTEST) ./kv/test_raftstore -run ^TestBasicConfChange3B$ || true
$(GOTEST) ./kv/test_raftstore -run ^TestConfChangeRemoveLeader3B$ || true
$(GOTEST) ./kv/test_raftstore -run ^TestConfChangeRecover3BTestTransferLeader3B$ || 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
$(TEST_CLEAN)
project3b_multiTests:
$(TEST_CLEAN)
for i in {1..30}; do \
$(GOTEST) ./kv/test_raftstore -run ^$(TEST_NAME)$$ | grep -E "PASS|FAIL|run" || true; \
done
$(TEST_CLEAN)
project3b_multiTestsWithError:
$(TEST_CLEAN)
for i in {1..30}; do \
$(GOTEST) ./kv/test_raftstore -run ^$(TEST_NAME)$$ | grep -v "info" || true; \
done
$(TEST_CLEAN)
project3b_multiTestsWithErrors:
$(TEST_CLEAN)
PASS_COUNT=0; \
for i in {1..30}; do \
RESULT=$$($(GOTEST) ./kv/test_raftstore -run ^$(TEST_NAME)$$ | grep -v "info" || true); \
echo "$$RESULT"; \
PASS_COUNT=$$(($$PASS_COUNT + $$(echo "$$RESULT" | grep -c "PASS"))); \
done; \
HALF_PASS_COUNT=$$(($$PASS_COUNT / 2)); \
GREEN='\033[0;32m'; \
NC='\033[0m'; \
echo -e "$$GREEN TOTAL tests: 30 $$NC"; \
echo -e "$$GREEN PASS tests: $$HALF_PASS_COUNT $$NC"
$(TEST_CLEAN)
project3b_TransferLeader:
$(TEST_CLEAN)
$(GOTEST) ./kv/test_raftstore -run ^TestTransferLeader3B$ || true
$(TEST_CLEAN)
project3b_ConfChange:
$(TEST_CLEAN)
$(GOTEST) ./kv/test_raftstore -run ^TestBasicConfChange3B$ || true
$(GOTEST) ./kv/test_raftstore -run ^TestConfChangeRemoveLeader3B$ || true
$(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
$(TEST_CLEAN)
project3b_TestConfChangeRemoveLeader3B10s:
$(TEST_CLEAN)
$(GOTEST) ./kv/test_raftstore -run ^TestConfChangeRemoveLeader3B$ || true
$(GOTEST) ./kv/test_raftstore -run ^TestConfChangeRemoveLeader3B$ || true
$(GOTEST) ./kv/test_raftstore -run ^TestConfChangeRemoveLeader3B$ || true
$(GOTEST) ./kv/test_raftstore -run ^TestConfChangeRemoveLeader3B$ || true
$(GOTEST) ./kv/test_raftstore -run ^TestConfChangeRemoveLeader3B$ || true
$(GOTEST) ./kv/test_raftstore -run ^TestConfChangeRemoveLeader3B$ || true
$(GOTEST) ./kv/test_raftstore -run ^TestConfChangeRemoveLeader3B$ || true
$(GOTEST) ./kv/test_raftstore -run ^TestConfChangeRemoveLeader3B$ || true
$(GOTEST) ./kv/test_raftstore -run ^TestConfChangeRemoveLeader3B$ || true
$(GOTEST) ./kv/test_raftstore -run ^TestConfChangeRemoveLeader3B$ || true
$(TEST_CLEAN)
project3b_TestConfChangeUnreliableRecover3B10s:
$(TEST_CLEAN)
$(GOTEST) ./kv/test_raftstore -run ^TestConfChangeUnreliableRecover3B$ || true
$(GOTEST) ./kv/test_raftstore -run ^TestConfChangeUnreliableRecover3B$ || true
$(GOTEST) ./kv/test_raftstore -run ^TestConfChangeUnreliableRecover3B$ || true
$(GOTEST) ./kv/test_raftstore -run ^TestConfChangeUnreliableRecover3B$ || true
$(GOTEST) ./kv/test_raftstore -run ^TestConfChangeUnreliableRecover3B$ || true
$(GOTEST) ./kv/test_raftstore -run ^TestConfChangeUnreliableRecover3B$ || true
$(GOTEST) ./kv/test_raftstore -run ^TestConfChangeUnreliableRecover3B$ || true
$(GOTEST) ./kv/test_raftstore -run ^TestConfChangeUnreliableRecover3B$ || true
$(GOTEST) ./kv/test_raftstore -run ^TestConfChangeUnreliableRecover3B$ || true
$(GOTEST) ./kv/test_raftstore -run ^TestConfChangeUnreliableRecover3B$ || true
$(TEST_CLEAN)
project3b_Split:
$(TEST_CLEAN)
$(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
$(TEST_CLEAN)
project3b_TestOneSplit3B10s:
$(TEST_CLEAN)
$(GOTEST) ./kv/test_raftstore -run ^TestOneSplit3B$ || true
$(GOTEST) ./kv/test_raftstore -run ^TestOneSplit3B$ || true
$(GOTEST) ./kv/test_raftstore -run ^TestOneSplit3B$ || true
$(GOTEST) ./kv/test_raftstore -run ^TestOneSplit3B$ || true
$(GOTEST) ./kv/test_raftstore -run ^TestOneSplit3B$ || true
$(GOTEST) ./kv/test_raftstore -run ^TestOneSplit3B$ || true
$(GOTEST) ./kv/test_raftstore -run ^TestOneSplit3B$ || true
$(GOTEST) ./kv/test_raftstore -run ^TestOneSplit3B$ || true
$(GOTEST) ./kv/test_raftstore -run ^TestOneSplit3B$ || true
$(GOTEST) ./kv/test_raftstore -run ^TestOneSplit3B$ || true
$(TEST_CLEAN)
project3b_TestSplitConfChangeSnapshotUnreliableRecoverConcurrentPartition3B10s:
$(TEST_CLEAN)
$(GOTEST) ./kv/test_raftstore -run ^TestSplitConfChangeSnapshotUnreliableRecoverConcurrentPartition3B$ || true
$(GOTEST) ./kv/test_raftstore -run ^TestSplitConfChangeSnapshotUnreliableRecoverConcurrentPartition3B$ || true
$(GOTEST) ./kv/test_raftstore -run ^TestSplitConfChangeSnapshotUnreliableRecoverConcurrentPartition3B$ || true
$(GOTEST) ./kv/test_raftstore -run ^TestSplitConfChangeSnapshotUnreliableRecoverConcurrentPartition3B$ || true
$(GOTEST) ./kv/test_raftstore -run ^TestSplitConfChangeSnapshotUnreliableRecoverConcurrentPartition3B$ || true
$(GOTEST) ./kv/test_raftstore -run ^TestSplitConfChangeSnapshotUnreliableRecoverConcurrentPartition3B$ || true
$(GOTEST) ./kv/test_raftstore -run ^TestSplitConfChangeSnapshotUnreliableRecoverConcurrentPartition3B$ || true
$(GOTEST) ./kv/test_raftstore -run ^TestSplitConfChangeSnapshotUnreliableRecoverConcurrentPartition3B$ || true
$(GOTEST) ./kv/test_raftstore -run ^TestSplitConfChangeSnapshotUnreliableRecoverConcurrentPartition3B$ || true
$(GOTEST) ./kv/test_raftstore -run ^TestSplitConfChangeSnapshotUnreliableRecoverConcurrentPartition3B$ || true
$(TEST_CLEAN)
project3c:
$(GOTEST) ./scheduler/server ./scheduler/server/schedulers -check.f="3C"
project4: project4a project4b project4c
project4a:
$(GOTEST) ./kv/transaction/... -run 4A
project4b:
$(GOTEST) ./kv/transaction/... -run 4B
project4c:
$(GOTEST) ./kv/transaction/... -run 4C