Skip to content

Commit c8ccb94

Browse files
authored
Add script to run blockade network tests. (#2756)
* Blockade: Use ${GOPATH} in volumes. * Add blockade run script to capture logs if the test fails.
1 parent c43c050 commit c8ccb94

File tree

2 files changed

+59
-6
lines changed

2 files changed

+59
-6
lines changed

contrib/blockade/blockade.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ containers:
1818
- 5080
1919
- 6080
2020
command: /gobin/dgraph zero --my=zero1:5080 --replicas 3 --idx 1 --bindall --expose_trace --logtostderr -v=2
21-
volumes: {"/home/mrjn/go/bin": "/gobin"}
21+
volumes:
22+
# Note: Any environment variables must use the ${} syntax.
23+
# ${GOPATH} works, $GOPATH does not.
24+
"${GOPATH}/bin": "/gobin"
2225

2326
zero2:
2427
image: dgraph/dgraph:latest
@@ -31,7 +34,8 @@ containers:
3134
- 5082
3235
- 6082
3336
command: /gobin/dgraph zero -o 2 --my=zero2:5082 --replicas 3 --peer=zero1:5080 --idx 2 --bindall --expose_trace --logtostderr -v=2
34-
volumes: {"/home/mrjn/go/bin": "/gobin"}
37+
volumes:
38+
"${GOPATH}/bin": "/gobin"
3539

3640
zero3:
3741
image: dgraph/dgraph:latest
@@ -45,7 +49,7 @@ containers:
4549
- 6083
4650
command: /gobin/dgraph zero -o 3 --my=zero3:5083 --replicas 3 --peer=zero1:5080 --idx 3 --bindall --expose_trace --logtostderr -v=2
4751
volumes:
48-
"/home/mrjn/go/bin": "/gobin"
52+
"${GOPATH}/bin": "/gobin"
4953

5054
dg1:
5155
image: dgraph/dgraph:latest
@@ -59,7 +63,7 @@ containers:
5963
- 9180
6064
command: /gobin/dgraph alpha --my=dg1:7180 --lru_mb=1024 --zero=zero1:5080 -o 100 --expose_trace --trace 1.0 --logtostderr -v=2
6165
volumes:
62-
"/home/mrjn/go/bin": "/gobin"
66+
"${GOPATH}/bin": "/gobin"
6367

6468
dg2:
6569
image: dgraph/dgraph:latest
@@ -74,7 +78,7 @@ containers:
7478
start_delay: 8
7579
command: /gobin/dgraph alpha --my=dg2:7182 --lru_mb=1024 --zero=zero1:5080 -o 102 --expose_trace --trace 1.0 --logtostderr -v=2
7680
volumes:
77-
"/home/mrjn/go/bin": "/gobin"
81+
"${GOPATH}/bin": "/gobin"
7882

7983
dg3:
8084
image: dgraph/dgraph:latest
@@ -89,7 +93,7 @@ containers:
8993
start_delay: 16
9094
command: /gobin/dgraph alpha --my=dg3:7183 --lru_mb=1024 --zero=zero1:5080 -o 103 --expose_trace --trace 1.0 --logtostderr -v=2
9195
volumes:
92-
"/home/mrjn/go/bin": "/gobin"
96+
"${GOPATH}/bin": "/gobin"
9397

9498
network:
9599
driver: "udn"

contrib/blockade/run.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash
2+
# Builds ./blockade and runs the blockade tests.
3+
#
4+
# Usage:
5+
# Run the test 32 times (about 8 hours):
6+
# ./run.sh
7+
# Run the test once:
8+
# ./run.sh 1
9+
10+
function cleanup_blockade {
11+
blockade destroy || true
12+
docker container prune -f
13+
if docker network ls | grep -q 'blockade_net'; then
14+
docker network ls |
15+
awk '/blockade_net/ { print $1 }' |
16+
xargs docker network rm
17+
fi
18+
}
19+
20+
21+
set -x -o pipefail
22+
23+
times=${1:-32}
24+
25+
go build -v .
26+
27+
cleanup_blockade
28+
# Each run takes about 15 minutes, so running 32 times will take about 8 hours.
29+
for i in $(seq 1 $times)
30+
do
31+
echo "===> Running Blockade #$i"
32+
if ! ./blockade 2>&1 | tee blockade$i.log; then
33+
echo "===> Blockade test failed"
34+
docker logs zero1 2>&1 | tee zero1.log
35+
docker logs zero2 2>&1 | tee zero2.log
36+
docker logs zero3 2>&1 | tee zero3.log
37+
docker logs dg1 2>&1 | tee dg1.log
38+
docker logs dg2 2>&1 | tee dg2.log
39+
docker logs dg3 2>&1 | tee dg3.log
40+
41+
cleanup_blockade
42+
exit 1
43+
fi
44+
done
45+
46+
echo "Blockade log summary:"
47+
grep '===>' blockade*.log
48+
49+
cleanup_blockade

0 commit comments

Comments
 (0)