forked from liferay/liferay-portal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-test-batch.xml
9452 lines (7727 loc) · 319 KB
/
build-test-batch.xml
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
<?xml version="1.0"?>
<project basedir="." name="portal-test-batch" xmlns:antelope="antlib:ise.antelope.tasks" xmlns:if="ant:if" xmlns:unless="ant:unless">
<import file="build-test.xml" />
<condition else="0" property="axis.variable" value="${env.AXIS_VARIABLE}">
<isset property="env.AXIS_VARIABLE" />
</condition>
<math
datatype="int"
operand1="${test.class.timeout.minutes}"
operand2="60"
operation="*"
result="test.class.timeout.seconds"
/>
<macrodef name="check-jenkins-console">
<sequential>
<if>
<isset property="env.BUILD_URL" />
<then>
<var name="tstamp.value" unset="true" />
<tstamp>
<format pattern="yyyyMMddkkmmssSSS" property="tstamp.value" />
</tstamp>
<propertyregex
input="${env.BUILD_URL}"
property="jenkins.build.url"
regexp="https:\/\/([^\.]+)\.[^\/]+"
replace="http://\1"
/>
<propertyregex
input="${jenkins.build.url}"
override="true"
property="jenkins.build.url"
regexp="http:\/\/([^\/]+)\/(\d+)"
replace="http://\1-\2/\2"
/>
<get
dest="${tstamp.value}.txt"
ignoreerrors="true"
src="${jenkins.build.url}/consoleText"
/>
<var name="jenkins.console.txt" unset="true" />
<loadfile
property="jenkins.console.txt"
srcfile="${tstamp.value}.txt"
/>
<delete file="${tstamp.value}.txt" />
<var name="tstamp.value" unset="true" />
<var name="junit.failure.count" unset="true" />
<var name="junit.failure.message" unset="true" />
<var name="junit.timestamp" unset="true" />
<if>
<contains string="${jenkins.console.txt}" substring="!MESSAGE error" />
<then>
<property name="junit.failure.count" value="1" />
<property name="junit.failure.message"><![CDATA[<failure message="!MESSAGE error" type="java.lang.Exception" />]]></property>
</then>
<elseif>
<contains string="${jenkins.console.txt}" substring="!MESSAGE warning" />
<then>
<property name="junit.failure.count" value="1" />
<property name="junit.failure.message"><![CDATA[<failure message="!MESSAGE warning" type="java.lang.Exception" />]]></property>
</then>
</elseif>
<else>
<property name="junit.failure.count" value="0" />
<property name="junit.failure.message" value="" />
</else>
</if>
<tstamp>
<format pattern="yyyy-MM-dd_kk:mm:ss" property="junit.timestamp" />
</tstamp>
<echo file="portal-impl/test-results/TEST-JenkinsLogAssertTest.xml"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<testsuite errors="0" failures="${junit.failure.count}" hostname="localhost" name="com.liferay.jenkins.JenkinsLogAsserterTest" skipped="0" tests="1" time="0.0" timestamp="${junit.timestamp}">
<properties />
<testcase classname="com.liferay.jenkins.JenkinsLogAsserterTest" name="testScanJenkinsLog" time="0.0">
${junit.failure.message}
</testcase>
<system-out></system-out>
<system-err></system-err>
</testsuite>]]></echo>
</then>
</if>
</sequential>
</macrodef>
<macrodef name="clean-restart-sybase">
<attribute default="false" name="retry" />
<sequential>
<exec executable="service">
<arg line="sybase stop" />
</exec>
<waitfor maxwait="60" maxwaitunit="second">
<not>
<socket port="5000" server="localhost" />
</not>
</waitfor>
<sleep if:true="@{retry}" seconds="10" />
<antcall target="clean-up-sybase-processes" />
<if if:true="@{retry}">
<available file="/opt/sybase.tar.gz" />
<then>
<delete dir="/opt/sybase" />
<exec executable="tar" failonerror="true">
<arg line="xf /opt/sybase.tar.gz -C /" />
</exec>
<exec executable="hostname" failonerror="true" outputproperty="hostname" />
<echo file="/opt/sybase/interfaces">lportal
master tcp ether ${hostname} 5000
query tcp ether ${hostname} 5000
lportal_BS
master tcp ether ${hostname} 5001
query tcp ether ${hostname} 5001
</echo>
</then>
<else>
<fail message="Unable to reset Sybase installation due to missing /opt/sybase.tar.gz." />
</else>
</if>
<exec executable="service" failonerror="true">
<arg line="sybase start" />
</exec>
<waitfor maxwait="60" maxwaitunit="second">
<socket port="5000" server="localhost" />
</waitfor>
<sleep if:true="@{retry}" seconds="10" />
</sequential>
</macrodef>
<macrodef name="copy-artifact-to-local-cache">
<attribute name="artifact.file" />
<attribute name="artifact.name" />
<attribute name="artifact.version" />
<sequential>
<local name="local.cache.artifact" />
<beanshell>
<![CDATA[
String artifactName = "@{artifact.name}";
String artifactVersion = "@{artifact.version}";
StringBuilder sb = new StringBuilder();
sb.append(project.getProperty("build.repository.local.dir"));
sb.append("/com/liferay/portal/");
sb.append(artifactName);
sb.append("/");
sb.append(artifactVersion);
sb.append("/");
sb.append(artifactName);
sb.append("-");
sb.append(artifactVersion);
sb.append(".jar");
project.setProperty("local.cache.artifact", sb.toString());
]]>
</beanshell>
<copy
failonerror="false"
file="@{artifact.file}"
tofile="${local.cache.artifact}"
/>
<propertyfile file="${project.dir}/.gradle/gradle.properties">
<entry key="@{artifact.name}.version" value="@{artifact.version}" />
</propertyfile>
</sequential>
</macrodef>
<macrodef name="database-test-action">
<attribute name="database.type" />
<element name="action" />
<sequential>
<local name="database.type" />
<property name="database.type" value="@{database.type}" />
<local name="database.docker.image" />
<local name="database.service.cmd.start" />
<local name="database.service.cmd.stop" />
<local name="database.service.executable" />
<local name="database.version.cmd" />
<get-database-property property.name="database.docker.image" />
<if>
<not>
<isset property="database.docker.image" />
</not>
<then>
<get-database-property property.name="database.service.cmd.start" />
<get-database-property property.name="database.service.cmd.stop" />
<get-database-property property.name="database.service.executable" />
<get-database-property property.name="database.version.cmd" />
</then>
</if>
<action />
</sequential>
</macrodef>
<macrodef name="database-test-run-test">
<attribute name="database.type" />
<attribute default="" name="database.version" />
<attribute default="true" name="rebuild.database" />
<attribute default="false" name="stop.app.server" />
<element name="test-action" />
<sequential>
<if>
<or>
<equals arg1="${test.batch.full.setup}" arg2="true" />
<isset property="env.JENKINS_HOME" />
</or>
<then>
<var name="database.type" unset="true" />
<property name="database.type" value="@{database.type}" />
<echo append="true" file="test.${env.HOSTNAME}.properties"><![CDATA[
database.type=@{database.type}]]></echo>
<if>
<not>
<equals arg1="@{database.version}" arg2="" />
</not>
<then>
<var name="database.@{database.type}.version" unset="true" />
<property name="database.@{database.type}.version" value="@{database.version}" />
<echo append="true" file="test.${env.HOSTNAME}.properties"><![CDATA[
database.@{database.type}.version=@{database.version}]]></echo>
</then>
</if>
<if>
<and>
<equals arg1="@{database.type}" arg2="mysql" />
<or>
<equals arg1="@{database.version}" arg2="5.5" />
<equals arg1="@{database.version}" arg2="5.7" />
</or>
</and>
<then>
<var name="database.major.version.build" unset="true" />
<var name="database.mysql.service.cmd.start" unset="true" />
<var name="database.mysql.service.cmd.stop" unset="true" />
<var name="mysql.executable" unset="true" />
<antelope:stringutil property="database.major.version.build" string="@{database.version}">
<antelope:replace regex="\." replacement="" />
</antelope:stringutil>
<property name="database.mysql.service.cmd.start" value="mysql${database.major.version.build} start" />
<property name="database.mysql.service.cmd.stop" value="mysql${database.major.version.build} stop" />
<property name="mysql.executable" value="mysql${database.major.version.build}" />
<echo append="true" file="test.${env.HOSTNAME}.properties"><![CDATA[
database.mysql.service.cmd.start=${database.mysql.service.cmd.start}
database.mysql.service.cmd.stop=${database.mysql.service.cmd.stop}]]></echo>
<echo append="true" file="sql/sql.${env.HOSTNAME}.properties"><![CDATA[
mysql.executable=${mysql.executable}]]></echo>
</then>
</if>
<if>
<equals arg1="@{database.type}" arg2="mariadb" />
<then>
<var name="mariadb.executable" unset="true" />
<property name="mariadb.executable" value="mariadb" />
<echo append="true" file="sql/sql.${env.HOSTNAME}.properties"><![CDATA[
mariadb.executable=${mariadb.executable}]]></echo>
</then>
</if>
<print-file file.name="sql/sql.${env.HOSTNAME}.properties" />
<database-test-action database.type="@{database.type}">
<action>
<if>
<isset property="database.docker.image" />
<then>
<echo>Using Docker for ${database.type}.</echo>
</then>
<elseif>
<equals arg1="${database.type}" arg2="db2" />
<then>
<echo></echo>
<echo>##</echo>
<echo>## ${database.version.cmd}</echo>
<echo>##</echo>
<echo></echo>
<exec executable="${database.version.cmd}" />
</then>
</elseif>
<else>
<local name="database.executable" />
<if>
<equals arg1="${database.type}" arg2="oracle" />
<then>
<propertycopy from="oracle.sqlplus.executable" name="database.executable" />
</then>
<else>
<propertycopy from="${database.type}.executable" name="database.executable" />
</else>
</if>
<echo></echo>
<echo>##</echo>
<echo>## ${database.executable} ${database.version.cmd}</echo>
<echo>##</echo>
<echo></echo>
<exec executable="${database.executable}">
<arg line="${database.version.cmd}" />
</exec>
</else>
</if>
</action>
</database-test-action>
<database-test-action database.type="@{database.type}">
<action>
<if>
<isset property="database.docker.image" />
<then>
<stop-docker-database />
</then>
<else>
<exec executable="${database.service.executable}">
<arg line="${database.service.cmd.stop}" />
</exec>
</else>
</if>
</action>
</database-test-action>
<database-test-action database.type="@{database.type}">
<action>
<set-portal-impl-portal-test-ext-properties />
<set-portal-impl-system-ext-properties />
<if>
<or>
<equals arg1="${env.DOCKER_ENABLED}" arg2="true" />
<isset property="database.${database.type}.docker.image" />
</or>
<then>
<antcall target="start-docker-containers" />
</then>
<elseif>
<or>
<and>
<equals arg1="@{database.type}" arg2="oracle" />
<equals arg1="@{database.version}" arg2="19.3.0.0.0" />
</and>
<and>
<equals arg1="@{database.type}" arg2="postgresql" />
<equals arg1="@{database.version}" arg2="11" />
</and>
</or>
<then>
<fail message="Unsupported database: @{database.type}-@{database.version}" />
</then>
</elseif>
<else>
<exec executable="${database.service.executable}" resultproperty="exec.result">
<arg line="${database.service.cmd.start}" />
</exec>
<diagnose-database-start database.type="@{database.type}" exec.result="${exec.result}" />
</else>
</if>
<antcall inheritall="false" target="copy-optional-jars">
<param name="database.type" value="@{database.type}" />
<param name="todir" value="lib/development" />
</antcall>
<get-test-app-server-lib-portal-dir />
<antcall inheritall="false" target="copy-optional-jars">
<param name="database.type" value="@{database.type}" />
<param name="todir" value="${test.app.server.lib.portal.dir}" />
</antcall>
<antcall if:true="@{rebuild.database}" inheritall="false" target="rebuild-database">
<param name="database.type" value="@{database.type}" />
</antcall>
<test-action />
<if if:true="@{stop.app.server}">
<available file=".testable.portal.started" />
<then>
<antcall target="stop-app-server" />
<delete failonerror="false" file=".testable.portal.started" />
</then>
</if>
<if>
<or>
<equals arg1="${env.DOCKER_ENABLED}" arg2="true" />
<isset property="database.${database.type}.docker.image" />
</or>
<then>
<antcall target="stop-docker-containers" />
</then>
<else>
<exec executable="${database.service.executable}" failonerror="true">
<arg line="${database.service.cmd.stop}" />
</exec>
</else>
</if>
</action>
</database-test-action>
</then>
<else>
<test-action />
<if>
<equals arg1="@{stop.app.server}" arg2="true" />
<then>
<antcall target="stop-app-server" />
<delete failonerror="false" file=".testable.portal.started" />
</then>
</if>
</else>
</if>
</sequential>
</macrodef>
<macrodef name="deploy-release-dependency-modules-post-startup">
<sequential>
<get-release-dependency-modules
post.startup.modules.only="true"
/>
<for list="${release.dependency.modules}" param="release.dependency.module">
<sequential>
<if>
<available file="@{release.dependency.module}" />
<then>
<echo>Deploying post-startup module: @{release.dependency.module}</echo>
<gradle-execute dir="@{release.dependency.module}" forcedcacheenabled="false" task="deploy" />
</then>
</if>
</sequential>
</for>
</sequential>
</macrodef>
<macrodef name="deploy-release-dependency-modules-pre-startup">
<sequential>
<get-release-dependency-modules
pre.startup.modules.only="true"
/>
<for list="${release.dependency.modules}" param="release.dependency.module">
<sequential>
<if>
<available file="@{release.dependency.module}" />
<then>
<echo>Deploying pre-startup module: @{release.dependency.module}</echo>
<gradle-execute dir="@{release.dependency.module}" forcedcacheenabled="false" task="deploy" />
</then>
</if>
</sequential>
</for>
</sequential>
</macrodef>
<macrodef name="diagnose-database-start">
<attribute name="database.type" />
<attribute name="exec.result" />
<sequential>
<if>
<equals arg1="@{database.type}" arg2="db2" />
<then>
<if>
<not>
<equals arg1="@{exec.result}" arg2="0" />
</not>
<then>
<exec executable="db2diag">
<arg line="-H 1d" />
</exec>
</then>
</if>
</then>
</if>
</sequential>
</macrodef>
<macrodef name="get-release-dependency-modules">
<attribute default="false" name="post.startup.modules.only" />
<attribute default="false" name="pre.startup.modules.only" />
<sequential>
<beanshell>
<![CDATA[
import java.nio.file.Files;
import org.apache.commons.lang.StringUtils;
String projectDir = project.getProperty("project.dir");
boolean postStartupModulesOnly = Boolean.parseBoolean("@{post.startup.modules.only}");
boolean preStartupModulesOnly = Boolean.parseBoolean("@{pre.startup.modules.only}");
List postStartupTestUtilModules = new ArrayList();
String testReleasePostStartupDependencyModules = project.getProperty("test.release.post.startup.dependency.modules");
if (testReleasePostStartupDependencyModules != null) {
postStartupTestUtilModules = Arrays.asList(testReleasePostStartupDependencyModules.split(","));
}
public List findFiles(File baseDir, String regex) {
List files = new ArrayList();
for (File file : baseDir.listFiles()) {
String filePath = file.toString();
if (file.isDirectory()) {
files.addAll(findFiles(file, regex));
}
else if (filePath.matches(regex)) {
files.add(file);
}
}
return files;
}
public List getModulesFromModuleGroups(String[] moduleGroups) {
List modules = new ArrayList();
for (String moduleGroup : moduleGroups) {
String moduleGroupPath = projectDir + "/" + moduleGroup;
File appBndFile = new File(moduleGroupPath, "app.bnd");
if (!appBndFile.exists()) {
modules.add(moduleGroup);
continue;
}
List moduleBuildGradleFiles = findFiles(new File(moduleGroupPath), moduleGroupPath + "/.+/build.gradle");
for (File moduleBuildGradleFile : moduleBuildGradleFiles) {
String module = moduleBuildGradleFile.getParent();
module = module.replace(projectDir + "/", "");
if (module.endsWith("-test")) {
System.out.println("Ignoring " + module);
continue;
}
modules.add(module);
}
}
return modules;
}
public List getTestUtilModules() {
List appBndFiles = findFiles(new File(projectDir, "modules/apps"), ".+/app.bnd");
File dxpAppsDir = new File(projectDir, "modules/dxp/apps");
if (dxpAppsDir.exists()) {
appBndFiles.addAll(findFiles(dxpAppsDir, ".+/app.bnd"));
}
File privateAppsDir = new File(projectDir, "modules/private/apps");
if (privateAppsDir.exists()) {
appBndFiles.addAll(findFiles(privateAppsDir, ".+/app.bnd"));
}
List releasedAppDirs = new ArrayList();
for (File appBndFile : appBndFiles) {
String fileContent = new String(Files.readAllBytes(appBndFile.toPath()));
if (fileContent.contains("Liferay-Releng-Bundle: true")) {
releasedAppDirs.add(appBndFile.getParentFile());
}
}
List testUtilModules = new ArrayList();
for (File releasedAppDir : releasedAppDirs) {
List testUtilModuleBuildGradleFiles = findFiles(releasedAppDir, ".+test-util/build.gradle");
for (File testUtilModuleBuildGradleFile : testUtilModuleBuildGradleFiles) {
String testUtilModule = testUtilModuleBuildGradleFile.getParent();
File skipTestIntegrationCheckFile = new File(testUtilModule, ".lfrbuild-ci-skip-test-integration-check");
if (skipTestIntegrationCheckFile.exists()) {
System.out.println("Ignoring " + testUtilModule.replace(projectDir + "/", ""));
continue;
}
if (postStartupModulesOnly && !isPostStartupTestUtilModule(testUtilModule)) {
System.out.println("Ignoring " + testUtilModule.replace(projectDir + "/", ""));
continue;
}
if (preStartupModulesOnly && isPostStartupTestUtilModule(testUtilModule)) {
System.out.println("Ignoring " + testUtilModule.replace(projectDir + "/", ""));
continue;
}
testUtilModule = testUtilModule.replace(projectDir + "/", "");
testUtilModules.add(testUtilModule);
}
}
return testUtilModules;
}
public boolean isPostStartupTestUtilModule(String testUtilModule) {
for (String postStartupTestUtilModule: postStartupTestUtilModules) {
if (testUtilModule.contains(postStartupTestUtilModule)) {
return true;
}
}
return false;
}
Set releaseDependentModules = new TreeSet();
releaseDependentModules.addAll(getTestUtilModules());
String deprecatedModuleGroups = project.getProperty("test.batch.deprecated.module.groups");
if (deprecatedModuleGroups != null) {
releaseDependentModules.addAll(getModulesFromModuleGroups(deprecatedModuleGroups.split(",")));
}
project.setProperty("release.dependency.modules", StringUtils.join(releaseDependentModules, ','));
]]>
</beanshell>
</sequential>
</macrodef>
<macrodef name="get-test-batch-app-server-start-executable-arg-line">
<sequential>
<propertycopy from="app.server.${app.server.type}.start.executable.arg.line" name="start.executable.arg.line" />
<var name="test.batch.app.server.start.executable.arg.line" value="${start.executable.arg.line}" />
<if>
<and>
<equals arg1="${app.server.type}" arg2="tomcat" />
<equals arg1="${test.batch.aspectj.enabled}" arg2="true" />
<not>
<os family="windows" />
</not>
</and>
<then>
<var name="test.batch.app.server.start.executable.arg.line" value="aspectj ${test.batch.app.server.start.executable.arg.line}" />
</then>
</if>
<if>
<and>
<equals arg1="${app.server.type}" arg2="tomcat" />
<equals arg1="${test.batch.code.coverage}" arg2="true" />
<not>
<contains string="${test.batch.name}" substring="functional" />
</not>
<not>
<os family="windows" />
</not>
</and>
<then>
<var name="test.batch.app.server.start.executable.arg.line" value="jacoco ${test.batch.app.server.start.executable.arg.line}" />
</then>
</if>
</sequential>
</macrodef>
<macrodef name="merge-test-results">
<sequential>
<antcall target="merge-test-results" />
<if>
<isset property="env.WORKSPACE" />
<then>
<mkdir dir="${env.WORKSPACE}/test-results" />
<copy
file="test-results/TESTS-TestSuites.xml"
tofile="${env.WORKSPACE}/test-results/TESTS-TestSuites.xml"
/>
<if>
<available file="${analytics.cloud.faro.dir}/osb-faro-functional-test/build/reports" />
<then>
<mkdir dir="${env.WORKSPACE}/test-results/cucumber/build/reports" />
<copy
todir="${env.WORKSPACE}/test-results/cucumber/build/reports"
>
<fileset
dir="${analytics.cloud.faro.dir}/osb-faro-functional-test/build/reports"
/>
</copy>
</then>
</if>
<if>
<available file="${analytics.cloud.faro.dir}/osb-faro-functional-test/test-results/functional/screenshots" />
<then>
<mkdir dir="${env.WORKSPACE}/test-results/cucumber/screenshots" />
<copy
todir="${env.WORKSPACE}/test-results/cucumber/screenshots"
>
<fileset
dir="${analytics.cloud.faro.dir}/osb-faro-functional-test/test-results/functional/screenshots"
/>
</copy>
</then>
</if>
</then>
</if>
</sequential>
</macrodef>
<macrodef name="prepare-liferay-classes">
<attribute name="merged.jar" />
<attribute name="portal.bundle.dir" />
<sequential>
<var name="merged-classes" value="${project.dir}/jacoco/merged-classes" />
<delete dir="${merged-classes}" />
<mkdir dir="${merged-classes}" />
<unzip
dest="${merged-classes}"
>
<patternset>
<include name="**/com/liferay/**" />
</patternset>
<fileset
dir="@{portal.bundle.dir}"
>
<include name="**/*.jar" />
<include name="**/*.war" />
</fileset>
</unzip>
<jar
destfile="@{merged.jar}"
update="true"
zip64Mode="always"
>
<fileset
dir="${merged-classes}"
>
<include name="**/*.class" />
</fileset>
</jar>
<delete dir="${merged-classes}" />
</sequential>
</macrodef>
<macrodef name="prepare-release-test-environment">
<attribute default="tomcat" name="app.server.type" />
<attribute default="true" name="setup.testable.jboss" />
<attribute default="true" name="setup.testable.tomcat" />
<attribute default="" name="test.build.fix.pack.zip.url" />
<attribute default="" name="test.fix.pack.base.url" />
<attribute default="" name="test.license.xml.url" />
<attribute default="" name="test.plugins.war.zip.url" />
<attribute default="" name="test.portal.bundle.dependencies.zip.url" />
<attribute default="" name="test.portal.bundle.elasticsearch.zip.url" />
<attribute default="" name="test.portal.bundle.osgi.zip.url" />
<attribute default="" name="test.portal.bundle.tools.zip.url" />
<attribute default="" name="test.portal.bundle.war.url" />
<attribute name="test.portal.bundle.zip.url" />
<attribute name="test.sql.zip.url" />
<sequential>
<propertycopy from="app.server.@{app.server.type}.bin.dir" name="test.app.server.bin.dir" />
<antcall inheritAll="false" target="prepare-test-bundle">
<param if:set="test.class" name="test.class" value="${test.class}" />
<param name="app.server.type" value="@{app.server.type}" />
<param name="test.app.server.bin.dir" value="${test.app.server.bin.dir}" />
<param name="test.build.bundle.zip.url" value="@{test.portal.bundle.zip.url}" />
<param name="test.build.fix.pack.zip.url" value="@{test.build.fix.pack.zip.url}" />
<param name="test.build.portal.dependencies.zip.url" value="@{test.portal.bundle.dependencies.zip.url}" />
<param name="test.build.portal.elasticsearch.zip.url" value="@{test.portal.bundle.elasticsearch.zip.url}" />
<param name="test.build.portal.osgi.zip.url" value="@{test.portal.bundle.osgi.zip.url}" />
<param name="test.build.portal.tools.zip.url" value="@{test.portal.bundle.tools.zip.url}" />
<param name="test.build.portal.war.url" value="@{test.portal.bundle.war.url}" />
<param name="test.fix.pack.base.url" value="@{test.fix.pack.base.url}" />
</antcall>
<if>
<matches pattern="https?://" string="@{test.license.xml.url}" />
<then>
<var name="test.build.license.xml.zip.url" unset="true" />
<property name="test.build.license.xml.zip.url" value="@{test.license.xml.url}" />
<echo append="true" file="test.${env.HOSTNAME}.properties"><![CDATA[${line.separator}test.build.license.xml.zip.url=@{test.license.xml.url}]]></echo>
</then>
</if>
<if>
<not>
<equals arg1="${test.deploy.license}" arg2="false" />
</not>
<then>
<antcall target="deploy-license-xml" />
</then>
</if>
<antcall target="deploy-sql-zip">
<param name="test.sql.zip.url" value="@{test.sql.zip.url}" />
</antcall>
<antcall inheritAll="false" target="setup-libs" />
<antcall inheritAll="false" target="setup-sdk" />
<antcall inheritAll="false" target="setup-yarn" />
<if>
<and>
<equals arg1="@{app.server.type}" arg2="jboss" />
<equals arg1="@{setup.testable.jboss}" arg2="true" />
</and>
<then>
<setup-testable-jboss />
</then>
<elseif>
<and>
<equals arg1="@{app.server.type}" arg2="tomcat" />
<equals arg1="@{setup.testable.tomcat}" arg2="true" />
</and>
<then>
<setup-test-batch-testable-tomcat
setup.proxy="@{setup.proxy}"
test.portal.bundle.version="${test.portal.bundle.version}"
/>
</then>
</elseif>
</if>
<if>
<matches pattern="https?://" string="@{test.plugins.war.zip.url}" />
<then>
<mirrors-get
dest="plugins.war.zip"
src="@{test.plugins.war.zip.url}"
/>
<unzip
dest="."
src="plugins.war.zip"
>
<mapper>
<globmapper
from="plugins/*"
to="plugins/marketplace/*"
/>
</mapper>
</unzip>
<delete file="plugins.war.zip" />
</then>
</if>
</sequential>
</macrodef>
<macrodef name="prepare-suite-search-engine">
<sequential>
<propertycopy from="search.engine[${env.CI_TEST_SUITE}]" name="suite.search.engine" silent="true" />
<if>
<contains string="${suite.search.engine}" substring="remote-elasticsearch" />
<then>
<ant antfile="build-test-elasticsearch7.xml" target="start-elasticsearch" />
</then>
</if>
<property name="test.batch.name" unless:set="test.batch.name" value="${env.TEST_BATCH_NAME}" />
<if>
<equals arg1="${suite.search.engine}" arg2="solr" />
<then>
<ant antfile="build-test-solr.xml" target="start-solr" />
<if>
<contains string="${test.batch.name}" substring="unit" />
<then>
<property name="run.solr.unit.tests" value="true" />
</then>
</if>
</then>
</if>
<if>
<contains string="${suite.search.engine}" substring="opensearch2" />
<then>
<ant antfile="build-test-opensearch2.xml" target="start-opensearch" />
<if>
<contains string="${test.batch.name}" substring="unit" />
<then>
<property name="run.opensearch2.unit.tests" value="true" />
</then>
</if>
</then>
</if>
</sequential>
</macrodef>
<macrodef name="prepare-test-build">
<sequential>
<trycatch property="exception.message">
<try>
<antcall target="setup-libs" />
<antcall target="prepare-test-build">
<param name="test.class.groups.size" value="${test.batch.size}" />
<param name="test.plugin.groups.size" value="${test.batch.size}" />
</antcall>
</try>
<catch>
<echo>${exception.message}</echo>
<fail message="Unable to prepare test build." />
</catch>
</trycatch>
</sequential>
</macrodef>
<macrodef name="prepare-test-build-custom">
<sequential>
<trycatch property="exception.message">