-
Notifications
You must be signed in to change notification settings - Fork 1
/
testsuite
executable file
·389 lines (344 loc) · 10.4 KB
/
testsuite
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
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
#!/bin/bash
#
# @author <a href="mailto:brent.n.douglas@gmail.com">Brent Douglas</a>
#
source ./functions
RETVAL=0
FAILED=""
AVAILABLE_DATABASES=( h2 postgresql mariadb derby )
AVAILABLE_CONTAINERS=( se glassfish tomee wildfly )
AVAILABLE_INJECTORS=( batch cdi spring guice seam )
AVAILABLE_TRANSPORTS=( local coherence gridgain hazelcast infinispan jgroups )
AVAILABLE_REPOSITORIES=( memory coherence ehcache gridgain hazelcast infinispan jdbc jpa mongo redis )
CONTAINERS=( se glassfish tomee wildfly )
# Permutations of these are used to run the tests
DATABASES=( h2 )
INJECTORS=( batch cdi )
TRANSPORTS=( local infinispan )
REPOSITORIES=( memory ehcache gridgain hazelcast infinispan jpa jdbc )
TEST_COHERENCE="false"
TEST_LOCAL_REPOSITORIES="false"
FAIL_FAST="false"
QUIET="false"
DEBUG="false"
INTEGRATION_TESTS="true"
TCK_TESTS="true"
BUILD_BASE_DIR="${TRAVIS_BUILD_DIR-$(pwd)}"
run() {
local dir="${1}"
local msg="${2}"
local profiles="${3}"
local ret=0
local command="maven"
[ "${QUIET}" == "true" ] && {
command="${command} -q"
}
echo "Starting ${msg} run with profiles ${profiles}"
(
cd "${dir}"
${command} clean verify "-P${profiles}" "-Droot.dir=${BUILD_BASE_DIR}"
)
ret=${?}
[ ${ret} -eq 0 ] || {
[ "${FAIL_FAST}" == "true" ] && {
terminate ${ret} "Failed ${msg} run with profiles ${profiles}"
}
FAILED+="\n${profiles}"
RETVAL=${ret}
red "Failed ${msg} run with profiles ${profiles}"
return ${ret}
}
green "Passed ${msg} run with profiles ${profiles}"
return ${ret}
}
tests() {
local profiles="test"
[ "${TEST_LOCAL_REPOSITORIES}" == "true" ] && {
profiles+=",repository"
}
[ "${TEST_COHERENCE}" == "true" ] && {
profiles+=",coherence"
}
for database in "${DATABASES[@]}"; do
if [ "h2" == "${database}" ]; then
run "test" "tests" "${profiles}"
else
run "test" "tests" "${profiles:+$profiles,}db-${database}"
fi
done
return ${?}
}
tck() {
local profiles="${@}"
local command="tck"
for container in "${CONTAINERS[@]}"; do
command+="${container:+,$container}"
done
command="${command}${profiles:+,$profiles}"
[ "${TEST_COHERENCE}" == "true" ] && {
command+=",coherence"
}
[ "${DEBUG}" == "true" ] && {
command+=",debug"
}
run "tck" "TCK" "${command}"
return ${?}
}
injectors() {
local profiles="${@}"
for injector in "${INJECTORS[@]}"; do
if [ "batch" == "${injector}" ]; then
tck "${profiles}" #in-batch
else
tck "${profiles:+$profiles,}in-${injector}"
fi
done
}
databases() {
local profiles="${@}"
for database in "${DATABASES[@]}"; do
if [ "h2" == "${database}" ]; then
injectors "${profiles}"
else
injectors "${profiles:+$profiles,}db-${database}"
fi
done
}
transports() {
local profiles="${@}"
for transport in "${TRANSPORTS[@]}"; do
if [ "local" == "${transport}" ]; then
databases "${profiles}"
else
databases "${profiles:+$profiles,}tr-${transport}"
fi
done
}
repositories() {
local profiles="${@}"
for repository in "${REPOSITORIES[@]}"; do
if [ "memory" == "${repository}" ]; then
transports "${profiles}"
else
transports "${profiles:+$profiles,}re-${repository}"
fi
done
}
testsuite() {
[ "${INTEGRATION_TESTS}" == "true" ] && {
tests
}
[ "${TCK_TESTS}" == "true" ] && {
repositories
}
}
print-available-injectors() {
local values=""
for injector in "${AVAILABLE_INJECTORS[@]}"; do
values="${values:+$values, }${injector}"
done
echo "Available injectors are: ${values}"
}
print-available-containers() {
local values=""
for container in "${AVAILABLE_CONTAINERS[@]}"; do
values="${values:+$values, }${container}"
done
echo "Available containers are: ${values}"
}
print-available-databases() {
local values=""
for database in "${AVAILABLE_DATABASES[@]}"; do
values="${values:+$values, }${database}"
done
echo "Available databases are: ${values}"
}
print-available-transports() {
local values=""
for transport in "${AVAILABLE_TRANSPORTS[@]}"; do
values="${values:+$values, }${transport}"
done
echo "Available transports are: ${values}"
}
print-available-repositories() {
local values=""
for repository in "${AVAILABLE_REPOSITORIES[@]}"; do
values="${values:+$values, }${repository}"
done
echo "Available repositories are: ${values}"
}
usage() {
cat <<EOF
Usage: testsuite [-i injector] [-c container] [-d database]
[-t transport] [-r repository] [-l] [-o] [-f] [-I]
[-T] [-q] [-h]
-i Comma separated list of injectors to run the tests for.
Selecting the value in-batch will use the default injector and
will not show up in the profile list. Available injectors are:
EOF
for injector in "${AVAILABLE_INJECTORS[@]}"; do
echo " - ${injector}"
done
cat <<EOF
-c Comma separated list of containers to run the tests for.
Available containers are:
EOF
for container in "${AVAILABLE_CONTAINERS[@]}"; do
echo " - ${container}"
done
cat <<EOF
-d Comma separated list of databases to run the tests for.
Selecting the value h2 will use the default database and
will not show up in the profile list. Available databases are:
EOF
for database in "${AVAILABLE_DATABASES[@]}"; do
echo " - ${database}"
done
cat <<EOF
-t Comma separated list of transports to run the tests for.
Selecting the value local will use the default transport and
will not show up in the profile list. Available transports are:
EOF
for transport in "${AVAILABLE_TRANSPORTS[@]}"; do
echo " - ${transport}"
done
cat <<EOF
-r Comma separated list of repositories to run the tests for.
Selecting the value memory will use the default repository and
will not show up in the profile list. Available repositories are:
EOF
for repository in "${AVAILABLE_REPOSITORIES[@]}"; do
echo " - ${repository}"
done
cat <<EOF
-l Include repository tests that require a local installation
(requires PostgreSQL, MariaDB, Redis and MongoDB).
-o Include Oracle Coherence tests (requires Oracle Coherence).
-f Fail fast. By default every test will be executed regardless of
failures. This option will terminate execution at the first
test failure.
-I Don't run the integration tests.
-T Don't run the TCK tests.
-q Quiet mode.
-x Debug mode for containers. See the 'debug' profile in the tck
module.
-h Print usage.
EOF
}
while getopts "i:c:d:r:t:lofITqxh" opt; do
case ${opt} in
i)
INJECTORS=()
IFS=',' read -ra TMP <<< "${OPTARG}"
for injector in "${TMP[@]}"; do
for available in "${AVAILABLE_INJECTORS[@]}"; do
[ "${available}" == "${injector}" ] && {
INJECTORS+=("${injector}")
continue 2 #TMP loop
}
done
red "Invalid injector: ${injector}"
print-available-injectors
exit 1
done
;;
c)
CONTAINERS=()
IFS=',' read -ra TMP <<< "${OPTARG}"
for container in "${TMP[@]}"; do
for available in "${AVAILABLE_CONTAINERS[@]}"; do
[ "${available}" == "${container}" ] && {
CONTAINERS+=("${container}")
continue 2 #TMP loop
}
done
red "Invalid container: ${container}"
print-available-containers
exit 1
done
;;
d)
DATABASES=()
IFS=',' read -ra TMP <<< "${OPTARG}"
for database in "${TMP[@]}"; do
for available in "${AVAILABLE_DATABASES[@]}"; do
[ "${available}" == "${database}" ] && {
DATABASES+=("${database}")
continue 2 #TMP loop
}
done
red "Invalid database: ${database}"
print-available-databases
exit 1
done
;;
t)
TRANSPORTS=()
IFS=',' read -ra TMP <<< "${OPTARG}"
for transport in "${TMP[@]}"; do
for available in "${AVAILABLE_TRANSPORTS[@]}"; do
[ "${available}" == "${transport}" ] && {
TRANSPORTS+=("${transport}")
continue 2 #TMP loop
}
done
red "Invalid transport: ${transport}"
print-available-transports
exit 1
done
;;
r)
REPOSITORIES=()
IFS=',' read -ra TMP <<< "${OPTARG}"
for repository in "${TMP[@]}"; do
for available in "${AVAILABLE_REPOSITORIES[@]}"; do
[ "${available}" == "${repository}" ] && {
REPOSITORIES+=("${repository}")
continue 2 #TMP loop
}
done
red "Invalid repository: ${repository}"
print-available-repositories
exit 1
done
;;
l)
TEST_LOCAL_REPOSITORIES="true"
;;
o)
TEST_COHERENCE="true"
;;
f)
FAIL_FAST="true"
;;
I)
INTEGRATION_TESTS="false"
;;
T)
TCK_TESTS="false"
;;
q)
QUIET="true"
;;
x)
DEBUG="true"
;;
h)
usage
exit 0
;;
\?)
red "Invalid option: -${OPTARG}"
usage
exit 1
;;
:)
red "Option -${OPTARG} requires an argument"
usage
exit 1
;;
esac
done
trap 'terminate 130' INT
testsuite
terminate ${RETVAL} "Failed profiles were: ${FAILED}"