-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-tests.sh
executable file
·257 lines (223 loc) · 9.44 KB
/
run-tests.sh
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
#!/bin/sh
set -e
# Should be the same as build.sh
GORELEASER_VERSION="v2.3.2"
while [ ! -z "$1" ]; do
case "$1" in
"cluster")
WITH_CLUSTER=1
;;
"race")
WITH_RACE=1
;;
"long")
WITH_LONG=1
;;
"nostop")
WITH_NOSTOP=1
;;
"shell")
WITH_SHELL=1
;;
"scylladb")
WITH_SCYLLADB=1
;;
*)
echo "Usage: $0 [cluster|race|long|nostop|scylladb]"
echo " cluster: Run test with clustered Redis & Cassandra"
echo " long: Run longer test"
echo " race: Run test with -race"
echo " nostop: Do not stop Cassandra & Redis at the end"
echo " shell: Open a shell instead of running tests. It will start Redis & Cassandra."
echo " It also forward the port 9200 to a SquirrelDB running inside this shell"
echo " The shell container will be named \"squirreldb-test-shell\""
echo "scylladb: Use ScyllaDB instead of Cassandra"
exit 1
esac
shift
done
if docker volume ls | grep -q squirreldb-buildcache; then
GO_MOUNT_CACHE="-v squirreldb-buildcache:/go/pkg"
fi
if [ "${WITH_CLUSTER}" = "1" ]; then
if [ "${WITH_SCYLLADB}" = "1" ]; then
echo "ScyllaDB is not yet supported in cluster with run-tests.sh"
exit 1
fi
echo
echo "== Starting cluster component using examples/squirreldb_ha/"
(cd examples/squirreldb_ha/; docker compose up -d cassandra1 cassandra2 cassandra3 redis1 redis2 redis3 redis4 redis5 redis6 redis_init)
docker_network="--network squirreldb_ha_default"
export SQUIRRELDB_CASSANDRA_ADDRESSES=cassandra1:9042,cassandra2:9042
export SQUIRRELDB_REDIS_ADDRESSES=redis1:6379,redis2:6379
export SQUIRRELDB_CASSANDRA_REPLICATION_FACTOR=3
elif [ "${WITH_SCYLLADB}" = "1" ]; then
echo
echo "== Starting ScyllaDB & Redis"
docker run --name squirreldb-test-scylla -d -e MAX_HEAP_SIZE=128M -e HEAP_NEWSIZE=24M scylladb/scylla || true
docker run --name squirreldb-test-redis -d redis || true
docker_network=""
export SQUIRRELDB_CASSANDRA_ADDRESSES=$(docker inspect squirreldb-test-scylla -f '{{ .NetworkSettings.IPAddress }}'):9042
export SQUIRRELDB_REDIS_ADDRESSES=$(docker inspect squirreldb-test-redis -f '{{ .NetworkSettings.IPAddress }}'):6379
export SQUIRRELDB_CASSANDRA_REPLICATION_FACTOR=1
else
echo
echo "== Starting Cassandra & Redis"
docker run --name squirreldb-test-cassandra -d -e MAX_HEAP_SIZE=128M -e HEAP_NEWSIZE=24M cassandra || true
docker run --name squirreldb-test-redis -d redis || true
docker_network=""
export SQUIRRELDB_CASSANDRA_ADDRESSES=$(docker inspect squirreldb-test-cassandra -f '{{ .NetworkSettings.IPAddress }}'):9042
export SQUIRRELDB_REDIS_ADDRESSES=$(docker inspect squirreldb-test-redis -f '{{ .NetworkSettings.IPAddress }}'):6379
export SQUIRRELDB_CASSANDRA_REPLICATION_FACTOR=1
fi
if [ "${WITH_RACE}" = "1" ]; then
race_opt="-ldflags='-linkmode external -extldflags=-static' -race"
else
race_opt=""
fi
lock_opt="--worker-processes 2 --worker-threads 25 --work-duration 100ms --worker-delay 10ms"
lock2_opt="--worker-processes 5 --worker-threads 1 --work-duration 250ms --worker-delay 500ms"
lock3_opt="--worker-processes 5 --worker-threads 1 --work-duration 250ms --worker-delay 500ms --with-block"
index_bench2_opt="--bench.scale-agent 10 --bench.scale-tenant 5"
if [ "${WITH_LONG}" = "1" ]; then
lock_opt="--worker-processes 3 --run-time 90s"
lock2_opt="${lock2_opt} --run-time 90s"
lock3_opt="${lock3_opt} --run-time 90s"
index_bench_opt="--bench.query 500 --bench.shard-end 10 --bench.shard-size 2000 --bench.worker-max-threads 5 --bench.worker-processes 2"
index_bench2_opt="${index_bench2_opt} --bench.scale-agent 25 --bench.scale-tenant 10"
remote_store_opt="--threads 3 --scale 10"
remote_store2_opt="--test.processes 2 --test.run-duration 1m"
redis_opt="--test.run-time=1m"
fi
export GORACE=halt_on_error=1
if [ "${WITH_SHELL}" = "1" ]; then
docker run $docker_network -p 127.0.0.1:9200:9201 --rm -ti -e HOME=/go/pkg \
-e SQUIRRELDB_LOG_DISABLE_COLOR \
-e SQUIRRELDB_CASSANDRA_ADDRESSES \
-e SQUIRRELDB_CASSANDRA_REPLICATION_FACTOR \
-e SQUIRRELDB_REDIS_ADDRESSES \
-e GORACE \
-e SQUIRRELDB_TELEMETRY_ENABLED=false -e SQUIRRELDB_LISTEN_ADDRESS=0.0.0.0:9201 \
-v $(pwd):/src -w /src ${GO_MOUNT_CACHE} \
--name squirreldb-test-shell \
--entrypoint '' \
goreleaser/goreleaser:${GORELEASER_VERSION} bash || true
else
echo "== waiting stores"
docker run $docker_network --rm -e HOME=/go/pkg \
-e SQUIRRELDB_LOG_DISABLE_COLOR \
-e SQUIRRELDB_CASSANDRA_ADDRESSES \
-e SQUIRRELDB_CASSANDRA_REPLICATION_FACTOR \
-e SQUIRRELDB_REDIS_ADDRESSES \
-e GORACE \
-v $(pwd):/src -w /src ${GO_MOUNT_CACHE} \
--entrypoint '' \
goreleaser/goreleaser:${GORELEASER_VERSION} \
sh -exc "go run $race_opt ./tests/wait-stores"
echo
echo "== Running squirreldb-cassandra-lock-bench (threaded)"
docker run $docker_network --rm -e HOME=/go/pkg \
-e SQUIRRELDB_LOG_DISABLE_COLOR \
-e SQUIRRELDB_CASSANDRA_ADDRESSES -e SQUIRRELDB_CASSANDRA_REPLICATION_FACTOR \
-e GORACE \
-v $(pwd):/src -w /src ${GO_MOUNT_CACHE} \
--entrypoint '' \
goreleaser/goreleaser:${GORELEASER_VERSION} \
sh -exc "go run $race_opt ./tests/squirreldb-cassandra-lock-bench/ $lock_opt"
echo
echo "== Running squirreldb-cassandra-lock-bench (single thread, more processes)"
docker run $docker_network --rm -e HOME=/go/pkg \
-e SQUIRRELDB_LOG_DISABLE_COLOR \
-e SQUIRRELDB_CASSANDRA_ADDRESSES -e SQUIRRELDB_CASSANDRA_REPLICATION_FACTOR \
-e GORACE \
-v $(pwd):/src -w /src ${GO_MOUNT_CACHE} \
--entrypoint '' \
goreleaser/goreleaser:${GORELEASER_VERSION} \
sh -exc "go run $race_opt ./tests/squirreldb-cassandra-lock-bench/ $lock2_opt"
echo "== Running squirreldb-cassandra-lock-bench (with blocking/unblocking from time to time)"
docker run $docker_network --rm -e HOME=/go/pkg \
-e SQUIRRELDB_LOG_DISABLE_COLOR \
-e SQUIRRELDB_CASSANDRA_ADDRESSES -e SQUIRRELDB_CASSANDRA_REPLICATION_FACTOR \
-e GORACE \
-v $(pwd):/src -w /src ${GO_MOUNT_CACHE} \
--entrypoint '' \
goreleaser/goreleaser:${GORELEASER_VERSION} \
sh -exc "go run $race_opt ./tests/squirreldb-cassandra-lock-bench/ $lock3_opt"
echo
echo "== Running squirreldb-cassandra-index-bench"
docker run $docker_network --rm -e HOME=/go/pkg \
-e SQUIRRELDB_LOG_DISABLE_COLOR \
-e SQUIRRELDB_CASSANDRA_ADDRESSES -e SQUIRRELDB_CASSANDRA_REPLICATION_FACTOR \
-e GORACE \
-v $(pwd):/src -w /src ${GO_MOUNT_CACHE} \
--entrypoint '' \
goreleaser/goreleaser:${GORELEASER_VERSION} \
sh -exc "go run $race_opt ./tests/squirreldb-cassandra-index-bench/ --verify $index_bench_opt"
echo
echo "== Running squirreldb-cassandra-index-bench2"
docker run $docker_network --rm -e HOME=/go/pkg \
-e SQUIRRELDB_LOG_DISABLE_COLOR \
-e SQUIRRELDB_CASSANDRA_ADDRESSES -e SQUIRRELDB_CASSANDRA_REPLICATION_FACTOR \
-e GORACE \
-v $(pwd):/src -w /src ${GO_MOUNT_CACHE} \
--entrypoint '' \
goreleaser/goreleaser:${GORELEASER_VERSION} \
sh -exc "go run $race_opt ./tests/squirreldb-cassandra-index-bench2/ $index_bench2_opt"
echo
echo "== Running squirreldb-promql-aggregate"
docker run $docker_network --rm -e HOME=/go/pkg \
-e SQUIRRELDB_LOG_DISABLE_COLOR \
-e SQUIRRELDB_CASSANDRA_ADDRESSES -e SQUIRRELDB_CASSANDRA_REPLICATION_FACTOR \
-e SQUIRRELDB_REDIS_ADDRESSES -e GORACE \
-v $(pwd):/src -w /src ${GO_MOUNT_CACHE} \
--entrypoint '' \
goreleaser/goreleaser:${GORELEASER_VERSION} \
sh -exc "go run $race_opt ./tests/squirreldb-promql-aggregate/"
echo
echo "== Running remote-storage-test"
docker run $docker_network --rm -e HOME=/go/pkg \
-e SQUIRRELDB_LOG_DISABLE_COLOR \
-e SQUIRRELDB_CASSANDRA_ADDRESSES -e SQUIRRELDB_CASSANDRA_REPLICATION_FACTOR \
-e SQUIRRELDB_REDIS_ADDRESSES -e GORACE \
-v $(pwd):/src -w /src ${GO_MOUNT_CACHE} \
--entrypoint '' \
goreleaser/goreleaser:${GORELEASER_VERSION} \
sh -exc "go run $race_opt ./tests/remote-storage-test/ $remote_store_opt"
echo
echo "== Running remote-storage-test2"
docker run $docker_network --rm -e HOME=/go/pkg \
-e SQUIRRELDB_LOG_DISABLE_COLOR \
-e SQUIRRELDB_CASSANDRA_ADDRESSES -e SQUIRRELDB_CASSANDRA_REPLICATION_FACTOR \
-e SQUIRRELDB_REDIS_ADDRESSES -e GORACE \
-v $(pwd):/src -w /src ${GO_MOUNT_CACHE} \
--entrypoint '' \
goreleaser/goreleaser:${GORELEASER_VERSION} \
sh -exc "go run $race_opt ./tests/remote-storage-test2/ $remote_store2_opt"
echo
echo "== Running squirreldb-cluster-redis"
docker run $docker_network --rm -e HOME=/go/pkg \
-e SQUIRRELDB_LOG_DISABLE_COLOR \
-e GORACE -e SQUIRRELDB_REDIS_ADDRESSES \
-v $(pwd):/src -w /src ${GO_MOUNT_CACHE} \
--entrypoint '' \
goreleaser/goreleaser:${GORELEASER_VERSION} \
sh -exc "go run $race_opt ./tests/squirreldb-cluster-redis/ $redis_opt"
echo
echo "== Success =="
fi
if [ ! "${WITH_NOSTOP}" = "1" ]; then
if [ "${WITH_CLUSTER}" = "1" ]; then
echo
echo "== Stopping cluster component using examples/squirreldb_ha/"
(cd examples/squirreldb_ha/; docker compose down -v)
else
echo
echo "== Stopping Cassandra & Redis"
if [ "${WITH_SCYLLADB}" = "1" ]; then
docker rm -f squirreldb-test-scylla
else
docker rm -f squirreldb-test-cassandra
fi
docker rm -f squirreldb-test-redis
fi
fi