forked from UNIC-IFF/blockchain-benchmarking-framework
-
Notifications
You must be signed in to change notification settings - Fork 1
/
control.sh
executable file
·228 lines (207 loc) · 5.5 KB
/
control.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
#!/bin/bash
DEFAULT_ENVFILE="$(dirname $0)/defaults.env"
ENVFILE=${ENVFILE:-"$DEFAULT_ENVFILE"}
### Define or load default variables
source $ENVFILE
###
### Source scripts under scripts directory
. $(dirname $0)/scripts/helper_functions.sh
###
NETWORKS_ROOT_DIR=${NETWORKS_ROOT_DIR:-"$(dirname $0)/networks"}
SCENARIOS_ROOT_DIR=${SCENARIOS_ROOT_DIR:-"$(dirname $0)/scenarios"}
MONSTACKS_ROOT_DIR=${MONSTACKS_ROOT_DIR:-"$(dirname $0)/monitoring-stacks"}
TRAFFIC_GENERATORS_ROOT_DIR=${TRAFFIC_GENERATORS_ROOT_DIR:-"$(dirname $0)/traffic-generators"}
USAGE="$(basename $0) is the main control script for the Blockchain Benchmarking Framework.
Usage : $(basename $0) <network-type> <action> <arguments>
Network types:
--list-network-types|-list
Prints a list of the supported network types
--list-traffic-generators|-list-tgen
Prints a list of the installed traffic-generators
--list-monitoring-stacks|-list-mon
Prints a list of the installed monitoring-stacks
--list-scenarios|-list-sc
Prints a list of the installed scenarios
--all|-a
Runs the action for the network of each supported type for the given arguments
<network-type>
Runs the action for the given network type. If there is no such type, it exits with error.
--monitoring-stack|-mon <name of mon stack>
Starts the monitoring stack
--traffic-generator|-tgen <name of traffic generator>
Starts the traffic generator
--scenario|-sc <name of mon stack>
Starts the scenario
Actions:
start --val-num|-n <num of validators>
Starts a network with <num_validators>
configure --val-num|-n <num of validators>
configures a network with <num_validators>
stop
Stops the running networks
clean
Cleans up the configuration directories of the networks
status
Prints the status of the networks
"
function help()
{
echo "$USAGE"
}
function generate_network_configs()
{
nvals=$1
echo "Generating network configuration for $nvals validators..."
echo " done!"
}
function start_network()
{
nvals=$1
echo "Starting network with $nvals validators..."
# TESTNET_NAME=$TESTNET_NAME docker-compose -f docker-compose-testnet.yml up -d
echo " network started!"
}
function control_monstack()
{
monstack=$1
echo "Control monitoring stack $1..."
# TESTNET_NAME=$TESTNET_NAME docker-compose -f docker-compose-testnet.yml up -d
$MONSTACKS_ROOT_DIR/$monstack/control.sh $2
#run_monitoring_services.sh
}
function control_tgen()
{
monstack=$1
echo "Control traffic-generator $1..."
# TESTNET_NAME=$TESTNET_NAME docker-compose -f docker-compose-testnet.yml up -d
./traffic-generators/$monstack/control.sh $2
#run_monitoring_services.sh
}
function control_scenario()
{
monstack=$1
echo "Control scenario $1..."
# TESTNET_NAME=$TESTNET_NAME docker-compose -f docker-compose-testnet.yml up -d
./scemarios/$monstack/control.sh $2
#run_monitoring_services.sh
}
function stop_network()
{
echo "Stopping network..."
# TESTNET_NAME=$TESTNET_NAME docker-compose -f docker-compose-testnet.yml down
echo " stopped!"
}
function print_status()
{
echo "Printing status of the network..."
# TESTNET_NAME=$TESTNET_NAME docker-compose -f docker-compose-testnet.yml status
echo " Finished!"
}
function do_cleanup()
{
echo "Cleaning up network configuration..."
# rm -rf ${DEPLOYMENT_DIR}/*
echo " clean up finished!"
}
function list_supported_networks()
{
echo "List supported networks:"
supported_nettypes=$(ls ${NETWORKS_ROOT_DIR})
echo "${supported_nettypes[@]}"
}
function list_supported_traffic_generators()
{
echo "List supported traffic generators:"
supported_nettypes=$(ls ${TRAFFIC_GENERATORS_ROOT_DIR})
echo "${supported_nettypes[@]}"
}
function list_supported_monstacks()
{
echo "List supported monitoring stacks:"
supported_nettypes=$(ls ${MONSTACKS_ROOT_DIR})
echo "${supported_nettypes[@]}"
}
function list_supported_scenarios()
{
echo "List supported scenarios:"
supported_nettypes=$(ls ${SCENARIOS_ROOT_DIR})
echo "${supported_nettypes[@]}"
}
ARGS="$@"
if [ $# -lt 1 ]
then
#echo "No args"
help
exit 1
fi
while [ "$1" != "" ]; do
case $1 in
--all|-a ) shift
echo "$@"
exit
while [ "$1" != "" ]; do
case $1 in
-n|--val-num ) shift
VAL_NUM=$1
;;
esac
shift
done
start_network $VAL_NUM
exit
;;
--monitoring-stack|-mon ) shift
echo "$@"
monstack_name=$1
shift
args="$@"
control_monstack $monstack_name $args
exit
;;
--scenario|-sc ) shift
echo "$@"
scenario_name=$1
shift
args="$@"
control_scenario $scenario_name $args
exit
;;
--traffic-generator|-tgen ) shift
echo "$@"
tgen_name=$1
shift
args="$@"
control_tgen $tgen_name $args
exit
;;
--list-network-types|-list ) shift
echo "$@"
list_supported_networks
exit
;;
--list-monitoring-stacks|-list_mon ) shift
echo "$@"
list_supported_monstacks
exit
;;
--list-traffic-generators|-list_tgen ) shift
echo "$@"
list_supported_traffic_generators
exit
;;
--list-scenarios|-list_sc ) shift
echo "$@"
list_supported_scenarios
exit
;;
*)
network_type=$1
shift
rest_args="$@"
echo $network_type $rest_args
${NETWORKS_ROOT_DIR}/$network_type/control.sh ${rest_args}
exit
;;
esac
shift
done