-
Notifications
You must be signed in to change notification settings - Fork 138
/
run_test.sh
executable file
·280 lines (244 loc) · 10.6 KB
/
run_test.sh
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
#!/bin/bash -ex
#
# Copyright (c) 2017, 2020 Oracle and/or its affiliates. All rights reserved.
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License v. 2.0, which is available at
# http://www.eclipse.org/legal/epl-2.0.
#
# This Source Code may also be made available under the following Secondary
# Licenses when the conditions for such availability set forth in the
# Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
# version 2 with the GNU Classpath Exception, which is available at
# https://www.gnu.org/software/classpath/license.html.
#
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
#
archive_cts(){
cp ${TS_HOME}/bin/xml/config_vi.log ${WORKSPACE}/results
cp ${TS_HOME}/bin/xml/smoke.log ${WORKSPACE}/results
cp ${S1AS_HOME}/domains/domain1/logs/server.log* ${WORKSPACE}/results
cp ${TS_HOME}/bin/ts.jte ${WORKSPACE}/results
echo ${BUILD_ID} > ${WORKSPACE}/results/count.txt
${GREP} "Number of Tests Passed" ${WORKSPACE}/results/smoke.log >> ${WORKSPACE}/results/count.txt
${GREP} "Number of Tests Failed" ${WORKSPACE}/results/smoke.log >> ${WORKSPACE}/results/count.txt
${GREP} "Number of Tests with Errors" ${WORKSPACE}/results/smoke.log >> ${WORKSPACE}/results/count.txt
cat ${WORKSPACE}/results/count.txt | ${SED} -e 's/\[javatest.batch\] Number/Number/g' > ${WORKSPACE}/results/CTS-GP-count.txt
rm ${WORKSPACE}/results/count.txt
tar -cvf ${WORKSPACE}/${TEST_ID}-results.tar.gz -C ${WORKSPACE}/results .
}
test_run_cts_smoke(){
TS_HOME=${WORKSPACE}/javaee-smoke
if [[ -z ${CTS_SMOKE_URL} ]]; then
echo "error: CTS_SMOKE_URL is not set"
exit 1
fi
CTS_SMOKE_BUNDLE=javaee-smoke-8.0_latest.zip
CTS_EXCLUDE_LIST=ts.jtx
pwd
uname -a
java -version
rm -rf /tmp/JTreport /tmp/JTwork /disk1/java_re/.javatest || true
wget ${CTS_SMOKE_URL}/${CTS_SMOKE_BUNDLE}
unzip -q ${CTS_SMOKE_BUNDLE}
cd ${TS_HOME}/bin
#cp $CTS_SMOKE/$CTS_EXCLUDE_LIST .
cp ts.jte ts.jte.orig
${SED} \
-e "s@javaee.home=@javaee\.home=${S1AS_HOME}@g" \
-e "s@javaee.home.ri=@javaee\.home\.ri=${S1AS_HOME}@g" \
-e "s/^orb\.host=/orb\.host=localhost/g" \
-e "s/^mailHost=/mailHost=localhost/g" \
-e "s/^mailuser1=/mailuser1=${USER:-root}@localhost/g" \
-e "s/^mailFrom=.*/mailFrom=${USER:-root}@localhost/g" \
-e "s/orb.host.ri=/orb.host.ri=localhost/g" \
-e "s/^work\.dir=\/files/work\.dir=\/tmp/g" \
-e "s/^report\.dir=\/files/report\.dir=\/tmp/g" \
-e "s/^tz=.*/tz=US\/Pacific/g" \
-e "s/modules\/gf-client.jar/lib\/gf-client.jar/g" \
-e "s/\${pathsep}\${ri\.modules}\/javax\.jms\.jar/\${pathsep}\${ri\.modules}\/javax\.jms-api\.jar\${pathsep}\$\{ri\.modules}\/javax\.jms\.jar/g" \
-e "s/\${pathsep}\${s1as\.modules}\/javax\.jms\.jar/\${pathsep}\${s1as\.modules}\/javax\.jms-api\.jar\${pathsep}\$\{s1as\.modules}\/javax\.jms\.jar/g" \
-e "s/implementation\.classes\.ri=/implementation\.classes\.ri=\${ri\.modules}\/cdi-api\.jar\${pathsep}\${ri\.modules}\/cdi-api-fragment\.jar\${pathsep}/g" \
-e "s/implementation\.classes=/implementation\.classes=\${s1as\.modules}\/cdi-api\.jar\${pathsep}\${s1as\.modules}\/cdi-api-fragment\.jar\${pathsep}/g" \
-e "s/tyrus-container-grizzly\.jar/tyrus-container-grizzly-client\.jar/g" \
-e "s/javamail\.password=/javamail\.password\=cts1/g" \
ts.jte > ts.jte.new
mv ts.jte.new ts.jte
cd ${TS_HOME}/bin/xml
export ANT_HOME=${TS_HOME}/tools/ant
export PATH=${ANT_HOME}/bin:${PATH}
# SECURITY MANAGER ON
${S1AS_HOME}/bin/asadmin start-domain
${S1AS_HOME}/bin/asadmin create-jvm-options "-Djava.security.manager"
${S1AS_HOME}/bin/asadmin stop-domain
if [[ -n ${1} ]]; then
${TS_HOME}/tools/ant/bin/ant \
-Dgroups.count=5 \
-Dgroup.id=${1} \
-Dgroups.work.dir=/tmp \
-f ${TS_HOME}/bin/xml/impl/glassfish/smoke-groups.xml \
smoke.split.groups
cat /tmp/javaee-smoke-group${1}.properties
${TS_HOME}/tools/ant/bin/ant \
-Dreport.dir=${WORKSPACE}/${BUILD_NUMBER}/JTReport \
-Dwork.dir=${WORKSPACE}/${BUILD_NUMBER}/JTWork \
-propertyfile /tmp/javaee-smoke-group${1}.properties \
-f smoke.xml \
smoke
else
${TS_HOME}/tools/ant/bin/ant \
-Dreport.dir=${WORKSPACE}/${BUILD_NUMBER}/JTReport \
-Dwork.dir=${WORKSPACE}/${BUILD_NUMBER}/JTWork \
-f smoke.xml \
smoke
fi
kill_process
archive_cts
}
archive_servlet_tck(){
cp ${S1AS_HOME}/domains/domain1/logs/server.log* ${WORKSPACE}/results
cp ${WORKSPACE}/tests.log ${WORKSPACE}/results
cp -r ${TS_HOME}/report/ ${WORKSPACE}/results
tar -cvf ${WORKSPACE}/${TEST_ID}-results.tar.gz ${WORKSPACE}/results
}
test_run_servlet_tck(){
export TS_HOME=${WORKSPACE}/servlettck
if [[ -z ${CTS_SMOKE_URL} ]]; then
echo "error: CTS_SMOKE_URL is not set"
exit 1
fi
pwd
uname -a
java -version
rm -rf /tmp/JTreport /tmp/JTwork /disk1/java_re/.javatest || true
wget ${CTS_SMOKE_URL}/servlettck-4.0_Latest.zip -O servlettck.zip
unzip -q servlettck.zip
if [[ -n ${1} ]]; then
TESTDIR=${WORKSPACE}/servlettck/src/com/sun/ts/tests
for i in `ls ${TESTDIR}`
do
if [[ (-d ${TESTDIR}/$i) && ( ${i} != "jsp" && ${i} != "common" && ${i} != "signaturetest") ]]; then
if [[ -z $(grep ${i} `dirname ${0}`/test_dir.properties) ]]; then
echo "A new folder ${i} is added in the test source which has no entry in the properties file"
exit 1
fi
fi
done
fi
cd ${TS_HOME}/bin
cp ts.jte ts.jte.orig
cat ts.jte.orig | ${SED} \
-e "s@webServerHost=@webServerHost=localhost@g" \
-e "s@webServerPort=@webServerPort=8080@g" \
-e "s@securedWebServicePort=@securedWebServicePort=8181@g" \
-e "s@web.home=@web\.home=${S1AS_HOME}@g" \
-e "s@javaee\.home\.ri=@javaee\.home\.ri=${S1AS_HOME}@g" \
-e "s/^orb\.host=/orb\.host=localhost/g" \
-e "s/^mailHost=/mailHost=localhost/g" \
-e "s/^mailuser1=/mailuser1=${USER:-root}@localhost/g" \
-e "s/^mailFrom=.*/mailFrom=${USER:-root}@localhost/g" \
-e "s/orb.host.ri=/orb.host.ri=localhost/g" \
-e "s/^work\.dir=\/files/work\.dir=\/tmp/g" -e "s/^report\.dir=\/files/report\.dir=\/tmp/g" \
-e "s/^tz=.*/tz=US\/Pacific/g" -e "s/modules\/gf-client.jar/lib\/gf-client.jar/g" \
-e "s/\${pathsep}\${ri\.modules}\/javax\.jms\.jar/\${pathsep}\${ri\.modules}\/javax\.jms-api\.jar\${pathsep}\$\{ri\.modules}\/javax\.jms\.jar/g" \
-e "s/\${pathsep}\${s1as\.modules}\/javax\.jms\.jar/\${pathsep}\${s1as\.modules}\/javax\.jms-api\.jar\${pathsep}\$\{s1as\.modules}\/javax\.jms\.jar/g" \
-e "s/implementation\.classes\.ri=/implementation\.classes\.ri=\${ri\.modules}\/cdi-api\.jar\${pathsep}\${ri\.modules}\/cdi-api-fragment\.jar\${pathsep}/g" \
-e "s/implementation\.classes=/implementation\.classes=\${s1as\.modules}\/cdi-api\.jar\${pathsep}\${s1as\.modules}\/cdi-api-fragment\.jar\${pathsep}/g" \
-e "s/implementation\.classes\.ri=/implementation\.classes\.ri=\${ri\.modules}\/tyrus-container-grizzly-client\.jar\${pathsep}/g" \
-e "s/implementation\.classes=/implementation\.classes=\${s1as\.modules}\/tyrus-container-grizzly-client\.jar\${pathsep}/g" \
-e "s/tyrus-container-grizzly\.jar/tyrus-container-grizzly-client\.jar/g" \
-e "s/impl\.vi=/impl\.vi\=glassfish/g" \
> ts.jte
echo "# Disabling signature tests for CI build pipeline" >> ts.jtx
echo "com/sun/ts/tests/signaturetest/servlet/ServletSigTest.java#signatureTest" >> ts.jtx
cd ${S1AS_HOME}
bin/asadmin start-domain
cd ${TS_HOME}/bin
ant config.security
ant deploy.all
if [ -n ${1} ]; then
cd ${TS_HOME}/src/com/sun/ts/tests/${1}
else
cd ${TS_HOME}/src/com/sun/ts/tests/
fi
export JAVA_OPTIONS="-Xbootclasspath/p:${TS_HOME}/lib/flow.jar"
(ant runclient -Dreport.dir=${WORKSPACE}/servlettck/report | tee ${WORKSPACE}/tests.log) || true
cd ${S1AS_HOME}
bin/asadmin stop-domain
kill_process
archive_servlet_tck
}
run_test_id(){
source `dirname $0`/../common_test.sh
kill_process
delete_workspace
unzip_test_resources ${WORKSPACE}/bundles/glassfish.zip
test_init
if [[ ${1} = "cts_smoke_all" ]]; then
test_run_cts_smoke
result=${WORKSPACE}/results/smoke.log
elif [[ ${1} = "cts_smoke_group-"* ]]; then
GROUP_ID=(`echo ${1} | sed 's/cts_smoke_group-//'`)
test_run_cts_smoke ${GROUP_ID}
result=${WORKSPACE}/results/smoke.log
elif [[ ${1} = "servlet_tck_"* ]]; then
TEST_DIR_PROPERTIES=`dirname ${0}`/test_dir.properties
TEST_DIR_PROP_KEY=(`echo ${1} | sed 's/servlet_tck_//'`)
TEST_DIR=(`cat ${TEST_DIR_PROPERTIES} | grep ${TEST_DIR_PROP_KEY} | cut -d'=' -f2`)
test_run_servlet_tck ${TEST_DIR}
result=${WORKSPACE}/results/tests.log
else
echo "Invalid Test ID"
exit 1
fi
cts_to_junit ${result} ${WORKSPACE}/results/junitreports/test_results_junit.xml ${1}
}
post_test_run(){
: # empty block not allowed in Bash
}
list_test_ids(){
echo cts_smoke_all servlet_tck_all servlet_tck_servlet-api-servlet servlet_tck_servlet-api-servlet-http servlet_tck_servlet-compat servlet_tck_servlet-pluggability servlet_tck_servlet-spec cts_smoke_group-1 cts_smoke_group-2 cts_smoke_group-3 cts_smoke_group-4 cts_smoke_group-5
}
cts_to_junit(){
junitCategory=${3}
cd ${WORKSPACE}/results
rm -rf ${2}
cat ${1} | ${GREP} -a "\[javatest.batch\] Finished Test" > results.txt
tail $((`${GREP} -n "Completed running" results.txt | ${AWK} '{print $1}' | cut -d ':' -f1`-`cat results.txt | wc -l`)) results.txt > summary.txt
echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" >> ${2}
echo "<testsuites>" >> ${2}
echo " <testsuite>" >> ${2}
for i in `${GREP} "\.\.\.\.\.\.\.\." summary.txt | ${AWK} '{print $4}'`
do
line=`echo ${i} | ${SED} s@"\.\.\.\.\.\.\.\."@" "@g`
status=`echo ${line} | ${AWK} '{print $1}'`
id=`echo ${line} | ${AWK} '{print $2}'`
classname=`echo ${id} | cut -d '#' -f1 | ${SED} s@"\/"@"_"@g | ${SED} s@".java"@@g`
name=`echo ${id} | cut -d '#' -f2`
echo " <testcase classname=\"${junitCategory}.${classname}\" name=\"${name}\">" >> ${2}
if [ "${status}" = "FAILED" ]
then
echo " <failure type=\"CtsFailure\"> n/a </failure>" >> ${2}
fi
echo " </testcase>" >> ${2}
done
echo " </testsuite>" >> ${2}
echo "</testsuites>" >> ${2}
}
delete_workspace(){
printf "\n%s \n\n" "===== DELETE WORKSPACE ====="
rm -rf ${WORKSPACE}/glassfish7 > /dev/null || true
rm -rf ${WORKSPACE}/servlettck > /dev/null || true
rm ${WORKSPACE}/servlettck.zip > /dev/null || true
rm -rf ${WORKSPACE}/javaee-smoke > /dev/null || true
rm ${WORKSPACE}/javaee-smoke-7.0_latest.zip > /dev/null || true
}
OPT=${1}
TEST_ID=${2}
case ${OPT} in
list_test_ids )
list_test_ids;;
run_test_id )
trap post_test_run EXIT
run_test_id ${TEST_ID} ;;
esac