forked from liferay/liferay-portal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-test-tck.xml
356 lines (272 loc) · 9.55 KB
/
build-test-tck.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
<?xml version="1.0"?>
<project basedir="." default="test" name="portal-test-tck" xmlns:antelope="antlib:ise.antelope.tasks">
<import file="build-test.xml" />
<macrodef name="update-tck-war-version">
<attribute name="tck.war.file" />
<sequential>
<tstamp>
<format pattern="yyyyMMddkkmmssSSS" property="tstamp.value" />
</tstamp>
<mkdir dir="${tstamp.value}" />
<unwar dest="${tstamp.value}" src="@{tck.war.file}">
<patternset>
<include name="WEB-INF/web.xml" />
</patternset>
</unwar>
<fixcrlf eol="lf" file="${tstamp.value}/WEB-INF/web.xml" />
<replace file="${tstamp.value}/WEB-INF/web.xml">
<replacefilter>
<replacetoken><![CDATA[
<!DOCTYPE web-app PUBLIC '-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN' 'http://java.sun.com/dtd/web-app_2_3.dtd'>
]]></replacetoken>
<replacevalue></replacevalue>
</replacefilter>
<replacefilter token="<web-app>" value="<web-app version="2.4">" />
</replace>
<zip destfile="@{tck.war.file}" update="true">
<fileset dir="${tstamp.value}" />
</zip>
<delete dir="${tstamp.value}" />
</sequential>
</macrodef>
<target name="clean-up-tck-dependencies">
<delete file="${liferay.home}/osgi/modules/com.liferay.portlet.tck.bridge.jar" />
<delete includeemptydirs="true">
<fileset
dir="${app.server.tomcat.dir}/webapps/"
includes="portlet_jp_*/**"
/>
</delete>
</target>
<target name="prepare-tck">
<delete dir="tools/tck" />
<if>
<isset property="portlet.tck.url" />
<then>
<tstamp>
<format pattern="yyyyMMddkkmmssSSS" property="tstamp.value" />
</tstamp>
<mirrors-get dest="${tstamp.value}.zip" src="${portlet.tck.url}" />
<unzip dest="tools/tck" src="${tstamp.value}.zip" />
<delete file="${tstamp.value}.zip" />
</then>
<else>
<unzip dest="tools/tck" src="${portlet.tck.zip}" />
</else>
</if>
<chmod
dir="tools/tck/bin"
includes="tsant*"
perm="744"
/>
<replace file="tools/tck/bin/ts.jte">
<replacefilter token="http://localhost:8080/pluto/tck" value="http://localhost:8080/c/portal/tck" />
</replace>
<echo append="true" file="tools/tck/bin/build.properties">
work.dir=${basedir.unix}/tools/tck/work</echo>
</target>
<target name="prepare-tck-dependencies">
<if>
<not>
<isset property="test.packages" />
</not>
<then>
<property name="test.packages" value="com.sun.ts.tests" />
</then>
</if>
<propertyregex
global="true"
input="${test.packages}."
property="test.directories"
regexp="\."
replace="/"
/>
<antcall target="prepare-tck" />
<var name="tck.servlet.context.names" value="" />
<for list="${test.directories}" param="test.directory">
<sequential>
<for param="tck.war.file">
<path>
<fileset
dir="tools/tck/dist/@{test.directory}"
excludes="**/portlet_jp_PortletSession_secondapp_web.war"
includes="**/*.war"
/>
</path>
<sequential>
<local name="tck.servlet.context.name" />
<basename file="@{tck.war.file}" property="tck.servlet.context.name" suffix=".war" />
<if>
<equals arg1="${tck.servlet.context.names}" arg2="" />
<then>
<var name="tck.servlet.context.names" value="${tck.servlet.context.name}" />
</then>
<else>
<var name="tck.servlet.context.names" value="${tck.servlet.context.names}|${tck.servlet.context.name}" />
</else>
</if>
<update-tck-war-version
tck.war.file="@{tck.war.file}"
/>
<copy
file="@{tck.war.file}"
flatten="true"
todir="${liferay.home}/deploy"
/>
</sequential>
</for>
</sequential>
</for>
<echo file="${liferay.home}/osgi/modules/com.liferay.portlet.tck.bridge.configuration.PortletTCKBridgeConfiguration.cfg">handShakeServerPort=${portlet.tck.bridge.handshake.port}
servletContextNames=${tck.servlet.context.names}</echo>
<gradle-execute dir="modules/test/portlet-tck-bridge" task="deploy" />
</target>
<target name="record-test-tck-package-names">
<ant antfile="build-test-tck.xml" target="prepare-tck" />
<beanshell>
<![CDATA[
import org.apache.tools.ant.DirectoryScanner;
List getGroupPackageNamesList(List packageNames, int groupsSize) {
List groupPackageNamesList = new ArrayList(groupsSize);
for (int i = 0; i < groupsSize; i++) {
groupPackageNamesList.add(new ArrayList());
}
for (int i = 0; i < packageNames.size(); i++) {
String packageName = packageNames.get(i);
List groupPackageNames = groupPackageNamesList.get(i % groupsSize);
groupPackageNames.add(packageName);
}
return groupPackageNamesList;
}
List getPackageNames() {
DirectoryScanner directoryScanner = new DirectoryScanner();
directoryScanner.setBasedir(project.getBaseDir());
directoryScanner.setIncludes(new String[] {"**/com/sun/ts/tests/**/*.war"});
directoryScanner.scan();
String[] fileNames = directoryScanner.getIncludedFiles();
Arrays.sort(fileNames);
List packageNames = new ArrayList();
for (String fileName : fileNames) {
int x = fileName.indexOf("com" + File.separator);
int y = fileName.lastIndexOf(File.separatorChar);
String packageName = fileName.substring(x, y);
if (packageName.endsWith("PortletSessionSecondapp")) {
continue;
}
packageNames.add(packageName.replace(File.separatorChar, '.'));
}
return packageNames;
}
int testClassGroupsSize = Integer.parseInt(project.getProperty("test.class.groups.size"));
List groupPackageNamesList = getGroupPackageNamesList(getPackageNames(), testClassGroupsSize);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < testClassGroupsSize; i++) {
List groupPackageNames = groupPackageNamesList.get(i);
sb.append("TEST_CLASS_GROUP_");
sb.append(i);
sb.append("=");
for (String packageName : groupPackageNames) {
sb.append(packageName);
sb.append(",");
}
if (!groupPackageNames.isEmpty()) {
sb.setLength(sb.length() - 1);
}
sb.append("\n\n");
}
sb.append("TEST_CLASS_GROUPS=");
for (int i = 0; i < testClassGroupsSize; i++) {
sb.append(i);
sb.append(" ");
}
if (testClassGroupsSize > 0) {
sb.setLength(sb.length() - 1);
}
project.setProperty("test.tck.package.names", sb.toString());
]]>
</beanshell>
<echo file="test.tck.package.names.properties">${test.tck.package.names}</echo>
</target>
<target depends="prepare-tck-dependencies" name="run-tck-tomcat">
<if>
<not>
<isset property="test.class.group" />
</not>
<then>
<antcall inheritAll="false" target="clean-up-java-processes" />
<antcall target="prepare-portal-ext-properties" />
<antcall target="prepare-system-ext-properties" />
<antcall inheritAll="false" target="rebuild-database" />
</then>
</if>
<antcall target="start-app-server">
<param name="testable.portal.started.marker.file" value=".testable.portal.started" />
</antcall>
<waitfor checkevery="100" checkeveryunit="millisecond" maxwait="10" maxwaitunit="minute" timeoutproperty="tck.wars.deployment.timeout">
<socket port="${portlet.tck.bridge.handshake.port}" server="localhost" />
</waitfor>
<if>
<isset property="tck.wars.deployment.timeout" />
<then>
<for param="logfile">
<path>
<fileset dir="${liferay.home}/logs" includes="*.log" />
</path>
<sequential>
<local name="logfile.content" />
<loadfile property="logfile.content" srcFile="@{logfile}" />
<echo>File content for ${liferay.home}/logs/@{logfile}:
${logfile.content}</echo>
</sequential>
</for>
<fail message="Timeout while waiting for TCK wars to deploy." />
</then>
</if>
<condition else="" property="tsant.file.suffix.bat" value=".bat">
<contains casesensitive="false" string="${os.name}" substring="Windows" />
</condition>
<for list="${test.directories}" param="test.directory">
<sequential>
<exec dir="tools/tck/src/@{test.directory}" executable="${basedir}/tools/tck/bin/tsant${tsant.file.suffix.bat}" failonerror="true">
<arg line="runclient" />
<env key="ANT_OPTS" value="-verbose:gc -Xloggc:/tmp/tsant-gc.log -Xms8m -Xmx8m -XX:MaxNewSize=2m -XX:MaxPermSize=6m -XX:MaxTenuringThreshold=0 -XX:NewSize=2m -XX:PermSize=6m -XX:+PrintGCCause -XX:+PrintGCDetails -XX:SurvivorRatio=65536 -XX:TargetSurvivorRatio=0" />
<env key="TS_HOME" value="${basedir}/tools/tck" />
</exec>
<mkdir dir="portal-impl/test-results" />
<java
classname="com.liferay.portal.tools.TCKtoJUnitConverter"
classpathref="project.classpath"
fork="true"
newenvironment="true"
>
<jvmarg value="-Dexternal-properties=com/liferay/portal/tools/dependencies/portal-tools.properties" />
<arg value="tools/tck/work/jtData/harness.trace" />
<arg value="portal-impl/test-results" />
</java>
</sequential>
</for>
<antcall target="clean-up-tck-dependencies" />
</target>
<target name="test-class-group">
<if>
<not>
<isset property="test.class.group.index" />
</not>
<then>
<fail>Use "ant test-class-group -Dtest.class.group.index=0".</fail>
</then>
</if>
<property file="${project.dir}/test.tck.package.names.properties" />
<propertycopy from="TEST_CLASS_GROUP_${test.class.group.index}" name="test.packages" />
<if>
<not>
<equals arg1="${test.packages}" arg2="" />
</not>
<then>
<antcall target="run-tck-tomcat">
<param name="test.class.group" value="true" />
</antcall>
</then>
</if>
</target>
</project>