-
Notifications
You must be signed in to change notification settings - Fork 18
/
Makefile
171 lines (144 loc) · 5.19 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
MAKEFILE_PATH := $(abspath $(dir $(abspath $(lastword $(MAKEFILE_LIST)))))
GO111MODULE := on
GOOS := $(shell uname | tr '[:upper:]' '[:lower:]')
GOARCH := $(shell go env GOARCH)
DOCKER_COMPOSE_TESTING := scylla
DOCKER_VERSION := latest
ifndef GOBIN
export GOBIN := $(MAKEFILE_PATH)/bin
endif
define dl_tgz
@mkdir -p $(GOBIN) 2>/dev/null
@if [ ! -f "$(GOBIN)/$(1)" ]; then \
echo "Downloading $(GOBIN)/$(1)"; \
curl --progress-bar -L $(2) | tar zxf - --wildcards --strip 1 -C $(GOBIN) '*/$(1)'; \
chmod +x "$(GOBIN)/$(1)"; \
fi
endef
$(GOBIN)/golangci-lint: GOLANGCI_VERSION = 1.62.0
$(GOBIN)/golangci-lint: Makefile
$(call dl_tgz,golangci-lint,https://github.com/golangci/golangci-lint/releases/download/v$(GOLANGCI_VERSION)/golangci-lint-$(GOLANGCI_VERSION)-$(GOOS)-amd64.tar.gz)
.PHONY: fmt
fmt:
gofumpt -w -extra .
.PHONY: check
check: $(GOBIN)/golangci-lint
$(GOBIN)/golangci-lint run
.PHONY: fix
fix: $(GOBIN)/golangci-lint
$(GOBIN)/golangci-lint run --fix
.PHONY: build
build:
@CGO_ENABLED=0 go build -ldflags="-s -w" -o bin/gemini ./cmd/gemini
debug-build:
@CGO_ENABLED=0 go build -gcflags "all=-N -l" -o bin/gemini ./cmd/gemini
.PHONY: build-docker
build-docker:
@docker build --target production -t scylladb/gemini:$(DOCKER_VERSION) --compress .
.PHONY: setup
setup: $(GOBIN)/golangci-lint scylla-setup debug-build
@pre-commit install
.PHONY: scylla-setup
scylla-setup:
@docker compose -f docker/docker-compose-$(DOCKER_COMPOSE_TESTING).yml up -d
until docker logs gemini-oracle 2>&1 | grep "Starting listening for CQL clients" > /dev/null; do sleep 0.2; done
until docker logs gemini-test 2>&1 | grep "Starting listening for CQL clients" > /dev/null; do sleep 0.2; done
.PHONY: scylla-shutdown
scylla-shutdown:
docker compose -f docker/docker-compose-$(DOCKER_COMPOSE_TESTING).yml down --volumes
.PHONY: test
test:
@go test -covermode=atomic -race -coverprofile=coverage.txt -timeout 5m -json -v ./... 2>&1 | gotestfmt -showteststatus
CQL_FEATURES ?= all
CONCURRENCY ?= 50
DURATION ?= 10m
WARMUP ?= 1m
DATASET_SIZE ?= large
SEED ?= $(shell date +%s)
GEMINI_BINARY ?= $(PWD)/bin/gemini
GEMINI_TEST_CLUSTER ?= $(shell docker inspect --format='{{ .NetworkSettings.Networks.gemini.IPAddress }}' gemini-test)
GEMINI_ORACLE_CLUSTER ?= $(shell docker inspect --format='{{ .NetworkSettings.Networks.gemini.IPAddress }}' gemini-oracle)
GEMINI_DOCKER_NETWORK ?= gemini
GEMINI_FLAGS = --fail-fast \
--level=info \
--non-interactive \
--materialized-views=false \
--consistency=LOCAL_QUORUM \
--test-host-selection-policy=token-aware \
--oracle-host-selection-policy=token-aware \
--mode=mixed \
--non-interactive \
--request-timeout=5s \
--connect-timeout=15s \
--use-server-timestamps=false \
--async-objects-stabilization-attempts=10 \
--max-mutation-retries=10 \
--async-objects-stabilization-backoff=1000ms \
--max-mutation-retries-backoff=1000ms \
--replication-strategy="{'class': 'NetworkTopologyStrategy', 'replication_factor': '1'}" \
--oracle-replication-strategy="{'class': 'NetworkTopologyStrategy', 'replication_factor': '1'}" \
--concurrency=$(CONCURRENCY) \
--use-lwt=true \
--dataset-size=$(DATASET_SIZE) \
--seed=$(SEED) \
--schema-seed=$(SEED) \
--cql-features=$(CQL_FEATURES) \
--duration=$(DURATION) \
--warmup=$(WARMUP) \
--profiling-port=6060 \
--drop-schema=true
.PHONY: pprof-profile
pprof-profile:
go tool pprof -http=:8080 -intel_syntax -call_tree -seconds 60 http://localhost:6060/debug/pprof/profile
.PHONY: pprof-heap
pprof-heap:
go tool pprof -http=:8080 -intel_syntax -call_tree -seconds 60 http://localhost:6060/debug/pprof/heap
.PHONY: pprof-goroutine
pprof-goroutine:
go tool pprof -http=:8080 -intel_syntax -call_tree -seconds 60 http://localhost:6060/debug/pprof/goroutine
.PHONY: pprof-block
pprof-block:
go tool pprof -http=:8080 -intel_syntax -call_tree -seconds 60 http://localhost:6060/debug/pprof/block
.PHONY: docker-integration-test
docker-integration-test:
@mkdir -p $(PWD)/results
@touch $(PWD)/results/gemini_seed
@echo $(GEMINI_SEED) > $(PWD)/results/gemini_seed
docker run \
-it \
--rm \
-p 6060:6060 \
--name gemini \
--network $(GEMINI_DOCKER_NETWORK) \
-v $(PWD)/results:/results \
-w / \
scylladb/gemini:$(DOCKER_VERSION) \
--test-cluster=gemini-test \
--oracle-cluster=gemini-oracle \
--outfile=/results/gemini_result.log \
--tracing-outfile=/results/gemini_tracing.log \
--test-statement-log-file=/results/gemini_test_statement.log \
--oracle-statement-log-file=/results/gemini_oracle_statement.log \
$(GEMINI_FLAGS)
.PHONY: integration-test
integration-test:
@mkdir -p $(PWD)/results
@touch $(PWD)/results/gemini_seed
@echo $(GEMINI_SEED) > $(PWD)/results/gemini_seed
@$(GEMINI_BINARY) \
--test-cluster=$(GEMINI_TEST_CLUSTER) \
--oracle-cluster=$(GEMINI_ORACLE_CLUSTER) \
--outfile=$(PWD)/results/gemini_result.log \
--tracing-outfile=$(PWD)/results/gemini_tracing.log \
--test-statement-log-file=$(PWD)/results/gemini_test_statement.log \
--oracle-statement-log-file=$(PWD)/results/gemini_oracle_statement.log \
$(GEMINI_FLAGS)
.PHONY: clean
clean: clean-bin clean-results
.PHONY: clean-bin
clean-bin:
@rm -rf bin
.PHONY: clean-results
clean-results:
@sudo rm -rf results/*.log
@sudo rm -rf results/gemini_seed