-
Notifications
You must be signed in to change notification settings - Fork 79
/
Makefile
613 lines (486 loc) · 22.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
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
PROJECT := go-driver
SCRIPTDIR := $(shell pwd)
CURR=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
ROOTDIR:=$(CURR)
GOVERSION ?= 1.22.8
GOIMAGE ?= golang:$(GOVERSION)
GOV2IMAGE ?= $(GOIMAGE)
ALPINE_IMAGE ?= alpine:3.17
TMPDIR := ${SCRIPTDIR}/.tmp
DOCKER_CMD:=docker run
GOBUILDTAGS:=$(TAGS)
GOBUILDTAGSOPT=-tags "$(GOBUILDTAGS)"
ARANGODB ?= arangodb/arangodb:latest
STARTER ?= arangodb/arangodb-starter:latest
ifndef TESTOPTIONS
TESTOPTIONS :=
endif
ifdef VERBOSE
TESTVERBOSEOPTIONS := -v
endif
CGO_ENABLED=0
ifdef RACE
TESTVERBOSEOPTIONS += -race
CGO_ENABLED=1
endif
ifndef AF_ENABLED
AF_ENABLED := "false"
endif
ifndef VST_ENABLED
VST_ENABLED := "false"
endif
TESTV2PARALLEL ?= 1
ORGPATH := github.com/arangodb
REPONAME := $(PROJECT)
REPODIR := $(ORGDIR)/$(REPONAME)
REPOPATH := $(ORGPATH)/$(REPONAME)
SOURCES_EXCLUDE:=vendor
SOURCES := $(shell find "$(ROOTDIR)" $(foreach SOURCE,$(SOURCES_EXCLUDE),-not -path '$(ROOTDIR)/$(SOURCE)/*') -name '*.go')
# Test variables
ifndef TESTCONTAINER
TESTCONTAINER := $(PROJECT)-test
endif
ifndef DBCONTAINER
DBCONTAINER := $(TESTCONTAINER)-db
endif
ifeq ("$(TEST_AUTH)", "none")
ARANGOENV := -e ARANGO_NO_AUTH=1
TEST_AUTHENTICATION :=
TESTS := $(REPOPATH) $(REPOPATH)/test
else ifeq ("$(TEST_AUTH)", "rootpw")
ARANGOENV := -e ARANGO_ROOT_PASSWORD=rootpw
TEST_AUTHENTICATION := basic:root:rootpw
GOBUILDTAGS += auth
TESTS := $(REPOPATH)/test
else ifeq ("$(TEST_AUTH)", "jwt")
ARANGOENV := -e ARANGO_ROOT_PASSWORD=rootpw
TEST_AUTHENTICATION := jwt:root:rootpw
GOBUILDTAGS += auth
TESTS := $(REPOPATH)/test
JWTSECRET := testing
JWTSECRETFILE := "${TMPDIR}/${TESTCONTAINER}-jwtsecret"
ARANGOVOL := -v "$(JWTSECRETFILE):/jwtsecret"
ARANGOARGS := --server.jwt-secret=/jwtsecret
endif
TEST_NET := --net=container:$(TESTCONTAINER)-ns
# By default we run tests against single endpoint to avoid problems with data propagation in Cluster mode
# e.g. when we create a document in one endpoint, it may not be visible in another endpoint for a while
TEST_ENDPOINTS := http://localhost:7001
TESTS := $(REPOPATH)/test
ifeq ("$(TEST_AUTH)", "rootpw")
CLUSTERENV := JWTSECRET=testing
TEST_JWTSECRET := testing
TEST_AUTHENTICATION := basic:root:
endif
ifeq ("$(TEST_AUTH)", "jwt")
CLUSTERENV := JWTSECRET=testing
TEST_JWTSECRET := testing
TEST_AUTHENTICATION := jwt:root:
endif
ifeq ("$(TEST_AUTH)", "jwtsuper")
CLUSTERENV := JWTSECRET=testing
TEST_JWTSECRET := testing
TEST_AUTHENTICATION := super:testing
endif
ifeq ("$(TEST_SSL)", "auto")
CLUSTERENV := SSL=auto $(CLUSTERENV)
TEST_ENDPOINTS = https://localhost:7001
endif
ifeq ("$(TEST_CONNECTION)", "vst")
TESTS := $(REPOPATH)/test
ifndef TEST_CONTENT_TYPE
TEST_CONTENT_TYPE := vpack
endif
endif
ifeq ("$(TEST_BENCHMARK)", "true")
TAGS := -bench=. -run=notests -cpu=1,2,4
TESTS := $(REPOPATH)/test
endif
ifdef TEST_ENDPOINTS_OVERRIDE
TEST_NET := --net=host
TEST_ENDPOINTS := $(TEST_ENDPOINTS_OVERRIDE)
endif
ifdef TEST_NET_OVERRIDE
TEST_NET := $(TEST_NET_OVERRIDE)
endif
ifdef ENABLE_VST11
VST11_SINGLE_TESTS := run-tests-single-vst-1.1
VST11_RESILIENTSINGLE_TESTS := run-tests-resilientsingle-vst-1.1
VST11_CLUSTER_TESTS := run-tests-cluster-vst-1.1
endif
TEST_RESOURCES_VOLUME :=
ifdef TEST_RESOURCES
TEST_RESOURCES_VOLUME := -v ${TEST_RESOURCES}:/tmp/resources
endif
ifeq ("$(DEBUG)", "true")
GOIMAGE := go-driver-tests:debug
DOCKER_DEBUG_ARGS := --security-opt=seccomp:unconfined
DEBUG_PORT := 2345
DOCKER_RUN_CMD := $(DOCKER_DEBUG_ARGS) $(GOIMAGE) /go/bin/dlv --listen=:$(DEBUG_PORT) --headless=true --api-version=2 exec /test_debug.test -- $(TESTOPTIONS)
DOCKER_V2_RUN_CMD := $(DOCKER_RUN_CMD)
else
DOCKER_RUN_CMD := $(GOIMAGE) go test -timeout 120m $(GOBUILDTAGSOPT) $(TESTOPTIONS) $(TESTVERBOSEOPTIONS) $(TESTS)
DOCKER_V2_RUN_CMD := $(GOV2IMAGE) go test -timeout 120m $(GOBUILDTAGSOPT) $(TESTOPTIONS) $(TESTVERBOSEOPTIONS) -parallel $(TESTV2PARALLEL) ./tests
endif
.PHONY: all build clean linter run-tests vulncheck
all: build
build: __dir_setup $(SOURCES)
go build -v $(REPOPATH) $(REPOPATH)/http $(REPOPATH)/vst $(REPOPATH)/agency $(REPOPATH)/jwt
clean:
@rm -rf "${TMPDIR}"
.PHONY: changelog
changelog:
@$(DOCKER_CMD) --rm \
-e CHANGELOG_GITHUB_TOKEN=$(shell cat ~/.arangodb/github-token) \
-v "${ROOTDIR}":/usr/local/src/your-app \
ferrarimarco/github-changelog-generator \
--user arangodb \
--project go-driver \
--no-author \
--unreleased-label "Master"
run-tests: run-unit-tests run-tests-single run-tests-cluster
ifeq ("$(AF_ENABLED)", "true")
make run-tests-resilientsingle
endif
# The below rule exists only for backward compatibility.
run-tests-http: run-unit-tests
run-unit-tests: run-v2-unit-tests
@$(DOCKER_CMD) \
--rm \
-v "${ROOTDIR}":/usr/code \
-e CGO_ENABLED=$(CGO_ENABLED) \
-w /usr/code/ \
$(GOIMAGE) \
go test $(TESTOPTIONS) $(REPOPATH) $(REPOPATH)/http $(REPOPATH)/agency $(REPOPATH)/vst/protocol
run-v2-unit-tests:
@$(DOCKER_CMD) \
--rm \
-v "${ROOTDIR}"/v2:/usr/code \
-e CGO_ENABLED=$(CGO_ENABLED) \
-w /usr/code/ \
$(GOIMAGE) \
go test $(TESTOPTIONS) $(REPOPATH)/v2/connection $(REPOPATH)/v2/arangodb/...
# Single server tests
run-tests-single: run-tests-single-json run-tests-single-vpack
ifeq ("$(VST_ENABLED)", "true")
make run-tests-single-vst-1.0 $(VST11_SINGLE_TESTS)
endif
run-tests-single-json: run-tests-single-json-with-auth run-tests-single-json-no-auth run-tests-single-json-jwt-super run-tests-single-json-ssl
run-tests-single-vpack: run-tests-single-vpack-with-auth run-tests-single-vpack-no-auth run-tests-single-vpack-ssl
run-tests-single-vst-1.0: run-tests-single-vst-1.0-with-auth run-tests-single-vst-1.0-no-auth run-tests-single-vst-1.0-ssl
run-tests-single-vst-1.1: run-tests-single-vst-1.1-with-auth run-tests-single-vst-1.1-jwt-auth run-tests-single-vst-1.1-no-auth run-tests-single-vst-1.1-ssl run-tests-single-vst-1.1-jwt-ssl
run-tests-single-json-no-auth:
@echo "Single server, HTTP+JSON, no authentication"
@${MAKE} TEST_MODE="single" TEST_AUTH="none" TEST_CONTENT_TYPE="json" __run_tests
run-tests-single-vpack-no-auth:
@echo "Single server, HTTP+Velocypack, no authentication"
@${MAKE} TEST_MODE="single" TEST_AUTH="none" TEST_CONTENT_TYPE="vpack" __run_tests
run-tests-single-vst-1.0-no-auth:
@echo "Single server, Velocystream 1.0, no authentication"
@${MAKE} TEST_MODE="single" TEST_AUTH="none" TEST_CONNECTION="vst" TEST_CVERSION="1.0" __run_tests
run-tests-single-vst-1.1-no-auth:
@echo "Single server, Velocystream 1.1, no authentication"
@${MAKE} TEST_MODE="single" TEST_AUTH="none" TEST_CONNECTION="vst" TEST_CVERSION="1.1" __run_tests
run-tests-single-json-with-auth:
@echo "Single server, HTTP+JSON, with authentication"
@${MAKE} TEST_MODE="single" TEST_AUTH="rootpw" TEST_CONTENT_TYPE="json" __run_tests
run-tests-single-json-http2-with-auth:
@echo "Single server, HTTP+JSON, with authentication"
@${MAKE} TEST_MODE="single" TAGS="http2" TEST_AUTH="rootpw" TEST_CONTENT_TYPE="json" __run_tests
run-tests-single-vpack-with-auth:
@echo "Single server, HTTP+Velocypack, with authentication"
@${MAKE} TEST_MODE="single" TEST_AUTH="rootpw" TEST_CONTENT_TYPE="vpack" __run_tests
run-tests-single-vst-1.0-with-auth:
@echo "Single server, Velocystream 1.0, with authentication"
@${MAKE} TEST_MODE="single" TEST_AUTH="rootpw" TEST_CONNECTION="vst" TEST_CVERSION="1.0" __run_tests
run-tests-single-vst-1.1-with-auth:
@echo "Single server, Velocystream 1.1, with authentication"
@${MAKE} TEST_MODE="single" TEST_AUTH="rootpw" TEST_CONNECTION="vst" TEST_CVERSION="1.1" __run_tests
run-tests-single-vst-1.1-jwt-auth:
@echo "Single server, Velocystream 1.1, JWT authentication"
@${MAKE} TEST_MODE="single" TEST_AUTH="jwt" TEST_CONNECTION="vst" TEST_CVERSION="1.1" __run_tests
run-tests-single-json-jwt-super:
@echo "Single server, HTTP+JSON, JWT super authentication"
@${MAKE} TEST_MODE="single" TEST_AUTH="jwtsuper" TEST_CONTENT_TYPE="json" __run_tests
run-tests-single-json-ssl:
@echo "Single server, HTTP+JSON, with authentication, SSL"
@${MAKE} TEST_MODE="single" TEST_AUTH="rootpw" TEST_SSL="auto" TEST_CONTENT_TYPE="json" __run_tests
run-tests-single-vpack-ssl:
@echo "Single server, HTTP+Velocypack, with authentication, SSL"
@${MAKE} TEST_MODE="single" TEST_AUTH="rootpw" TEST_SSL="auto" TEST_CONTENT_TYPE="vpack" __run_tests
run-tests-single-vst-1.0-ssl:
@echo "Single server, Velocystream 1.0, with authentication, SSL"
@${MAKE} TEST_MODE="single" TEST_AUTH="rootpw" TEST_SSL="auto" TEST_CONNECTION="vst" TEST_CVERSION="1.0" __run_tests
run-tests-single-vst-1.1-ssl:
@echo "Single server, Velocystream 1.1, with authentication, SSL"
@${MAKE} TEST_MODE="single" TEST_AUTH="rootpw" TEST_SSL="auto" TEST_CONNECTION="vst" TEST_CVERSION="1.1" __run_tests
run-tests-single-vst-1.1-jwt-ssl:
@echo "Single server, Velocystream 1.1, JWT authentication, SSL"
@${MAKE} TEST_MODE="single" TEST_AUTH="jwt" TEST_SSL="auto" TEST_CONNECTION="vst" TEST_CVERSION="1.1" __run_tests
# ResilientSingle server tests
run-tests-resilientsingle: run-tests-resilientsingle-json run-tests-resilientsingle-vpack
ifeq ("$(VST_ENABLED)", "true")
make run-tests-resilientsingle-vst-1.0 $(VST11_RESILIENTSINGLE_TESTS)
endif
run-tests-resilientsingle-json: run-tests-resilientsingle-json-with-auth run-tests-resilientsingle-json-no-auth
run-tests-resilientsingle-vpack: run-tests-resilientsingle-vpack-with-auth run-tests-resilientsingle-vpack-no-auth
run-tests-resilientsingle-vst-1.0: run-tests-resilientsingle-vst-1.0-with-auth run-tests-resilientsingle-vst-1.0-no-auth
run-tests-resilientsingle-vst-1.1: run-tests-resilientsingle-vst-1.1-with-auth run-tests-resilientsingle-vst-1.1-jwt-auth run-tests-resilientsingle-vst-1.1-no-auth
run-tests-resilientsingle-json-no-auth:
@echo "Resilient Single server, HTTP+JSON, no authentication"
@${MAKE} TEST_MODE="resilientsingle" TEST_AUTH="none" TEST_CONTENT_TYPE="json" __run_tests
run-tests-resilientsingle-vpack-no-auth:
@echo "Resilient Single server, HTTP+Velocypack, no authentication"
@${MAKE} TEST_MODE="resilientsingle" TEST_AUTH="none" TEST_CONTENT_TYPE="vpack" __run_tests
run-tests-resilientsingle-vst-1.0-no-auth:
@echo "Resilient Single server, Velocystream 1.0, no authentication"
@${MAKE} TEST_MODE="resilientsingle" TEST_AUTH="none" TEST_CONNECTION="vst" TEST_CVERSION="1.0" __run_tests
run-tests-resilientsingle-vst-1.1-no-auth:
@echo "Resilient Single server, Velocystream 1.1, no authentication"
@${MAKE} TEST_MODE="resilientsingle" TEST_AUTH="none" TEST_CONNECTION="vst" TEST_CVERSION="1.1" __run_tests
run-tests-resilientsingle-json-with-auth:
@echo "Resilient Single server, HTTP+JSON, with authentication"
@${MAKE} TEST_MODE="resilientsingle" TEST_AUTH="rootpw" TEST_CONTENT_TYPE="json" __run_tests
run-tests-resilientsingle-vpack-with-auth:
@echo "Resilient Single server, HTTP+Velocypack, with authentication"
@${MAKE} TEST_MODE="resilientsingle" TEST_AUTH="rootpw" TEST_CONTENT_TYPE="vpack" __run_tests
run-tests-resilientsingle-vst-1.0-with-auth:
@echo "Resilient Single server, Velocystream 1.0, with authentication"
@${MAKE} TEST_MODE="resilientsingle" TEST_AUTH="rootpw" TEST_CONNECTION="vst" TEST_CVERSION="1.0" __run_tests
run-tests-resilientsingle-vst-1.1-with-auth:
@echo "Resilient Single server, Velocystream 1.1, with authentication"
@${MAKE} TEST_MODE="resilientsingle" TEST_AUTH="rootpw" TEST_CONNECTION="vst" TEST_CVERSION="1.1" __run_tests
run-tests-resilientsingle-vst-1.1-jwt-auth:
@echo "Resilient Single server, Velocystream 1.1, JWT authentication"
@${MAKE} TEST_MODE="resilientsingle" TEST_AUTH="jwt" TEST_CONNECTION="vst" TEST_CVERSION="1.1" __run_tests
# Cluster mode tests
run-tests-cluster: run-tests-cluster-json run-tests-cluster-vpack
ifeq ("$(VST_ENABLED)", "true")
make run-tests-cluster-vst-1.0 $(VST11_CLUSTER_TESTS)
endif
run-tests-cluster-json: run-tests-cluster-json-no-auth run-tests-cluster-json-with-auth run-tests-cluster-json-ssl
run-tests-cluster-vpack: run-tests-cluster-vpack-no-auth run-tests-cluster-vpack-with-auth run-tests-cluster-vpack-ssl
run-tests-cluster-vst-1.0: run-tests-cluster-vst-1.0-no-auth run-tests-cluster-vst-1.0-with-auth run-tests-cluster-vst-1.0-ssl
run-tests-cluster-vst-1.1: run-tests-cluster-vst-1.1-no-auth run-tests-cluster-vst-1.1-with-auth run-tests-cluster-vst-1.1-ssl
run-tests-cluster-json-no-auth:
@echo "Cluster server, JSON, no authentication"
@${MAKE} TEST_MODE="cluster" TEST_AUTH="none" TEST_CONTENT_TYPE="json" __run_tests
run-tests-cluster-vpack-no-auth:
@echo "Cluster server, Velocypack, no authentication"
@${MAKE} TEST_MODE="cluster" TEST_AUTH="none" TEST_CONTENT_TYPE="vpack" __run_tests
run-tests-cluster-vst-1.0-no-auth:
@echo "Cluster server, Velocystream 1.0, no authentication"
@${MAKE} TEST_MODE="cluster" TEST_AUTH="none" TEST_CONNECTION="vst" TEST_CVERSION="1.0" __run_tests
run-tests-cluster-vst-1.1-no-auth:
@echo "Cluster server, Velocystream 1.1, no authentication"
@${MAKE} TEST_MODE="cluster" TEST_AUTH="none" TEST_CONNECTION="vst" TEST_CVERSION="1.1" __run_tests
run-tests-cluster-json-with-auth:
@echo "Cluster server, with authentication"
@${MAKE} TEST_MODE="cluster" TEST_AUTH="rootpw" TEST_CONTENT_TYPE="json" __run_tests
run-tests-cluster-json-jwt-super:
@echo "Cluster server, HTTP+JSON, JWT super authentication"
@${MAKE} TEST_MODE="cluster" TEST_AUTH="jwtsuper" TEST_CONTENT_TYPE="json" __run_tests
run-tests-cluster-vpack-with-auth:
@echo "Cluster server, Velocypack, with authentication"
@${MAKE} TEST_MODE="cluster" TEST_AUTH="rootpw" TEST_CONTENT_TYPE="vpack" __run_tests
run-tests-cluster-vst-1.0-with-auth:
@echo "Cluster server, Velocystream 1.0, with authentication"
@${MAKE} TEST_MODE="cluster" TEST_AUTH="rootpw" TEST_CONNECTION="vst" TEST_CVERSION="1.0" __run_tests
run-tests-cluster-vst-1.1-with-auth:
@echo "Cluster server, Velocystream 1.1, with authentication"
@${MAKE} TEST_MODE="cluster" TEST_AUTH="rootpw" TEST_CONNECTION="vst" TEST_CVERSION="1.1" __run_tests
run-tests-cluster-json-ssl:
@echo "Cluster server, SSL, with authentication"
@${MAKE} TEST_MODE="cluster" TEST_AUTH="rootpw" TEST_SSL="auto" TEST_CONTENT_TYPE="json" __run_tests
run-tests-cluster-vpack-ssl:
@echo "Cluster server, Velocypack, SSL, with authentication"
@${MAKE} TEST_MODE="cluster" TEST_AUTH="rootpw" TEST_SSL="auto" TEST_CONTENT_TYPE="vpack" __run_tests
run-tests-cluster-vst-1.0-ssl:
@echo "Cluster server, Velocystream 1.0, SSL, with authentication"
@${MAKE} TEST_MODE="cluster" TEST_AUTH="rootpw" TEST_SSL="auto" TEST_CONNECTION="vst" TEST_CVERSION="1.0" __run_tests
run-tests-cluster-vst-1.1-ssl:
@echo "Cluster server, Velocystream 1.1, SSL, with authentication"
@${MAKE} TEST_MODE="cluster" TEST_AUTH="rootpw" TEST_SSL="auto" TEST_CONNECTION="vst" TEST_CVERSION="1.1" __run_tests
# Internal test tasks
__run_tests: __test_debug__ __test_prepare __test_go_test __test_cleanup
__test_go_test:
$(DOCKER_CMD) \
--name=$(TESTCONTAINER) \
$(TEST_NET) \
-v "${ROOTDIR}":/usr/code ${TEST_RESOURCES_VOLUME} \
-e TEST_ENDPOINTS=$(TEST_ENDPOINTS) \
-e TEST_NOT_WAIT_UNTIL_READY=$(TEST_NOT_WAIT_UNTIL_READY) \
-e TEST_AUTHENTICATION=$(TEST_AUTHENTICATION) \
-e TEST_JWTSECRET=$(TEST_JWTSECRET) \
-e TEST_CONNECTION=$(TEST_CONNECTION) \
-e TEST_CVERSION=$(TEST_CVERSION) \
-e TEST_CONTENT_TYPE=$(TEST_CONTENT_TYPE) \
-e TEST_PPROF=$(TEST_PPROF) \
-e TEST_MODE=$(TEST_MODE) \
-e TEST_BACKUP_REMOTE_REPO=$(TEST_BACKUP_REMOTE_REPO) \
-e TEST_BACKUP_REMOTE_CONFIG='$(TEST_BACKUP_REMOTE_CONFIG)' \
-e TEST_DEBUG='$(TEST_DEBUG)' \
-e TEST_ENABLE_SHUTDOWN=$(TEST_ENABLE_SHUTDOWN) \
-e TEST_REQUEST_LOG=$(TEST_REQUEST_LOG) \
-e TEST_DISALLOW_UNKNOWN_FIELDS=$(TEST_DISALLOW_UNKNOWN_FIELDS) \
-e ENABLE_DATABASE_EXTRA_FEATURES=$(ENABLE_DATABASE_EXTRA_FEATURES) \
-e GODEBUG=tls13=1 \
-e CGO_ENABLED=$(CGO_ENABLED) \
-w /usr/code/ \
$(DOCKER_RUN_CMD) && echo "success!" || ( \
echo "failure! \n\nARANGODB-STARTER logs:"; \
docker logs ${TESTCONTAINER}-s; \
echo "\nARANGODB logs:"; \
docker ps -f name=${TESTCONTAINER}-s- -q | xargs -L 1 docker logs; \
echo "\nV1 Tests with ARGS: TEST_MODE=${TEST_MODE} TEST_AUTH=${TEST_AUTH} TEST_CONTENT_TYPE=${TEST_CONTENT_TYPE} TEST_SSL=${TEST_SSL} TEST_CONNECTION=${TEST_CONNECTION} TEST_CVERSION=${TEST_CVERSION}\n\n"; \
exit 1)
# Internal test tasks
__run_v2_tests: __test_v2_debug__ __test_prepare __test_v2_go_test __test_cleanup
__test_v2_go_test:
$(DOCKER_CMD) \
--name=$(TESTCONTAINER) \
$(TEST_NET) \
-v "${ROOTDIR}":/usr/code:ro ${TEST_RESOURCES_VOLUME} \
-e TEST_ENDPOINTS=$(TEST_ENDPOINTS) \
-e TEST_NOT_WAIT_UNTIL_READY=$(TEST_NOT_WAIT_UNTIL_READY) \
-e TEST_AUTHENTICATION=$(TEST_AUTHENTICATION) \
-e TEST_JWTSECRET=$(TEST_JWTSECRET) \
-e TEST_MODE=$(TEST_MODE) \
-e TEST_BACKUP_REMOTE_REPO=$(TEST_BACKUP_REMOTE_REPO) \
-e TEST_BACKUP_REMOTE_CONFIG='$(TEST_BACKUP_REMOTE_CONFIG)' \
-e TEST_DEBUG='$(TEST_DEBUG)' \
-e TEST_ENABLE_SHUTDOWN=$(TEST_ENABLE_SHUTDOWN) \
-e ENABLE_DATABASE_EXTRA_FEATURES=$(ENABLE_DATABASE_EXTRA_FEATURES) \
-e GODEBUG=tls13=1 \
-e CGO_ENABLED=$(CGO_ENABLED) \
-w /usr/code/v2/ \
$(DOCKER_V2_RUN_CMD) && echo "success!" || ( \
echo "failure! \n\nARANGODB-STARTER logs:"; \
docker logs ${TESTCONTAINER}-s; \
echo "\nARANGODB logs:"; \
docker ps -f name=${TESTCONTAINER}-s- -q | xargs -L 1 docker logs; \
echo "\nV2 Tests with ARGS: TEST_MODE=${TEST_MODE} TEST_AUTH=${TEST_AUTH} TEST_CONTENT_TYPE=${TEST_CONTENT_TYPE} TEST_SSL=${TEST_SSL} TEST_CONNECTION=${TEST_CONNECTION} TEST_CVERSION=${TEST_CVERSION}\n\n"; \
exit 1)
__test_debug__:
ifeq ("$(DEBUG)", "true")
@docker build -f Dockerfile.debug --build-arg GOVERSION=$(GOVERSION) --build-arg "TESTS_DIRECTORY=./test" -t $(GOIMAGE) .
endif
__test_v2_debug__:
ifeq ("$(DEBUG)", "true")
@docker build -f Dockerfile.debug --build-arg GOVERSION=$(GOVERSION) --build-arg "TESTS_DIRECTORY=./tests" --build-arg "TESTS_ROOT_PATH=v2" -t $(GOIMAGE) .
endif
__dir_setup:
@mkdir -p "${TMPDIR}"
@echo "${TMPDIR}"
__test_prepare: __dir_setup
ifdef TEST_ENDPOINTS_OVERRIDE
@-docker rm -f -v $(TESTCONTAINER) &> /dev/null
@sleep 3
else
ifdef JWTSECRET
echo "$JWTSECRET" > "${JWTSECRETFILE}"
endif
@-docker rm -f -v $(TESTCONTAINER) &> /dev/null
@TESTCONTAINER=$(TESTCONTAINER) ARANGODB=$(ARANGODB) ALPINE_IMAGE=$(ALPINE_IMAGE) ENABLE_BACKUP=$(ENABLE_BACKUP) \
ARANGO_LICENSE_KEY=$(ARANGO_LICENSE_KEY) STARTER=$(STARTER) STARTERMODE=$(TEST_MODE) TMPDIR="${TMPDIR}" \
ENABLE_DATABASE_EXTRA_FEATURES=$(ENABLE_DATABASE_EXTRA_FEATURES) DEBUG_PORT=$(DEBUG_PORT) $(CLUSTERENV) "${ROOTDIR}/test/cluster.sh" start
endif
__test_cleanup:
ifdef TESTCONTAINER
@TESTCONTAINERS=$$(docker ps -a -q --filter="name=$(TESTCONTAINER)")
@if [ -n "$$TESTCONTAINERS" ]; then docker rm -f -v $$(docker ps -a -q --filter="name=$(TESTCONTAINER)"); fi
endif
ifndef TEST_ENDPOINTS_OVERRIDE
@TESTCONTAINER=$(TESTCONTAINER) ARANGODB=$(ARANGODB) ALPINE_IMAGE=$(ALPINE_IMAGE) STARTER=$(STARTER) STARTERMODE=$(TEST_MODE) "${ROOTDIR}/test/cluster.sh" cleanup
else
@-docker rm -f -v $(TESTCONTAINER) &> /dev/null
endif
@sleep 3
# Benchmarks
run-benchmarks-single-json-no-auth:
@echo "Benchmarks: Single server, JSON no authentication"
@${MAKE} TEST_MODE="single" TEST_AUTH="none" TEST_CONTENT_TYPE="json" TEST_BENCHMARK="true" __run_tests
run-benchmarks-single-vpack-no-auth:
@echo "Benchmarks: Single server, Velocypack, no authentication"
@${MAKE} TEST_MODE="single" TEST_AUTH="none" TEST_CONTENT_TYPE="vpack" TEST_BENCHMARK="true" __run_tests
## Lint
.PHONY: tools
tools: __dir_setup
@echo ">> Fetching golangci-lint linter"
@GOBIN=$(TMPDIR)/bin go install github.com/golangci/golangci-lint/cmd/[email protected]
@echo ">> Fetching goimports"
@GOBIN=$(TMPDIR)/bin go install golang.org/x/tools/cmd/[email protected]
@echo ">> Fetching license check"
@GOBIN=$(TMPDIR)/bin go install github.com/google/[email protected]
@echo ">> Fetching govulncheck"
@GOBIN=$(TMPDIR)/bin go install golang.org/x/vuln/cmd/[email protected]
@echo ">> Fetching github-release"
@GOBIN=$(TMPDIR)/bin go install github.com/github-release/[email protected]
.PHONY: license
license:
@echo ">> Ensuring license of files"
@$(TMPDIR)/bin/addlicense -f "$(ROOTDIR)/HEADER" $(SOURCES)
.PHONY: license-verify
license-verify:
@echo ">> Verify license of files"
@$(TMPDIR)/bin/addlicense -f "$(ROOTDIR)/HEADER" -check $(SOURCES)
.PHONY: fmt
fmt:
@echo ">> Ensuring style of files"
@$(TMPDIR)/bin/goimports -w $(SOURCES)
.PHONY: fmt-verify
fmt-verify: license-verify
@echo ">> Verify files style"
@if [ X"$$($(TMPDIR)/bin/goimports -l $(SOURCES) | wc -l)" != X"0" ]; then echo ">> Style errors"; $(TMPDIR)/bin/goimports -l $(SOURCES); exit 1; fi
.PHONY: linter
linter: fmt-verify
@$(TMPDIR)/bin/golangci-lint run ./...
.PHONY: vulncheck
vulncheck:
$(TMPDIR)/bin/govulncheck ./...
# V2
v2-%:
@(cd "$(ROOTDIR)/v2"; make)
run-v2-tests: run-v2-tests-single run-v2-tests-cluster
ifeq ("$(AF_ENABLED)", "true")
make run-v2-tests-resilientsingle
endif
run-v2-tests-cluster: run-v2-tests-cluster-with-basic-auth run-v2-tests-cluster-without-ssl run-v2-tests-cluster-without-auth run-v2-tests-cluster-with-jwt-auth
run-v2-tests-cluster-with-basic-auth:
@echo "Cluster server, with basic authentication, v2"
@${MAKE} TEST_MODE="cluster" TEST_SSL="auto" TEST_AUTH="rootpw" __run_v2_tests
run-v2-tests-cluster-with-jwt-auth:
@echo "Cluster server, with JWT authentication, v2"
@${MAKE} TEST_MODE="cluster" TEST_SSL="auto" TEST_AUTH="jwt" __run_v2_tests
run-v2-tests-cluster-without-auth:
@echo "Cluster server, without authentication, v2"
@${MAKE} TEST_MODE="cluster" TEST_SSL="auto" TEST_AUTH="none" __run_v2_tests
run-v2-tests-cluster-without-ssl:
@echo "Cluster server, without authentication and SSL, v2"
@${MAKE} TEST_MODE="cluster" TEST_AUTH="none" __run_v2_tests
run-v2-tests-single: run-v2-tests-single-without-auth run-v2-tests-single-with-auth
run-v2-tests-single-without-auth:
@echo "Single server, without authentication, v2"
@${MAKE} TEST_MODE="single" TEST_AUTH="none" __run_v2_tests
run-v2-tests-single-with-auth:
@echo "Single server, with authentication, v2"
@${MAKE} TEST_MODE="single" TEST_SSL="auto" TEST_AUTH="rootpw" __run_v2_tests
run-v2-tests-resilientsingle: run-v2-tests-resilientsingle-with-auth
run-v2-tests-resilientsingle-with-auth:
@echo "Resilient Single, with authentication, v2"
@${MAKE} TEST_MODE="resilientsingle" TEST_AUTH="rootpw" TESTV2PARALLEL=1 __run_v2_tests
GH_RELEASE := $(TMPDIR)/bin/github-release
RELEASE := $(SCRIPTDIR)/tools/release
V2_VERSION := ./v2/version/VERSION
release-patch:
go run $(RELEASE) -type=patch -github-release=$(GH_RELEASE)
release-minor:
go run $(RELEASE) -type=minor -github-release=$(GH_RELEASE)
release-major:
go run $(RELEASE) -type=major -github-release=$(GH_RELEASE)
release-v2-patch:
go run $(RELEASE) -type=patch -github-release=$(GH_RELEASE) -versionfile=$(V2_VERSION)
release-v2-minor:
go run $(RELEASE) -type=minor -github-release=$(GH_RELEASE) -versionfile=$(V2_VERSION)
release-v2-major:
go run $(RELEASE) -type=major -github-release=$(GH_RELEASE) -versionfile=$(V2_VERSION)