-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbench-confgen.sh
executable file
·285 lines (241 loc) · 7 KB
/
bench-confgen.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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
#!/usr/bin/env mksh
set -o pipefail
typeset -r WORKDIR="${ dirname "${0}"; }"
typeset -r WORKDIR_PATH="${ cd "${WORKDIR}" && pwd; }"
### DEBUGGING FLAGS
# set -n # Uncomment to check script syntax, without execution.
# # NB. Do not forget to put the above comment back in or
# # the shell script will not execute!
# Uncomment to debug this shell script
set -x
# 'verbose', displays input lines as they are read
set -v
# DBGTRAP='print " file: ${.sh.file} cmd: "${.sh.command}" line: ${.sh.lineno} \n \
# shlvl: ${.sh.level} subshlvl: ${.sh.subshlevel} func: ${.sh.fun} exit: $? "'
# uncomment the following line to print detailed info on every line as it is run
# trap "${DBGTRAP}" DEBUG
# Make sure all math stuff runs in the "C" locale to avoid problems
# with alternative # radix point representations (e.g. ',' instead of
# '.' in de_DE.*-locales). This needs to be set _before_ any
# floating-point constants are defined in this script).
if [[ "${LC_ALL-}" != '' ]] ; then
export \
LC_MONETARY="${LC_ALL}" \
LC_MESSAGES="${LC_ALL}" \
LC_COLLATE="${LC_ALL}" \
LC_CTYPE="${LC_ALL}"
unset LC_ALL
fi
export LC_NUMERIC='C'
### FILES AND VARIABLES
typeset -r progname="${ basename "${0}"; }"
function usage
{
BOLD="\e[1m"
NORM="\e[0m"
cat <<EOF
${ print "${BOLD}NAME${NORM}"; }
${progname} - generates configuration files for use with oltpbench.
${ print "${BOLD}DESCRIPTION${NORM}"; }
${progname}is a small utility which creates a config
file for use with oltpbench. It only creates them for one database at a
time, adding the necessary info to run the user specified benchmarks.
${ print "${BOLD}OPTIONS${NORM}"; }
-f <fqdn> FQDN of the database host.
-u <user> Username to use for connecting to DB.
-p <pass> Password for the user.
-t <dbtype> Type of database being targeted (those indicated with a '*' need
config templates to be added):
mysql
mariadb
postgres
db2
oracle
rac
sqlserver
sqlite*
hstore*
hsqldb*
h2*
monetdb
nuodb*
timesten*
amazonrds*
sqlazure*
-b <bench> Type of benchmark to configure. Can be a comma separated list, with no spaces:
tpcc
tpch
chbenchmark
auctionmark
epinions
jpab
resourcestresser
seats
tatp
twitter
wiki
ycsb
voter
linkbench
sibench
-a <boolean> Accept Oracle OTN License (required for oracle & rac).
-d <database> Name of DB.
-n <port> Port DB is listening on.
-r <rate> Rate limit for workload.
-c <clients> number of clients that will be simulated connecting to the database.
-i <isolation> either: TRANSACTION_READ_COMMITED || TRANSACTION_SERIALIZABLE
${ print "${BOLD}IMPLEMENTATION${NORM}"; }
version ${progname} (Blue Medora Inc.) v1.0
author Ritchie J Latimore <[email protected]>
copyright Copyright (c) 2016 Blue Medora Inc.
EOF
exit 2
}
### TRAPS
trap 'print "\n${progname} has finished\n"' EXIT
### FUNCTIONS
function fatal_error
{
print -u2 -n "${progname}: "
print -u2 -f %q "$@"
exit 1
}
# Generate a config file with the user specified values
function genconf
{
typeset f="${fqdn}" \
pn="${port}" \
d="${database}" \
u="${user}" \
p="${pass}" \
ty="${dbtype}" \
tf="${tmpfile}" \
t=$(mktemp) \
od="${outdir}" \
r="${rate:=unlimited}" \
c="${clients:=10}" \
i="${isolation:=TRANSACTION_READ_COMMITED}" \
s="${scale:=100}"
if [[ -z ${od} ]]; then
typeset o="templates/${f}.xml"
else
typeset o="${od}/${f}.xml"
fi
cat "config-templates/dbs/${ty}.xml" | sed "s/|FQDN|/${f}/; s/|PORT|/${pn}/; s/|DB|/${d}/" > ${t}
cat "config-templates/opts.xml" | sed "s/|USER|/${u}/; s/|PASS|/${p}/; s/|RATE|/${r}/; s/|CLIENTS|/${c}/" >> ${t}
for b in ${bench[@]}; do
print "\n<!-- partition -->\n" >> ${t}
cat "config-templates/benchmarks/${b}.xml" \
| sed "s/|SCALE|/${s}/; s/|ISOLATION|/${i}/" >> ${t}
done
printf "\n</parameters>\n" >> ${t}
cp "${t}" "${o}" && rm "${t}"
return 0
}
function main
{
set -a
typeset -a all_benches
all_benches+=(
tpcc
tpch
chbenchmark
auctionmark
epinions
jpab
resourcestresser
seats
tatp
twitter
wiki
ycsb
voter
linkbench
sibench
)
typeset -a bench
bench=( ${bench:=${all_benches[@]}} )
(( $# == 0 )) && usage
while getopts f:a:u:p:t:d:r:c:s:i:n:b:o: OPT; do
case "${OPT}" in
f )
fqdn="${OPTARG}"
;;
a )
typeset -l ACCEPT_OTN_BOOL="${OPTARG}" # downcase this var
export ACCEPT_OTN_BOOL
;;
u )
user="${OPTARG}"
;;
p )
pass="${OPTARG}"
;;
t )
typeset -u dbtype="${OPTARG}" # upcase whatever the user passes
if [[ ${dbtype} == "ORACLE" || ${dbtype} == "RAC" ]]; then
[[ ${ACCEPT_OTN_BOOL} == "true" ]] \
|| { printf "You must set the 'ACCEPT_OTN_BOOL' variable to 'true'.\n" && exit 2; }
./ojdbc-get.sh
mvn clean
mvn package -P fixerrors
elif [[ ${dbtype} == "DB2" ]]; then
sed -i "s/|BASICAUTH|/${BASICAUTH}/" db2jcc4-get.sh
cat db2jcc4-get.sh
./db2jcc4-get.sh
ls -al lib
mvn clean
mvn -U org.apache.maven.plugins:maven-install-plugin:2.5.2:install-file \
-DlocalRepositoryPath=lib/repo \
-Dfile="${PWD}/lib/db2jcc4.jar" \
-DgroupId=com.ibm.db2.jcc \
-DartifactId=db2jcc4 \
-Dversion=4.23.42 \
-Dpackaging=jar \
-DgeneratePom=true | tee install.out
mvn -U package -P fixerrors | tee package.out
fi
;;
d )
database="${OPTARG}"
;;
r )
rate="${OPTARG}"
;;
c )
clients="${OPTARG}"
;;
s )
scale="${OPTARG}"
;;
i )
isolation="${OPTARG}"
;;
n )
port="${OPTARG}"
;;
b )
if [[ -z ${OPTARG} ]]; then
eval :
else
unset bench
IFS=,
bench=( ${OPTARG} )
unset IFS
fi
;;
o )
outdir="${OPTARG}"
;;
* )
usage
;;
esac
done
genconf
return 0
}
### PROGRAM START
main "$@"
exit $?
# EOF.