-
Notifications
You must be signed in to change notification settings - Fork 975
/
Makefile
464 lines (378 loc) · 15.8 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
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
SHELL := /bin/bash
PATH := ./work/redis-git/src:${PATH}
ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
STUNNEL_BIN := $(shell which stunnel)
BREW_BIN := $(shell which brew)
YUM_BIN := $(shell which yum)
APT_BIN := $(shell which apt-get)
PROFILE ?= ci
REDIS ?= unstable
define REDIS_CLUSTER_CONFIG1
c2043458aa5646cee429fdd5e3c18220dddf2ce5 127.0.0.1:7380 master - 1434887920102 1434887920002 0 connected 12000-16383
27f88788f03a86296b7d860152f4ae24ee59c8c9 127.0.0.1:7379 myself,master - 0 0 1 connected 0-11999
2c07344ffa94ede5ea57a2367f190af6144c1adb 127.0.0.1:7382 slave c2043458aa5646cee429fdd5e3c18220dddf2ce5 1434887920102 1434887920002 2 connected
1c541b6daf98719769e6aacf338a7d81f108a180 127.0.0.1:7381 slave 27f88788f03a86296b7d860152f4ae24ee59c8c9 1434887920102 1434887920002 3 connected
vars currentEpoch 3 lastVoteEpoch 0
endef
define REDIS_CLUSTER_CONFIG2
2c07344ffa94ede5ea57a2367f190af6144c1adb 127.0.0.1:7382 slave c2043458aa5646cee429fdd5e3c18220dddf2ce5 1434887920102 1434887920002 2 connected
27f88788f03a86296b7d860152f4ae24ee59c8c9 127.0.0.1:7379 master - 1434887920102 1434887920002 1 connected 0-11999
1c541b6daf98719769e6aacf338a7d81f108a180 127.0.0.1:7381 slave 27f88788f03a86296b7d860152f4ae24ee59c8c9 1434887920102 1434887920002 3 connected
c2043458aa5646cee429fdd5e3c18220dddf2ce5 127.0.0.1:7380 myself,master - 0 0 0 connected 12000-16383
vars currentEpoch 3 lastVoteEpoch 0
endef
define REDIS_CLUSTER_CONFIG3
1c541b6daf98719769e6aacf338a7d81f108a180 127.0.0.1:7381 myself,slave 27f88788f03a86296b7d860152f4ae24ee59c8c9 0 0 3 connected
2c07344ffa94ede5ea57a2367f190af6144c1adb 127.0.0.1:7382 slave c2043458aa5646cee429fdd5e3c18220dddf2ce5 1434887920102 1434887920002 2 connected
c2043458aa5646cee429fdd5e3c18220dddf2ce5 127.0.0.1:7380 master - 1434887920102 1434887920002 0 connected 12000-16383
27f88788f03a86296b7d860152f4ae24ee59c8c9 127.0.0.1:7379 master - 1434887920102 1434887920002 1 connected 0-11999
vars currentEpoch 3 lastVoteEpoch 0
endef
define REDIS_CLUSTER_CONFIG4
c2043458aa5646cee429fdd5e3c18220dddf2ce5 127.0.0.1:7380 master - 0 1434887920102 0 connected 12000-16383
1c541b6daf98719769e6aacf338a7d81f108a180 127.0.0.1:7381 slave 27f88788f03a86296b7d860152f4ae24ee59c8c9 0 1434887920102 3 connected
2c07344ffa94ede5ea57a2367f190af6144c1adb 127.0.0.1:7382 myself,slave c2043458aa5646cee429fdd5e3c18220dddf2ce5 0 0 2 connected
27f88788f03a86296b7d860152f4ae24ee59c8c9 127.0.0.1:7379 master - 0 1434887920102 1 connected 0-11999
vars currentEpoch 3 lastVoteEpoch 0
endef
define REDIS_CLUSTER_CONFIG8
c2043458aa5646cee429fdd5e3c18220dddf2ce5 127.0.0.1:7580 master - 1434887920102 1434887920002 0 connected 10001-16383
27f88788f03a86296b7d860152f4ae24ee59c8c9 127.0.0.1:7579 myself,master - 0 0 1 connected 0-10000
2c07344ffa94ede5ea57a2367f190af6144c1adb 127.0.0.1:7582 slave c2043458aa5646cee429fdd5e3c18220dddf2ce5 1434887920102 1434887920002 2 connected
1c541b6daf98719769e6aacf338a7d81f108a180 127.0.0.1:7581 slave 27f88788f03a86296b7d860152f4ae24ee59c8c9 1434887920102 1434887920002 3 connected
vars currentEpoch 3 lastVoteEpoch 0
endef
define REDIS_CLUSTER_CONFIG_SSL_1
cf2354ef19ee813a962350b51438314aebce1fe2 127.0.0.1:7479@17479 myself,master - 0 1578163609000 0 connected 0-10000
cac8e053dd6f85fab470be57d29dcbac2a4b85c4 127.0.0.1:7480@17480 slave cf2354ef19ee813a962350b51438314aebce1fe2 0 1578163609301 1 connected
6554e5b1b158dccd4b1d9ca294a3e46a2d3e556d 127.0.0.1:7481@17481 master - 0 1578163609301 2 connected 10001-16383
vars currentEpoch 2 lastVoteEpoch 0
endef
define REDIS_CLUSTER_CONFIG_SSL_2
cf2354ef19ee813a962350b51438314aebce1fe2 127.0.0.1:7479@17479 master - 0 1578163609245 0 connected 0-10000
cac8e053dd6f85fab470be57d29dcbac2a4b85c4 127.0.0.1:7480@17480 myself,slave cf2354ef19ee813a962350b51438314aebce1fe2 0 1578163609000 1 connected
6554e5b1b158dccd4b1d9ca294a3e46a2d3e556d 127.0.0.1:7481@17481 master - 0 1578163609245 2 connected 10001-16383
vars currentEpoch 2 lastVoteEpoch 0
endef
define REDIS_CLUSTER_CONFIG_SSL_3
cac8e053dd6f85fab470be57d29dcbac2a4b85c4 127.0.0.1:7480@17480 slave cf2354ef19ee813a962350b51438314aebce1fe2 0 1578163609279 1 connected
cf2354ef19ee813a962350b51438314aebce1fe2 127.0.0.1:7479@17479 master - 0 1578163609279 0 connected 0-10000
6554e5b1b158dccd4b1d9ca294a3e46a2d3e556d 127.0.0.1:7481@17481 myself,master - 0 1578163609000 2 connected 10001-16383
vars currentEpoch 2 lastVoteEpoch 0
endef
#######
# Redis
#######
.PRECIOUS: work/redis-%.conf
# Sentinel monitored slave
work/redis-6483.conf:
@mkdir -p $(@D)
@echo port 6483 >> $@
@echo daemonize yes >> $@
@echo pidfile $(shell pwd)/work/redis-6483.pid >> $@
@echo logfile $(shell pwd)/work/redis-6483.log >> $@
@echo save \"\" >> $@
@echo appendonly no >> $@
@echo client-output-buffer-limit pubsub 256k 128k 5 >> $@
@echo unixsocket $(ROOT_DIR)/work/socket-6483 >> $@
@echo unixsocketperm 777 >> $@
@echo enable-debug-command yes >> $@
ifeq ($(REDIS),unstable)
@echo slaveof localhost 6482 >> $@
@echo replica-announce-ip localhost >> $@
else
@echo slaveof 127.0.1 6482 >> $@
endif
work/redis-%.conf:
@mkdir -p $(@D)
@echo port $* >> $@
@echo daemonize yes >> $@
@echo pidfile $(shell pwd)/work/redis-$*.pid >> $@
@echo logfile $(shell pwd)/work/redis-$*.log >> $@
@echo save \"\" >> $@
@echo appendonly no >> $@
@echo client-output-buffer-limit pubsub 256k 128k 5 >> $@
@echo unixsocket $(ROOT_DIR)/work/socket-$* >> $@
@echo unixsocketperm 777 >> $@
@echo enable-debug-command yes >> $@
ifeq ($(REDIS),unstable)
@echo replica-announce-ip localhost >> $@
endif
work/redis-%.pid: work/redis-%.conf work/redis-git/src/redis-server
work/redis-git/src/redis-server $<
redis-start: work/redis-6479.pid work/redis-6480.pid work/redis-6481.pid work/redis-6482.pid work/redis-6483.pid work/redis-6484.pid
##########
# Sentinel
##########
.PRECIOUS: work/sentinel-%.conf
work/sentinel-%.conf:
@mkdir -p $(@D)
@echo port $* >> $@
@echo daemonize yes >> $@
@echo pidfile $(shell pwd)/work/redis-sentinel-$*.pid >> $@
@echo logfile $(shell pwd)/work/redis-sentinel-$*.log >> $@
ifeq ($(REDIS),unstable)
@echo sentinel monitor mymaster localhost 6482 1 >> $@
@echo sentinel announce-hostnames yes >> $@
@echo sentinel resolve-hostnames yes >> $@
@echo sentinel announce-ip localhost >> $@
else
@echo sentinel monitor mymaster 127.0.0.1 6482 1 >> $@
endif
@echo sentinel down-after-milliseconds mymaster 200 >> $@
@echo sentinel failover-timeout mymaster 200 >> $@
@echo sentinel parallel-syncs mymaster 1 >> $@
@echo unixsocket $(ROOT_DIR)/work/socket-$* >> $@
@echo unixsocketperm 777 >> $@
work/sentinel-26381.conf:
@mkdir -p $(@D)
@echo port 26381 >> $@
@echo daemonize yes >> $@
@echo pidfile $(shell pwd)/work/redis-sentinel-26381.pid >> $@
@echo logfile $(shell pwd)/work/redis-sentinel-26381.log >> $@
ifeq ($(REDIS),unstable)
@echo sentinel monitor mymaster localhost 6484 1 >> $@
@echo sentinel announce-hostnames yes >> $@
@echo sentinel resolve-hostnames yes >> $@
else
@echo sentinel monitor mymaster 127.0.0.1 6484 1 >> $@
endif
@echo sentinel down-after-milliseconds mymaster 200 >> $@
@echo sentinel failover-timeout mymaster 200 >> $@
@echo sentinel parallel-syncs mymaster 1 >> $@
@echo unixsocket $(ROOT_DIR)/work/socket-$* >> $@
@echo unixsocketperm 777 >> $@
@echo requirepass foobared >> $@
work/sentinel-%.pid: work/sentinel-%.conf work/redis-git/src/redis-server
work/redis-git/src/redis-server $< --sentinel
sleep 0.5
sentinel-start: work/sentinel-26379.pid work/sentinel-26380.pid work/sentinel-26381.pid
##########
# Cluster
##########
.PRECIOUS: work/cluster-node-%.conf
work/cluster-node-7385.conf:
@mkdir -p $(@D)
@echo port 7385 >> $@
@echo daemonize yes >> $@
@echo pidfile $(shell pwd)/work/cluster-node-7385.pid >> $@
@echo logfile $(shell pwd)/work/cluster-node-7385.log >> $@
@echo save \"\" >> $@
@echo appendonly no >> $@
@echo unixsocket $(ROOT_DIR)/work/socket-7385 >> $@
@echo cluster-enabled yes >> $@
@echo cluster-node-timeout 150 >> $@
@echo cluster-config-file $(shell pwd)/work/cluster-node-config-7385.conf >> $@
@echo requirepass foobared >> $@
work/cluster-node-7479.conf:
@mkdir -p $(@D)
@echo port 7479 >> $@
@echo daemonize yes >> $@
@echo pidfile $(shell pwd)/work/cluster-node-7479.pid >> $@
@echo logfile $(shell pwd)/work/cluster-node-7479.log >> $@
@echo save \"\" >> $@
@echo appendonly no >> $@
@echo cluster-enabled yes >> $@
@echo cluster-node-timeout 150 >> $@
@echo cluster-config-file $(shell pwd)/work/cluster-node-config-7479.conf >> $@
@echo cluster-announce-port 7442 >> $@
@echo requirepass foobared >> $@
work/cluster-node-7480.conf:
@mkdir -p $(@D)
@echo port 7480 >> $@
@echo daemonize yes >> $@
@echo pidfile $(shell pwd)/work/cluster-node-7480.pid >> $@
@echo logfile $(shell pwd)/work/cluster-node-7480.log >> $@
@echo save \"\" >> $@
@echo appendonly no >> $@
@echo cluster-enabled yes >> $@
@echo cluster-node-timeout 150 >> $@
@echo cluster-config-file $(shell pwd)/work/cluster-node-config-7480.conf >> $@
@echo cluster-announce-port 7444 >> $@
@echo requirepass foobared >> $@
work/cluster-node-7481.conf:
@mkdir -p $(@D)
@echo port 7481 >> $@
@echo daemonize yes >> $@
@echo pidfile $(shell pwd)/work/cluster-node-7481.pid >> $@
@echo logfile $(shell pwd)/work/cluster-node-7481.log >> $@
@echo save \"\" >> $@
@echo appendonly no >> $@
@echo cluster-enabled yes >> $@
@echo cluster-node-timeout 150 >> $@
@echo cluster-config-file $(shell pwd)/work/cluster-node-config-7481.conf >> $@
@echo cluster-announce-port 7445 >> $@
@echo requirepass foobared >> $@
work/cluster-node-%.conf:
@mkdir -p $(@D)
@echo port $* >> $@
@echo daemonize yes >> $@
@echo pidfile $(shell pwd)/work/cluster-node-$*.pid >> $@
@echo logfile $(shell pwd)/work/cluster-node-$*.log >> $@
@echo save \"\" >> $@
@echo appendonly no >> $@
@echo client-output-buffer-limit pubsub 256k 128k 5 >> $@
@echo unixsocket $(ROOT_DIR)/work/socket-$* >> $@
@echo cluster-enabled yes >> $@
@echo cluster-node-timeout 150 >> $@
@echo cluster-config-file $(shell pwd)/work/cluster-node-config-$*.conf >> $@
work/cluster-node-%.pid: work/cluster-node-%.conf work/redis-git/src/redis-server
work/redis-git/src/redis-server $< || true
cluster-start: work/cluster-node-7379.pid work/cluster-node-7380.pid work/cluster-node-7381.pid work/cluster-node-7382.pid work/cluster-node-7383.pid work/cluster-node-7384.pid work/cluster-node-7385.pid work/cluster-node-7479.pid work/cluster-node-7480.pid work/cluster-node-7481.pid work/cluster-node-7582.pid
##########
# stunnel
##########
work/stunnel.conf:
@mkdir -p $(@D)
@echo cert=$(ROOT_DIR)/work/ca/certs/localhost.cert.pem >> $@
@echo key=$(ROOT_DIR)/work/ca/private/localhost.decrypted.key.pem >> $@
@echo capath=$(ROOT_DIR)/work/ca/certs/ca.cert.pem >> $@
@echo cafile=$(ROOT_DIR)/work/ca/certs/ca.cert.pem >> $@
@echo delay=yes >> $@
@echo pid=$(ROOT_DIR)/work/stunnel.pid >> $@
@echo foreground = no >> $@
@echo [stunnel] >> $@
@echo accept = 127.0.0.1:6443 >> $@
@echo connect = 127.0.0.1:6479 >> $@
@echo [redis-sni-vritual] >> $@
@echo accept = 127.0.0.1:36443 >> $@
@echo cert=$(ROOT_DIR)/work/ca/certs/foo-host.cert.pem >> $@
@echo key=$(ROOT_DIR)/work/ca/private/foo-host.decrypted.key.pem >> $@
@echo connect = unavailable.internal.mydomain.com:6666 >> $@
@echo [redis-sni1] >> $@
@echo sni = redis-sni-vritual:redis-sni1.local >> $@
@echo key=$(ROOT_DIR)/work/ca/private/localhost.decrypted.key.pem >> $@
@echo cert=$(ROOT_DIR)/work/ca/certs/localhost.cert.pem >> $@
@echo connect = localhost:6480 >> $@
@echo [redis-sni2] >> $@
@echo sni = redis-sni-vritual:redis-sni2.local >> $@
@echo connect = localhost:6479 >> $@
@echo cert=$(ROOT_DIR)/work/ca/certs/foo-host.cert.pem >> $@
@echo key=$(ROOT_DIR)/work/ca/private/foo-host.decrypted.key.pem >> $@
@echo [foo-host] >> $@
@echo accept = 127.0.0.1:6444 >> $@
@echo connect = 127.0.0.1:6479 >> $@
@echo cert=$(ROOT_DIR)/work/ca/certs/foo-host.cert.pem >> $@
@echo key=$(ROOT_DIR)/work/ca/private/foo-host.decrypted.key.pem >> $@
@echo [ssl-cluster-node-1] >> $@
@echo accept = 127.0.0.1:7442 >> $@
@echo connect = 127.0.0.1:7479 >> $@
@echo [ssl-cluster-node-2] >> $@
@echo accept = 127.0.0.1:7444 >> $@
@echo connect = 127.0.0.1:7480 >> $@
@echo [ssl-cluster-node-3] >> $@
@echo accept = 127.0.0.1:7445 >> $@
@echo connect = 127.0.0.1:7481 >> $@
@echo [ssl-sentinel-1] >> $@
@echo accept = 127.0.0.1:26822 >> $@
@echo connect = 127.0.0.1:26379 >> $@
@echo [ssl-sentinel-2] >> $@
@echo accept = 127.0.0.1:26823 >> $@
@echo connect = 127.0.0.1:26380 >> $@
@echo [ssl-sentinel-3] >> $@
@echo accept = 127.0.0.1:26824 >> $@
@echo connect = 127.0.0.1:26381 >> $@
@echo [ssl-sentinel-master] >> $@
@echo accept = 127.0.0.1:6925 >> $@
@echo connect = 127.0.0.1:6482 >> $@
@echo [ssl-sentinel-slave] >> $@
@echo accept = 127.0.0.1:6926 >> $@
@echo connect = 127.0.0.1:6482 >> $@
@echo [stunnel-client-cert] >> $@
@echo accept = 127.0.0.1:6445 >> $@
@echo connect = 127.0.0.1:6479 >> $@
@echo verify=2 >> $@
@echo [stunnel-master-slave-node-1] >> $@
@echo accept = 127.0.0.1:8443 >> $@
@echo connect = 127.0.0.1:6482 >> $@
@echo [stunnel-master-slave-node-2] >> $@
@echo accept = 127.0.0.1:8444 >> $@
@echo connect = 127.0.0.1:6483 >> $@
work/stunnel.pid: work/stunnel.conf ssl-keys
which stunnel4 >/dev/null 2>&1 && stunnel4 $(ROOT_DIR)/work/stunnel.conf || stunnel $(ROOT_DIR)/work/stunnel.conf
stunnel-start: work/stunnel.pid
export REDIS_CLUSTER_CONFIG1
export REDIS_CLUSTER_CONFIG2
export REDIS_CLUSTER_CONFIG3
export REDIS_CLUSTER_CONFIG4
export REDIS_CLUSTER_CONFIG8
export REDIS_CLUSTER_CONFIG_SSL_1
export REDIS_CLUSTER_CONFIG_SSL_2
export REDIS_CLUSTER_CONFIG_SSL_3
start: cleanup
@echo "$$REDIS_CLUSTER_CONFIG1" > work/cluster-node-config-7379.conf
@echo "$$REDIS_CLUSTER_CONFIG2" > work/cluster-node-config-7380.conf
@echo "$$REDIS_CLUSTER_CONFIG3" > work/cluster-node-config-7381.conf
@echo "$$REDIS_CLUSTER_CONFIG4" > work/cluster-node-config-7382.conf
@echo "$$REDIS_CLUSTER_CONFIG8" > work/cluster-node-config-7582.conf
@echo "$$REDIS_CLUSTER_CONFIG_SSL_1" > work/cluster-node-config-7479.conf
@echo "$$REDIS_CLUSTER_CONFIG_SSL_2" > work/cluster-node-config-7480.conf
@echo "$$REDIS_CLUSTER_CONFIG_SSL_3" > work/cluster-node-config-7481.conf
$(MAKE) redis-start
$(MAKE) sentinel-start
$(MAKE) cluster-start
$(MAKE) stunnel-start
cleanup: stop
@mkdir -p work
rm -f work/cluster-node*.conf 2>/dev/null
rm -f work/*.rdb work/*.aof work/*.conf work/*.log 2>/dev/null
rm -f *.aof
rm -f *.rdb
rm -f work/socket-*
##########
# SSL Keys
# - remove Java keystore as becomes stale
##########
work/keystore.jks:
@mkdir -p $(@D)
- rm -f work/*.jks
- rm -Rf work/ca
src/test/bash/create_certificates.sh
ssl-keys: work/keystore.jks
stop:
pkill stunnel || true
pkill redis-server && sleep 1 || true
pkill redis-sentinel && sleep 1 || true
test-coverage: start
mvn -DskipITs=false clean compile verify jacoco:report -P$(PROFILE)
$(MAKE) stop
test: start
mvn -DskipITs=false clean compile verify -P$(PROFILE)
$(MAKE) stop
prepare: stop
ifndef STUNNEL_BIN
ifeq ($(shell uname -s),Linux)
ifdef APT_BIN
sudo apt-get install -y stunnel
else
ifdef YUM_BIN
sudo yum install stunnel
else
@@echo "Cannot install stunnel using yum/apt-get"
@exit 1
endif
endif
endif
ifeq ($(shell uname -s),Darwin)
ifndef BREW_BIN
@@echo "Cannot install stunnel because missing brew.sh"
@exit 1
endif
brew install stunnel
endif
endif
work/redis-git/src/redis-cli work/redis-git/src/redis-server:
[ -d "work/redis-git" ] && cd work/redis-git && git reset --hard || \
git clone https://github.com/antirez/redis.git work/redis-git
cd work/redis-git && git checkout -q $(REDIS) && git pull origin $(REDIS)
$(MAKE) -C work/redis-git clean
$(MAKE) -C work/redis-git -j4
clean:
rm -Rf work/
rm -Rf target/
release:
mvn release:clean
mvn release:prepare
mvn release:perform
ls target/checkout/target/*-bin.zip | xargs gpg -b -a
ls target/checkout/target/*-bin.tar.gz | xargs gpg -b -a