forked from dfarrell07/wcbench
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloop_wcbench.sh
executable file
·232 lines (213 loc) · 6.53 KB
/
loop_wcbench.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
#!/usr/bin/env sh
# Helper script to run WCBench tests in a loop, used for testing
# Script assumes it lives in the same dir as wcbench.sh
# Exit codes
EX_USAGE=64
EX_OK=0
# Output verbose debug info (true) or not (anything else)
VERBOSE=false
###############################################################################
# Prints usage message
# Globals:
# None
# Arguments:
# None
# Returns:
# None
###############################################################################
usage()
{
cat << EOF
Usage $0 [options]
Run WCBench against OpenDaylight in a loop.
OPTIONS:
-h Show this help message
-v Output verbose debug info
-l <num_runs> Loop WCBench given number of times without restarting ODL
-r <num_runs> Loop WCBench given number of times, restart ODL between runs
-t <time> Run WCBench for a given number of minutes
-p <processors> Pin ODL to given number of processors
EOF
}
###############################################################################
# Starts ODL, optionally pinning it to a given number of processors
# Globals:
# processors
# VERBOSE
# Arguments:
# None
# Returns:
# WCBench exit status
###############################################################################
start_odl()
{
if "$VERBOSE" = true; then
if [ -z $processors ]; then
# Start ODL, don't pass processor info
echo "Starting ODL, not passing processor info"
./wcbench.sh -vo
else
# Start ODL, pinning it to given number of processors
echo "Pinning ODL to $processors processor(s)"
./wcbench.sh -vp $processors -o
fi
else
if [ -z $processors ]; then
# Start ODL, don't pass processor info
echo "Starting ODL, not passing processor info"
./wcbench.sh -o
else
# Start ODL, pinning it to given number of processors
echo "Pinning ODL to $processors processor(s)"
./wcbench.sh -p $processors -o
fi
fi
}
###############################################################################
# Run WCBench against ODL, optionally passing a WCBench run time
# Globals:
# run_time
# VERBOSE
# Arguments:
# None
# Returns:
# WCBench exit status
###############################################################################
run_wcbench()
{
if "$VERBOSE" = true; then
if [ -z $run_time ]; then
# Flag means run WCBench
echo "Running WCBench, not passing run time info"
./wcbench.sh -vr
else
# Flags mean use $run_time WCBench runs, run WCBench
echo "Running WCBench with $run_time minute(s) run time"
./wcbench.sh -vt $run_time -r
fi
else
if [ -z $run_time ]; then
# Flag means run WCBench
echo "Running WCBench, not passing run time info"
./wcbench.sh -r
else
# Flags mean use $run_time WCBench runs, run WCBench
echo "Running WCBench with $run_time minute(s) run time"
./wcbench.sh -t $run_time -r
fi
fi
}
###############################################################################
# Run WCBench against ODL a given number of times without restarting ODL
# Globals:
# None
# Arguments:
# The number of times to run WCBench against ODL
# Returns:
# Exit status of run_wcbench
###############################################################################
loop_no_restart()
{
num_runs=$1
echo "Looping WCBench without restarting ODL"
for (( runs_done = 0; runs_done < $num_runs; runs_done++ )); do
echo "Starting run $(expr $runs_done + 1) of $num_runs"
start_odl
# Do this last so fn returns same exit code
run_wcbench
done
}
###############################################################################
# Run WCBench against ODL a given number of times, restart ODL between runs
# Globals:
# VERBOSE
# Arguments:
# The number of times to run WCBench against ODL
# Returns:
# WCBench exit status
###############################################################################
loop_with_restart()
{
num_runs=$1
echo "Looping WCBench, restarting ODL each run"
for (( runs_done = 0; runs_done < $num_runs; runs_done++ )); do
echo "Starting run $(expr $runs_done + 1) of $num_runs"
start_odl
run_wcbench
# Stop ODL. Do this last so fn returns same exit code.
if "$VERBOSE" = true; then
./wcbench.sh -vk
else
./wcbench.sh -k
fi
done
}
# If executed with no options
if [ $# -eq 0 ]; then
usage
exit $EX_USAGE
fi
# Used to output help if no valid action results from arguments
action_taken=false
# Parse options given from command line
while getopts ":hvl:p:r:t:" opt; do
case "$opt" in
h)
# Help message
usage
exit $EX_OK
;;
v)
# Output debug info verbosely
VERBOSE=true
;;
l)
# Loop without restarting ODL between WCBench runs
num_runs=${OPTARG}
if [[ $num_runs -lt 1 ]]; then
echo "Doing less than 1 run doesn't make sense"
exit $EX_USAGE
else
echo "Will run WCBench against ODL $num_runs time(s)"
fi
# Kick off testing loop
loop_no_restart $num_runs
action_taken=true
;;
p)
# Pin a given number of processors
# Note that this option must be given before -o (start ODL)
processors=${OPTARG}
if [ $processors -lt 1 ]; then
echo "Can't pin ODL to less than one processor"
exit $EX_USAGE
fi
;;
r)
# Restart ODL between each WCBench run
num_runs=${OPTARG}
if [[ $num_runs -lt 1 ]]; then
echo "Doing less than 1 run doesn't make sense"
exit $EX_USAGE
else
echo "Will run WCBench against ODL $num_runs time(s)"
fi
# Kick off testing loop
loop_with_restart $num_runs
action_taken=true
;;
t)
# Set length of WCBench run in minutes
run_time=${OPTARG}
;;
*)
# Print usage message
usage
exit $EX_USAGE
esac
done
# Output help message if no valid action was taken
if ! "$action_taken" = true; then
usage
exit $EX_USAGE
fi