forked from liferay/liferay-portal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-test-elasticsearch7.xml
1110 lines (963 loc) · 36.7 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">
<import file="build-test.xml" />
<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
xpack.ml.enabled: false</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.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.http.ssl.certificate: certs/localhost/localhost.crt
xpack.security.http.ssl.certificate_authorities: [ "certs/ca/ca.crt" ]
xpack.security.http.ssl.key: certs/localhost/localhost.key</echo>
</sequential>
</macrodef>
<macrodef name="configure-elasticsearch7-ltr-test-properties">
<sequential>
<var name="elasticsearch.version" unset="true" />
<var name="elasticsearch.ltr-linear-regression-model.zip.name" unset="true" />
<var name="elasticsearch.ltr-linear-regression-model.zip.url" unset="true" />
<var name="elasticsearch.ltr.url" unset="true" />
<var name="elasticsearch.ltr.version" unset="true" />
<var name="elasticsearch.ltr.zip.nam" unset="true" />
<property name="elasticsearch.version" value="7.3.1" />
<property name="elasticsearch.ltr.version" value="1.1.2" />
<property name="elasticsearch.ltr-linear-regression-model.zip.name" value="ltr-linear-regression-model.zip" />
<property name="elasticsearch.ltr-linear-regression-model.zip.url" value="http://files.liferay.com/private/apps/elastic/elasticsearch/${elasticsearch.ltr-linear-regression-model.zip.name}" />
<property name="elasticsearch.ltr.zip.name" value="ltr-${elasticsearch.ltr.version}-es${elasticsearch.version}.zip" />
<property name="elasticsearch.ltr.url" value="http://es-learn-to-rank.labs.o19s.com/${elasticsearch.ltr.zip.name}" />
</sequential>
</macrodef>
<macrodef name="configure-elasticsearch7-test-properties">
<sequential>
<var name="elastic.kibana.dir" unset="true" />
<var name="elastic.kibana.tar.name.linux" unset="true" />
<var name="elastic.kibana.tar.name.mac" unset="true" />
<var name="elastic.kibana.tar.url.linux" unset="true" />
<var name="elastic.kibana.tar.url.mac" unset="true" />
<var name="elastic.kibana.zip.name.windows" unset="true" />
<var name="elastic.kibana.zip.url.windows" unset="true" />
<var name="elasticsearch.version" unset="true" />
<var name="elasticsearch.dir" unset="true" />
<var name="elasticsearch.analysis-icu.zip.name" unset="true" />
<var name="elasticsearch.analysis-icu.zip.url" unset="true" />
<var name="elasticsearch.analysis-kuromoji.zip.name" unset="true" />
<var name="elasticsearch.analysis-kuromoji.zip.url" unset="true" />
<var name="elasticsearch.analysis-smartcn.zip.name" unset="true" />
<var name="elasticsearch.analysis-smartcn.zip.url" unset="true" />
<var name="elasticsearch.analysis-stempel.zip.name" unset="true" />
<var name="elasticsearch.analysis-stempel.zip.url" unset="true" />
<property name="elasticsearch.version" value="7.3.1" />
<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}" />
</sequential>
</macrodef>
<macrodef name="configure-kibana-properties">
<sequential>
<echo append="true" file="${elastic.kibana.dir}/config/kibana.yml">${line.separator}elasticsearch.hosts: "http://localhost:9200"
pid.file: ${elastic.kibana.dir}/bin/pid-kibana
server.basePath: "/o/portal-search-elasticsearch-xpack-monitoring/xpack-monitoring-proxy"
server.rewriteBasePath: false</echo>
</sequential>
</macrodef>
<macrodef name="configure-kibana-x-pack-security-properties">
<sequential>
<echo append="true" file="${elastic.kibana.dir}/config/kibana.yml">${line.separator}elasticsearch.password: "${elastic.xpack.kibana.user.password}"
elasticsearch.ssl.certificateAuthorities: [ "${elasticsearch.dir}-1/config/certs/ca/ca.crt" ]
elasticsearch.username: "kibana"
server.ssl.certificate: ${elasticsearch.dir}-1/config/certs/localhost/localhost.crt
server.ssl.enabled: true
server.ssl.key: ${elasticsearch.dir}-1/config/certs/localhost/localhost.key
xpack.security.encryptionKey: "xsomethingxatxleastx32xcharactersx"
xpack.security.sessionTimeout: 600000</echo>
<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>
</sequential>
</macrodef>
<macrodef name="configure-portal-elasticsearch-osgi-properties">
<sequential>
<echo append="true" file="${liferay.home}/osgi/configs/com.liferay.portal.search.elasticsearch7.configuration.ElasticsearchConfiguration.config">${line.separator}operationMode="REMOTE"</echo>
</sequential>
</macrodef>
<macrodef name="configure-portal-x-pack-osgi-properties">
<sequential>
<propertyregex
defaultValue="${elastic.xpack.elastic.user.password}"
input="${elastic.xpack.elastic.user.password}"
override="true"
property="osgi.config.elastic.user.password"
regexp="="
replace="\\\\="
/>
<echo append="true" file="${liferay.home}/osgi/configs/com.liferay.portal.search.elasticsearch7.xpack.monitoring.web.internal.configuration.XPackMonitoringConfiguration.config">kibanaPassword="${osgi.config.elastic.user.password}"
kibanaURL="https://localhost:5601"
proxyServletLogEnable="true"</echo>
<echo append="true" file="${liferay.home}/osgi/configs/com.liferay.portal.search.elasticsearch7.xpack.security.internal.configuration.XPackSecurityConfiguration.config">certificateFormat="PEM"
password="${osgi.config.elastic.user.password}"
requiresAuthentication="true"
sslCertificateAuthoritiesPaths="${elasticsearch.dir}-1/config/certs/ca/ca.crt"
sslCertificatePath="${elasticsearch.dir}-1/config/certs/localhost/localhost.crt"
sslKeyPath="${elasticsearch.dir}-1/config/certs/localhost/localhost.key"
transportSSLEnabled="true"</echo>
</sequential>
</macrodef>
<macrodef name="configure-portal-x-pack-security-truststore">
<sequential>
<if>
<os family="unix" />
<then>
<exec dir="${elasticsearch.dir}-1/bin" executable="/bin/bash">
<arg value="-c" />
<arg value="./elasticsearch-certutil cert --ca-cert ${elasticsearch.dir}-1/config/certs/ca/ca.crt --ca-key ${elasticsearch.dir}-1/config/certs/ca/ca.key --pass liferay --ip 127.0.0.1 --dns localhost --name localhost --out ${elasticsearch.dir}-1/config/certs/localhost.p12" />
</exec>
<exec dir="${elasticsearch.dir}-1/bin" executable="/bin/bash">
<arg value="-c" />
<arg value="keytool -importkeystore -deststorepass liferay -destkeystore ${elasticsearch.dir}-1/config/certs/localhost.jks -srckeystore ${elasticsearch.dir}-1/config/certs/localhost.p12 -srcstoretype PKCS12 -srcstorepass liferay" />
</exec>
</then>
<elseif>
<os family="windows" />
<then>
<exec dir="${elasticsearch.dir}-1/bin" executable="cmd">
<arg value="/c" />
<arg value="elasticsearch-certutil cert --ca-cert ${elasticsearch.dir}-1/config/certs/ca/ca.crt --ca-key ${elasticsearch.dir}-1/config/certs/ca/ca.key --pass liferay --ip 127.0.0.1 --dns localhost --name localhost --out ${elasticsearch.dir}-1/config/certs/localhost.p12" />
</exec>
<exec dir="${elasticsearch.dir}-1/bin" executable="cmd">
<arg value="/c" />
<arg value="keytool -importkeystore -deststorepass liferay -destkeystore ${elasticsearch.dir}-1/config/certs/localhost.jks -srckeystore ${elasticsearch.dir}-1/config/certs/localhost.p12 -srcstoretype PKCS12 -srcstorepass liferay" />
</exec>
</then>
</elseif>
</if>
<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}-1/config/certs/localhost.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}-1/config/certs/localhost.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>
<if>
<os family="unix" />
<then>
<exec dir="${elasticsearch.dir}/bin" executable="/bin/bash">
<arg value="-c" />
<arg value="./elasticsearch-certutil ca --pem --ca-dn CN=localhost --out ${elasticsearch.dir}/bin/elastic-stack-ca.zip" />
</exec>
</then>
<elseif>
<os family="windows" />
<then>
<exec dir="${elasticsearch.dir}/bin" executable="cmd">
<arg value="/c" />
<arg value="elasticsearch-certutil ca --pem --ca-dn CN=localhost --out ${elasticsearch.dir}/bin/elastic-stack-ca.zip" />
</exec>
</then>
</elseif>
</if>
<unzip
dest="${elasticsearch.dir}/bin"
src="${elasticsearch.dir}/bin/elastic-stack-ca.zip"
/>
<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}/bin/ca/ca.crt --ca-key ${elasticsearch.dir}/bin/ca/ca.key --pem --ip 127.0.0.1 --dns localhost --name localhost --out ${elasticsearch.dir}/bin/certificate-bundle.zip" />
</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}/bin/ca/ca.crt --ca-key ${elasticsearch.dir}/bin/ca/ca.key --pem --ip 127.0.0.1 --dns localhost --name localhost --out ${elasticsearch.dir}/bin/certificate-bundle.zip" />
</exec>
</then>
</elseif>
</if>
<unzip
dest="${elasticsearch.dir}/bin"
src="${elasticsearch.dir}/bin/certificate-bundle.zip"
/>
<move
file="${elasticsearch.dir}/bin/ca"
todir="${elasticsearch.dir}/config/certs"
/>
<move
file="${elasticsearch.dir}/bin/localhost"
todir="${elasticsearch.dir}/config/certs"
/>
<delete file="${elasticsearch.dir}/bin/elastic-stack-ca.zip" />
<delete file="${elasticsearch.dir}/bin/certificate-bundle.zip" />
</sequential>
</macrodef>
<macrodef name="prepare-elasticsearch-analyzers">
<sequential>
<lstopwatch action="start" name="prepare.elasticsearch.analyzers" />
<chmod
maxparallel="10"
perm="a+rwx"
type="both"
>
<fileset
dir="${elasticsearch.dir}"
/>
</chmod>
<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" />
<if>
<not>
<available file="${elasticsearch.dir}/${elasticsearch.ltr.zip.name}" />
</not>
<then>
<mirrors-get
dest="${elasticsearch.dir}/${elasticsearch.ltr.zip.name}"
skipChecksum="true"
src="${elasticsearch.ltr.url}"
/>
</then>
</if>
<if>
<os family="unix" />
<then>
<exec dir="${elasticsearch.dir}/bin" executable="/bin/bash" inputstring="y
">
<arg value="-c" />
<arg value="./elasticsearch-plugin install file:///${elasticsearch.dir}/${elasticsearch.ltr.zip.name}" />
</exec>
</then>
<elseif>
<os family="windows" />
<then>
<exec dir="${elasticsearch.dir}/bin" executable="cmd" inputstring="y
">
<arg value="/c" />
<arg value="elasticsearch-plugin install file:///${elasticsearch.dir}/${elasticsearch.ltr.zip.name}" />
</exec>
</then>
</elseif>
</if>
<lstopwatch action="total" name="prepare.elasticsearch.ltr" />
</sequential>
</macrodef>
<macrodef name="set-x-pack-user-passwords">
<sequential>
<if>
<os family="unix" />
<then>
<exec dir="${elasticsearch.dir}-1/bin" executable="/bin/bash" outputproperty="elastic.xpack.user.passwords">
<arg value="-c" />
<arg value="./elasticsearch-setup-passwords auto --batch" />
</exec>
</then>
<elseif>
<os family="windows" />
<then>
<exec dir="${elasticsearch.dir}-1/bin" executable="cmd" outputproperty="elastic.xpack.user.passwords">
<arg value="/c" />
<arg value="elasticsearch-setup-passwords auto --batch" />
</exec>
</then>
</elseif>
</if>
<propertyregex
input="${elastic.xpack.user.passwords}"
override="true"
property="elastic.xpack.kibana.user.password"
regexp="(PASSWORD kibana = )(\S*)"
select="\2"
/>
<propertyregex
input="${elastic.xpack.user.passwords}"
override="true"
property="elastic.xpack.elastic.user.password"
regexp="(PASSWORD elastic = )(\S*)"
select="\2"
/>
<exec executable="curl" outputproperty="curl.output">
<arg value="https://localhost:9200" />
<arg value="-ku" />
<arg value="elastic:${elastic.xpack.elastic.user.password}" />
</exec>
<echo>${curl.output}</echo>
</sequential>
</macrodef>
<macrodef name="start-x-pack-trial">
<sequential>
<exec executable="curl" outputproperty="curl.output.trial">
<arg value="-k" />
<arg value="-X POST" />
<arg value="-ku" />
<arg value="elastic:${elastic.xpack.elastic.user.password}" />
<arg value="https://localhost:9200/_license/start_trial?acknowledge=true&pretty" />
</exec>
<echo>${curl.output.trial}</echo>
<if>
<and>
<contains string="${curl.output}" substring="You Know, for Search" />
<contains string="${curl.output.trial}" substring=""trial_was_started" : true" />
</and>
<then>
<echo>Elasticsearch started with X-Pack Security.</echo>
</then>
<else>
<fail>Elasticsearch failed to start with X-Pack Security.</fail>
</else>
</if>
</sequential>
</macrodef>
<macrodef name="unzip-boston-dataset-index">
<sequential>
<if>
<not>
<available file="${liferay.home}/${elasticsearch.boston-dataset-index.zip.name}" />
</not>
<then>
<mirrors-get
dest="${liferay.home}/${elasticsearch.boston-dataset-index.zip.name}"
skipChecksum="true"
src="${elasticsearch.boston-dataset-index.zip.url}"
/>
</then>
</if>
<unzip
dest="${liferay.home}/data/elasticsearch7/repo"
src="${liferay.home}/${elasticsearch.boston-dataset-index.zip.name}"
/>
</sequential>
</macrodef>
<macrodef name="unzip-elasticsearch">
<sequential>
<delete dir="${elasticsearch.dir}" />
<if>
<and>
<not>
<available file="${app.server.parent.dir}/${elasticsearch.tar.name.linux}" />
</not>
<os family="unix" />
</and>
<then>
<mirrors-get
dest="${app.server.parent.dir}/${elasticsearch.tar.name.linux}"
skipChecksum="true"
src="${elasticsearch.tar.url.linux}"
/>
<untar
compression="gzip"
dest="${app.server.parent.dir}"
src="${app.server.parent.dir}/${elasticsearch.tar.name.linux}"
/>
</then>
<elseif>
<and>
<not>
<available file="${app.server.parent.dir}/${elasticsearch.tar.name.mac}" />
</not>
<os family="mac" />
</and>
<then>
<mirrors-get
dest="${app.server.parent.dir}/${elasticsearch.tar.name.mac}"
skipChecksum="true"
src="${elasticsearch.tar.url.mac}"
/>
<untar
compression="gzip"
dest="${app.server.parent.dir}"
src="${app.server.parent.dir}/${elasticsearch.tar.name.mac}"
/>
</then>
</elseif>
<elseif>
<and>
<not>
<available file="${app.server.parent.dir}/${elasticsearch.zip.name.windows}" />
</not>
<os family="windows" />
</and>
<then>
<mirrors-get
dest="${app.server.parent.dir}/${elasticsearch.zip.name.windows}"
skipChecksum="true"
src="${elasticsearch.zip.url.windows}"
/>
<unzip
dest="${app.server.parent.dir}"
src="${app.server.parent.dir}/${elasticsearch.zip.name.windows}"
/>
</then>
</elseif>
</if>
</sequential>
</macrodef>
<macrodef name="unzip-kibana">
<sequential>
<delete file="${app.server.parent.dir}/${elastic.kibana.tar.name.mac}" />
<delete file="${app.server.parent.dir}/${elastic.kibana.tar.name.linux}" />
<delete file="${app.server.parent.dir}/${elastic.kibana.zip.name.windows}" />
<if>
<and>
<not>
<available file="${app.server.parent.dir}/${elastic.kibana.tar.name.mac}" />
</not>
<os family="mac" />
</and>
<then>
<mirrors-get
dest="${app.server.parent.dir}/${elastic.kibana.tar.name.mac}"
skipChecksum="true"
src="${elastic.kibana.tar.url.mac}"
/>
<exec dir="${app.server.parent.dir}" executable="/bin/bash">
<arg value="-c" />
<arg value="tar -zxf ${elastic.kibana.tar.name.mac}" />
</exec>
</then>
<elseif>
<and>
<not>
<available file="${app.server.parent.dir}/${elastic.kibana.tar.name.linux}" />
</not>
<os family="unix" />
</and>
<then>
<mirrors-get
dest="${app.server.parent.dir}/${elastic.kibana.tar.name.linux}"
skipChecksum="true"
src="${elastic.kibana.tar.url.linux}"
/>
<untar
compression="gzip"
dest="${app.server.parent.dir}"
src="${app.server.parent.dir}/${elastic.kibana.tar.name.linux}"
/>
</then>
</elseif>
<elseif>
<and>
<not>
<available file="${app.server.parent.dir}/${elastic.kibana.zip.name}" />
</not>
<os family="windows" />
</and>
<then>
<mirrors-get
dest="${app.server.parent.dir}/${elastic.kibana.zip.name.windows}"
skipChecksum="true"
src="${elastic.kibana.zip.url.windows}"
/>
<unzip
dest="${app.server.parent.dir}"
src="${app.server.parent.dir}/${elastic.kibana.zip.name.windows}"
/>
</then>
</elseif>
</if>
<delete dir="${elastic.kibana.dir}" />
<if>
<os family="mac" />
<then>
<move
file="${app.server.parent.dir}/kibana-${elasticsearch.version}-darwin-x86_64"
tofile="${elastic.kibana.dir}"
/>
</then>
<elseif>
<os family="unix" />
<then>
<move
file="${app.server.parent.dir}/kibana-${elasticsearch.version}-linux-x86_64"
tofile="${elastic.kibana.dir}"
/>
</then>
</elseif>
<elseif>
<os family="windows" />
<then>
<move
file="${app.server.parent.dir}/kibana-${elasticsearch.version}-windows-x86"
tofile="${elastic.kibana.dir}"
/>
</then>
</elseif>
</if>
</sequential>
</macrodef>
<macrodef name="unzip-ltr-linear-regression-model">
<sequential>
<if>
<not>
<available file="${liferay.home}/${elasticsearch.ltr-linear-regression-model.zip.name}" />
</not>
<then>
<mirrors-get
dest="${liferay.home}/${elasticsearch.ltr-linear-regression-model.zip.name}"
skipChecksum="true"
src="${elasticsearch.ltr-linear-regression-model.zip.url}"
/>
</then>
</if>
<unzip
dest="${liferay.home}/data/elasticsearch7/repo"
src="${liferay.home}/${elasticsearch.ltr-linear-regression-model.zip.name}"
/>
</sequential>
</macrodef>
<target name="add-boston-dataset-index">
<unzip-boston-dataset-index />
<antcall target="restore-backup">
<param name="backup.index" value="${backup.index}" />
<param name="elasticsearch.port" value="${elasticsearch.port}" />
</antcall>
<echo>Finished adding Boston dataset index.</echo>
</target>
<target name="add-ltr-linear-regression-model">
<configure-elasticsearch7-test-properties />
<configure-elasticsearch7-ltr-test-properties />
<unzip-ltr-linear-regression-model />
<antcall target="restore-backup">
<param name="backup.index" value="${backup.index}" />
<param name="elasticsearch.port" value="${elasticsearch.port}" />
</antcall>
<echo>Finished adding LTR linear regression model.</echo>
</target>
<target name="configure-elasticsearch-cluster-properties">
<math
datatype="int"
operand1="${remote.elasticsearch.cluster.size}"
operand2="2"
operation="/"
result="elasticsearch.master-eligible.nodes.quorum"
/>
<math
datatype="int"
operand1="${elasticsearch.master-eligible.nodes.quorum}"
operand2="1"
operation="+"
result="elasticsearch.master-eligible.nodes.quorum"
/>
<echo append="true" file="${elasticsearch.dir}/config/elasticsearch.yml">${line.separator}discovery.zen.minimum_master_nodes: ${elasticsearch.master-eligible.nodes.quorum}
xpack.monitoring.collection.enabled: true</echo>
</target>
<target name="deploy-elasticsearch7">
<gradle-execute dir="${project.dir}/modules/apps/portal-search-elasticsearch7" task="deploy">
<arg value="clean" />
</gradle-execute>
<echo file="${liferay.home}/osgi/configs/com.liferay.portal.bundle.blacklist.internal.BundleBlacklistConfiguration.config">blacklistBundleSymbolicNames="com.liferay.portal.mobile.device.detection.fiftyonedegrees.api,com.liferay.portal.mobile.device.detection.fiftyonedegrees.enterprise,com.liferay.portal.mobile.device.detection.fiftyonedegrees.enterprise.test.data,com.liferay.portal.mobile.device.detection.fiftyonedegrees,com.liferay.portal.search.elasticsearch6.spi,com.liferay.portal.search.elasticsearch6.api,com.liferay.portal.search.elasticsearch6.impl,com.liferay.portal.search.elasticsearch6.xpack.security.impl,com.liferay.portal.search.elasticsearch6.xpack.monitoring.web"</echo>
</target>
<target name="prepare-additional-elasticsearch-dirs">
<var name="elasticsearch.node.number" value="0" />
<antelope:repeat count="${remote.elasticsearch.cluster.size}">
<math
datatype="int"
operand1="${elasticsearch.node.number}"
operand2="1"
operation="+"
result="elasticsearch.node.number"
/>
<delete dir="${elasticsearch.dir}-${elasticsearch.node.number}" />
<copy
todir="${elasticsearch.dir}-${elasticsearch.node.number}"
>
<fileset
dir="${elasticsearch.dir}"
/>
</copy>
</antelope:repeat>
<delete dir="${elasticsearch.dir}" />
</target>
<target name="restore-backup">
<exec executable="curl" outputproperty="curl.output">
<arg line="-X PUT "localhost:${elasticsearch.port}/_snapshot/my_backup" -H 'Content-Type: application/json' -d'{"type": "fs","settings": {"location": "${liferay.home}/data/elasticsearch7/repo"}}'" />
</exec>
<echo>Defining snapshot repository.${line.separator}${curl.output}</echo>
<exec executable="curl" outputproperty="curl.output">
<arg line="-X POST "localhost:${elasticsearch.port}/_snapshot/my_backup/snapshot_2/_restore" -H 'Content-Type: application/json' -d'{"indices": "${backup.index}","ignore_unavailable": true,"include_global_state": true,"rename_pattern": "index_(.+)","rename_replacement": "restored_index_$1"}'" />
</exec>
<echo>Restoring snapshot.${line.separator}${curl.output}</echo>
</target>
<target name="start-elasticsearch">
<lstopwatch action="start" name="start.elasticsearch" />
<configure-elasticsearch7-test-properties />
<unzip-elasticsearch />
<prepare-elasticsearch-analyzers />
<get-testcase-property property.name="remote.elasticsearch.ltr.enabled" />
<if>
<equals arg1="${remote.elasticsearch.ltr.enabled}" arg2="true" />
<then>
<configure-elasticsearch7-ltr-test-properties />
<prepare-elasticsearch-ltr />
<echo append="true" file="${elasticsearch.dir}/config/elasticsearch.yml">${line.separator}path.repo: ${liferay.home}/data/elasticsearch7/repo</echo>
<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>
</then>
</if>
<configure-elasticsearch-properties />
<get-testcase-property property.name="elastic.xpack.enabled" />
<if>
<equals arg1="${elastic.xpack.enabled}" arg2="true" />
<then>
<generate-x-pack-security-certificates />
<configure-elasticsearch-x-pack-security-properties />
</then>
</if>
<configure-portal-elasticsearch-osgi-properties />
<get-testcase-property property.name="remote.elasticsearch.cluster.size" />
<if>
<not>
<isset property="remote.elasticsearch.cluster.size" />
</not>
<then>
<property name="remote.elasticsearch.cluster.size" value="1" />
</then>
</if>
<antcall target="configure-elasticsearch-cluster-properties" />
<antcall target="prepare-additional-elasticsearch-dirs" />
<antcall target="start-elasticsearch-node" />
<if>
<equals arg1="${elastic.xpack.enabled}" arg2="true" />
<then>
<sleep seconds="30" />
<set-x-pack-user-passwords />
<start-x-pack-trial />
<configure-portal-x-pack-osgi-properties />
<configure-portal-x-pack-security-truststore />
<antcall target="start-kibana" />
<lstopwatch action="total" name="start.elasticsearch" />
</then>
<else>
<waitfor maxwait="20" maxwaitunit="second" timeoutproperty="elasticsearch.server.not.started">
<http url="http://localhost:9200/" />
</waitfor>
<lstopwatch action="total" name="start.elasticsearch" />
<var name="elasticsearch.node.number" value="0" />
<antelope:repeat count="${remote.elasticsearch.cluster.size}">
<math
datatype="int"
operand1="${elasticsearch.node.number}"
operand2="1"
operation="+"
result="elasticsearch.node.number"
/>
<print-file file.name="${elasticsearch.dir}-${elasticsearch.node.number}/logs/LiferayElasticsearchCluster.log" />
</antelope:repeat>
<fail if="elasticsearch.server.not.started" message="Elasticsearch server failed to initialize." />
</else>
</if>
</target>
<target name="start-elasticsearch-node">
<sequential>
<lstopwatch action="start" name="start.elasticsearch.node" />
<var name="elasticsearch.node.number" value="0" />
<get-java-jdk-home />
<antelope:repeat count="${remote.elasticsearch.cluster.size}">
<math
datatype="int"
operand1="${elasticsearch.node.number}"
operand2="1"
operation="+"
result="elasticsearch.node.number"
/>
<chmod
maxparallel="10"
perm="a+rwx"
type="both"
>
<fileset
dir="${elasticsearch.dir}-${elasticsearch.node.number}"
/>
</chmod>
<if>
<os family="mac" />
<then>
<exec dir="${elasticsearch.dir}-${elasticsearch.node.number}/bin" executable="/bin/bash">
<arg value="-c" />
<arg value="./elasticsearch -d -p pid-elasticsearch" />
</exec>
</then>
<elseif>
<os family="unix" />
<then>
<exec dir="${elasticsearch.dir}-${elasticsearch.node.number}/bin" executable="/bin/bash">
<arg value="-c" />
<arg value="sudo -H -u shutdown bash -c 'export JAVA_HOME=${java.jdk.home} && ./elasticsearch -d -p pid-elasticsearch'" />
</exec>
</then>
</elseif>
<elseif>
<os family="windows" />
<then>
<exec dir="${elasticsearch.dir}-${elasticsearch.node.number}/bin" executable="cmd" spawn="true">
<arg value="/c" />
<arg value="elasticsearch -d -p pid-elasticsearch" />
</exec>
</then>
</elseif>
</if>
</antelope:repeat>
<lstopwatch action="total" name="start.elasticsearch.node" />
</sequential>
</target>
<target name="start-kibana">
<lstopwatch action="start" name="start.kibana" />
<configure-elasticsearch7-test-properties />
<unzip-kibana />
<chmod
maxparallel="10"
perm="a+x"
type="both"
>
<fileset
dir="${elastic.kibana.dir}/bin"
>
<include name="**" />
</fileset>
<fileset
dir="${elastic.kibana.dir}/node"
>
<include name="**" />
</fileset>
</chmod>
<get-testcase-property property.name="elastic.xpack.enabled" />
<if>
<equals arg1="${elastic.xpack.enabled}" arg2="true" />
<then>
<configure-kibana-properties />
<configure-kibana-x-pack-security-properties />
</then>
</if>
<if>
<os family="unix" />
<then>
<exec dir="${elastic.kibana.dir}/bin" executable="/bin/bash">
<arg value="-c" />
<arg value="./kibana > kibana.log 2>&1 &" />
</exec>
</then>
<elseif>