-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathMakefile
190 lines (156 loc) · 5.71 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
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
VERSION ?= $(shell git describe --tags 2>/dev/null || echo "dev")
COMMIT ?= $(shell git rev-parse HEAD 2>/dev/null || echo "unknown")
BUILD_DATE ?= $(shell git log -1 --format=%cd --date=format:%Y-%m-%dT%H:%M:%SZ 2>/dev/null || date -u +"%Y-%m-%dT%H:%M:%SZ")
LDFLAGS_VERSION := -X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.date=$(BUILD_DATE)
CQL_FEATURES ?= normal
CONCURRENCY ?= 16
DURATION ?= 10m
WARMUP ?= 0
MODE ?= mixed
DATASET_SIZE ?= large
SEED ?= $(shell date +%s)
GEMINI_BINARY ?= $(PWD)/bin/gemini
GEMINI_DOCKER_NETWORK ?= gemini
define get_scylla_ip
$(shell docker inspect --format "{{ .NetworkSettings.Networks.$(GEMINI_DOCKER_NETWORK).IPAddress }}" "$(1)")
endef
GEMINI_FLAGS ?= --fail-fast \
--level=info \
--consistency=QUORUM \
--test-host-selection-policy=token-aware \
--oracle-host-selection-policy=round-robin \
--mode=$(MODE) \
--request-timeout=5s \
--connect-timeout=15s \
--use-server-timestamps=false \
--async-objects-stabilization-attempts=10 \
--max-mutation-retries=10 \
--replication-strategy="{'class': 'NetworkTopologyStrategy', 'replication_factor': '1'}" \
--oracle-replication-strategy="{'class': 'NetworkTopologyStrategy', 'replication_factor': '1'}" \
--concurrency=$(CONCURRENCY) \
--dataset-size=$(DATASET_SIZE) \
--seed=$(SEED) \
--schema-seed=$(SEED) \
--cql-features=$(CQL_FEATURES) \
--duration=$(DURATION) \
--warmup=$(WARMUP) \
--profiling-port=6060 \
--drop-schema=true \
--oracle-statement-log-file=$(PWD)/results/oracle-statements.log.zst \
--test-statement-log-file=$(PWD)/results/test-statements.log.zst \
--statement-log-file-compression=zstd
.PHONY: tidy
tidy:
@go mod tidy
.PHONY: check
check:
@go tool golangci-lint run
.PHONY: fix
fix:
@go tool golangci-lint run --fix
.PHONY: fieldalign
fieldalign:
@go tool fieldalignment -fix ./cmd/...
@go tool fieldalignment -fix ./pkg/...
.PHONY: fmt
fmt:
@go tool gofumpt -w -extra .
.PHONY: build
build:
@CGO_ENABLED=0 go build -ldflags="-s -w" -ldflags="$(LDFLAGS_VERSION)" -o bin/gemini ./cmd/gemini
.PHONY: debug-build
debug-build:
@CGO_ENABLED=0 go build -ldflags="$(LDFLAGS_VERSION)" -gcflags="-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: scylla-setup debug-build
@pre-commit install
.PHONY: scylla-setup
scylla-setup:
@docker compose -f docker/docker-compose-$(DOCKER_COMPOSE_TESTING).yml up -d --wait
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: scylla-setup-cluster
scylla-setup-cluster:
@docker compose -f docker/docker-compose-scylla-cluster.yml up -d --wait
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-1 2>&1 | grep "Starting listening for CQL clients" > /dev/null; do sleep 0.2; done
until docker logs gemini-test-2 2>&1 | grep "Starting listening for CQL clients" > /dev/null; do sleep 0.2; done
until docker logs gemini-test-3 2>&1 | grep "Starting listening for CQL clients" > /dev/null; do sleep 0.2; done
.PHONY: scylla-shutdown-cluster
scylla-shutdown-cluster:
@docker compose -f docker/docker-compose-scylla-cluster.yml down --volumes
.PHONY: test
test:
@go test -covermode=atomic -tags testing -race -coverprofile=coverage.txt -timeout 5m -json -v ./... 2>&1 | go tool gotestfmt -showteststatus
.PHONY: pprof-profile
pprof-profile:
@go tool pprof -http=:8080 http://localhost:6060/debug/pprof/profile
.PHONY: pprof-heap
pprof-heap:
@go tool pprof -http=:8081 http://localhost:6060/debug/pprof/heap
.PHONY: pprof-goroutine
pprof-goroutine:
@go tool pprof -http=:8082 http://localhost:6060/debug/pprof/goroutine
.PHONY: pprof-block
pprof-block:
@go tool pprof -http=:8083 http://localhost:6060/debug/pprof/block
.PHONY: pprof-mutex
pprof-mutex:
@go tool pprof -http=:8084 http://localhost:6060/debug/pprof/mutex
.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 \
--memory=4G \
-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 \
$(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="$(call get_scylla_ip,gemini-test)" \
--oracle-cluster="$(call get_scylla_ip,gemini-oracle)" \
$(GEMINI_FLAGS)
.PHONY: integration-cluster-test
integration-cluster-test:
@mkdir -p $(PWD)/results
@touch $(PWD)/results/gemini_seed
@echo $(GEMINI_SEED) > $(PWD)/results/gemini_seed
$(GEMINI_BINARY) \
--test-cluster="$(call get_scylla_ip,gemini-test-1),$(call get_scylla_ip,gemini-test-2),$(call get_scylla_ip,gemini-test-3)" \
--oracle-cluster="$(call get_scylla_ip,gemini-oracle)" \
$(GEMINI_FLAGS)
.PHONY: clean
clean: clean-bin clean-results
.PHONY: clean-bin
clean-bin:
@rm -rf bin
.PHONY: clean-results
clean-results:
@rm -rf results/*.log
@rm -rf results/gemini_seed