-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
/
testcas.sh
executable file
·541 lines (528 loc) · 16.6 KB
/
testcas.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
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
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
#!/bin/bash
RED="\e[31m"
GREEN="\e[32m"
CYAN="\e[36m"
ENDCOLOR="\e[0m"
#clear
find ./ci/tests -type f -name "*.sh" -exec chmod +x {} \;
dockerPlatform="unknown"
docker ps &> /dev/null
if [[ $? -ne 0 ]] ; then
echo "Docker engine is not available."
else
dockerPlatform=$(docker version --format '{{json .Server.Os}}')
printf "Docker engine platform is ${GREEN}%s${ENDCOLOR}\n" "$dockerPlatform."
fi
function isDockerOnLinux() {
if [[ $dockerPlatform =~ "linux" ]]; then
return 0
fi
printf "${RED}Docker engine is not available for the linux platform.%n${ENDCOLOR}"
return 1
}
function isDockerOnWindows() {
if [[ $dockerPlatform =~ "windows" ]]; then
return 0
fi
printf "${RED}Docker engine is not available for the windows platform.%n${ENDCOLOR}"
return 1
}
printHelp() {
printf "\nUsage: ${CYAN}./testcas.sh${ENDCOLOR} --category [category1,category2,...] [--help] [--test TestClass]\n\t[--ignore-failures] [--no-watch] [--no-wrapper] [--no-retry] [--debug] [--no-parallel]\n\t[--dry-run][--info] [--with-coverage] [--no-build-cache] \n"
printf "\nTo see what test categories are available, use:\n"
printf "\t${GREEN}./gradlew -q testCategories${ENDCOLOR}\n"
echo -e "\nPlease see the test script for details."
}
task=""
parallel="--parallel "
dryRun=""
info=""
gradleCmd="./gradlew"
flags="--no-daemon --configure-on-demand --build-cache -x javadoc -x check -Dverbose=true "
coverageTask=""
while (( "$#" )); do
case "$1" in
--max-workers)
parallel="${parallel} --max-workers=8"
shift
;;
--no-cache)
parallel="--no-configuration-cache "
shift
;;
--no-parallel)
parallel="--no-parallel "
shift
;;
--pts)
printf "Running tests with predictive test selection mode: ${GREEN}$2${ENDCOLOR}\n"
flags+=" -Dpts.mode=$2 "
shift 2
;;
--no-pts)
flags+=" -DPTS_ENABLED=false "
shift
;;
--with-coverage)
currentDir=`pwd`
case "${currentDir}" in
*api*|*core*|*support*|*webapp*)
coverageTask="jacocoTestReport"
;;
*)
coverageTask="jacocoRootReport"
;;
esac
shift
;;
--info)
info="--info "
shift
;;
--dry-run)
dryRun="--dry-run "
shift
;;
--no-wrapper)
gradleCmd="gradle"
shift
;;
--help)
printHelp
exit 0
;;
--debug)
debug=" --debug-jvm "
parallel=""
shift
;;
--events)
flags+=" -DtestLoggingEvents=$2 "
shift 2
;;
--offline)
flags+=" --offline "
shift
;;
--no-watch)
flags+=" --no-watch-fs "
shift
;;
--test|--tests)
tests="--tests \"$2\" "
shift 2
;;
--no-retry)
flags+=" -DskipTestRetry=true "
shift
;;
--ignore-failures)
flags+=" -DignoreTestFailures=true "
shift
;;
--no-build-cache)
flags+=" --no-build-cache "
shift
;;
--category)
category="$2"
for item in $(echo "$category" | sed "s/,/ /g")
do
categoryItem=$(echo "${item}" | awk '{print tolower($0)}')
case "${categoryItem}" in
test|simple|run|basic|unit|unittests)
task+="testSimple "
;;
grouper)
task+="testGrouper "
;;
webapp)
task+="testWebApp "
;;
throttle|throttling|bucket4j|authenticationthrottling)
task+="testAuthenticationThrottling "
;;
authnhandler|authenticationhandler)
task+="testAuthenticationHandler "
;;
authnmetadata|authenticationmetadata)
task+="testAuthenticationMetadata "
;;
authnpolicy|authpolicy|authenticationpolicy)
task+="testAuthenticationPolicy "
;;
authz|heimdall|authorization)
task+="testAuthorization "
;;
auth|authn|authentication)
task+="testAuthentication "
;;
tickets|ticketing)
task+="testTickets "
;;
syncope)
isDockerOnLinux && ./ci/tests/syncope/run-syncope-server.sh
task+="testSyncope "
;;
native|graal|graalvm)
task+="testNative "
;;
delegation)
task+="testDelegation "
;;
cookie)
task+="testCookie "
;;
consent)
task+="testConsent "
task+="testConsent "
;;
duo|duosecurity)
task+="testDuoSecurity "
;;
event|events)
task+="testEvents "
;;
impersonation|surrogate)
task+="testImpersonation "
;;
x509)
task+="testX509 "
;;
shell)
task+="testSHELL "
;;
cipher)
task+="testCipher "
;;
elastic)
isDockerOnLinux && ./ci/tests/elastic/run-elastic-apm.sh
task+="testElastic "
;;
gcp|googlecloud|gcloud)
isDockerOnLinux && ./ci/tests/gcp/run-gcp-server.sh
task+="testGCP "
;;
web)
isDockerOnLinux && ./ci/tests/httpbin/run-httpbin-server.sh
task+="testWeb "
;;
scim)
isDockerOnLinux && ./ci/tests/scim/run-scim-server.sh
task+="testSCIM "
;;
logout|slo)
task+="testLogout "
;;
cas)
task+="testCAS "
;;
metrics|stats)
task+="testMetrics "
;;
services|regsvc|registeredservice)
task+="testRegisteredService "
;;
actuator|endpoint|actuatorendpoint)
task+="testActuatorEndpoint "
;;
utility|utils|util)
task+="testUtility "
;;
wsfed|wsfederation)
task+="testWSFederation "
;;
attrs|attr|attributes)
task+="testAttributes "
;;
expiration-policy|exppolicy|expp|expirationpolicy)
task+="testExpirationPolicy "
;;
password-ops|pswd|pswd-ops|psw|passwordops|ppolicy)
task+="testPasswordOps "
;;
sms)
task+="testSMS "
;;
audit|audits)
task+="testAudits "
;;
uma)
task+="testUMA "
;;
filesystem|files|file|fsys)
task+="testFileSystem "
;;
config|casconfig|ccfg|cfg|cas-config|casconfiguration)
task+="testCasConfiguration "
;;
geolocation|geo)
task+="testGeoLocation "
;;
git|scm)
task+="testGit "
;;
groovy|script)
task+="testGroovy "
;;
groovyauthentication)
task+="testGroovyAuthentication "
;;
groovymfa)
task+="testGroovyMfa "
;;
groovyservices)
task+="testGroovyServices "
;;
hibernate)
task+="testHibernate "
;;
jdbcmfa)
task+="testJDBCMFA "
;;
jdbc|jpa|database|db|rdbms|hsql)
task+="testJDBC "
;;
jdbcauthentication|jdbcauthn)
task+="testJDBCAuthentication "
;;
oauthtoken)
task+="testOAuthToken "
;;
oauthweb)
task+="testOAuthWeb "
;;
oauth)
task+="testOAuth "
;;
oidc)
isDockerOnLinux && ./ci/tests/mail/run-mail-server.sh
task+="testOIDC "
;;
mfa)
task+="testMFA "
;;
mfaprovider|gauth|webauthn|fido)
task+="testMFAProvider "
;;
mfatrigger)
task+="testMFATrigger "
;;
mfatrusteddevices|mfadevices|trusteddevices)
task+="testMFATrustedDevices "
;;
saml2sp|samlsp|samlserviceprovider)
task+="testSAMLServiceProvider "
;;
metadata|md|samlmetadata)
task+="testSAMLMetadata "
;;
saml1)
task+="testSAML1 "
;;
saml2web|samlweb)
task+="testSAML2Web "
;;
saml2)
task+="testSAML2 "
;;
samlresponse)
task+="testSAMLResponse "
;;
samlattributes|samlattrs)
task+="testSAMLAttributes "
;;
saml)
task+="testSAML "
;;
samllogout)
task+="testSAMLLogout "
;;
jmx)
task+="testJMX "
;;
restfulapiauthentication|restfulauthn|restauthn)
task+="testRestfulApiAuthentication "
;;
rest|restful|restapi|restfulapi)
task+="testRestfulApi "
;;
webflow-mfa-actions|swf-mfa_actions|webflowmfaactions)
task+="testWebflowMfaActions "
;;
webflowauthenticationactions|swfauthnactions|webflowauthnactions)
task+="testWebflowAuthenticationActions "
;;
webflowactions|swfactions|webflow-actions)
task+="testWebflowActions "
;;
webflowevents|webflow-events)
task+="testWebflowEvents "
;;
webflowconfig|swfcfg|webflowcfg|webflow-config)
task+="testWebflowConfig "
;;
webflowaccountactions)
task+="testWebflowAccountActions "
;;
webflowserviceactions)
task+="testWebflowServiceActions "
;;
webflowmfaconfig)
task+="testWebflowMfaConfig "
;;
webflow|swf)
task+="testWebflow "
;;
hz|hazelcast)
task+="testHazelcast "
;;
ignite)
task+="testIgnite "
;;
spnego)
task+="testSpnego "
;;
azure|cosmosdb)
isDockerOnLinux && ./ci/tests/cosmosdb/run-cosmosdb-server.sh
task+="testAzure "
;;
simple|unit)
task+="testSimple "
;;
mssql|mssqlserver)
isDockerOnLinux && ./ci/tests/mssqlserver/run-mssql-server.sh
task+="testMsSqlServer "
;;
influx|influxdb)
isDockerOnLinux && ./ci/tests/influxdb/run-influxdb-server.sh
task+="testInfluxDb "
;;
memcached|memcache|kryo)
isDockerOnLinux && ./ci/tests/memcached/run-memcached-server.sh
task+="testMemcached "
;;
activedirectory|ad)
isDockerOnLinux && ./ci/tests/ldap/run-ad-server.sh true
task+="testActiveDirectory "
;;
ldapservices)
isDockerOnLinux && ./ci/tests/ldap/run-ldap-server.sh
task+="testLdapServices "
;;
ldaprepository|ldaprepo)
isDockerOnLinux && ./ci/tests/ldap/run-ldap-server.sh
task+="testLdapRepository "
;;
ldapauthentication|ldapauthn)
isDockerOnLinux && ./ci/tests/ldap/run-ldap-server.sh
task+="testLdapAuthentication "
;;
ldapattributes|ldapattrs)
isDockerOnLinux && ./ci/tests/ldap/run-ldap-server.sh
task+="testLdapAttributes "
;;
ldap)
isDockerOnLinux && ./ci/tests/ldap/run-ldap-server.sh
task+="testLdap "
;;
mongodbmfa)
isDockerOnLinux && ./ci/tests/mongodb/run-mongodb-server.sh
task+="testMongoDbMFA "
;;
mongo|mongodb)
isDockerOnLinux && ./ci/tests/mongodb/run-mongodb-server.sh
task+="testMongoDb "
;;
mysql)
isDockerOnLinux && ./ci/tests/mysql/run-mysql-server.sh
task+="testMySQL "
;;
maria|mariadb)
isDockerOnLinux && ./ci/tests/mariadb/run-mariadb-server.sh
task+="testMariaDb "
;;
postgres|pg|postgresql)
isDockerOnLinux && ./ci/tests/postgres/run-postgres-server.sh
task+="testPostgres "
;;
cassandra)
isDockerOnLinux && ./ci/tests/cassandra/run-cassandra-server.sh
task+="testCassandra "
;;
kafka)
isDockerOnLinux && ./ci/tests/kafka/run-kafka-server.sh
task+="testKafka "
;;
aws|amz|amazonwebservices)
isDockerOnLinux && ./ci/tests/aws/run-aws-server.sh
task+="testAmazonWebServices "
;;
radius)
isDockerOnLinux && ./ci/tests/radius/run-radius-server.sh
task+="testRadius "
;;
mail|email)
isDockerOnLinux && ./ci/tests/mail/run-mail-server.sh
task+="testMail "
;;
zoo|zookeeper)
isDockerOnLinux && ./ci/tests/zookeeper/run-zookeeper-server.sh
task+="testZooKeeper "
;;
dynamodb|dynamo)
isDockerOnLinux && ./ci/tests/dynamodb/run-dynamodb-server.sh
task+="testDynamoDb "
;;
oracle)
isDockerOnLinux && ./ci/tests/oracle/run-oracle-server.sh
task+="testOracle "
;;
redis)
isDockerOnLinux && ./ci/tests/redis/run-redis-server.sh
task+="testRedis "
;;
activemq|amq|jms|rabbitmq|artemis|amqp)
isDockerOnLinux && ./ci/tests/rabbitmq/run-rabbitmq-server.sh
task+="testAMQP "
;;
*)
printf "${RED}Unable to recognize test category: ${item}${ENDCOLOR}\n"
printHelp
exit 1
;;
esac
done
shift 2
;;
*)
printf "${RED}Unable to accept parameter: $1${ENDCOLOR}\n"
printHelp
exit 1
;;
esac
done
if [[ -n "$coverageTask" ]]; then
task=""
printf "${GREEN}Running code coverage task [${coverageTask}] will disable all other task executions. Make sure all test tasks that generate code coverage data have already executed.${ENDCOLOR}\n"
fi
if [[ -z "$task" ]] && [[ -z "$coverageTask" ]]; then
printHelp
exit 1
fi
cmd="$gradleCmd ${GREEN}$task $tests${ENDCOLOR}${flags}${debug}${dryRun}${info}${parallel}${GREEN}$coverageTask${ENDCOLOR}"
printf "${cmd} %n"
echo
cmd="$gradleCmd $task $tests $flags ${debug} ${parallel} ${dryRun} ${info} ${coverageTask}"
eval "$cmd"
retVal=$?
echo -e "***************************************************************************************"
printf "${CYAN}Gradle build finished at `date` with exit code $retVal ${ENDCOLOR}%n"
echo -e "***************************************************************************************"
if [ $retVal == 0 ]; then
printf "${GREEN}Gradle build finished successfully.${ENDCOLOR}%n"
exit 0
else
printf "${RED}Gradle build did NOT finish successfully.${ENDCOLOR}%n"
exit $retVal
fi