forked from liferay/liferay-portal
-
Notifications
You must be signed in to change notification settings - Fork 2
/
build-test-opensearch2.xml
255 lines (220 loc) · 8.71 KB
/
build-test-opensearch2.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
<?xml version="1.0"?>
<project basedir="." name="portal-test-opensearch2" xmlns:antelope="antlib:ise.antelope.tasks" xmlns:if="ant:if" xmlns:unless="ant:unless">
<import file="build-test.xml" />
<property name="opensearch.version" value="2.16.0" />
<property name="opensearch.analysis-icu.zip.url" value="https://artifacts.opensearch.org/releases/plugins/analysis-icu/${opensearch.version}/analysis-icu-${opensearch.version}.zip" />
<property name="opensearch.analysis-kuromoji.zip.url" value="https://artifacts.opensearch.org/releases/plugins/analysis-kuromoji/${opensearch.version}/analysis-kuromoji-${opensearch.version}.zip" />
<property name="opensearch.analysis-smartcn.zip.url" value="https://artifacts.opensearch.org/releases/plugins/analysis-smartcn/${opensearch.version}/analysis-smartcn-${opensearch.version}.zip" />
<property name="opensearch.analysis-stempel.zip.url" value="https://artifacts.opensearch.org/releases/plugins/analysis-stempel/${opensearch.version}/analysis-stempel-${opensearch.version}.zip" />
<property name="opensearch.dir" value="${app.server.parent.dir}/opensearch-${opensearch.version}" />
<target name="start-opensearch">
<ant antfile="build-test.xml" target="deploy-osgi-apps">
<property name="osgi.app.includes" value="portal-search-opensearch2" />
</ant>
<if>
<not>
<available file="${app.server.parent.dir}/opensearch-${opensearch.version}-linux-x64.tar.gz" />
</not>
<then>
<mirrors-get
dest="${app.server.parent.dir}/opensearch-${opensearch.version}-linux-x64.tar.gz"
skipChecksum="true"
src="https://artifacts.opensearch.org/releases/bundle/opensearch/${opensearch.version}/opensearch-${opensearch.version}-linux-x64.tar.gz"
/>
</then>
</if>
<if>
<not>
<available file="${liferay.home}/data/opensearch2/repo" type="dir" />
</not>
<then>
<mkdir dir="${liferay.home}/data/opensearch2/repo" />
</then>
</if>
<untar
compression="gzip"
dest="${app.server.parent.dir}"
src="${app.server.parent.dir}/opensearch-${opensearch.version}-linux-x64.tar.gz"
/>
<echo file="${opensearch.dir}/config/opensearch.yml">cluster.name: LiferayOpenSearchCluster
discovery.type: single-node
http.host: ["_local_", "_site_"]
indices.query.bool.max_clause_count: 4096
path.repo: ${liferay.home}/data/opensearch2/repo
plugins.security.disabled: true</echo>
<if>
<or>
<isset property="env.JENKINS_HOME" />
<isset property="opensearch.java.home" />
</or>
<then>
<property name="opensearch.java.home" unless:set="opensearch.java.home" value="/opt/java/jdk11" />
<replace
file="${opensearch.dir}/bin/opensearch-env"
token="#!/usr/bin/env bash"
value="#!/usr/bin/env bash${line.separator}OPENSEARCH_JAVA_HOME=${opensearch.java.home}"
/>
</then>
</if>
<replaceregexp
file="${opensearch.dir}/config/jvm.options"
flags="g"
match="(?<=-Xm.).*"
replace="2g"
/>
<get-testcase-property if:set="env.JENKINS_HOME" property.name="opensearch.security.enabled" />
<if>
<istrue value="${opensearch.security.enabled}" />
<then>
<replaceregexp
file="${opensearch.dir}/config/opensearch.yml"
flags="g"
match="\nplugins.security.disabled: true"
replace=""
/>
<chmod
maxparallel="10"
perm="a+rwx"
type="both"
>
<fileset
dir="${opensearch.dir}"
/>
</chmod>
<exec dir="${opensearch.dir}/plugins/opensearch-security/tools" executable="/bin/bash">
<arg value="-c" />
<arg value="printf '%s\n' y y N | ./install_demo_configuration.sh" />
</exec>
<exec dir="${opensearch.dir}/config" executable="/bin/bash" osfamily="unix">
<arg value="-c" />
<arg value="openssl pkcs12 -certpbe PBE-SHA1-3DES -keypbe PBE-SHA1-3DES -macalg sha1 -export -in esnode.pem -inkey esnode-key.pem -out esnode.p12 -passout pass:liferay" />
</exec>
<exec dir="${opensearch.dir}/config" executable="cmd" osfamily="windows" spawn="true">
<arg value="/c" />
<arg value="openssl pkcs12 -certpbe PBE-SHA1-3DES -keypbe PBE-SHA1-3DES -macalg sha1 -export -in esnode.pem -inkey esnode-key.pem -out esnode.p12 -passout pass:liferay" />
</exec>
</then>
</if>
<if>
<not>
<available file="${opensearch.dir}/analysis-icu-${opensearch.version}.zip" />
</not>
<then>
<mirrors-get
dest="${opensearch.dir}/analysis-icu-${opensearch.version}.zip"
skipChecksum="true"
src="${opensearch.analysis-icu.zip.url}"
/>
</then>
</if>
<if>
<not>
<available file="${opensearch.dir}/analysis-kuromoji-${opensearch.version}.zip" />
</not>
<then>
<mirrors-get
dest="${opensearch.dir}/analysis-kuromoji-${opensearch.version}.zip"
skipChecksum="true"
src="${opensearch.analysis-kuromoji.zip.url}"
/>
</then>
</if>
<if>
<not>
<available file="${opensearch.dir}/analysis-smartcn-${opensearch.version}.zip" />
</not>
<then>
<mirrors-get
dest="${opensearch.dir}/analysis-smartcn-${opensearch.version}.zip"
skipChecksum="true"
src="${opensearch.analysis-smartcn.zip.url}"
/>
</then>
</if>
<if>
<not>
<available file="${opensearch.dir}/analysis-stempel-${opensearch.version}.zip" />
</not>
<then>
<mirrors-get
dest="${opensearch.dir}/analysis-stempel-${opensearch.version}.zip"
skipChecksum="true"
src="${opensearch.analysis-stempel.zip.url}"
/>
</then>
</if>
<chmod
maxparallel="10"
perm="a+rwx"
type="both"
>
<fileset
dir="${liferay.home}/data/opensearch2"
/>
<fileset
dir="${opensearch.dir}"
/>
</chmod>
<for list="analysis-icu-${opensearch.version}.zip,analysis-kuromoji-${opensearch.version}.zip,analysis-smartcn-${opensearch.version}.zip,analysis-stempel-${opensearch.version}.zip" param="opensearch.plugin.name">
<sequential>
<exec dir="${opensearch.dir}/bin" executable="/bin/bash">
<arg value="-c" />
<arg value="./opensearch-plugin install file:///${opensearch.dir}/@{opensearch.plugin.name}" />
</exec>
</sequential>
</for>
<echo file="${liferay.home}/osgi/configs/com.liferay.portal.bundle.blacklist.internal.configuration.BundleBlacklistConfiguration.config">blacklistBundleSymbolicNames=[\
"com.liferay.portal.search.elasticsearch.cross.cluster.replication.impl",\
"com.liferay.portal.search.elasticsearch.monitoring.web",\
"com.liferay.portal.search.elasticsearch7.api",\
"com.liferay.portal.search.elasticsearch7.impl",\
"com.liferay.portal.search.learning.to.rank.api",\
"com.liferay.portal.search.learning.to.rank.impl"\
]</echo>
<echo file="${liferay.home}/osgi/configs/com.liferay.portal.search.opensearch2.configuration.OpenSearchConnectionConfiguration-REMOTE.config">active="true"
connectionId="REMOTE"</echo>
<if>
<istrue value="${opensearch.security.enabled}" />
<then>
<echo append="true" file="${liferay.home}/osgi/configs/com.liferay.portal.search.opensearch2.configuration.OpenSearchConnectionConfiguration-REMOTE.config">
authenticationEnabled="true"
httpSSLEnabled="true"
networkHostAddresses=["https://localhost:9200"]
password="admin"
truststorePassword="liferay"
truststorePath="${opensearch.dir}/config/esnode.p12"
truststoreType="pkcs12"
username="admin"</echo>
</then>
</if>
<echo file="${liferay.home}/osgi/configs/com.liferay.portal.search.opensearch2.configuration.OpenSearchConfiguration.config">remoteClusterConnectionId="REMOTE"</echo>
<lstopwatch action="start" name="start.opensearch.node" />
<exec dir="${opensearch.dir}/bin" executable="/bin/bash" osfamily="unix">
<arg value="-c" />
<arg if:set="env.JENKINS_HOME" value="sudo -H -u shutdown bash -c './opensearch -d -p pid-opensearch'" />
<arg unless:set="env.JENKINS_HOME" value="./opensearch -d -p pid-opensearch" />
</exec>
<property name="opensearch.port" unless:set="opensearch.port" value="9200" />
<waitfor maxwait="120" maxwaitunit="second" timeoutproperty="opensearch.server.not.started">
<socket port="${opensearch.port}" server="localhost" />
</waitfor>
<print-files dir="${opensearch.dir}/logs/" exclude="*_*" include="LiferayOpenSearchCluster*.log" />
<lstopwatch action="total" name="start.opensearch.node" />
<fail if="opensearch.server.not.started" message="OpenSearch server on port ${opensearch.port} failed to initialize." />
</target>
<target name="stop-opensearch">
<if>
<available file="${opensearch.dir}/pid-opensearch" />
<then>
<exec dir="${opensearch.dir}" executable="/bin/bash" osfamily="unix">
<arg value="-c" />
<arg value="pkill -F pid-opensearch" />
</exec>
</then>
<else>
<echo>The OpenSearch server in ${opensearch.dir} has already been stopped</echo>
</else>
</if>
<print-files dir="${opensearch.dir}/logs/" exclude="*_*" include="LiferayOpenSearchCluster*.log" />
</target>
</project>