-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathMakefile
More file actions
635 lines (554 loc) · 37.3 KB
/
Copy pathMakefile
File metadata and controls
635 lines (554 loc) · 37.3 KB
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
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
# ----------------------------------------------------------------------------------------------------------------------
# Copyright (c) 2021, 2025 Oracle and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at
# https://oss.oracle.com/licenses/upl.
#
# ----------------------------------------------------------------------------------------------------------------------
# This is the Makefile to build the Coherence Go Client
# ----------------------------------------------------------------------------------------------------------------------
# This is the version of the coherence-go-client
VERSION ?=2.4.0
CURRDIR := $(shell pwd)
USER_ID := $(shell echo "`id -u`:`id -g`")
override BUILD_BIN := $(CURRDIR)/bin
override PROTO_DIR := $(CURRDIR)/etc/proto
override PROTOV1_DIR := $(CURRDIR)/etc/proto-v1
override PROTOTOPICS_DIR := $(CURRDIR)/etc/topics
# ----------------------------------------------------------------------------------------------------------------------
# Set the location of various build tools
# ----------------------------------------------------------------------------------------------------------------------
override BUILD_OUTPUT := $(CURRDIR)/build/_output
override BUILD_BIN := $(CURRDIR)/bin
override PROTO_OUT := $(CURRDIR)/proto
override BUILD_TARGETS := $(BUILD_OUTPUT)/targets
override TEST_LOGS_DIR := $(BUILD_OUTPUT)/test-logs
override COVERAGE_DIR := $(BUILD_OUTPUT)/coverage
override DAPR_DIR := $(BUILD_OUTPUT)/dapr-test
override DAPR_TEST_DIR := $(CURRDIR)/test/dapr
override COPYRIGHT_JAR := glassfish-copyright-maven-plugin-2.4.jar
override BUILD_CERTS := $(CURRDIR)/test/utils/certs
override ENV_FILE := test/utils/.env
# Maven version is always 1.0.0 as it is only for testing
MVN_VERSION ?= 1.0.0
SHELL := /bin/bash
# Coherence CE version to run base tests against
COHERENCE_VERSION ?= 22.06.13
COHERENCE_GROUP_ID ?= com.oracle.coherence.ce
COHERENCE_WKA1 ?= server1
COHERENCE_WKA2 ?= server1
CLUSTER_PORT ?= 7574
# Profiles to include for building
PROFILES ?=
COHERENCE_BASE_IMAGE ?= gcr.io/distroless/java11-debian11
CURL_OPTS = -L --retry 10 --retry-delay 5
# For GitHub Rate limiting
ifdef GITHUB_TOKEN
CURL_AUTH = -H "Authorization: token $(GITHUB_TOKEN)" $(CURL_OPTS)
else
CURL_AUTH = $(CURL_OPTS)
endif
# ----------------------------------------------------------------------------------------------------------------------
# Set the location of various build tools
# ----------------------------------------------------------------------------------------------------------------------
TOOLS_DIRECTORY = $(CURRDIR)/build/tools
TOOLS_BIN = $(TOOLS_DIRECTORY)/bin
# ----------------------------------------------------------------------------------------------------------------------
# The test application images used in integration tests
# ----------------------------------------------------------------------------------------------------------------------
RELEASE_IMAGE_PREFIX ?= ghcr.io/oracle/
TEST_APPLICATION_IMAGE_1 := $(RELEASE_IMAGE_PREFIX)coherence-go-test-1:1.0.0
TEST_APPLICATION_IMAGE_2 := $(RELEASE_IMAGE_PREFIX)coherence-go-test-2:1.0.0
GO_TEST_FLAGS ?= -timeout 50m
DOCKER_COMPOSE:=$(shell type -p docker-compose || echo docker compose)
# ----------------------------------------------------------------------------------------------------------------------
# Options to append to the Maven command
# ----------------------------------------------------------------------------------------------------------------------
MAVEN_OPTIONS ?= -Dmaven.wagon.httpconnectionManager.ttlSeconds=25 -Dmaven.wagon.http.retryHandler.count=3
MAVEN_BUILD_OPTS :=$(USE_MAVEN_SETTINGS) -Drevision=$(MVN_VERSION) -Dcoherence.version=$(COHERENCE_VERSION) -Dcoherence.group.id=$(COHERENCE_GROUP_ID) $(MAVEN_OPTIONS)
CURRDIR := $(shell pwd)
GOROOT=$(shell go env GOROOT)
# ----------------------------------------------------------------------------------------------------------------------
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
# ----------------------------------------------------------------------------------------------------------------------
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
endif
# ----------------------------------------------------------------------------------------------------------------------
# Setting SHELL to bash allows bash commands to be executed by recipes.
# Options are set to exit when a recipe line exits non-zero or a piped command fails.
# ----------------------------------------------------------------------------------------------------------------------
SHELL = /usr/bin/env bash -o pipefail
.SHELLFLAGS = -ec
GITCOMMIT ?= $(shell git rev-list -1 HEAD)
GITREPO := https://github.com/oracle/coherence-go-client.git
SOURCE_DATE_EPOCH := $(shell git show -s --format=format:%ct HEAD)
DATE_FMT := "%Y-%m-%dT%H:%M:%SZ"
BUILD_DATE := $(shell date -u -d "@$SOURCE_DATE_EPOCH" "+${DATE_FMT}" 2>/dev/null || date -u -r "${SOURCE_DATE_EPOCH}" "+${DATE_FMT}" 2>/dev/null || date -u "+${DATE_FMT}")
BUILD_USER := $(shell whoami)
GOS = $(shell find . -type f -name "*.go" ! -name "*_test.go")
SKIP_PROTO_GENERATION ?= false
# ======================================================================================================================
# Makefile targets start here
# ======================================================================================================================
# ----------------------------------------------------------------------------------------------------------------------
# Display the Makefile help - this is a list of the targets with a description.
# This target MUST be the first target in the Makefile so that it is run when running make with no arguments
# ----------------------------------------------------------------------------------------------------------------------
help: ## Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-25s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
# ======================================================================================================================
# Build targets
# ======================================================================================================================
##@ Build
# ----------------------------------------------------------------------------------------------------------------------
# Clean-up all of the build artifacts
# ----------------------------------------------------------------------------------------------------------------------
.PHONY: clean
clean: ## Cleans the build
@echo "Cleaning Project"
-rm -rf $(BUILD_OUTPUT)
-rm -rf bin
-rm -rf $(BUILD_CERTS)
@mkdir -p $(TEST_LOGS_DIR)
@mkdir -p $(COVERAGE_DIR)
@mkdir -p $(BUILD_OUTPUT)
@mkdir -p $(PROTO_OUT)
@mkdir -p $(BUILD_CERTS)
mvn -B -f java/pom.xml $(MAVEN_BUILD_OPTS) clean
.PHONY: certs
certs: ## Generates certificates for TLS tests
@echo "Generating certs"
./scripts/keys.sh $(BUILD_CERTS)
# ----------------------------------------------------------------------------------------------------------------------
# Configure the build properties
# ----------------------------------------------------------------------------------------------------------------------
$(BUILD_PROPS):
@echo "Creating build directories"
@mkdir -p $(BUILD_OUTPUT)
@mkdir -p $(BUILD_BIN)
# ----------------------------------------------------------------------------------------------------------------------
# Build the Coherence Go Client Test Image
# ----------------------------------------------------------------------------------------------------------------------
.PHONY: build-test-images
build-test-images: ## Build the Test images
@echo "${MAVEN_BUILD_OPTS}"
mvn -B -f java/pom.xml clean package jib:dockerBuild -DskipTests -P member1$(PROFILES) -Djib.to.image=$(TEST_APPLICATION_IMAGE_1) -Dcoherence.test.base.image=$(COHERENCE_BASE_IMAGE) $(MAVEN_BUILD_OPTS)
mvn -B -f java/pom.xml clean package jib:dockerBuild -DskipTests -P member2$(PROFILES) -Djib.to.image=$(TEST_APPLICATION_IMAGE_2) -Dcoherence.test.base.image=$(COHERENCE_BASE_IMAGE) $(MAVEN_BUILD_OPTS)
echo "CURRENT_UID=$(USER_ID)" >> $(ENV_FILE)
# ----------------------------------------------------------------------------------------------------------------------
# Performs a copyright check.
# To add exclusions add the file or folder pattern using the -X parameter.
# Add directories to be scanned at the end of the parameter list.
# ----------------------------------------------------------------------------------------------------------------------
.PHONY: copyright
copyright: getcopyright ## Check copyright headers
@java -cp scripts/$(COPYRIGHT_JAR) \
org.glassfish.copyright.Copyright -C scripts/copyright.txt \
-X bin/ \
-X ./test/test/utils.go \
-X dependency-reduced-pom.xml \
-X ./coherence/coherence.test \
-X binaries/ \
-X build/ \
-X proto/ \
-X /Dockerfile \
-X .Dockerfile \
-X runner \
-X go.sum \
-X HEADER.txt \
-X .iml \
-X .jar \
-X jib-cache/ \
-X .jks \
-X .json \
-X LICENSE.txt \
-X Makefile \
-X cohctl-terminal.gif \
-X .md \
-X .mvn/ \
-X mvnw \
-X mvnw.cmd \
-X .png \
-X .sh \
-X temp/ \
-X .proto \
-X /test-report.xml \
-X THIRD_PARTY_LICENSES.txt \
-X .tpl \
-X .txt \
-X test_utils/certs \
-X test/utils/certs \
-X pkg/data/assets/
# ----------------------------------------------------------------------------------------------------------------------
# Executes golangci-lint to perform various code review checks on the source.
# ----------------------------------------------------------------------------------------------------------------------
.PHONY: golangci
golangci: $(TOOLS_BIN)/golangci-lint ## Go code review
GOGC=50 $(TOOLS_BIN)/golangci-lint run -v --timeout=5m --max-same-issues=0 ./...
cd examples && GOGC=50 $(TOOLS_BIN)/golangci-lint run -v --timeout=5m --max-same-issues=0 ./...
# ----------------------------------------------------------------------------------------------------------------------
# Download and build proto files
# ----------------------------------------------------------------------------------------------------------------------
.PHONY: generate-proto
generate-proto: $(TOOLS_BIN)/protoc ## Generate Proto Files
ifeq ($(SKIP_PROTO_GENERATION),true)
@echo "Skipping proto generation..."
else
mkdir -p $(PROTO_DIR) || true
curl $(CURL_AUTH) -o $(PROTO_DIR)/services.proto https://raw.githubusercontent.com/oracle/coherence/22.06.13/prj/coherence-grpc/src/main/proto/services.proto
curl $(CURL_AUTH) -o $(PROTO_DIR)/messages.proto https://raw.githubusercontent.com/oracle/coherence/22.06.13/prj/coherence-grpc/src/main/proto/messages.proto
echo "" >> $(PROTO_DIR)/services.proto
echo "" >> $(PROTO_DIR)/messages.proto
echo 'option go_package = "github.com/oracle/coherence-go-client/proto";' >> $(PROTO_DIR)/services.proto
echo 'option go_package = "github.com/oracle/coherence-go-client/proto";' >> $(PROTO_DIR)/messages.proto
$(TOOLS_BIN)/protoc --proto_path=./etc/proto --go_out=./proto --go_opt=paths=source_relative --go-grpc_out=./proto --go-grpc_opt=paths=source_relative etc/proto/messages.proto etc/proto/services.proto
endif
# ----------------------------------------------------------------------------------------------------------------------
# Download and build proto files - v1
# ----------------------------------------------------------------------------------------------------------------------
.PHONY: generate-proto-v1
generate-proto-v1: $(TOOLS_BIN)/protoc ## Generate Proto Files v1
ifeq ($(SKIP_PROTO_GENERATION),true)
@echo "Skipping proto generation..."
else
mkdir -p $(PROTOV1_DIR) || true
mkdir -p $(PROTOTOPICS_DIR) || true
curl $(CURL_AUTH) -o $(PROTOV1_DIR)/proxy_service_messages_v1.proto https://raw.githubusercontent.com/oracle/coherence/refs/heads/main/prj/coherence-grpc/src/main/proto/proxy_service_messages_v1.proto
curl $(CURL_AUTH) -o $(PROTOV1_DIR)/proxy_service_v1.proto https://raw.githubusercontent.com/oracle/coherence/refs/heads/main/prj/coherence-grpc/src/main/proto/proxy_service_v1.proto
curl $(CURL_AUTH) -o $(PROTOV1_DIR)/common_messages_v1.proto https://raw.githubusercontent.com/oracle/coherence/refs/heads/main/prj/coherence-grpc/src/main/proto/common_messages_v1.proto
curl $(CURL_AUTH) -o $(PROTOV1_DIR)/cache_service_messages_v1.proto https://raw.githubusercontent.com/oracle/coherence/refs/heads/main/prj/coherence-grpc/src/main/proto/cache_service_messages_v1.proto
curl $(CURL_AUTH) -o $(PROTOV1_DIR)/queue_service_messages_v1.proto https://raw.githubusercontent.com/oracle/coherence/refs/heads/main/prj/coherence-grpc/src/main/proto/queue_service_messages_v1.proto
curl $(CURL_AUTH) -o $(PROTOTOPICS_DIR)/topic_service_messages_v1.proto https://raw.githubusercontent.com/oracle/coherence/refs/heads/main/prj/coherence-grpc/src/main/proto/topic_service_messages_v1.proto
echo "" >> $(PROTOV1_DIR)/proxy_service_messages_v1.proto
echo "" >> $(PROTOV1_DIR)/proxy_service_v1.proto
echo "" >> $(PROTOV1_DIR)/common_messages_v1.proto
echo "" >> $(PROTOV1_DIR)/cache_service_messages_v1.proto
echo "" >> $(PROTOV1_DIR)/queue_service_messages_v1.proto
echo "" >> $(PROTOTOPICS_DIR)/topic_service_messages_v1.proto
echo 'option go_package = "github.com/oracle/coherence-go-client/proto/v1";' >> $(PROTOV1_DIR)/proxy_service_messages_v1.proto
echo 'option go_package = "github.com/oracle/coherence-go-client/proto/v1";' >> $(PROTOV1_DIR)/proxy_service_v1.proto
echo 'option go_package = "github.com/oracle/coherence-go-client/proto/v1";' >> $(PROTOV1_DIR)/common_messages_v1.proto
echo 'option go_package = "github.com/oracle/coherence-go-client/proto/v1";' >> $(PROTOV1_DIR)/cache_service_messages_v1.proto
echo 'option go_package = "github.com/oracle/coherence-go-client/proto/v1";' >> $(PROTOV1_DIR)/queue_service_messages_v1.proto
echo 'option go_package = "github.com/oracle/coherence-go-client/proto/v1/topics";' >> $(PROTOTOPICS_DIR)/topic_service_messages_v1.proto
mkdir ./proto/v1 ./proto/topics || true
$(TOOLS_BIN)/protoc --proto_path=./etc/proto-v1 --go_out=./proto/v1 --go_opt=paths=source_relative --go-grpc_out=./proto/v1 --go-grpc_opt=paths=source_relative etc/proto-v1/proxy_service_messages_v1.proto etc/proto-v1/proxy_service_v1.proto etc/proto-v1/common_messages_v1.proto etc/proto-v1/cache_service_messages_v1.proto etc/proto-v1/queue_service_messages_v1.proto
$(TOOLS_BIN)/protoc --proto_path=./etc/topics --proto_path=./etc/proto-v1 --go_out=./proto/topics --go_opt=paths=source_relative --go-grpc_out=./proto/topics --go-grpc_opt=paths=source_relative etc/topics/topic_service_messages_v1.proto
cat proto/topics/topic_service_messages_v1.pb.go | sed 's,^\tv1 "github.com/oracle/coherence-go-client/proto/v1",\tv1 "github.com/oracle/coherence-go-client/v2/proto/v1",' > /tmp/proto-queues
mv /tmp/proto-queues proto/topics/topic_service_messages_v1.pb.go
endif
# ----------------------------------------------------------------------------------------------------------------------
# Show the local documentation
# ----------------------------------------------------------------------------------------------------------------------
.PHONY: show-docs
show-docs: ## Show the Documentation
@echo "Serving documentation on http://localhost:6060/pkg/github.com/oracle/coherence-go-client/v2"
go install golang.org/x/tools/cmd/godoc@latest
godoc -goroot $(GOROOT) -http=:6060
# ======================================================================================================================
# Miscellaneous targets
# ======================================================================================================================
##@ Miscellaneous
.PHONY: trivy-scan
trivy-scan: gettrivy ## Scan the CLI using trivy
$(TOOLS_BIN)/trivy fs --cache-dir ${TRIVY_CACHE} --exit-code 1 --skip-dirs "./java" .
# ======================================================================================================================
# Targets related to running KinD clusters for testing
# ======================================================================================================================
##@ KinD
KIND_CLUSTER ?= go-client
KIND_IMAGE ?= "kindest/node:v1.33.0@sha256:91e9ed777db80279c22d1d1068c091b899b2078506e4a0f797fbf6e397c0b0b2"
KIND_SCRIPTS := ./scripts/kind
NAMESPACE ?= coherence-perf
OPERATOR_VERSION ?= v3.5.0
COHERENCE_IMAGE ?= ghcr.io/oracle/coherence-ce:14.1.2-0-2-java17
INITIAL_HEAP ?= 1g
GO_CLIENT_ARCH ?= amd64
GO_IMAGE ?= perf-go-client:1.0.0
# ----------------------------------------------------------------------------------------------------------------------
# Start a Kind cluster
# ----------------------------------------------------------------------------------------------------------------------
.PHONY: kind
kind: ## Run a default KinD cluster
kind create cluster --name $(KIND_CLUSTER) --wait 10m --config $(KIND_SCRIPTS)/kind-config.yaml --image $(KIND_IMAGE)
$(KIND_SCRIPTS)/kind-label-node.sh
# ----------------------------------------------------------------------------------------------------------------------
# Stop and delete the Kind cluster
# ----------------------------------------------------------------------------------------------------------------------
.PHONY: kind-stop
kind-stop: ## Stop and delete the KinD cluster
kind delete cluster --name $(KIND_CLUSTER)
# ----------------------------------------------------------------------------------------------------------------------
# Deploy Coherence Operator
# ----------------------------------------------------------------------------------------------------------------------
.PHONY: deploy-operator
deploy-operator: ## Deploy the Coherence Operator
kubectl apply -f https://github.com/oracle/coherence-operator/releases/download/$(OPERATOR_VERSION)/coherence-operator.yaml
kubectl -n coherence wait --timeout=300s --for condition=available deployment/coherence-operator-controller-manager
# ----------------------------------------------------------------------------------------------------------------------
# UnDeploy Coherence Operator
# ----------------------------------------------------------------------------------------------------------------------
.PHONY: undeploy-operator
undeploy-operator: ## UnDeploy the Coherence Operator
kubectl delete -f https://github.com/oracle/coherence-operator/releases/download/$(OPERATOR_VERSION)/coherence-operator.yaml || true
# ----------------------------------------------------------------------------------------------------------------------
# Deploy Coherence Cluster
# ----------------------------------------------------------------------------------------------------------------------
.PHONY: deploy-coherence
deploy-coherence: ## Deploy the Coherence Cluster
envsubst < $(KIND_SCRIPTS)/coherence-cluster.yaml | kubectl apply -n $(NAMESPACE) -f -
sleep 5
kubectl -n $(NAMESPACE) wait --timeout=300s --for condition=Ready coherence/perf-cluster
#-----------------------------------------------------------------------------------------------------------------------
# Deploy Coherence Cluster
# ----------------------------------------------------------------------------------------------------------------------
.PHONY: build-go-client
build-go-client: ## Make Go Client
cd test/e2e/kind && CGO_ENABLED=0 GOOS=linux GOARCH=$(GO_CLIENT_ARCH) GO111MODULE=on go build -trimpath -o runner . && docker build --no-cache -t $(GO_IMAGE) .
kind --name $(KIND_CLUSTER) load docker-image $(GO_IMAGE)
#-----------------------------------------------------------------------------------------------------------------------
# Load Schools Data
# ----------------------------------------------------------------------------------------------------------------------
.PHONY: load-schools
load-schools: ## Load Schools
kubectl -n $(NAMESPACE) apply -f $(KIND_SCRIPTS)/load-schools.yaml
kubectl wait -n $(NAMESPACE) --timeout=1200s --for condition=Complete job/go-perf-load-schools
kubectl -n $(NAMESPACE) delete -f $(KIND_SCRIPTS)/load-schools.yaml || true
#-----------------------------------------------------------------------------------------------------------------------
# Test Schools
# ----------------------------------------------------------------------------------------------------------------------
.PHONY: deploy-test-schools
deploy-test-schools: ## Deploy Test Schools
kubectl -n $(NAMESPACE) apply -f $(KIND_SCRIPTS)/test-schools.yaml
#-----------------------------------------------------------------------------------------------------------------------
# Stop Schools Test
# ----------------------------------------------------------------------------------------------------------------------
.PHONY: undeploy-test-schools
undeploy-test-schools: ## Undeploy Test Schools
kubectl -n $(NAMESPACE) delete -f $(KIND_SCRIPTS)/test-schools.yaml
# ----------------------------------------------------------------------------------------------------------------------
# UnDeploy Coherence Cluster
# ----------------------------------------------------------------------------------------------------------------------
.PHONY: undeploy-coherence
undeploy-coherence: ## UnDeploy the Coherence Cluster
kubectl delete -n $(NAMESPACE) -f $(KIND_SCRIPTS)/coherence-cluster.yaml || true
# ----------------------------------------------------------------------------------------------------------------------
# Create Perf namespace
# ----------------------------------------------------------------------------------------------------------------------
.PHONY: create-namespace
create-namespace: ## Create the perf test namespace
kubectl create namespace $(NAMESPACE)
# ----------------------------------------------------------------------------------------------------------------------
# Delete Perf namespace
# ----------------------------------------------------------------------------------------------------------------------
.PHONY: delete-namespace
delete-namespace: ## Create the perf test namespace
kubectl delete namespace $(NAMESPACE) || true
# ======================================================================================================================
# Test targets
# ======================================================================================================================
##@ Test
# ----------------------------------------------------------------------------------------------------------------------
# Executes the Go unit tests
# ----------------------------------------------------------------------------------------------------------------------
.PHONY: test
test: test-clean gotestsum $(BUILD_PROPS) ## Run the unit tests
CGO_ENABLED=0 $(GOTESTSUM) --format testname --junitfile $(TEST_LOGS_DIR)/coherence-test.xml \
-- $(GO_TEST_FLAGS) -v -coverprofile=$(COVERAGE_DIR)/cover-unit.out ./coherence/...
go tool cover -func=$(COVERAGE_DIR)/cover-unit.out | grep -v '0.0%'
# ----------------------------------------------------------------------------------------------------------------------
# Executes the Go end to end tests for standalone Coherence
# ----------------------------------------------------------------------------------------------------------------------
.PHONY: test-e2e-standalone
test-e2e-standalone: test-clean test gotestsum $(BUILD_PROPS) ## Run e2e tests with Coherence
cd test && CGO_ENABLED=0 $(GOTESTSUM) --format testname --junitfile $(TEST_LOGS_DIR)/go-client-test.xml \
-- $(GO_TEST_FLAGS) -v -coverprofile=$(COVERAGE_DIR)/cover-functional.out -v ./e2e/standalone/... -coverpkg=github.com/oracle/coherence-go-client/v2/coherence/...
go tool cover -func=$(COVERAGE_DIR)/cover-functional.out | grep -v '0.0%'
# ----------------------------------------------------------------------------------------------------------------------
# Executes the Go streaming tests for standalone Coherence
# ----------------------------------------------------------------------------------------------------------------------
.PHONY: test-e2e-streaming
test-e2e-streaming: test-clean test gotestsum $(BUILD_PROPS) ## Run e2e tests with Coherence
cd test && CGO_ENABLED=0 $(GOTESTSUM) --format testname --junitfile $(TEST_LOGS_DIR)/go-streaming-test.xml \
-- $(GO_TEST_FLAGS) -v -coverprofile=$(COVERAGE_DIR)/cover-functional.out -v ./e2e/streaming/... -coverpkg=github.com/oracle/coherence-go-client/v2/coherence/...
# ----------------------------------------------------------------------------------------------------------------------
# Executes the Go end to end tests for standalone Coherence with Scope set
# ----------------------------------------------------------------------------------------------------------------------
.PHONY: test-e2e-standalone-scope
test-e2e-standalone-scope: test-clean test gotestsum $(BUILD_PROPS) ## Run e2e tests with Coherence with Scope set
cd test && CGO_ENABLED=0 $(GOTESTSUM) --format testname --junitfile $(TEST_LOGS_DIR)/go-client-test-scope.xml \
-- $(GO_TEST_FLAGS) -v -coverprofile=$(COVERAGE_DIR)/cover-functional-scope.out -v ./e2e/scope/... -coverpkg=github.com/oracle/coherence-go-client/v2/coherence/...
go tool cover -func=$(COVERAGE_DIR)/cover-functional-scope.out | grep -v '0.0%'
# ----------------------------------------------------------------------------------------------------------------------
# Executes the Go end to end tests for standalone Coherence with Queues
# ----------------------------------------------------------------------------------------------------------------------
.PHONY: test-e2e-standalone-queues
test-e2e-standalone-queues: test-clean test gotestsum $(BUILD_PROPS) ## Run e2e tests with Coherence queues
cd test && CGO_ENABLED=0 $(GOTESTSUM) --format testname --junitfile $(TEST_LOGS_DIR)/go-client-test-queues.xml \
-- $(GO_TEST_FLAGS) -v -coverprofile=$(COVERAGE_DIR)/cover-functional-queues.out -v ./e2e/queues/... -coverpkg=github.com/oracle/coherence-go-client/v2/coherence/...
go tool cover -func=$(COVERAGE_DIR)/cover-functional-queues.out | grep -v '0.0%'
# ----------------------------------------------------------------------------------------------------------------------
# Executes the Go end to end tests for standalone Coherence with Topics
# ----------------------------------------------------------------------------------------------------------------------
.PHONY: test-e2e-standalone-topics
test-e2e-standalone-topics: test-clean test gotestsum $(BUILD_PROPS) ## Run e2e tests with Coherence queues
cd test && CGO_ENABLED=0 $(GOTESTSUM) --format testname --junitfile $(TEST_LOGS_DIR)/go-client-test-topics.xml \
-- $(GO_TEST_FLAGS) -v -coverprofile=$(COVERAGE_DIR)/cover-functional-topics.out -v ./e2e/topics/... -coverpkg=github.com/oracle/coherence-go-client/v2/coherence/...
go tool cover -func=$(COVERAGE_DIR)/cover-functional-topics.out | grep -v '0.0%'
# ----------------------------------------------------------------------------------------------------------------------
# Executes the Go end to end tests for gRPC v1 tests
# ----------------------------------------------------------------------------------------------------------------------
.PHONY: test-v1-base
test-v1-base: test-clean test gotestsum $(BUILD_PROPS) ## Run e2e tests with Coherence
cd test && CGO_ENABLED=0 $(GOTESTSUM) --format testname --junitfile $(TEST_LOGS_DIR)/go-client-test-v1.xml \
-- $(GO_TEST_FLAGS) -v -coverprofile=$(COVERAGE_DIR)/cover-functional-v1.out -v ./v1/base/... -coverpkg=github.com/oracle/coherence-go-client/v2/coherence/...
go tool cover -func=$(COVERAGE_DIR)/cover-functional-v1.out | grep -v '0.0%'
# ----------------------------------------------------------------------------------------------------------------------
# Executes the test of the examples
# ----------------------------------------------------------------------------------------------------------------------
.PHONY: test-examples
test-examples: test-clean gotestsum $(BUILD_PROPS) ## Run examples tests with Coherence
./scripts/run-test-examples.sh
# ----------------------------------------------------------------------------------------------------------------------
# Executes the tests for DAPR
# ----------------------------------------------------------------------------------------------------------------------
.PHONY: test-dapr
test-dapr: gotestsum $(BUILD_PROPS) ## Run dapr tests with Coherence
./scripts/run-test-dapr.sh $(DAPR_TEST_DIR) $(DAPR_DIR)
# ----------------------------------------------------------------------------------------------------------------------
# Executes the tests for DAPR TLS
# ----------------------------------------------------------------------------------------------------------------------
.PHONY: test-dapr-tls
test-dapr-tls: gotestsum $(BUILD_PROPS) ## Run dapr tests with Coherence with TLS
./scripts/run-test-dapr.sh $(DAPR_TEST_DIR) $(DAPR_DIR) true
# ----------------------------------------------------------------------------------------------------------------------
# Startup cluster members via docker compose
# ----------------------------------------------------------------------------------------------------------------------
.PHONY: test-cluster-startup
test-cluster-startup: $(BUILD_PROPS) ## Startup any test cluster members using docker-compose
cd test/utils && $(DOCKER_COMPOSE) -f docker-compose-2-members.yaml up -d
# ----------------------------------------------------------------------------------------------------------------------
# Shutdown any cluster members via docker compose
# ----------------------------------------------------------------------------------------------------------------------
.PHONY: test-cluster-shutdown
test-cluster-shutdown: ## Shutdown any test cluster members using docker-compose
cd test/utils && $(DOCKER_COMPOSE) -f docker-compose-2-members.yaml down || true
# ----------------------------------------------------------------------------------------------------------------------
# Run Near Cache Profile Tests
# ----------------------------------------------------------------------------------------------------------------------
.PHONY: profile-near-cache
profile-near-cache: ## Run Near Cache Profile Tests
cd coherence && go test -run=^TestNearCacheExpiry1 -cpuprofile=$(TEST_LOGS_DIR)/cpu.out -memprofile=$(TEST_LOGS_DIR)/mem.out
echo top | go tool pprof $(TEST_LOGS_DIR)/cpu.out
echo top | go tool pprof $(TEST_LOGS_DIR)/mem.out
# ----------------------------------------------------------------------------------------------------------------------
# Startup standalone coherence via java -jar
# ----------------------------------------------------------------------------------------------------------------------
.PHONY: test-coherence-startup
test-coherence-startup: ## Startup standalone cluster
scripts/startup-clusters.sh $(TEST_LOGS_DIR) $(CLUSTER_PORT) $(COHERENCE_GROUP_ID) ${COHERENCE_VERSION}
@echo "Clusters started up"
# ----------------------------------------------------------------------------------------------------------------------
# Shutdown coherence via java -jar
# ----------------------------------------------------------------------------------------------------------------------
.PHONY: test-coherence-shutdown
test-coherence-shutdown: ## shutdown standalone cluster
@ps -ef | grep shutMeDownPlease | grep -v grep | awk '{print $$2}' | xargs kill -9 || true
@echo "Clusters shutdown"
# ----------------------------------------------------------------------------------------------------------------------
# Find or download gotestsum
# ----------------------------------------------------------------------------------------------------------------------
.PHONY: gotestsum
GOTESTSUM = $(TOOLS_BIN)/gotestsum
gotestsum: ## Download gotestsum locally if necessary.
GOBIN=`pwd`/build/tools/bin go install gotest.tools/gotestsum@v1.12.0
# ----------------------------------------------------------------------------------------------------------------------
# Cleans the test cache
# ----------------------------------------------------------------------------------------------------------------------
.PHONY: test-clean
test-clean: gotestsum ## Clean the go test cache
@echo "Cleaning test cache"
@mkdir -p $(TEST_LOGS_DIR)
go clean -testcache
# ----------------------------------------------------------------------------------------------------------------------
# Executes the Go discovery tests for standalone Coherence
# ----------------------------------------------------------------------------------------------------------------------
.PHONY: test-discovery
test-discovery: test-clean gotestsum $(BUILD_PROPS) ## Run Discovery tests with Coherence
make test-coherence-shutdown || true
make test-coherence-startup
cd test && CGO_ENABLED=0 $(GOTESTSUM) --format testname --junitfile $(TEST_LOGS_DIR)/cohctl-test-discovery.xml \
-- $(GO_TEST_FLAGS) -v ./e2e/discovery/...
make test-coherence-shutdown
# ----------------------------------------------------------------------------------------------------------------------
# Executes the Go perf tests for standalone Coherence
# ----------------------------------------------------------------------------------------------------------------------
.PHONY: test-perf
test-perf: test-clean gotestsum $(BUILD_PROPS) ## Run Discovery tests with Coherence
./scripts/perf-cluster.sh $(TEST_LOGS_DIR)/cli $(COHERENCE_VERSION) stop || true
mkdir -p $(TEST_LOGS_DIR)/cli
./scripts/perf-cluster.sh $(TEST_LOGS_DIR)/cli $(COHERENCE_VERSION) start
cd test && CGO_ENABLED=0 $(GOTESTSUM) --format testname --junitfile $(TEST_LOGS_DIR)/cohctl-test-perf.xml \
-- $(GO_TEST_FLAGS) -v ./e2e/perf/...
./scripts/perf-cluster.sh $(TEST_LOGS_DIR)/cli $(COHERENCE_VERSION) stop || true
rm -rf $(TEST_LOGS_DIR)/cli/*
# ----------------------------------------------------------------------------------------------------------------------
# Executes the Go resolver tests for standalone Coherence
# ----------------------------------------------------------------------------------------------------------------------
.PHONY: test-resolver
test-resolver: test-clean gotestsum $(BUILD_PROPS) ## Run Resolver tests with Coherence
cd test && COHERENCE_RESOLVER_DEBUG=true CGO_ENABLED=0 $(GOTESTSUM) --format testname --junitfile $(TEST_LOGS_DIR)/cohctl-test-resover.xml \
-- $(GO_TEST_FLAGS) -v ./e2e/resolver/...
# ----------------------------------------------------------------------------------------------------------------------
# Executes the Go resolver cluster tests for standalone Coherence
# ----------------------------------------------------------------------------------------------------------------------
.PHONY: test-resolver-cluster
test-resolver-cluster: test-clean gotestsum $(BUILD_PROPS) ## Run Resolver tests with Coherence
make test-coherence-shutdown || true
make test-coherence-startup
cd test && COHERENCE_RESOLVER_DEBUG=true CGO_ENABLED=0 $(GOTESTSUM) --format testname --junitfile $(TEST_LOGS_DIR)/cohctl-test-resover-cluster.xml \
-- $(GO_TEST_FLAGS) -v ./e2e/resolver_cluster/...
make test-coherence-shutdown
# ----------------------------------------------------------------------------------------------------------------------
# Obtain the golangci-lint binary
# ----------------------------------------------------------------------------------------------------------------------
$(TOOLS_BIN)/golangci-lint:
@mkdir -p $(TOOLS_BIN)
curl $(CURL_AUTH) -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(TOOLS_BIN) v1.64.8
# ----------------------------------------------------------------------------------------------------------------------
# Find or download copyright
# ----------------------------------------------------------------------------------------------------------------------
.PHONY: getcopyright
getcopyright: ## Download copyright jar locally if necessary.
@test -f scripts/$(COPYRIGHT_JAR) || curl $(CURL_AUTH) -o scripts/$(COPYRIGHT_JAR) \
https://repo.maven.apache.org/maven2/org/glassfish/copyright/glassfish-copyright-maven-plugin/2.4/glassfish-copyright-maven-plugin-2.4.jar
# ----------------------------------------------------------------------------------------------------------------------
# Obtain the protoc binary
# ----------------------------------------------------------------------------------------------------------------------
$(TOOLS_BIN)/protoc:
@mkdir -p $(TOOLS_BIN)
./scripts/download-protoc.sh $(TOOLS_DIRECTORY)
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.36.6
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.5.1
# go-get-tool will 'go get' any package $2 and install it to $1.
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
define go-get-tool
@[ -f $(1) ] || { \
set -e ;\
TMP_DIR=$$(mktemp -d) ;\
cd $$TMP_DIR ;\
go mod init tmp ;\
echo "Downloading $(2) into $(TOOLS_BIN)" ;\
GOBIN=$(TOOLS_BIN) go get $(2) ;\
rm -rf $$TMP_DIR ;\
}
endef
# ----------------------------------------------------------------------------------------------------------------------
# Find or download trivy
# ----------------------------------------------------------------------------------------------------------------------
.PHONY: gettrivy
gettrivy:
@mkdir -p $(TOOLS_BIN)
curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b $(TOOLS_BIN) v0.51.2