forked from liferay/liferay-portal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-test-elasticsearch7.xml
1437 lines (1233 loc) · 48.3 KB
/
build-test-elasticsearch7.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-elasticsearch" xmlns:antelope="antlib:ise.antelope.tasks" xmlns:if="ant:if" xmlns:unless="ant:unless">
<import file="build-test.xml" />
<get-testcase-property if:set="env.JENKINS_HOME" property.name="elastic.override.version" />
<propertycopy from="suite.elastic.version[${env.CI_TEST_SUITE}]" name="suite.elastic.version" silent="true" />
<if>
<isset property="elastic.override.version" />
<then>
<property name="elasticsearch.version" value="${elastic.override.version}" />
</then>
<elseif>
<isset property="suite.elastic.version" />
<then>
<property name="elasticsearch.version" value="${suite.elastic.version}" />
</then>
</elseif>
<else>
<property name="elasticsearch.version" value="7.12.0" />
</else>
</if>
<property name="elastic.kibana.dir" value="${app.server.parent.dir}/kibana-${elasticsearch.version}" />
<property name="elastic.kibana.tar.name.linux" value="kibana-${elasticsearch.version}-linux-x86_64.tar.gz" />
<property name="elastic.kibana.tar.name.mac" value="kibana-${elasticsearch.version}-darwin-x86_64.tar.gz" />
<property name="elastic.kibana.tar.url.linux" value="https://artifacts.elastic.co/downloads/kibana/${elastic.kibana.tar.name.linux}" />
<property name="elastic.kibana.tar.url.mac" value="https://artifacts.elastic.co/downloads/kibana/${elastic.kibana.tar.name.mac}" />
<property name="elastic.kibana.zip.name.windows" value="kibana-${elasticsearch.version}-windows-x86_64.zip" />
<property name="elastic.kibana.zip.url.windows" value="https://artifacts.elastic.co/downloads/kibana/${elastic.kibana.zip.name.windows}" />
<property name="elasticsearch.dir" value="${app.server.parent.dir}/elasticsearch-${elasticsearch.version}" />
<property name="elasticsearch.analysis-icu.zip.name" value="analysis-icu-${elasticsearch.version}.zip" />
<property name="elasticsearch.analysis-icu.zip.url" value="https://artifacts.elastic.co/downloads/elasticsearch-plugins/analysis-icu/${elasticsearch.analysis-icu.zip.name}" />
<property name="elasticsearch.analysis-kuromoji.zip.name" value="analysis-kuromoji-${elasticsearch.version}.zip" />
<property name="elasticsearch.analysis-kuromoji.zip.url" value="https://artifacts.elastic.co/downloads/elasticsearch-plugins/analysis-kuromoji/${elasticsearch.analysis-kuromoji.zip.name}" />
<property name="elasticsearch.analysis-smartcn.zip.name" value="analysis-smartcn-${elasticsearch.version}.zip" />
<property name="elasticsearch.analysis-smartcn.zip.url" value="https://artifacts.elastic.co/downloads/elasticsearch-plugins/analysis-smartcn/${elasticsearch.analysis-smartcn.zip.name}" />
<property name="elasticsearch.analysis-stempel.zip.name" value="analysis-stempel-${elasticsearch.version}.zip" />
<property name="elasticsearch.analysis-stempel.zip.url" value="https://artifacts.elastic.co/downloads/elasticsearch-plugins/analysis-stempel/${elasticsearch.analysis-stempel.zip.name}" />
<property name="elasticsearch.tar.name.linux" value="elasticsearch-${elasticsearch.version}-linux-x86_64.tar.gz" />
<property name="elasticsearch.tar.name.mac" value="elasticsearch-${elasticsearch.version}-darwin-x86_64.tar.gz" />
<property name="elasticsearch.zip.name.windows" value="elasticsearch-${elasticsearch.version}-windows-x86_64.zip" />
<property name="elasticsearch.tar.url.linux" value="https://artifacts.elastic.co/downloads/elasticsearch/${elasticsearch.tar.name.linux}" />
<property name="elasticsearch.tar.url.mac" value="https://artifacts.elastic.co/downloads/elasticsearch/${elasticsearch.tar.name.mac}" />
<property name="elasticsearch.zip.url.windows" value="https://artifacts.elastic.co/downloads/elasticsearch/${elasticsearch.zip.name.windows}" />
<property name="elasticsearch.sidecar.version" value="7.9.0" />
<property name="elasticsearch.sidecar.analysis-icu.zip.url" value="https://artifacts.elastic.co/downloads/elasticsearch-plugins/analysis-icu/analysis-icu-${elasticsearch.sidecar.version}.zip" />
<property name="elasticsearch.sidecar.analysis-kuromoji.zip.url" value="https://artifacts.elastic.co/downloads/elasticsearch-plugins/analysis-kuromoji/analysis-kuromoji-${elasticsearch.sidecar.version}.zip" />
<property name="elasticsearch.sidecar.analysis-smartcn.zip.url" value="https://artifacts.elastic.co/downloads/elasticsearch-plugins/analysis-smartcn/analysis-smartcn-${elasticsearch.sidecar.version}.zip" />
<property name="elasticsearch.sidecar.analysis-stempel.zip.url" value="https://artifacts.elastic.co/downloads/elasticsearch-plugins/analysis-stempel/analysis-stempel-${elasticsearch.sidecar.version}.zip" />
<property name="elasticsearch.sidecar.no.jdk.tar.url" value="https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-oss-${elasticsearch.sidecar.version}-no-jdk-linux-x86_64.tar.gz" />
<macrodef name="check-elasticsearch-security">
<attribute name="authentication.type" />
<sequential>
<if>
<equals arg1="@{authentication.type}" arg2="basic" />
<then>
<exec executable="curl" outputproperty="curl.elasticsearch.check.output">
<arg value="-ku" />
<arg value="elastic:${elastic.xpack.elastic.user.password}" />
<arg value="https://localhost:9200" />
</exec>
</then>
<elseif>
<equals arg1="@{authentication.type}" arg2="PKI" />
<then>
<exec executable="curl" outputproperty="curl.elasticsearch.check.output">
<arg value="--cert" />
<arg value="${elasticsearch.dir}/config/certs/elastic-certificates.crt" />
<arg value="--key" />
<arg value="${elasticsearch.dir}/config/certs/elastic-certificates.key" />
<arg value="-k" />
<arg value="https://localhost:9200" />
</exec>
</then>
</elseif>
</if>
<echo>${curl.elasticsearch.check.output}</echo>
<fail message="Unable to reach Elasticsearch server using @{authentication.type} authentication">
<condition>
<not>
<contains string="${curl.elasticsearch.check.output}" substring="cluster_name" />
</not>
</condition>
</fail>
</sequential>
</macrodef>
<macrodef name="configure-elasticsearch-jdk11">
<sequential>
<replace
file="${elasticsearch.dir}/bin/elasticsearch-env"
>
<replacetoken><![CDATA[JAVA="$JAVA_HOME/bin/java"]]></replacetoken>
<replacevalue><![CDATA[JAVA="/opt/java/jdk11/bin/java"]]></replacevalue>
</replace>
</sequential>
</macrodef>
<macrodef name="configure-elasticsearch-ltr-properties">
<sequential>
<echo append="true" file="${elasticsearch.dir}/config/elasticsearch.yml">${line.separator}xpack.ml.enabled: false
path.repo: ${liferay.home}/data/elasticsearch7/repo</echo>
</sequential>
</macrodef>
<macrodef name="configure-elasticsearch-monitoring-property">
<sequential>
<echo append="true" file="${elasticsearch.dir}/config/elasticsearch.yml">${line.separator}xpack.monitoring.collection.enabled: true</echo>
</sequential>
</macrodef>
<macrodef name="configure-elasticsearch-properties">
<sequential>
<echo append="true" file="${elasticsearch.dir}/config/elasticsearch.yml">${line.separator}bootstrap.system_call_filter: false
cluster.name: LiferayElasticsearchCluster</echo>
</sequential>
</macrodef>
<macrodef name="configure-elasticsearch-second-cluster-properties">
<sequential>
<echo file="${elasticsearch.dir}-2/config/elasticsearch.yml">${line.separator}bootstrap.system_call_filter: false
cluster.name: LiferayElasticsearchClusterTwo
http.port: 9202
transport.port: 9500-9600</echo>
</sequential>
</macrodef>
<macrodef name="configure-elasticsearch-x-pack-pki-security-properties">
<sequential>
<echo append="true" file="${elasticsearch.dir}/config/elasticsearch.yml">${line.separator}xpack.security.enabled: true
xpack.security.http.ssl.certificate: certs/elastic-certificates.crt
xpack.security.http.ssl.certificate_authorities : [ "certs/ca.crt" ]
xpack.security.http.ssl.client_authentication: required
xpack.security.http.ssl.enabled: true
xpack.security.http.ssl.key: certs/elastic-certificates.key
xpack.security.http.ssl.verification_mode: certificate
xpack.security.transport.ssl.certificate: certs/elastic-certificates.crt
xpack.security.transport.ssl.certificate_authorities : [ "certs/ca.crt" ]
xpack.security.transport.ssl.client_authentication: required
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.key: certs/elastic-certificates.key
xpack.security.transport.ssl.verification_mode: certificate
xpack:
security:
authc:
realms:
pki:
pki1:
order: 0</echo>
<echo append="true" file="${elasticsearch.dir}/config/role_mapping.yml">${line.separator}superuser:
- "CN=liferay.com,OU=Search,DC=liferay,DC=com"
kibana_system:
- "CN=liferay.com,OU=Search,DC=liferay,DC=com"</echo>
</sequential>
</macrodef>
<macrodef name="configure-elasticsearch-x-pack-security-properties">
<sequential>
<echo append="true" file="${elasticsearch.dir}/config/elasticsearch.yml">${line.separator}xpack.security.enabled: true
xpack.security.http.ssl.enabled: true
xpack.security.http.ssl.keystore.path: certs/elastic-certificates.p12
xpack.security.http.ssl.truststore.path: certs/elastic-certificates.p12
xpack.security.transport.ssl.certificate: certs/elastic-certificates.crt
xpack.security.transport.ssl.certificate_authorities: [ "certs/ca.crt" ]
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.key: certs/elastic-certificates.key
xpack.security.transport.ssl.verification_mode: certificate</echo>
</sequential>
</macrodef>
<macrodef name="configure-kibana-properties">
<sequential>
<echo append="true" file="${elastic.kibana.dir}/config/kibana.yml">
elasticsearch.hosts: "http://localhost:9200"
pid.file: ${elastic.kibana.dir}/bin/pid-kibana
server.basePath: "/o/portal-search-elasticsearch-monitoring/monitoring-proxy"
server.rewriteBasePath: false</echo>
</sequential>
</macrodef>
<macrodef name="configure-kibana-x-pack-security-properties">
<sequential>
<replace
file="${elastic.kibana.dir}/config/kibana.yml"
>
<replacetoken><![CDATA[elasticsearch.hosts: "http://localhost:9200"]]></replacetoken>
<replacevalue><![CDATA[elasticsearch.hosts: "https://localhost:9200"]]></replacevalue>
</replace>
<echo append="true" file="${elastic.kibana.dir}/config/kibana.yml">
elasticsearch.ssl.certificateAuthorities: [ "${elasticsearch.dir}/config/certs/ca.crt" ]
server.ssl.certificate: ${elasticsearch.dir}/config/certs/elastic-certificates.crt
server.ssl.enabled: true
server.ssl.key: ${elasticsearch.dir}/config/certs/elastic-certificates.key
xpack.security.encryptionKey: "xsomethingxatxleastx32xcharactersx"
xpack.security.sessionTimeout: 600000</echo>
<if>
<equals arg1="${elastic.pki.authentication.enabled}" arg2="true" />
<then>
<echo append="true" file="${elastic.kibana.dir}/config/kibana.yml">
elasticsearch.ssl.alwaysPresentCertificate: true
elasticsearch.ssl.certificate: ${elasticsearch.dir}/config/certs/elastic-certificates.crt
elasticsearch.ssl.key: ${elasticsearch.dir}/config/certs/elastic-certificates.key
elasticsearch.ssl.verificationMode: certificate
server.ssl.certificateAuthorities: [ "${elasticsearch.dir}/config/certs/ca.crt" ]</echo>
</then>
<else>
<echo append="true" file="${elastic.kibana.dir}/config/kibana.yml">
elasticsearch.password: "${elastic.xpack.elastic.user.password}"
elasticsearch.username: "elastic"</echo>
</else>
</if>
<get-testcase-property if:set="env.JENKINS_HOME" property.name="elasticsearch.jdk11.enabled" />
<echo append="true" file="${elastic.kibana.dir}/config/node.options" if:true="${elasticsearch.jdk11.enabled}">${line.separator}--tls-max-v1.2</echo>
</sequential>
</macrodef>
<macrodef name="configure-portal-ccr-osgi-properties">
<sequential>
<replaceregexp
file="${liferay.home}/osgi/configs/com.liferay.portal.search.elasticsearch7.configuration.ElasticsearchConfiguration.config"
match="(?<=logExceptionsOnly=B?")false"
replace="true"
/>
<configure-portal-second-connection-osgi-properties connection.name="localcluster" />
</sequential>
</macrodef>
<macrodef name="configure-portal-remote-elasticsearch-osgi-properties">
<sequential>
<echo append="true" file="${liferay.home}/osgi/configs/com.liferay.portal.search.elasticsearch7.configuration.ElasticsearchConfiguration.config">${line.separator}productionModeEnabled="true"</echo>
</sequential>
</macrodef>
<macrodef name="configure-portal-second-connection-osgi-properties">
<attribute name="connection.name" />
<sequential>
<echo file="${liferay.home}/osgi/configs/com.liferay.portal.search.elasticsearch7.configuration.ElasticsearchConnectionConfiguration~@{connection.name}.config">active="true"
connectionId="@{connection.name}"
networkHostAddresses=["http://localhost:9202"]</echo>
</sequential>
</macrodef>
<macrodef name="configure-portal-x-pack-osgi-properties">
<sequential>
<echo append="true" file="${liferay.home}/osgi/configs/com.liferay.portal.search.elasticsearch7.configuration.ElasticsearchConfiguration.config">${line.separator}remoteClusterConnectionId="xpack"</echo>
<propertyregex
defaultValue="${elastic.xpack.elastic.user.password}"
input="${elastic.xpack.elastic.user.password}"
override="true"
property="osgi.config.elastic.user.password"
regexp="="
replace="\\\\="
/>
<echo file="${liferay.home}/osgi/configs/com.liferay.portal.search.elasticsearch.monitoring.web.internal.configuration.MonitoringConfiguration.config">kibanaPassword="${osgi.config.elastic.user.password}"
kibanaURL="https://localhost:5601"
proxyServletLogEnable="true"</echo>
<echo file="${liferay.home}/osgi/configs/com.liferay.portal.search.elasticsearch7.configuration.ElasticsearchConnectionConfiguration~xpack.config">active="true"
authenticationEnabled="true"
connectionId="xpack"
httpSSLEnabled="true"
networkHostAddresses=["https://localhost:9200"]
password="${osgi.config.elastic.user.password}"
truststorePassword="liferay"
truststorePath="${elasticsearch.dir}/config/certs/elastic-certificates.p12"
truststoreType="pkcs12"
username="elastic"</echo>
</sequential>
</macrodef>
<macrodef name="configure-portal-x-pack-pki-osgi-properties">
<sequential>
<echo append="true" file="${liferay.home}/osgi/configs/com.liferay.portal.search.elasticsearch7.configuration.ElasticsearchConfiguration.config">${line.separator}remoteClusterConnectionId="pki"</echo>
<propertyregex
defaultValue="${elastic.xpack.elastic.user.password}"
input="${elastic.xpack.elastic.user.password}"
override="true"
property="osgi.config.elastic.user.password"
regexp="="
replace="\\\\="
/>
<echo file="${liferay.home}/osgi/configs/com.liferay.portal.search.elasticsearch.monitoring.web.internal.configuration.MonitoringConfiguration.config">kibanaPassword="${osgi.config.elastic.user.password}"
kibanaURL="https://localhost:5601"
proxyServletLogEnable="true"</echo>
<echo file="${liferay.home}/osgi/configs/com.liferay.portal.search.elasticsearch7.configuration.ElasticsearchConnectionConfiguration~pki.config">active="true"
authenticationEnabled="false"
connectionId="pki"
httpSSLEnabled="true"
networkHostAddresses=["https://localhost:9200"]
truststorePassword="liferay"
truststorePath="${elasticsearch.dir}/config/certs/elastic-certificates.p12"
truststoreType="pkcs12"</echo>
</sequential>
</macrodef>
<macrodef name="configure-portal-x-pack-security-truststore">
<sequential>
<if>
<equals arg1="${app.server.type}" arg2="tomcat" />
<then>
<echo append="true" file="${app.server.tomcat.dir}/bin/setenv.bat">
${line.separator}CATALINA_OPTS="${CATALINA_OPTS} -Djavax.net.ssl.trustStore=${elasticsearch.dir}/config/certs/elastic-certificates.jks -Djavax.net.ssl.trustStorePassword=liferay"</echo>
<echo append="true" file="${app.server.tomcat.dir}/bin/setenv.sh">
${line.separator}CATALINA_OPTS="${CATALINA_OPTS} -Djavax.net.ssl.trustStore=${elasticsearch.dir}/config/certs/elastic-certificates.jks -Djavax.net.ssl.trustStorePassword=liferay"</echo>
</then>
<else>
<echo>Set setenv.bat and setenv.sh manually before attempting to connect with portal.</echo>
</else>
</if>
</sequential>
</macrodef>
<macrodef name="generate-x-pack-security-certificates">
<sequential>
<exec dir="${elasticsearch.dir}/bin" executable="/bin/bash" osfamily="unix">
<arg value="-c" />
<arg value="./elasticsearch-certutil ca --pem --out ${elasticsearch.dir}/bin/elastic-stack-ca.zip" />
</exec>
<exec dir="${elasticsearch.dir}/bin" executable="cmd" osfamily="windows">
<arg value="/c" />
<arg value="elasticsearch-certutil ca --pem --out ${elasticsearch.dir}/bin/elastic-stack-ca.zip" />
</exec>
<unzip
dest="${elasticsearch.dir}/bin"
src="${elasticsearch.dir}/bin/elastic-stack-ca.zip"
/>
<exec dir="${elasticsearch.dir}/bin" executable="/bin/bash" osfamily="unix">
<arg value="-c" />
<arg value="./elasticsearch-certutil cert --ca-cert ${elasticsearch.dir}/bin/ca/ca.crt --ca-key ${elasticsearch.dir}/bin/ca/ca.key --pem --ip 127.0.0.1 --dns localhost --name "CN=liferay.com,OU=Search,DC=liferay,DC=com" --out ${elasticsearch.dir}/bin/elastic-certificates.zip" />
</exec>
<exec dir="${elasticsearch.dir}/bin" executable="cmd" osfamily="windows">
<arg value="/c" />
<arg value="elasticsearch-certutil cert --ca-cert ${elasticsearch.dir}/bin/ca/ca.crt --ca-key ${elasticsearch.dir}/bin/ca/ca.key --pem --ip 127.0.0.1 --dns localhost --name "CN=liferay.com,OU=Search,DC=liferay,DC=com" --out ${elasticsearch.dir}/bin/elastic-certificates.zip" />
</exec>
<unzip
dest="${elasticsearch.dir}/bin"
src="${elasticsearch.dir}/bin/elastic-certificates.zip"
/>
<move
todir="${elasticsearch.dir}/config/certs"
>
<fileset
dir="${elasticsearch.dir}/bin/CN=liferay.com,OU=Search,DC=liferay,DC=com"
/>
<mapper
from="CN=liferay.com,OU=Search,DC=liferay,DC=com.*"
to="elastic-certificates.*"
type="glob"
/>
</move>
<move
todir="${elasticsearch.dir}/config/certs"
>
<fileset
dir="${elasticsearch.dir}/bin/ca"
/>
</move>
<delete file="${elasticsearch.dir}/bin/elastic-stack-ca.zip" />
<delete file="${elasticsearch.dir}/bin/elastic-certificates.zip" />
<delete dir="${elasticsearch.dir}/bin/CN=liferay.com,OU=Search,DC=liferay,DC=com" />
</sequential>
</macrodef>
<macrodef name="generate-x-pack-security-truststores">
<sequential>
<if>
<os family="unix" />
<then>
<exec dir="${elasticsearch.dir}/bin" executable="/bin/bash">
<arg value="-c" />
<arg value="./elasticsearch-certutil cert --ca-cert ${elasticsearch.dir}/config/certs/ca.crt --ca-key ${elasticsearch.dir}/config/certs/ca.key --pass liferay --ip 127.0.0.1 --dns localhost --name "CN=liferay.com,OU=Search,DC=liferay,DC=com" --out ${elasticsearch.dir}/config/certs/elastic-certificates.p12" />
</exec>
<exec dir="${elasticsearch.dir}/bin" executable="/bin/bash">
<arg value="-c" />
<arg value="keytool -importkeystore -deststorepass liferay -destkeystore ${elasticsearch.dir}/config/certs/elastic-certificates.jks -srckeystore ${elasticsearch.dir}/config/certs/elastic-certificates.p12 -srcstoretype PKCS12 -srcstorepass liferay" />
</exec>
<exec dir="${elasticsearch.dir}/bin" executable="/bin/bash">
<arg value="-c" />
<arg value="./elasticsearch-keystore create" />
</exec>
<exec dir="${elasticsearch.dir}/bin" executable="/bin/bash" inputstring="liferay
">
<arg value="-c" />
<arg value="./elasticsearch-keystore add xpack.security.http.ssl.keystore.secure_password" />
</exec>
<exec dir="${elasticsearch.dir}/bin" executable="/bin/bash" inputstring="liferay
">
<arg value="-c" />
<arg value="./elasticsearch-keystore add xpack.security.http.ssl.truststore.secure_password" />
</exec>
</then>
<elseif>
<os family="windows" />
<then>
<exec dir="${elasticsearch.dir}/bin" executable="cmd">
<arg value="/c" />
<arg value="elasticsearch-certutil cert --ca-cert ${elasticsearch.dir}/config/certs/ca.crt --ca-key ${elasticsearch.dir}/config/certs/ca.key --pass liferay --ip 127.0.0.1 --dns localhost --name "CN=liferay.com,OU=Search,DC=liferay,DC=com" --out ${elasticsearch.dir}/config/certs/elastic-certificates.p12" />
</exec>
<exec dir="${elasticsearch.dir}/bin" executable="cmd">
<arg value="/c" />
<arg value="keytool -importkeystore -deststorepass liferay -destkeystore ${elasticsearch.dir}/config/certs/elastic-certificates.jks -srckeystore ${elasticsearch.dir}/config/certs/elastic-certificates.p12 -srcstoretype PKCS12 -srcstorepass liferay" />
</exec>
<exec dir="${elasticsearch.dir}/bin" executable="cmd">
<arg value="/c" />
<arg value="elasticsearch-keystore create" />
</exec>
<exec dir="${elasticsearch.dir}/bin" executable="cmd" inputstring="liferay
">
<arg value="/c" />
<arg value="elasticsearch-keystore add xpack.security.http.ssl.keystore.secure_password" />
</exec>
<exec dir="${elasticsearch.dir}/bin" executable="cmd" inputstring="liferay
">
<arg value="/c" />
<arg value="elasticsearch-keystore add xpack.security.http.ssl.truststore.secure_password" />
</exec>
</then>
</elseif>
</if>
</sequential>
</macrodef>
<macrodef name="prepare-additional-elasticsearch-bundles">
<attribute name="total.bundles" />
<sequential>
<delete dir="${elasticsearch.dir}-1" />
<move
file="${elasticsearch.dir}"
tofile="${elasticsearch.dir}-1"
/>
<var name="elasticsearch.bundle.copy.count" value="0" />
<math
datatype="int"
operand1="@{total.bundles}"
operand2="1"
operation="-"
result="elasticsearch.bundle.copy.count"
/>
<var name="elasticsearch.bundle.counter" value="1" />
<antelope:repeat count="${elasticsearch.bundle.copy.count}">
<math
datatype="int"
operand1="${elasticsearch.bundle.counter}"
operand2="1"
operation="+"
result="elasticsearch.bundle.counter"
/>
<delete dir="${elasticsearch.dir}-${elasticsearch.bundle.counter}" />
<copy
todir="${elasticsearch.dir}-${elasticsearch.bundle.counter}"
>
<fileset
dir="${elasticsearch.dir}-1"
/>
</copy>
</antelope:repeat>
</sequential>
</macrodef>
<macrodef name="prepare-elasticsearch-analyzers">
<sequential>
<lstopwatch action="start" name="prepare.elasticsearch.analyzers" />
<if>
<not>
<available file="${elasticsearch.dir}/${elasticsearch.analysis-icu.zip.name}" />
</not>
<then>
<mirrors-get
dest="${elasticsearch.dir}/${elasticsearch.analysis-icu.zip.name}"
skipChecksum="true"
src="${elasticsearch.analysis-icu.zip.url}"
/>
</then>
</if>
<if>
<not>
<available file="${elasticsearch.dir}/${elasticsearch.analysis-kuromoji.zip.name}" />
</not>
<then>
<mirrors-get
dest="${elasticsearch.dir}/${elasticsearch.analysis-kuromoji.zip.name}"
skipChecksum="true"
src="${elasticsearch.analysis-kuromoji.zip.url}"
/>
</then>
</if>
<if>
<not>
<available file="${elasticsearch.dir}/${elasticsearch.analysis-smartcn.zip.name}" />
</not>
<then>
<mirrors-get
dest="${elasticsearch.dir}/${elasticsearch.analysis-smartcn.zip.name}"
skipChecksum="true"
src="${elasticsearch.analysis-smartcn.zip.url}"
/>
</then>
</if>
<if>
<not>
<available file="${elasticsearch.dir}/${elasticsearch.analysis-stempel.zip.name}" />
</not>
<then>
<mirrors-get
dest="${elasticsearch.dir}/${elasticsearch.analysis-stempel.zip.name}"
skipChecksum="true"
src="${elasticsearch.analysis-stempel.zip.url}"
/>
</then>
</if>
<if>
<os family="unix" />
<then>
<for list="${elasticsearch.analysis-icu.zip.name},${elasticsearch.analysis-kuromoji.zip.name},${elasticsearch.analysis-smartcn.zip.name},${elasticsearch.analysis-stempel.zip.name}" param="elasticsearch.plugin.name">
<sequential>
<exec dir="${elasticsearch.dir}/bin" executable="/bin/bash">
<arg value="-c" />
<arg value="./elasticsearch-plugin install file:///${elasticsearch.dir}/@{elasticsearch.plugin.name}" />
</exec>
</sequential>
</for>
</then>
<elseif>
<os family="windows" />
<then>
<for list="${elasticsearch.analysis-icu.zip.name},${elasticsearch.analysis-kuromoji.zip.name},${elasticsearch.analysis-smartcn.zip.name},${elasticsearch.analysis-stempel.zip.name}" param="elasticsearch.plugin.name">
<sequential>
<exec dir="${elasticsearch.dir}/bin" executable="cmd">
<arg value="/c" />
<arg value="elasticsearch-plugin install file:///${elasticsearch.dir}/@{elasticsearch.plugin.name}" />
</exec>
</sequential>
</for>
</then>
</elseif>
</if>
<lstopwatch action="total" name="prepare.elasticsearch.analyzers" />
</sequential>
</macrodef>
<macrodef name="prepare-elasticsearch-ltr">
<sequential>
<lstopwatch action="start" name="prepare.elasticsearch.ltr" />
<property name="elasticsearch.ltr.zip.name" value="ltr-plugin-v1.5.0-es${elasticsearch.version}.zip" />
<if>
<not>
<available file="${elasticsearch.dir}/${elasticsearch.ltr.zip.name}" />
</not>
<then>
<mirrors-get
dest="${elasticsearch.dir}/${elasticsearch.ltr.zip.name}"
skipChecksum="true"
src="http://es-learn-to-rank.labs.o19s.com/${elasticsearch.ltr.zip.name}"
/>
</then>
</if>
<exec dir="${elasticsearch.dir}/bin" executable="/bin/bash" inputstring="y
" osfamily="unix">
<arg value="-c" />
<arg value="./elasticsearch-plugin install file:///${elasticsearch.dir}/${elasticsearch.ltr.zip.name}" />
</exec>
<exec dir="${elasticsearch.dir}/bin" executable="cmd" inputstring="y
" osfamily="windows">
<arg value="/c" />
<arg value="elasticsearch-plugin install file:///${elasticsearch.dir}/${elasticsearch.ltr.zip.name}" />
</exec>
<lstopwatch action="total" name="prepare.elasticsearch.ltr" />
</sequential>
</macrodef>
<macrodef name="set-up-standard-elasticsearch">
<sequential>
<unzip-elasticsearch />
<prepare-elasticsearch-analyzers />
<configure-elasticsearch-properties />
<configure-portal-remote-elasticsearch-osgi-properties />
</sequential>
</macrodef>
<macrodef name="set-x-pack-user-passwords">
<sequential>
<exec dir="${elasticsearch.dir}/bin" executable="/bin/bash" osfamily="unix" outputproperty="elastic.xpack.user.passwords">
<arg value="-c" />
<arg value="./elasticsearch-setup-passwords auto --batch" />
</exec>
<exec dir="${elasticsearch.dir}/bin" executable="cmd" osfamily="windows" outputproperty="elastic.xpack.user.passwords">
<arg value="/c" />
<arg value="elasticsearch-setup-passwords auto --batch" />
</exec>
<propertyregex
input="${elastic.xpack.user.passwords}"
override="true"
property="elastic.xpack.elastic.user.password"
regexp="(PASSWORD elastic = )(\S*)"
select="\2"
/>
</sequential>
</macrodef>
<macrodef name="start-elastic-trial">
<attribute default="" name="authentication.type" />
<attribute default="9200" name="elasticsearch.port" />
<sequential>
<if>
<equals arg1="@{authentication.type}" arg2="basic" />
<then>
<exec executable="curl" outputproperty="curl.elastic.trial.output">
<arg value="-X POST" />
<arg value="https://localhost:@{elasticsearch.port}/_license/start_trial?acknowledge=true" />
<arg value="-ku" />
<arg value="elastic:${elastic.xpack.elastic.user.password}" />
</exec>
</then>
<elseif>
<equals arg1="@{authentication.type}" arg2="PKI" />
<then>
<exec executable="curl" outputproperty="curl.elastic.trial.output">
<arg value="-X POST" />
<arg value="https://localhost:@{elasticsearch.port}/_license/start_trial?acknowledge=true" />
<arg value="--cert" />
<arg value="${elasticsearch.dir}/config/certs/elastic-certificates.crt" />
<arg value="--key" />
<arg value="${elasticsearch.dir}/config/certs/elastic-certificates.key" />
<arg value="-ku" />
<arg value="elastic:${elastic.xpack.elastic.user.password}" />
</exec>
</then>
</elseif>
<else>
<exec executable="curl" outputproperty="curl.elastic.trial.output">
<arg value="-X POST" />
<arg value="http://localhost:@{elasticsearch.port}/_license/start_trial?acknowledge=true" />
</exec>
</else>
</if>
<echo>${curl.elastic.trial.output}</echo>
<if>
<contains string="${curl.elastic.trial.output}" substring=""trial_was_started":true" />
<then>
<echo>Trial license activated on Elasticsearch port @{elasticsearch.port}.</echo>
</then>
<else>
<fail>Trial license failed to activate on Elasticsearch port @{elasticsearch.port}.</fail>
</else>
</if>
</sequential>
</macrodef>
<macrodef name="start-elasticsearch-with-clustering">
<sequential>
<set-up-standard-elasticsearch />
<prepare-additional-elasticsearch-bundles total.bundles="${elasticsearch.cluster.size}" />
<var name="elasticsearch.node.number" value="1" />
<var name="elasticsearch.port.number" value="9200" />
<antelope:repeat count="${elasticsearch.cluster.size}">
<antcall target="start-elasticsearch-node">
<param name="elasticsearch.bundle.number" value="${elasticsearch.node.number}" />
<param name="elasticsearch.port" value="${elasticsearch.port.number}" />
</antcall>
<math
datatype="int"
operand1="${elasticsearch.node.number}"
operand2="1"
operation="+"
result="elasticsearch.node.number"
/>
<math
datatype="int"
operand1="${elasticsearch.port.number}"
operand2="1"
operation="+"
result="elasticsearch.port.number"
/>
</antelope:repeat>
</sequential>
</macrodef>
<macrodef name="start-elasticsearch-with-ltr">
<sequential>
<set-up-standard-elasticsearch />
<configure-elasticsearch-ltr-properties />
<prepare-elasticsearch-ltr />
<if>
<not>
<available file="${liferay.home}/data/elasticsearch7/repo" type="dir" />
</not>
<then>
<mkdir dir="${liferay.home}/data/elasticsearch7/repo" />
</then>
</if>
<chmod
maxparallel="10"
perm="a+rwx"
type="both"
>
<fileset
dir="${liferay.home}/data/elasticsearch7/repo"
/>
</chmod>
<antcall target="start-elasticsearch-node" />
</sequential>
</macrodef>
<macrodef name="start-elasticsearch-with-multiple-connections">
<sequential>
<set-up-standard-elasticsearch />
<prepare-additional-elasticsearch-bundles total.bundles="2" />
<configure-elasticsearch-second-cluster-properties />
<antcall target="start-elasticsearch-node">
<param name="elasticsearch.bundle.number" value="1" />
</antcall>
<antcall target="start-elasticsearch-node">
<param name="elasticsearch.bundle.number" value="2" />
<param name="elasticsearch.port" value="9202" />
</antcall>
<if>
<istrue value="${elasticsearch.ccr.enabled}" />
<then>
<start-elastic-trial />
<start-elastic-trial elasticsearch.port="9202" />
<configure-portal-ccr-osgi-properties />
</then>
<else>
<configure-portal-second-connection-osgi-properties connection.name="connection2" />
</else>
</if>
</sequential>
</macrodef>
<macrodef name="start-elasticsearch-with-xpack">
<sequential>
<set-up-standard-elasticsearch />
<generate-x-pack-security-certificates />
<generate-x-pack-security-truststores />
<configure-portal-x-pack-security-truststore />
<configure-elasticsearch-monitoring-property />
<if>
<equals arg1="${elastic.pki.authentication.enabled}" arg2="true" />
<then>
<configure-elasticsearch-x-pack-pki-security-properties />
</then>
<else>
<configure-elasticsearch-x-pack-security-properties />
</else>
</if>
<get-testcase-property if:set="env.JENKINS_HOME" property.name="elasticsearch.jdk11.enabled" />
<configure-elasticsearch-jdk11 if:true="${elasticsearch.jdk11.enabled}" />
<antcall target="start-elasticsearch-node" />
<set-x-pack-user-passwords />
<if>
<equals arg1="${elastic.pki.authentication.enabled}" arg2="true" />
<then>
<start-elastic-trial authentication.type="PKI" />
<check-elasticsearch-security authentication.type="PKI" />
<configure-portal-x-pack-pki-osgi-properties />
</then>
<else>
<start-elastic-trial authentication.type="basic" />
<check-elasticsearch-security authentication.type="basic" />
<configure-portal-x-pack-osgi-properties />
</else>
</if>
<antcall target="start-kibana" />
</sequential>
</macrodef>
<macrodef name="unzip-boston-dataset-index">
<sequential>
<property name="boston-dataset-index.zip.name" value="boston-dataset-index.zip" />
<if>
<not>
<available file="${liferay.home}/${boston-dataset-index.zip.name}" />
</not>
<then>
<mirrors-get
dest="${liferay.home}/${boston-dataset-index.zip.name}"
skipChecksum="true"
src="http://files.liferay.com/private/apps/elastic/elasticsearch/${boston-dataset-index.zip.name}"
/>
</then>
</if>
<unzip
dest="${liferay.home}/data/elasticsearch7/repo"
src="${liferay.home}/${boston-dataset-index.zip.name}"
/>
</sequential>
</macrodef>
<macrodef name="unzip-elasticsearch">
<sequential>
<delete dir="${elasticsearch.dir}" />
<if>
<os family="mac" />
<then>
<if>
<not>
<available file="${app.server.parent.dir}/${elasticsearch.tar.name.mac}" />
</not>
<then>
<mirrors-get
dest="${app.server.parent.dir}/${elasticsearch.tar.name.mac}"
skipChecksum="true"
src="${elasticsearch.tar.url.mac}"
/>
</then>
</if>
<untar
compression="gzip"
dest="${app.server.parent.dir}"
src="${app.server.parent.dir}/${elasticsearch.tar.name.mac}"
/>
</then>
</if>
<if>
<os family="unix" />
<then>
<if>
<not>
<available file="${app.server.parent.dir}/${elasticsearch.tar.name.linux}" />
</not>
<then>
<mirrors-get
dest="${app.server.parent.dir}/${elasticsearch.tar.name.linux}"
skipChecksum="true"
src="${elasticsearch.tar.url.linux}"
/>
</then>
</if>
<untar
compression="gzip"
dest="${app.server.parent.dir}"
src="${app.server.parent.dir}/${elasticsearch.tar.name.linux}"
/>
</then>
</if>
<if>
<os family="windows" />
<then>
<if>
<not>
<available file="${app.server.parent.dir}/${elasticsearch.zip.name.windows}" />
</not>
<then>
<mirrors-get
dest="${app.server.parent.dir}/${elasticsearch.zip.name.windows}"
skipChecksum="true"
src="${elasticsearch.zip.url.windows}"
/>
</then>
</if>
<unzip
dest="${app.server.parent.dir}"
src="${app.server.parent.dir}/${elasticsearch.zip.name.windows}"
/>
</then>
</if>
<chmod
maxparallel="10"
perm="a+rwx"
type="both"
>
<fileset
dir="${elasticsearch.dir}"
/>
</chmod>
</sequential>
</macrodef>
<macrodef name="unzip-kibana">
<sequential>
<delete dir="${elastic.kibana.dir}" />
<if>
<os family="mac" />
<then>
<if>
<not>
<available file="${app.server.parent.dir}/${elastic.kibana.tar.name.mac}" />
</not>
<then>
<mirrors-get
dest="${app.server.parent.dir}/${elastic.kibana.tar.name.mac}"
skipChecksum="true"
src="${elastic.kibana.tar.url.mac}"
/>
</then>
</if>
<exec dir="${app.server.parent.dir}" executable="/bin/bash">
<arg value="-c" />
<arg value="tar -zxf ${elastic.kibana.tar.name.mac}" />
</exec>
<move
file="${app.server.parent.dir}/kibana-${elasticsearch.version}-darwin-x86_64"
tofile="${elastic.kibana.dir}"
/>
</then>
</if>
<if>
<os family="unix" />
<then>