-
Notifications
You must be signed in to change notification settings - Fork 56
/
run.sh
executable file
·154 lines (124 loc) · 3.36 KB
/
run.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
# defaults:
DBFILE=temp.db
INFOFILE=hammer/last-experiment.json
TPSLOG=logs/tps.py.log
DEPLOYLOG=logs/deploy.py.log
SENDLOG=logs/send.py.log
if [ -z "$CH_TXS" ] || [ -z "$CH_THREADING" ]; then
echo "You must set 2 ENV variables, examples:"
echo "export CH_TXS=1000 CH_THREADING=sequential"
echo "export CH_TXS=5000 CH_THREADING=\"threaded2 20\""
exit
fi
if (( $# != 1 && $# != 2 )); then
echo "Syntax:"
echo "./run.sh info-word [network-scripts-prefix]"
echo "e.g."
echo "./run.sh Geth-t2.xlarge"
echo "./run.sh Geth-t2.xlarge geth-clique"
echo "The first case assumes that network nodes are started manually."
exit
fi
INFOWORD=$1
# exit when any command fails
set -e
# keep track of the last executed command
trap 'last_command=$current_command; current_command=$BASH_COMMAND' DEBUG
# echo an error message before exiting
trap 'echo; echo "\"${last_command}\" command filed with exit code $?."' EXIT
#
function title {
echo =============================
echo = $1
echo =============================
}
echo
title "chainhammer v52 - run all ="
echo
echo infoword: $INFOWORD
echo number of transactions: $CH_TXS
echo concurrency algo: $CH_THREADING
echo
echo infofile: $INFOFILE
echo blocks database: $DBFILE
echo log files:
echo $TPSLOG
echo $DEPLOYLOG
echo $SENDLOG
echo
# exit
if (( $# == 2 )); then
title start network
source networks/$2-start.sh
echo
fi
title "activate virtualenv"
source env/bin/activate
echo
python --version
echo
cd hammer
rm -f $INFOFILE
title is_up.py
echo Loops until the node is answering on the expected port.
./is_up.py
echo Great, node is available now.
echo
title tps.py
echo start listener tps.py, show here but also log into file $TPSLOG
echo this ENDS after send.py below writes a new INFOFILE $INFOFILE
unbuffer ./tps.py | tee "../$TPSLOG" &
echo
title sleep 1.5 seconds
echo to have tps.py say its thing before deploy.py starts printing
echo
sleep 1.5
echo
title deploy.py
echo Deploy the smartContract, deploy.py will then trigger tps.py to START counting.
echo Logging into file $DEPLOYLOG.
echo
./deploy.py > "../$DEPLOYLOG"
sleep 0
echo
title send.py
echo Send $CH_TXS transactions with non/concurrency algo \'$CH_THREADING\', plus possibly wait 10 more blocks.
echo Then send.py triggers tps.py to end counting. Logging all into file $SENDLOG.
echo
./send.py $CH_TXS $CH_THREADING > "../$SENDLOG"
echo
title "sleep 2"
echo wait 2 second until also tps.py has written its results.
echo
sleep 2
echo
title blocksDB_create.py
echo read blocks from node1 into SQL db
cd ../reader
./blocksDB_create.py $DBFILE ../$INFOFILE
echo
title blocksDB_diagramming.py
echo make time series diagrams from SQL db
./blocksDB_diagramming.py $DBFILE $INFOWORD ../$INFOFILE
echo
title page_generator.py
./page_generator.py ../$INFOFILE ../$TPSLOG
echo
cd ..
# switch off the trap already here, because sometimes the 2nd kill in networks/$2-stop.sh is not needed anymore:
set +e
trap '' EXIT
if (( $# == 2 )); then
title stop network
source networks/$2-stop.sh
# sleep 0
# echo should be stopped now
# scripts/netstat_port8545.sh
echo
# TODO: Perhaps each time also call networks/$2-clean.sh
# to reset chain to block 0 ???
# or at least docker-compose down already in -stop.sh?
fi
title "Ready."
echo See that image, and those .md and .html pages.
echo