forked from liferay/liferay-portal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-test-solr.xml
429 lines (371 loc) · 12.2 KB
/
build-test-solr.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
<?xml version="1.0"?>
<project basedir="." name="portal-test-solr" xmlns:antelope="antlib:ise.antelope.tasks">
<import file="build-test.xml" />
<macrodef name="configure-app-server-ssl-jvm-arguments">
<sequential>
<if>
<equals arg1="${app.server.type}" arg2="tomcat" />
<then>
<if>
<os family="unix" />
<then>
<echo append="true" file="${app.server.tomcat.bin.dir}/setenv.sh">
CATALINA_OPTS="${CATALINA_OPTS} -Djavax.net.ssl.trustStore=${solr.dir}/server/etc/solr-ssl.keystore.jks -Djavax.net.ssl.trustStorePassword=secret"</echo>
</then>
<elseif>
<os family="windows" />
<then>
<echo append="true" file="${app.server.tomcat.bin.dir}/setenv.bat">
CATALINA_OPTS="${CATALINA_OPTS} -Djavax.net.ssl.trustStore=${solr.dir}/server/etc/solr-ssl.keystore.jks -Djavax.net.ssl.trustStorePassword=secret"</echo>
</then>
</elseif>
</if>
</then>
</if>
</sequential>
</macrodef>
<macrodef name="configure-liferay-solr-adapter-osgi-configs">
<sequential>
<echo file="${liferay.home}/osgi/configs/com.liferay.portal.search.solr.configuration.SolrConfiguration.cfg">readURL=http://localhost:8983/solr/liferay
writeURL=http://localhost:8983/solr/liferay</echo>
</sequential>
</macrodef>
<macrodef name="configure-liferay-solr-solrcloud-osgi-configs">
<sequential>
<echo append="true" file="${liferay.home}/osgi/configs/com.liferay.portal.search.solr.configuration.SolrConfiguration.cfg">
clientType=CLOUD</echo>
</sequential>
</macrodef>
<macrodef name="configure-liferay-solr-ssl-adapter-properties">
<sequential>
<replace
file="${liferay.home}/osgi/configs/com.liferay.portal.search.solr.configuration.SolrConfiguration.cfg"
>
<replacetoken><![CDATA[http://]]></replacetoken>
<replacevalue><![CDATA[https://]]></replacevalue>
</replace>
<echo append="true" file="${liferay.home}/osgi/configs/com.liferay.portal.search.solr.configuration.SolrConfiguration.cfg">
authenticationMode=CERT</echo>
<echo file="${liferay.home}/osgi/configs/com.liferay.portal.search.solr.configuration.SolrSSLSocketFactoryConfiguration.cfg">keyStorePath=${solr.dir}/server/etc/solr-ssl.keystore.jks
trustStorePath=${solr.dir}/server/etc/solr-ssl.keystore.jks</echo>
</sequential>
</macrodef>
<macrodef name="configure-solr-logging">
<sequential>
<replace
file="${solr.dir}/server/solr/solr.xml"
>
<replacetoken><![CDATA[</solr>]]></replacetoken>
<replacevalue expandproperties="true"><![CDATA[
<logging>
<str name="enabled">true</str>
<watcher>
<int name="size">100</int>
<str name="threshold">INFO</str>
</watcher>
</logging>
</solr>]]></replacevalue>
</replace>
<replace
file="${solr.dir}/server/resources/log4j.properties"
>
<replacetoken><![CDATA[WARN]]></replacetoken>
<replacevalue><![CDATA[INFO]]></replacevalue>
</replace>
</sequential>
</macrodef>
<macrodef name="configure-solr-ssl-properties">
<sequential>
<if>
<os family="unix" />
<then>
<echo append="true" file="${solr.dir}/bin/solr.in.sh">SOLR_SSL_KEY_STORE=${solr.dir}/server/etc/solr-ssl.keystore.jks
SOLR_SSL_KEY_STORE_PASSWORD=secret
SOLR_SSL_TRUST_STORE=${solr.dir}/server/etc/solr-ssl.keystore.jks
SOLR_SSL_TRUST_STORE_PASSWORD=secret
SOLR_SSL_WANT_CLIENT_AUTH=true</echo>
</then>
<elseif>
<os family="windows" />
<then>
<echo append="true" file="${solr.dir}/bin/solr.in.cmd">SOLR_SSL_KEY_STORE=${solr.dir}/server/etc/solr-ssl.keystore.jks
SOLR_SSL_KEY_STORE_PASSWORD=secret
SOLR_SSL_TRUST_STORE=${solr.dir}/server/etc/solr-ssl.keystore.jks
SOLR_SSL_TRUST_STORE_PASSWORD=secret
SOLR_SSL_WANT_CLIENT_AUTH=true</echo>
</then>
</elseif>
</if>
</sequential>
</macrodef>
<macrodef name="create-solr-core">
<sequential>
<if>
<os family="unix" />
<then>
<exec dir="${solr.dir}/bin" executable="/bin/bash">
<arg value="-c" />
<arg value="./solr create_core -c liferay -d ${solr.dir}/server/solr/liferay/conf" />
</exec>
</then>
<elseif>
<os family="windows" />
<then>
<exec dir="${solr.dir}/bin" executable="cmd">
<arg value="/c" />
<arg value="solr create_core -c liferay -d ${solr.dir}/server/solr/liferay/conf" />
</exec>
</then>
</elseif>
</if>
</sequential>
</macrodef>
<macrodef name="create-solr-ssl-keystore">
<sequential>
<get-ip-address />
<exec dir="${solr.dir}/server/etc" executable="keytool">
<arg value="-genkeypair" />
<arg line="-alias solr-ssl" />
<arg line="-dname "CN=localhost, OU=Organizational Unit, O=Organization, L=Location, ST=State, C=Country"" />
<arg line="-ext SAN=DNS:localhost,IP:${ip.address},IP:127.0.0.1" />
<arg line="-keyalg RSA" />
<arg line="-keypass secret" />
<arg line="-keysize 2048" />
<arg line="-keystore solr-ssl.keystore.jks" />
<arg line="-storepass secret" />
<arg line="-validity 9999" />
</exec>
</sequential>
</macrodef>
<macrodef name="prepare-solr-configurations">
<sequential>
<copy
overwrite="true"
todir="${solr.dir}/server/solr/liferay/conf"
>
<fileset
dir="${solr.dir}/server/solr/configsets/data_driven_schema_configs/conf"
>
<exclude name="solrconfig.xml" />
</fileset>
<fileset
dir="modules/apps/portal-search-solr/portal-search-solr/src/main/resources/META-INF/resources"
>
<include name="schema.xml" />
<include name="solrconfig.xml" />
</fileset>
</copy>
<replace
file="${solr.dir}/server/solr/liferay/conf/solrconfig.xml"
>
<replacetoken><![CDATA[<maxWarmingSearchers>2</maxWarmingSearchers>]]></replacetoken>
<replacevalue><![CDATA[<maxWarmingSearchers>5</maxWarmingSearchers>]]></replacevalue>
</replace>
<echo file="${solr.dir}/server/solr/liferay/core.properties">config=solrconfig.xml
dataDir=data
name=liferay
schema=schema.xml</echo>
</sequential>
</macrodef>
<macrodef name="prepare-solr-solrcloud-configurations">
<sequential>
<copy
todir="${solr.dir}/server/solr/configsets/liferay_configs/conf"
>
<fileset
dir="${solr.dir}/server/solr/liferay/conf"
/>
</copy>
</sequential>
</macrodef>
<macrodef name="prepare-solr-solrcloud-example">
<sequential>
<copy
todir="${solr.dir}/example/cloud/node1/solr"
>
<fileset
dir="${solr.dir}/server/solr"
>
<include name="solr.xml" />
<include name="zoo.cfg" />
</fileset>
</copy>
<copy
todir="${solr.dir}/example/cloud/node2/solr"
>
<fileset
dir="${solr.dir}/server/solr"
>
<include name="solr.xml" />
<include name="zoo.cfg" />
</fileset>
</copy>
</sequential>
</macrodef>
<macrodef name="start-solr-solrcloud-example">
<sequential>
<if>
<os family="unix" />
<then>
<chmod
file="${solr.dir}/bin/solr"
perm="a+x"
/>
<exec dir="${solr.dir}/bin" executable="/bin/bash">
<arg value="-c" />
<arg value="./solr start -cloud -p 8983 -s ${solr.dir}/example/cloud/node1/solr" />
</exec>
<exec dir="${solr.dir}/bin" executable="/bin/bash">
<arg value="-c" />
<arg value="./solr start -cloud -p 7574 -s ${solr.dir}/example/cloud/node2/solr -z localhost:9983" />
</exec>
<exec dir="${solr.dir}/bin" executable="/bin/bash">
<arg value="-c" />
<arg value="./solr create_collection -c liferay -p 8983 -d liferay_configs -shards 2 -replicationFactor 2" />
</exec>
</then>
<elseif>
<os family="windows" />
<then>
<exec dir="${solr.dir}/bin" executable="cmd" spawn="true">
<arg value="/c" />
<arg value="solr start -cloud -p 8983 -s ${solr.dir}/example/cloud/node1/solr" />
</exec>
<exec dir="${solr.dir}/bin" executable="cmd" spawn="true">
<arg value="/c" />
<arg value="solr start -cloud -p 7574 -s ${solr.dir}/example/cloud/node2/solr -z localhost:9983" />
</exec>
<exec dir="${solr.dir}/bin" executable="cmd" spawn="true">
<arg value="/c" />
<arg value="solr create_collection -c liferay -p 8983 -d liferay_configs -shards 2 -replicationFactor 2" />
</exec>
</then>
</elseif>
</if>
</sequential>
</macrodef>
<macrodef name="unzip-solr">
<sequential>
<delete dir="${solr.dir}" />
<if>
<not>
<available file="${app.server.parent.dir}/${solr.zip.name}" />
</not>
<then>
<mirrors-get
dest="${app.server.parent.dir}/${solr.zip.name}"
skipChecksum="true"
src="${solr.zip.url}"
verbose="true"
/>
</then>
</if>
<unzip
dest="${app.server.parent.dir}"
src="${app.server.parent.dir}/${solr.zip.name}"
/>
</sequential>
</macrodef>
<target name="deploy-solr">
<gradle-execute dir="modules/apps/portal-search-solr/portal-search-solr" 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.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="start-solr">
<unzip-solr />
<prepare-solr-configurations />
<configure-liferay-solr-adapter-osgi-configs />
<get-testcase-property property.name="solr.ssl.authentication.enabled" />
<if>
<equals arg1="${solr.ssl.authentication.enabled}" arg2="true" />
<then>
<create-solr-ssl-keystore />
<configure-solr-ssl-properties />
<configure-liferay-solr-ssl-adapter-properties />
<configure-app-server-ssl-jvm-arguments />
</then>
</if>
<get-testcase-property property.name="solr.logging.info.level" />
<if>
<equals arg1="${solr.logging.info.level}" arg2="true" />
<then>
<configure-solr-logging />
</then>
</if>
<get-testcase-property property.name="solr.solrcloud.enabled" />
<if>
<equals arg1="${solr.solrcloud.enabled}" arg2="true" />
<then>
<antcall target="start-solr-solrcloud" />
</then>
<else>
<antcall target="start-solr-core" />
<create-solr-core />
</else>
</if>
</target>
<target name="start-solr-core">
<if>
<os family="unix" />
<then>
<chmod
file="${solr.dir}/bin/solr"
perm="a+x"
/>
<exec dir="${solr.dir}/bin" executable="/bin/bash">
<arg value="-c" />
<arg value="./solr start -V" />
</exec>
</then>
<elseif>
<os family="windows" />
<then>
<exec dir="${solr.dir}/bin" executable="cmd" spawn="true">
<arg value="/c" />
<arg value="solr start -V" />
</exec>
</then>
</elseif>
</if>
<local name="solr.server.not.started" />
<waitfor maxwait="10" maxwaitunit="second" timeoutproperty="solr.server.not.started">
<socket port="8983" server="localhost" />
</waitfor>
<fail if="solr.server.not.started" message="Solr server failed to initialize." />
</target>
<target name="start-solr-solrcloud">
<prepare-solr-solrcloud-configurations />
<prepare-solr-solrcloud-example />
<configure-liferay-solr-solrcloud-osgi-configs />
<start-solr-solrcloud-example />
</target>
<target name="stop-solr-core">
<get-testcase-property property.name="solr.solrcloud.enabled" />
<if>
<os family="unix" />
<then>
<exec dir="${solr.dir}/bin" executable="/bin/bash">
<arg value="-c" />
<arg value="./solr stop -all" />
</exec>
</then>
<elseif>
<os family="windows" />
<then>
<exec dir="${solr.dir}/bin" executable="cmd" spawn="true">
<arg value="/c" />
<arg value="solr stop -all" />
</exec>
</then>
</elseif>
</if>
<local name="solr.server.running" />
<waitfor maxwait="15" maxwaitunit="second" timeoutproperty="solr.server.running">
<not>
<socket port="8983" server="localhost" />
</not>
</waitfor>
<fail if="solr.server.running" message="Solr server failed to stop." />
</target>
</project>