-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage
executable file
·164 lines (135 loc) · 3.41 KB
/
manage
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
#!/bin/bash
usage() {
cat <<-EOF
Usage: $0 [command] [options]
Commands:
up - Creates the application container from the built images
When using the '--logs' option, use ctrl-c to exit logging. Use "down" or "stop" to stop the run.
Examples:
$0 start
$0 start --logs
$0 start --wait --logs
start - Same as up
stop - Stops the services. This is a non-destructive process. The volumes and containers
are not deleted so they will be reused the next time you run start.
EOF
exit 1
}
function build() {
docker build -t tendermint-load-test .
cd tendermint
./gen-network-config.sh
docker-compose -f ./docker-compose.yml up -d
cd ..
}
function rebuild() {
cd tendermint
docker-compose down
./gen-network-config.sh
docker-compose -f ./docker-compose.yml up -d
cd ..
}
function start() {
# rate: time: size:
read -p "Test name: " TEST
read -p "Transaction rate: " RATE
read -p "Time limit: " TIME
read -p "Size: " SIZE
read -p "Transaciton type: " TXN_TYPE
if [ -z $RATE ]
then
RATE=1000
fi
if [ -z $TIME ]
then
TIME=10
fi
if [ -z $SIZE ]
then
SIZE=250
fi
if [ -z $TXN_TYPE ]
then
TXN_TYPE="async"
fi
if [ -z $TEST ]
then
TEST="default"
fi
mkdir -p tests
mkdir -p tests/$TEST
echo "Starting coordinator with rate: $RATE time: $TIME size: $SIZE"
h1=$(curl "http://0.0.0.0:26657/abci_info?" | jq .result.response.last_block_height | tr -d '"')
h1=$((h1+3))
./build/tm-load-test \
coordinator \
--expect-workers 1 \
--bind localhost:26670 \
-c 1 -T $TIME -r $RATE -s $SIZE \
--broadcast-tx-method $TXN_TYPE \
--endpoints ws://0.0.0.0:26657/websocket,ws://0.0.0.0:26757/websocket,ws://0.0.0.0:26857/websocket,ws://0.0.0.0:26957/websocket\
--endpoint-select-method any \
--stats-output ./tests/$TEST/"$RATE:$TIME:$SIZE".csv &
echo "Starting worker 1"
start_worker &
# echo "Starting worker 2"
# start_worker
wait
h2=$(curl "http://0.0.0.0:26657/abci_info?" | jq .result.response.last_block_height | tr -d '"')
h2=$((h2+3))
echo $h1 $h2
txns=$(calculate_throughput $h1 $h2)
throughput=$((txns/TIME))
# echo $throughput
echo "Final throughput: $throughput" >> "./tests/$TEST/"$RATE:$TIME:$SIZE".csv"
}
function start_worker() {
./build/tm-load-test worker
}
function calculate_throughput() {
h1=$1
h2=$2
count=0
for((i=h1;i<=h2;i++)) {
data=$(curl "http://0.0.0.0:26657/block?height=$i" | jq .result.block.data.txs| tr -d '[]')
readarray -d, -t -s 1 txs <<< "$data"
n=${#txs[@]}
count=$((count+n))
}
echo $count
}
function stop() {
cd tendermint
docker-compose -f ./docker-compose.yml down
sudo rm -rf network-config
cd ..
}
function down() {
cd tendermint
docker-compose -f ./docker-compose.yml down
sudo rm -rf network-config
cd ..
docker image rm tendermint-load-test:latest
}
# =================================================================================================================
COMMAND=$1
case "$COMMAND" in
build)
build
;;
rebuild)
rebuild
;;
start | up)
start
;;
stop)
stop
;;
down)
down
;;
*)
usage
;;
esac