-
-
Notifications
You must be signed in to change notification settings - Fork 314
/
JenkinsfileBase
1465 lines (1340 loc) · 55.4 KB
/
JenkinsfileBase
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
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!groovy
import org.tap4j.consumer.TapConsumer;
import org.tap4j.consumer.TapConsumerFactory;
import org.tap4j.model.TestSet;
def makeTest(testParam) {
String tearDownCmd = "$RESOLVED_MAKE; \$MAKE -f ./aqa-tests/TKG/testEnv.mk testEnvTeardown"
// Note: keyword source cannot be used in Jenkins script. Therefore, using "." instead.
String makeTestCmd = "$RESOLVED_MAKE;cd ./aqa-tests; . ./scripts/testenv/testenvSettings.sh;cd ./TKG; \$MAKE $testParam"
//unset LD_LIBRARY_PATH workaround for issue https://github.com/adoptium/infrastructure/issues/2934
if (JDK_IMPL == 'hotspot' && JDK_VERSION == '8' && PLATFORM.contains('alpine-linux')) {
makeTestCmd = "unset LD_LIBRARY_PATH; $makeTestCmd"
}
try {
sh "$tearDownCmd"
if (env.DOCKER_REGISTRY_URL && env.DOCKER_REGISTRY_URL_CREDENTIAL_ID && env.BASE_DOCKER_REGISTRY_CREDENTIAL_ID) {
withCredentials([
usernamePassword(credentialsId: "${env.DOCKER_REGISTRY_URL_CREDENTIAL_ID}", usernameVariable: 'DOCKER_REGISTRY_CREDENTIALS_USR', passwordVariable: 'DOCKER_REGISTRY_CREDENTIALS_PSW'),
usernamePassword(credentialsId: "${env.BASE_DOCKER_REGISTRY_CREDENTIAL_ID}", usernameVariable: 'BASE_DOCKER_REGISTRY_CREDENTIAL_USR', passwordVariable: 'BASE_DOCKER_REGISTRY_CREDENTIAL_PSW')
]) {
sh "$makeTestCmd"
}
} else if (env.DOCKER_REGISTRY_URL && env.DOCKER_REGISTRY_URL_CREDENTIAL_ID) {
withCredentials([
usernamePassword(credentialsId: "${env.DOCKER_REGISTRY_URL_CREDENTIAL_ID}", usernameVariable: 'DOCKER_REGISTRY_CREDENTIALS_USR', passwordVariable: 'DOCKER_REGISTRY_CREDENTIALS_PSW'),
]) {
sh "$makeTestCmd"
}
} else {
sh "$makeTestCmd"
}
} catch (err) {
currentBuild.result = 'UNSTABLE'
} finally {
sh "$tearDownCmd"
}
}
def setupEnv() {
env.JOBSTARTTIME = sh(script: 'LC_TIME=C date +"%a, %d %b %Y %T %z"', returnStdout: true).trim()
// Terminate any previous test related processes that are running
terminateTestProcesses()
if ( params.JDK_VERSION ) {
env.ORIGIN_JDK_VERSION = params.JDK_VERSION
env.JDK_VERSION = params.JDK_VERSION.equalsIgnoreCase("next") ? "" : params.JDK_VERSION
}
env.USE_TESTENV_PROPERTIES = params.USE_TESTENV_PROPERTIES
env.SPEC = "${SPEC}"
if(!params.USE_TESTENV_PROPERTIES){
ADOPTOPENJDK_REPO = params.ADOPTOPENJDK_REPO ? params.ADOPTOPENJDK_REPO : "https://github.com/adoptium/aqa-tests.git"
OPENJ9_REPO = params.OPENJ9_REPO ? params.OPENJ9_REPO : "https://github.com/eclipse-openj9/openj9.git"
String[] tkg = getGitRepoBranch(params.TKG_OWNER_BRANCH, "adoptium:master", "TKG")
TKG_REPO = tkg[0]
TKG_BRANCH = tkg[1]
//For Zos, the right repo should be something like: git@github.ibm.com:runtimes/openj9-openjdk-jdk**-zos.git and for now there is only jdk11
env.JDK_REPO = params.JDK_REPO ? params.JDK_REPO : ""
if (env.SPEC.startsWith('zos')) {
ADOPTOPENJDK_REPO = ADOPTOPENJDK_REPO.replace("https://github.com/","git@github.com:")
OPENJ9_REPO = OPENJ9_REPO.replace("https://github.com/","git@github.com:")
}
OPENJ9_BRANCH = params.OPENJ9_BRANCH ? params.OPENJ9_BRANCH : "master"
}
PLATFORM = params.PLATFORM ? params.PLATFORM : ""
ADOPTOPENJDK_BRANCH = params.ADOPTOPENJDK_BRANCH ? params.ADOPTOPENJDK_BRANCH : "master"
CLONE_OPENJ9 = params.CLONE_OPENJ9 ? params.CLONE_OPENJ9 : "true"
CUSTOM_TARGET = params.CUSTOM_TARGET ? params.CUSTOM_TARGET : ""
UPSTREAM_JOB_NAME = params.UPSTREAM_JOB_NAME ? params.UPSTREAM_JOB_NAME : ""
UPSTREAM_JOB_NUMBER = params.UPSTREAM_JOB_NUMBER ? params.UPSTREAM_JOB_NUMBER : ""
SSH_AGENT_CREDENTIAL = params.SSH_AGENT_CREDENTIAL ? params.SSH_AGENT_CREDENTIAL : ""
KEEP_WORKSPACE = params.KEEP_WORKSPACE ? params.KEEP_WORKSPACE : false
OPENJ9_SHA = params.OPENJ9_SHA ? params.OPENJ9_SHA : ""
CLOUD_PROVIDER = params.CLOUD_PROVIDER ? params.CLOUD_PROVIDER : ""
env.JDK_BRANCH = params.JDK_BRANCH ? params.JDK_BRANCH : ""
env.USER_CREDENTIALS_ID = params.USER_CREDENTIALS_ID ? params.USER_CREDENTIALS_ID : ""
env.TEST_JDK_HOME = "$WORKSPACE/jdkbinary/j2sdk-image"
env.JVM_VERSION = params.JVM_VERSION ? params.JVM_VERSION : ""
env.JVM_OPTIONS = params.JVM_OPTIONS ? params.JVM_OPTIONS : ""
env.APPLICATION_OPTIONS = params.APPLICATION_OPTIONS ? params.APPLICATION_OPTIONS : ""
env.EXTRA_DOCKER_ARGS = params.EXTRA_DOCKER_ARGS ? params.EXTRA_DOCKER_ARGS : ""
env.OPENJDK_SHA = params.OPENJDK_SHA ? params.OPENJDK_SHA : ""
env.OPENLIBERTY_SHA = params.OPENLIBERTY_SHA ? params.OPENLIBERTY_SHA : ""
env.TEST_FLAG = params.TEST_FLAG ? params.TEST_FLAG : ''
env.KEEP_REPORTDIR = params.KEEP_REPORTDIR ? params.KEEP_REPORTDIR : false
SDK_RESOURCE = params.SDK_RESOURCE ? params.SDK_RESOURCE : "upstream"
env.AUTO_DETECT = params.AUTO_DETECT
env.EXTERNAL_CUSTOM_REPO=params.EXTERNAL_CUSTOM_REPO? params.EXTERNAL_CUSTOM_REPO : ""
env.EXTERNAL_REPO_BRANCH=params.EXTERNAL_REPO_BRANCH ? params.EXTERNAL_REPO_BRANCH : "master"
env.EXTERNAL_TEST_CMD=params.EXTERNAL_TEST_CMD ? params.EXTERNAL_TEST_CMD : "mvn clean install"
env.DYNAMIC_COMPILE=params.DYNAMIC_COMPILE ? params.DYNAMIC_COMPILE : false
env.USE_JRE=params.USE_JRE ? params.USE_JRE : false
env.RERUN_LINK = ""
env.FAILED_TESTS = ""
env.FAILED_TEST_TARGET = ""
env.CUSTOM_TARGET_KEY_VALUE =""
env.DOCKER_REGISTRY_URL = params.DOCKER_REGISTRY_URL ? params.DOCKER_REGISTRY_URL : ""
env.DOCKER_REGISTRY_DIR = params.DOCKER_REGISTRY_DIR ? params.DOCKER_REGISTRY_DIR : ""
env.DOCKER_REGISTRY_URL_CREDENTIAL_ID = params.DOCKER_REGISTRY_URL_CREDENTIAL_ID ? params.DOCKER_REGISTRY_URL_CREDENTIAL_ID : ""
env.BASE_DOCKER_REGISTRY_CREDENTIAL_ID = params.BASE_DOCKER_REGISTRY_CREDENTIAL_ID ? params.BASE_DOCKER_REGISTRY_CREDENTIAL_ID : ""
ITERATIONS = params.ITERATIONS ? "${params.ITERATIONS}".toInteger() : 1
env.TKG_ITERATIONS = params.TKG_ITERATIONS ? "${params.TKG_ITERATIONS}".toInteger() : 1
env.EXIT_FAILURE = params.EXIT_FAILURE ? params.EXIT_FAILURE : false
env.EXIT_SUCCESS = params.EXIT_SUCCESS ? params.EXIT_SUCCESS : false
NUM_MACHINES = params.NUM_MACHINES ? params.NUM_MACHINES.toInteger() : 1
env.LIB_DIR = JOB_NAME.contains("SmokeTests") ? "${WORKSPACE}/../../../../../testDependency/lib" : "${WORKSPACE}/../../testDependency/lib"
env.OPENJCEPLUS_GIT_REPO = params.OPENJCEPLUS_GIT_REPO ?: "https://github.com/ibmruntimes/OpenJCEPlus.git"
env.OPENJCEPLUS_GIT_BRANCH = params.OPENJCEPLUS_GIT_BRANCH ?: "semeru-java${params.JDK_VERSION}"
env.LIGHT_WEIGHT_CHECKOUT = (params.LIGHT_WEIGHT_CHECKOUT == false) ? params.LIGHT_WEIGHT_CHECKOUT : true
env.GENERATE_JOBS = params.GENERATE_JOBS ?: false
if (JOB_NAME.contains("Grinder")) {
def currentDate = new Date()
def currentDateTime = currentDate.format("yyyyMMddHHmmss", TimeZone.getTimeZone('UTC'))
env.TAP_NAME = "${JOB_NAME}_${currentDateTime}.tap"
// If personal repo and branch are set, test jobs need to be regenerated (with LIGHT_WEIGHT_CHECKOUT = false)
// to take personal repo and branch.
// Therefore, set LIGHT_WEIGHT_CHECKOUTto false and GENERATE_JOBS to true.
// This is a known Jenkins issue: https://issues.jenkins.io/browse/JENKINS-42971
if (!ADOPTOPENJDK_REPO.contains("adoptium/aqa-tests")) {
env.LIGHT_WEIGHT_CHECKOUT = false
env.GENERATE_JOBS = true
echo "ADOPTOPENJDK_REPO is set to personal repo in Grinder. Auto-set LIGHT_WEIGHT_CHECKOUT: ${env.LIGHT_WEIGHT_CHECKOUT} and GENERATE_JOBS: ${env.GENERATE_JOBS}"
}
} else {
env.TAP_NAME = "${JOB_NAME}.tap"
}
if (params.CODE_COVERAGE) {
// GCOV strips # num from folder path in BUILD pipeline, e.g., /home/jenkins/workspace/Build_JDK11_x86-64_linux_Personal/build/linux-x86_64-normal-server-release/vm
env.GCOV_PREFIX_STRIP = 1
env.GCOV_PREFIX = env.TEST_JDK_HOME
}
if (params.JRE_IMAGE) {
env.JRE_IMAGE = "${WORKSPACE}/${params.JRE_IMAGE}"
}
if (params.USE_JRE) {
env.USE_JRE = 1
}
if (params.JDK_IMPL) {
env.JDK_IMPL = params.JDK_IMPL
} else if (params.JVM_VERSION) {
env.JDK_IMPL = getJDKImpl(params.JVM_VERSION)
}
if( params.PERF_ROOT ) {
env.PERF_ROOT = params.PERF_ROOT
} else {
env.PERF_ROOT = "$WORKSPACE/../../benchmarks"
}
env.JCK_VERSION = params.JCK_VERSION ? params.JCK_VERSION : ""
env.JCK_ROOT = params.JCK_ROOT ? params.JCK_ROOT : ""
env.JCK_GIT_REPO = params.JCK_GIT_REPO ? params.JCK_GIT_REPO : ""
env.OCP_SERVER = params.OCP_SERVER ? params.OCP_SERVER : ''
env.OCP_TOKEN = params.OCP_TOKEN ? params.OCP_TOKEN : ''
if (env.BUILD_LIST.contains('external')) {
env.DIAGNOSTICLEVEL ='noDetails'
}
if( params.DOCKERIMAGE_TAG ) {
env.DOCKERIMAGE_TAG = params.DOCKERIMAGE_TAG
}
if ( env.SPEC.contains('sunos')) {
sh 'env'
} else {
sh 'printenv'
}
}
def setupParallelEnv() {
stage('setupParallelEnv') {
def maxChildJobNum = 25
int childJobNum = 1
def UPSTREAM_TEST_JOB_NAME = ""
def UPSTREAM_TEST_JOB_NUMBER = ""
if (params.PARALLEL == "NodesByIterations") {
childJobNum = NUM_MACHINES
// limit childJobNum
if (childJobNum > 20) {
echo "Due to the limited machines, NUM_MACHINES can only be set up to 20. Current NUM_MACHINES is ${NUM_MACHINES}."
echo "Reset NUM_MACHINES to 20..."
childJobNum = 20
}
} else if (params.PARALLEL == "Dynamic") {
try {
//get cached TRSS JSON data
timeout(time: 1, unit: 'HOURS') {
copyArtifacts fingerprintArtifacts: true, projectName: "getTRSSOutput", selector: lastSuccessful(), target: 'aqa-tests/TKG/resources/TRSS'
sh "cd ./aqa-tests/TKG/resources/TRSS; gzip -cd TRSSOutput.tar.gz | tar xof -; rm TRSSOutput.tar.gz"
}
} catch (Exception e) {
echo 'Exception: ' + e.toString()
echo 'Cannot get cached TRSS JSON data. Skipping copyArtifacts...'
}
try {
// check pre-stage test libs on the machine
// check for each lib. If lib does not exist, donwload it.
// If lib exists, SHA will be checked. Re-download if SHA does not match.
timeout(time: 20, unit: 'MINUTES') {
def customUrl = "https://ci.adoptium.net/job/test.getDependency/lastSuccessfulBuild/artifact/"
if (PLATFORM.contains("windows")) {
env.LIB_DIR = env.LIB_DIR.replaceAll("\\\\", "/")
}
sh "perl ./aqa-tests/TKG/scripts/getDependencies.pl -path ${env.LIB_DIR} -task default -customUrl ${customUrl}"
}
} catch (Exception e) {
echo 'Exception: ' + e.toString()
echo "Cannot pre-stage test libs from ${env.LIB_DIR} on the machine. Skipping..."
}
String PARALLEL_OPTIONS = "TEST=${TARGET}"
if (params.TRSS_URL) {
PARALLEL_OPTIONS += " TRSS_URL=${params.TRSS_URL}"
}
int NUM_LIST = -1
int MAX_NUM_MACHINES = Math.min(20, getMachineLimit());
if (params.NUM_MACHINES) {
int numOfMachines = getNumMachines()
PARALLEL_OPTIONS += " NUM_MACHINES=${numOfMachines} TEST_TIME="
NUM_LIST = genParallelList(PARALLEL_OPTIONS)
} else if (params.TEST_TIME) {
String PARALLEL_OPTIONS_TEMP = PARALLEL_OPTIONS
PARALLEL_OPTIONS += " TEST_TIME=${params.TEST_TIME} NUM_MACHINES="
NUM_LIST = genParallelList(PARALLEL_OPTIONS)
if (NUM_LIST > MAX_NUM_MACHINES) {
echo "TEST_TIME (${params.TEST_TIME} minutes) is not possible as it exceeds the machine limit."
echo "Regenerate parallel list with NUM_MACHINES=${MAX_NUM_MACHINES}."
PARALLEL_OPTIONS = PARALLEL_OPTIONS_TEMP + " NUM_MACHINES=${MAX_NUM_MACHINES} TEST_TIME="
NUM_LIST = genParallelList(PARALLEL_OPTIONS)
}
} else {
PARALLEL_OPTIONS += " TEST_TIME= NUM_MACHINES="
NUM_LIST = genParallelList(PARALLEL_OPTIONS)
}
if (NUM_LIST > 0) {
childJobNum = NUM_LIST
echo "Saving parallelList.mk file on jenkins..."
dir('aqa-tests/TKG') {
archiveArtifacts artifacts: 'parallelList.mk', fingerprint: true, allowEmptyArchive: false
}
} else {
assert false : "Build failed because cannot find NUM_LIST in parallelList.mk file."
}
}
UPSTREAM_TEST_JOB_NAME = JOB_NAME
UPSTREAM_TEST_JOB_NUMBER = BUILD_NUMBER
echo "[PARALLEL: ${params.PARALLEL}] childJobNum is ${childJobNum}, creating jobs and running them in parallel..."
parallel_tests = [:]
create_jobs = [:]
for (int i = 0; i < childJobNum; i++) {
def buildListName = env.BUILD_LIST
def childTest = ""
def childTarget = TARGET
if (params.PARALLEL == "NodesByIterations") {
childTest = "iteration_${i}"
} else if (params.PARALLEL == "Dynamic") {
childTest = "testList_${i}"
childTarget = "-f parallelList.mk ${childTest}"
}
def TEST_JOB_NAME = "${JOB_NAME}_${childTest}"
generateJob(create_jobs, childTest, TEST_JOB_NAME)
def childParams = []
// loop through all the params and change the parameters if needed
params.each { param ->
// set PARALLEL, NUM_MACHINES and TEST_TIME to default values
if (param.key == "BUILD_LIST") {
childParams << string(name: param.key, value: "${buildListName}")
} else if (param.key == "TARGET") {
childParams << string(name: param.key, value: "${childTarget}")
} else if (param.key == "PARALLEL") {
childParams << string(name: param.key, value: "None")
} else if (param.key == "NUM_MACHINES") {
childParams << string(name: param.key, value: "")
} else if (param.key == "TEST_TIME") {
childParams << string(name: param.key, value: "")
}else {
def value = param.value.toString()
if (value == "true" || value == "false") {
childParams << booleanParam(name: param.key, value: value.toBoolean())
} else {
childParams << string(name: param.key, value: value)
}
}
}
childParams << string(name: 'UPSTREAM_TEST_JOB_NAME', value: UPSTREAM_TEST_JOB_NAME)
childParams << string(name: 'UPSTREAM_TEST_JOB_NUMBER', value: UPSTREAM_TEST_JOB_NUMBER)
parallel_tests[childTest] = {
build job: TEST_JOB_NAME, parameters: childParams, propagate: false
}
}
if (create_jobs) {
parallel create_jobs
}
// return to top level pipeline file in order to exit node block before running tests in parallel
}
}
// Returns NUM_LIST from parallelList.mk.
// NUM_LIST can be different than numOfMachines.
def genParallelList(PARALLEL_OPTIONS) {
String unsetLLP = ""
//unset LD_LIBRARY_PATH workaround for issue https://github.com/adoptium/infrastructure/issues/2934
if (JDK_IMPL == 'hotspot' && JDK_VERSION == '8' && PLATFORM.contains('alpine-linux')) {
unsetLLP = "unset LD_LIBRARY_PATH;"
}
sh "cd ./aqa-tests/TKG; ${unsetLLP} make genParallelList ${PARALLEL_OPTIONS}"
def parallelList = "aqa-tests/TKG/parallelList.mk"
int NUM_LIST = -1
if (fileExists("${parallelList}")) {
if (SPEC.startsWith('zos')) {
echo 'Converting parallelList.mk file from ebcdic to ascii...'
sh "iconv -f ibm-1047 -t iso8859-1 ${parallelList} > ${parallelList}.ascii; rm ${parallelList}; mv ${parallelList}.ascii ${parallelList}"
}
echo "read parallelList.mk file: ${parallelList}"
def properties = readProperties file: "${parallelList}"
if (properties.NUM_LIST) {
NUM_LIST = properties.NUM_LIST.toInteger()
}
}
return NUM_LIST
}
// Returns num
// num = params.NUM_MACHINES. If it is not provided, the default value is 1
// num cannot be greater than machines limit
def getNumMachines() {
int num = params.NUM_MACHINES ? params.NUM_MACHINES.toInteger() : 1
int limit = getMachineLimit()
echo "machine limit is ${limit}"
if (num > limit) {
echo "Number of machines cannot be greater than ${limit}. Set num to ${limit}"
num = limit
}
return num
}
def getMachineLimit(){
int limit = nodesByLabel(LABEL).size()
// Set limit for dynamic vm agents to 100
if (LABEL.contains('ci.agent.dynamic')) {
limit = 100
}
return limit
}
def createJob( TEST_JOB_NAME, ARCH_OS ) {
def jobParams = [:]
jobParams.put('TEST_JOB_NAME', TEST_JOB_NAME)
jobParams.put('ARCH_OS_LIST', ARCH_OS)
if (params.DAYS_TO_KEEP) {
jobParams.put('DAYS_TO_KEEP', DAYS_TO_KEEP)
}
if (params.BUILDS_TO_KEEP) {
jobParams.put('BUILDS_TO_KEEP', BUILDS_TO_KEEP)
}
//get level and group if TEST_JOB_NAME matches the format of Test_openjdk11_j9_extended.functional_ppc64_aix
//otherwise, use default level and group value in template
if (TEST_JOB_NAME.startsWith("Test_openjdk")) {
def level = ""
def group = ""
def tokens = TEST_JOB_NAME.split('_');
if (tokens.size() > 3 && tokens[3].contains(".")) {
level = tokens[3].split("\\.")[0]
group = tokens[3].split("\\.")[1]
}
if (level && group) {
jobParams.put('LEVELS', level)
jobParams.put('GROUPS', group)
}
}
def templatePath = 'aqa-tests/buildenv/jenkins/testJobTemplate'
if (!fileExists(templatePath)) {
sh "curl -Os https://raw.githubusercontent.com/adoptium/aqa-tests/master/buildenv/jenkins/testJobTemplate"
templatePath = 'testJobTemplate'
}
if (env.LIGHT_WEIGHT_CHECKOUT) {
jobParams.put('LIGHT_WEIGHT_CHECKOUT', env.LIGHT_WEIGHT_CHECKOUT)
}
def create = jobDsl targets: templatePath, ignoreExisting: false, additionalParameters: jobParams
return create
}
def setup() {
stage('Setup') {
setupEnv()
if (params.CUSTOMIZED_SDK_URL) {
if (params.SDK_RESOURCE == 'nightly') {
// remove single quote to allow variables to be set in CUSTOMIZED_SDK_URL
CUSTOMIZED_SDK_URL_OPTION = "-c ${params.CUSTOMIZED_SDK_URL}"
} else if (!params.SDK_RESOURCE || params.SDK_RESOURCE == 'customized') {
SDK_RESOURCE = "customized"
CUSTOMIZED_SDK_URL_OPTION = "-c '${params.CUSTOMIZED_SDK_URL}'"
if (params.ADDITIONAL_ARTIFACTS_REQUIRED == "RI_JDK") {
def server = Artifactory.server params.ARTIFACTORY_SERVER
def artifactoryUrl = server.getUrl()
def repoForRi = ''
def riURL = ''
if (params.ARTIFACTORY_REPO.contains(',')) {
String[] repos = params.ARTIFACTORY_REPO.split(",")
// Assumption: ARTIFACTORY_REPO=X,Y (X=to upload results, Y=to download ri)
repoForRi = repos[1].trim()
if (!env.SPEC.startsWith('aix') && !env.SPEC.startsWith('zos')) {
riURL = "${artifactoryUrl}/${repoForRi}/Latest/${PLATFORM}/${JDK_VERSION}"
}
}
CUSTOMIZED_SDK_URL_OPTION = "-c '${params.CUSTOMIZED_SDK_URL} ${riURL}'"
}
} else {
error("SDK_RESOURCE: ${params.SDK_RESOURCE} and CUSTOMIZED_SDK_URL: ${params.CUSTOMIZED_SDK_URL} combo is not supported!")
}
} else {
if (params.SDK_RESOURCE == 'customized') {
error("SDK_RESOURCE: ${params.SDK_RESOURCE}, please provide CUSTOMIZED_SDK_URL")
} else {
CUSTOMIZED_SDK_URL_OPTION = ""
}
}
if (SDK_RESOURCE == 'upstream') {
timeout(time: 1, unit: 'HOURS') {
dir('jdkbinary') {
step([$class: 'CopyArtifact',
fingerprintArtifacts: true,
flatten: true,
filter: "**/*.tar.gz,**/*.tgz,**/*.zip,**/*.jar,**/*.Z,**/*sbom*.json",
projectName: "${params.UPSTREAM_JOB_NAME}",
selector: [$class: 'SpecificBuildSelector', buildNumber: "${params.UPSTREAM_JOB_NUMBER}"]])
}
}
}
OPENJ9_REPO_OPTION = ""
OPENJ9_BRANCH_OPTION = ""
TKG_REPO_OPTION = ""
TKG_BRANCH_OPTION = ""
OPENJ9_SHA_OPTION = ""
CLONE_OPENJ9_OPTION = (params.CLONE_OPENJ9) ? "--clone_openj9 ${params.CLONE_OPENJ9}" : ""
// if CLONE_OPENJ9 parameter is not set, only clone openj9 if we are running functional tests
if (CLONE_OPENJ9_OPTION == "") {
if (env.BUILD_LIST.contains('functional')) {
CLONE_OPENJ9_OPTION = "--clone_openj9 true"
// If USE_TESTENV_PROPERTIES = false, set Openj9 repo and brnach.
// Otherwise, testenv.properties will be used.
// And the Openj9 repo and brnach values will be set in get.sh
if(!params.USE_TESTENV_PROPERTIES) {
OPENJ9_REPO_OPTION = "--openj9_repo ${OPENJ9_REPO}"
OPENJ9_BRANCH_OPTION = "--openj9_branch ${OPENJ9_BRANCH}"
OPENJ9_SHA_OPTION = (params.OPENJ9_SHA) ? "--openj9_sha ${params.OPENJ9_SHA}" : ""
}
} else {
CLONE_OPENJ9_OPTION = "--clone_openj9 false"
}
}
JDK_VERSION_OPTION = env.JDK_VERSION ? "-j ${env.JDK_VERSION}" : ""
JDK_IMPL_OPTION = env.JDK_IMPL ? "-i ${env.JDK_IMPL}" : ""
// system test repository exports to be used by system/common.xml
if(!params.USE_TESTENV_PROPERTIES){
String[] adoptSystemTest = getGitRepoBranch(params.ADOPTOPENJDK_SYSTEMTEST_OWNER_BRANCH, "adoptium:master", "aqa-systemtest")
env.ADOPTOPENJDK_SYSTEMTEST_REPO = adoptSystemTest[0]
env.ADOPTOPENJDK_SYSTEMTEST_BRANCH = adoptSystemTest[1]
String[] openj9SystemTest = getGitRepoBranch(params.OPENJ9_SYSTEMTEST_OWNER_BRANCH, "eclipse:master", "openj9-systemtest")
env.OPENJ9_SYSTEMTEST_REPO = openj9SystemTest[0]
env.OPENJ9_SYSTEMTEST_BRANCH = openj9SystemTest[1]
String[] stf = getGitRepoBranch(params.STF_OWNER_BRANCH, "adoptium:master", "STF")
env.STF_REPO = stf[0]
env.STF_BRANCH = stf[1]
TKG_REPO_OPTION = "--tkg_repo ${TKG_REPO}"
TKG_BRANCH_OPTION = "--tkg_branch ${TKG_BRANCH}"
}
// vendor test
// expect VENDOR_TEST_* to be comma separated string parameters
VENDOR_TEST_REPOS = (params.VENDOR_TEST_REPOS) ? "--vendor_repos \"${params.VENDOR_TEST_REPOS}\"" : ""
VENDOR_TEST_BRANCHES = (params.VENDOR_TEST_BRANCHES) ? "--vendor_branches \"${params.VENDOR_TEST_BRANCHES}\"" : ""
VENDOR_TEST_DIRS = (params.VENDOR_TEST_DIRS) ? "--vendor_dirs \"${params.VENDOR_TEST_DIRS}\"" : ""
VENDOR_TEST_SHAS = (params.VENDOR_TEST_SHAS) ? "--vendor_shas \"${params.VENDOR_TEST_SHAS}\"" : ""
// handle three cases (true/false/null) in params.TEST_IMAGES_REQUIRED and params.DEBUG_IMAGES_REQUIRED
// Only set image required to false if params is set to false. In get.sh, the default value is true
TEST_IMAGES_REQUIRED = (params.TEST_IMAGES_REQUIRED == false) ? "--test_images_required false" : ""
DEBUG_IMAGES_REQUIRED = (params.DEBUG_IMAGES_REQUIRED == false) ? "--debug_images_required false" : ""
CODE_COVERAGE_OPTION = params.CODE_COVERAGE ? "--code_coverage true" : ""
ADDITIONAL_ARTIFACTS_REQUIRED_OPTION = (params.ADDITIONAL_ARTIFACTS_REQUIRED) ? "--additional_artifacts_required ${params.ADDITIONAL_ARTIFACTS_REQUIRED}" : ""
CURL_OPTS = (params.CURL_OPTS) ? "--curl_opts \"${params.CURL_OPTS}\"" : ""
GET_SH_CMD = "./get.sh -s `pwd`/.. -p $PLATFORM -r ${SDK_RESOURCE} ${JDK_VERSION_OPTION} ${JDK_IMPL_OPTION} ${CUSTOMIZED_SDK_URL_OPTION} ${CLONE_OPENJ9_OPTION} ${OPENJ9_REPO_OPTION} ${OPENJ9_BRANCH_OPTION} ${OPENJ9_SHA_OPTION} ${TKG_REPO_OPTION} ${TKG_BRANCH_OPTION} ${VENDOR_TEST_REPOS} ${VENDOR_TEST_BRANCHES} ${VENDOR_TEST_DIRS} ${VENDOR_TEST_SHAS} ${TEST_IMAGES_REQUIRED} ${DEBUG_IMAGES_REQUIRED} ${CODE_COVERAGE_OPTION} ${CURL_OPTS} ${ADDITIONAL_ARTIFACTS_REQUIRED_OPTION}"
RESOLVED_MAKE = "if [ `uname` = AIX ] || [ `uname` = SunOS ] || [ `uname` = *BSD ]; then MAKE=gmake; else MAKE=make; fi"
dir( WORKSPACE) {
// use sshagent with Jenkins credentials ID for all platforms except zOS
// on zOS use the user's ssh key
if (!env.SPEC.startsWith('zos')) {
get_sources_with_authentication()
} else {
get_sources()
}
getJobProperties()
}
}
}
def setup_jck_interactives() {
def targetDir = "${env.WORKSPACE}/../../jck_run/jdk${JDK_VERSION}/jdk"
if (PLATFORM.contains("windows")) {
targetDir = "c:/Users/jenkins/jck_run/jdk${JDK_VERSION}/jdk"
}
def tarBall = CUSTOMIZED_SDK_URL.tokenize('/').last()
echo "tarBall is ${tarBall}"
def jckRunDirExists = sh(script: """
if [ -d "${targetDir}" ]; then
echo true
else
echo false
fi
""", returnStdout: true).toBoolean()
if (jckRunDirExists) {
def jdkDir = ""
if (PLATFORM.contains("windows")) {
jdkDir = sh(script: "unzip -l `pwd`/jdkbinary/${tarBall} | head -n 4 | tail -n 1 | xargs -n 1 echo | tail -n 1", returnStdout: true).trim().replaceFirst(".\$","")
if (PLATFORM.contains("x86-32_windows")) {
jdkDir = "${jdkDir}_32"
} else if (PLATFORM.contains("x86-64_windows")) {
jdkDir = "${jdkDir}_64"
}
} else {
jdkDir = sh(script: "tar -tf `pwd`/jdkbinary/${tarBall} | head -1", returnStdout: true).trim().replaceFirst(".\$","")
}
def jckRunDir = "${targetDir}/${jdkDir}"
def jckRunJDKExists = sh(script: """
if [ -d "${jckRunDir}" ]; then
echo true
else
echo false
fi
""", returnStdout: true).toBoolean()
if (!jckRunJDKExists) {
sh returnStatus: true, script: """
cd ${targetDir}
mkdir ${jdkDir}
cd ${jdkDir}
cp -r ${TEST_JDK_HOME}/* .
chgrp -R jck ${targetDir}/${jdkDir}
chmod -R 775 ${targetDir}/${jdkDir}
"""
}
}
}
def getJobProperties() {
def jobProperties = "./aqa-tests/job.properties"
if (fileExists("${jobProperties}")) {
echo "readProperties file: ${jobProperties}"
def properties = readProperties file: "${jobProperties}"
if (properties.TEST_JDK_HOME) {
env.TEST_JDK_HOME = properties.TEST_JDK_HOME
echo "Reset TEST_JDK_HOME to ${TEST_JDK_HOME}"
}
}
}
def get_sources_with_authentication() {
sshagent(credentials:["${params.USER_CREDENTIALS_ID}"], ignoreMissing: true) {
get_sources()
}
}
def get_sources() {
dir('aqa-tests') {
if (params.CUSTOMIZED_SDK_URL_CREDENTIAL_ID) {
// USERNAME and PASSWORD reference with a withCredentials block will not be visible within job output
withCredentials([usernamePassword(credentialsId: "${params.CUSTOMIZED_SDK_URL_CREDENTIAL_ID}", usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
sh "$GET_SH_CMD"
}
} else {
sh "$GET_SH_CMD"
}
}
if (params.SETUP_JCK_RUN && env.BUILD_LIST.contains('jck') && SDK_RESOURCE.contains('customized')) {
setup_jck_interactives()
}
}
def makeCompileTest(){
String makeTestCmd = "bash ./compile.sh"
//unset LD_LIBRARY_PATH workaround for issue https://github.com/adoptium/infrastructure/issues/2934
if (JDK_IMPL == 'hotspot' && JDK_VERSION == '8' && PLATFORM.contains('alpine-linux')) {
makeTestCmd = "unset LD_LIBRARY_PATH; $makeTestCmd"
}
dir('aqa-tests') {
if (!env.SPEC.startsWith('zos')) {
sshagent (credentials: ["$params.SSH_AGENT_CREDENTIAL"], ignoreMissing: true) {
sh "$makeTestCmd";
}
} else {
sh "$makeTestCmd";
}
}
}
def buildTest() {
stage('Build') {
echo 'Building tests...'
if ( params.PERF_CREDENTIALS_ID ) {
withCredentials([usernamePassword(credentialsId: "$params.PERF_CREDENTIALS_ID",
passwordVariable: "PASSWORD_VAR", usernameVariable: "USERNAME_VAR")]) {
env.PERF_USERNAME = USERNAME_VAR
env.PERF_PASSWORD = PASSWORD_VAR
}
}
if (params.UPSTREAM_TEST_JOB_NAME && params.UPSTREAM_TEST_JOB_NUMBER) {
try {
timeout(time: 1, unit: 'HOURS') {
copyArtifacts fingerprintArtifacts: true, projectName: params.UPSTREAM_TEST_JOB_NAME, selector: specific(params.UPSTREAM_TEST_JOB_NUMBER), filter: "**/parallelList.mk", target: './aqa-tests/TKG/'
}
} catch (Exception e) {
echo 'Exception: ' + e.toString()
echo "Cannot run copyArtifacts from ${params.UPSTREAM_TEST_JOB_NAME} ${params.UPSTREAM_TEST_JOB_NUMBER}. Skipping copyArtifacts..."
}
}
try {
// check pre-stage test libs on the machine
// check for each lib. If lib does not exist, donwload it.
// If lib exists, SHA will be checked. Re-download if SHA does not match.
timeout(time: 20, unit: 'MINUTES') {
def customUrl = "https://ci.adoptium.net/job/test.getDependency/lastSuccessfulBuild/artifact/"
if (PLATFORM.contains("windows")) {
env.LIB_DIR = env.LIB_DIR.replaceAll("\\\\", "/")
}
sh "perl ./aqa-tests/TKG/scripts/getDependencies.pl -path ${env.LIB_DIR} -task default -customUrl ${customUrl}"
}
} catch (Exception e) {
echo 'Exception: ' + e.toString()
echo "Cannot pre-stage test libs from ${env.LIB_DIR} on the machine. Skipping..."
}
try {
if (env.BUILD_LIST.contains('system')) {
//get pre-staged test jars from systemtest.getDependency build before system test compilation
timeout(time: 60, unit: 'MINUTES') {
copyArtifacts fingerprintArtifacts: true, projectName: "systemtest.getDependency", selector: lastSuccessful(), target: 'aqa-tests'
}
}
} catch (Exception e) {
echo 'Exception: ' + e.toString()
echo 'Cannot run copyArtifacts from test.getDependency/systemtest.getDependency. Skipping copyArtifacts...'
}
if (BUILD_LIST.contains("external")){
try {
timeout(time: 60, unit: 'MINUTES') {
copyArtifacts fingerprintArtifacts: true, projectName: "UploadFileOnJenkins", selector: specific("2"), target: 'aqa-tests/external/criu/'
copyArtifacts fingerprintArtifacts: true, projectName: "UploadFileOnJenkins", selector: specific("3"), target: 'aqa-tests/external/criu/'
}
} catch (Exception e) {
echo 'Exception: ' + e.toString()
echo 'Cannot run copyArtifacts from UploadFileOnJenkins. Skipping copyArtifacts...'
}
}
if (fileExists('jdkbinary/openjdk-test-image')) {
env.TESTIMAGE_PATH = "$WORKSPACE/jdkbinary/openjdk-test-image"
}
if (fileExists('jdkbinary/openjdk-test-image/openj9')) {
env.NATIVE_TEST_LIBS = "$WORKSPACE/jdkbinary/openjdk-test-image/openj9"
}
if (!params.DYNAMIC_COMPILE) {
if(params.CUSTOMIZED_SDK_URL_CREDENTIAL_ID) {
withCredentials([usernamePassword(credentialsId: "${params.CUSTOMIZED_SDK_URL_CREDENTIAL_ID}",
usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
makeCompileTest()
}
} else {
makeCompileTest()
}
}
if (params.CODE_COVERAGE) {
echo "Clean gcda files before generating new Code Coverage info"
sh "find ${WORKSPACE}/jdkbinary/j2sdk-image -name '*.gcda' -type f -delete"
}
}
}
def runTest( ) {
stage('Test') {
echo 'Running tests...'
def CUSTOM_OPTION = ''
TARGET = "${params.TARGET}";
if (TARGET.contains('custom') && CUSTOM_TARGET!='') {
if (TARGET == 'system_custom') {
env.SYSTEM_CUSTOM_TARGET=CUSTOM_TARGET
} else {
// remove suffix, then set CUSTOM_OPTION (i.e., jdk_custom_0 will become jdk_custom)
def removeSuffix = TARGET.replaceAll(/_\d+$/, "")
CUSTOM_OPTION = "${removeSuffix.toUpperCase()}_TARGET='${CUSTOM_TARGET}'"
}
}
if (!TARGET.startsWith('-f')) {
TARGET="_${params.TARGET}"
} else if (TARGET.contains('-f parallelList.mk') && SPEC.startsWith('zos')) {
def parallelList = "aqa-tests/TKG/parallelList.mk"
if (fileExists("${parallelList}")) {
echo 'Converting parallelList.mk file from ascii to ebcdic...'
sh "iconv -f iso8859-1 -t ibm-1047 ${parallelList} > ${parallelList}.ebcdic; rm ${parallelList}; mv ${parallelList}.ebcdic ${parallelList}"
}
}
RUNTEST_CMD = "${TARGET} ${CUSTOM_OPTION}"
if (env.BUILD_LIST.contains('jck') || env.BUILD_LIST.contains('openjdk') || env.BUILD_LIST.contains('functional')) {
if (env.SPEC.startsWith('aix')) {
sh "/usr/bin/X11/X -force -vfb -x abx -x dbe -x GLX -secIP 000 :0 &"
env.DISPLAY = "unix:0"
echo "env.DISPLAY is ${env.DISPLAY}"
} else if (env.SPEC.startsWith('sunos')) {
sh "/usr/X11/bin/Xvfb :2 -screen 0 1024x768x24 &"
env.DISPLAY = ":2"
echo "env.DISPLAY is ${env.DISPLAY}"
}
}
for (int i = 1; i <= ITERATIONS; i++) {
echo "ITERATION: ${i}/${ITERATIONS}"
if (env.SPEC.contains('linux') && !(LABEL.contains('ci.agent.dynamic') && CLOUD_PROVIDER == 'azure') && (BUILD_LIST != "external")) {
// Add an additional 10 second timeout due to issue: https://github.com/adoptium/temurin-build/issues/2368#issuecomment-756683888
wrap([$class: 'Xvfb', autoDisplayName: true, timeout:20]) {
def DISPLAY = sh (
script: 'ps -f | grep \'[X]vfb\' | awk \'{print \$9}\'',
returnStdout: true
).trim()
env.DISPLAY = "${DISPLAY}"
echo "env.DISPLAY is ${env.DISPLAY}"
makeTest("${RUNTEST_CMD}")
}
} else {
makeTest("${RUNTEST_CMD}")
}
}
if (params.CODE_COVERAGE) {
echo 'Generating Code Coverage Reports...'
dir("$WORKSPACE/jdkbinary/j2sdk-image") {
// Current lcov generates "Cannot open source file" info, but does not affect results, since Build and Test paths difference are corrected after summary.
sh "lcov --capture --quiet --directory . --output-file codeCoverageInfoOrigin.info --rc geninfo_adjust_src_path='/home/jenkins/workspace/ => ${WORKSPACE}/jdkbinary/j2sdk-image/jenkins/workspace/'"
sh "lcov --quiet --output-file codeCoverageInfoFinal.info --remove codeCoverageInfoOrigin.info '/usr/include/*' '/usr/local/*' '/home/*/attrlookup.gperf'"
sh "genhtml --quiet codeCoverageInfoFinal.info --output-directory code_coverage_report"
}
}
def resultSum = [:]
def matcher = manager.getLogMatcher(".*(TOTAL: \\d+)\\s*(EXECUTED: \\d+)\\s*(PASSED: \\d+)\\s*(FAILED: \\d+)\\s*(DISABLED: \\d+)?\\s*(SKIPPED: \\d+)\\s*\$")
if (matcher?.matches()) {
for (int i = 1; i <= matcher.groupCount(); i++) {
if (matcher.group(i) != null) {
def matchVals = matcher.group(i).split(": ")
resultSum[matchVals[0]] = matchVals[1] as int
}
}
checkTestResults(resultSum)
} else {
currentBuild.result = 'FAILURE'
echo 'Could not find test result, set build result to FAILURE.'
def summary = manager.createSummary("error.svg")
summary.appendText("TEST BUILD FAILURE!", false)
}
}
}
def checkTestResults(results) {
if (results.isEmpty()) {
return
}
def summary = null
if (results["TOTAL"] == 0) {
currentBuild.result = 'FAILURE'
echo 'No test ran, set build result to FAILURE.'
summary = manager.createSummary("folder-delete.svg")
summary.appendText("NO TEST FOUND!", false)
return
}
if (results["FAILED"] != 0) {
currentBuild.result = 'UNSTABLE'
echo 'There were test failures, set build result to UNSTABLE.'
summary = manager.createSummary("warning.svg")
} else {
summary = manager.createSummary("accept.svg")
}
summary.appendText("TEST TARGETS SUMMARY:<ul>", false)
results.each {
summary.appendText("<li><b>$it.key</b> : $it.value</li>", false)
}
summary.appendText("</ul>", false)
}
def post(output_name) {
stage('Post') {
if (env.DISPLAY != null) {
env.DISPLAY = ""
}
if (output_name.contains(',')) {
output_name = "specifiedTarget"
}
else {
output_name = output_name.replace("/","_")
}
def tar_cmd = "tar -cf"
// Use pigz if we can as it is faster - 2> hides fallback message
def tar_cmd_suffix = "| (pigz -9 2>/dev/null || gzip -9)"
def suffix = ".tar.gz"
def pax_opt = ""
if (SPEC.startsWith('zos')) {
echo 'Converting tap file from ebcdic to ascii...'
sh 'cd ./aqa-tests/TKG'
def tapFiles = findFiles(glob: "**/*.tap")
for (String tapFile : tapFiles) {
sh "iconv -f ibm-1047 -t iso8859-1 ${tapFile} > ${tapFile}.ascii; rm ${tapFile}; mv ${tapFile}.ascii ${tapFile}"
}
tar_cmd = "pax -wf"
suffix = ".pax.Z"
pax_opt = "-x pax"
tar_cmd_suffix = ""
}
step([$class: "TapPublisher", testResults: "aqa-tests/TKG/**/*.tap", outputTapToConsole: false, failIfNoResults: true])
//call the archive function for each file
archiveFile("aqa-tests/testenv/testenv.properties", true)
archiveFile("aqa-tests/TKG/**/*.tap", true)
archiveAQAvitFiles()
if (env.BUILD_LIST.startsWith('jck')) {
xunit (
tools: [Custom(customXSL: "$WORKSPACE/aqa-tests/jck/xUnit.xsl",
deleteOutputFiles: true,
failIfNotNew: false,
pattern: "**/TKG/output_*/**/report.xml",
skipNoTestFiles: true,
stopProcessingIfError: true)]
)
}
//for performance test, archive regardless the build result
if (env.BUILD_LIST.startsWith('perf')) {
def benchmark_output_tar_name = "benchmark_test_output${suffix}"
sh "${tar_cmd} ${benchmark_output_tar_name} ${pax_opt} ./aqa-tests/TKG/output_*"
if (!params.ARTIFACTORY_SERVER) {
echo "ARTIFACTORY_SERVER is not set. Saving artifacts on jenkins."
archiveArtifacts artifacts: benchmark_output_tar_name, fingerprint: true, allowEmptyArchive: true
} else {
def pattern = "${env.WORKSPACE}/*_output.*"
uploadToArtifactory(pattern)
}
} else if ((currentBuild.result == 'UNSTABLE' || currentBuild.result == 'FAILURE' || currentBuild.result == 'ABORTED') || params.ARCHIVE_TEST_RESULTS) {
def test_output_tar_name = "${output_name}_test_output${suffix}"
if (tar_cmd.startsWith('tar')) {
sh "${tar_cmd} - ${pax_opt} ./aqa-tests/TKG/output_* ${tar_cmd_suffix} > ${test_output_tar_name}"
} else {
sh "${tar_cmd} ${test_output_tar_name} ${pax_opt} ./aqa-tests/TKG/output_* ${tar_cmd_suffix}"
}
// TODO: archiveFile() should be used
if (!params.ARTIFACTORY_SERVER) {
echo "ARTIFACTORY_SERVER is not set. Saving artifacts on jenkins."
archiveArtifacts artifacts: test_output_tar_name, fingerprint: true, allowEmptyArchive: true
} else {
def pattern = "${env.WORKSPACE}/*_output.*"
uploadToArtifactory(pattern)
}
if (env.BUILD_LIST.startsWith('external')) {
archiveFile("**/Dockerfile.*", true)
}
if (params.ARCHIVE_TEST_RESULTS && !env.JDK_VERSION.contains(',') && env.BUILD_LIST.contains('jck')) {
def natives_tar_name = "natives${suffix}"
def natives_dir = "${WORKSPACE}/../../jck_root/JCK${env.JDK_VERSION}-unzipped/natives"
if (tar_cmd.startsWith('tar')) {
sh "${tar_cmd} - ${pax_opt} ${natives_dir} ${tar_cmd_suffix} > ${natives_tar_name}"
} else {
sh "${tar_cmd} ${natives_tar_name} ${pax_opt} ${natives_dir} ${tar_cmd_suffix}"
}
archiveFile(natives_tar_name, false)
}
}
if (params.CODE_COVERAGE) {
echo "Archive Code Coverage Report"
def code_coverage_report_tar_name = "${output_name}_code_coverage_report${suffix}"
dir("${WORKSPACE}/jdkbinary/j2sdk-image") {
if (tar_cmd.startsWith('tar')) {
sh "${tar_cmd} - ${pax_opt} codeCoverageInfoFinal.info code_coverage_report ${tar_cmd_suffix} > ${code_coverage_report_tar_name}"
} else {
sh "${tar_cmd} ${code_coverage_report_tar_name} ${pax_opt} codeCoverageInfoFinal.info code_coverage_report ${tar_cmd_suffix}"
}
}
if (!params.ARTIFACTORY_SERVER) {
echo "ARTIFACTORY_SERVER is not set. Saving artifacts on jenkins."
archiveArtifacts artifacts: code_coverage_report_tar_name, fingerprint: true, allowEmptyArchive: true
} else {
def pattern = "${env.WORKSPACE}/*_code_coverage_report.*"
uploadToArtifactory(pattern)
}
}
addFailedTestsGrinderLink()
try {
junit allowEmptyResults: true, keepLongStdio: true, testResults: '**/work/**/*.jtr.xml, **/result/**/*.jtr.xml, **/junitreports/**/*.xml, **/external_test_reports/**/*.xml'
} catch (Exception e) {
echo "Caught exception: ${e.message}"
}
}
}
def testBuild() {
TIME_LIMIT = params.TIME_LIMIT ? params.TIME_LIMIT.toInteger() : 10
timeout(time: TIME_LIMIT, unit: 'HOURS') {
try {
addJobDescription()
setup()
addGrinderLink()
// prepare environment and compile test projects
if ((params.PARALLEL == "NodesByIterations" && NUM_MACHINES > 1)
|| (params.PARALLEL == "Dynamic" && (NUM_MACHINES > 1 || (params.TEST_TIME && !params.NUM_MACHINES)))) {
setupParallelEnv()
} else {
testExecution()
}
} finally {
// Terminate any left over test job processes
terminateTestProcesses()
if (!params.KEEP_WORKSPACE) {
forceCleanWS()
// clean up remaining core files
if (PLATFORM.contains("mac")) {
sh "find /cores -name '*core*' -print 2>/dev/null -exec rm -f {} \\; || true"
} else if (PLATFORM.contains("windows")) {
sh "find /cygdrive/c/temp -name '*core*' -print 2>/dev/null -exec rm -f {} \\; || true"
} else {
sh "find /tmp -name '*core*' -print 2>/dev/null -exec rm -f {} \\; || true"
}
}
}
}
}
def testExecution() {
try {
//ToDo: temporary workaround for jck test parallel runs
// until build.xml is added into each subfolder
if( env.BUILD_LIST.startsWith('jck/')) {
def temp = env.BUILD_LIST
env.BUILD_LIST = "jck"
buildTest()
env.BUILD_LIST = temp
} else {
buildTest()