source: other-projects/nightly-tasks/diffcol/trunk/task@ 27536

Last change on this file since 27536 was 27536, checked in by ak19, 11 years ago

FileUtils functions instead of util.pm

File size: 6.4 KB
Line 
1#!/bin/bash
2
3if [ "x$TASK_HOME" == "x" ]; then
4 TASK_HOME=`pwd`;
5fi
6
7export DATA_DIR=$TASK_HOME/diffcol-data
8export UPLOAD_DIR=$TASK_HOME/diffcol-reports
9export [email protected]
10
11#check key environment vars are set
12if [ "$UPLOAD_DIR" == "" ]; then
13 echo "Please set a UPLOAD_DIR for the test in an environment.sh file"
14 exit
15fi
16if [ "$DATA_DIR" == "" ]; then
17 echo "Please set a DATA_DIR for the test in an environment.sh file"
18 exit
19fi
20if [ "$MONITOR_EMAIL" == "" ]; then
21 echo "Please set a MONITOR_EMAIL for the test in an environment.sh file"
22 exit
23fi
24
25
26if [ "$DATA_DIR" == "/" ]; then
27 echo "DATA_DIR should not be the fs root"
28 exit
29fi
30
31echo "DATA_DIR: $DATA_DIR"
32echo "UPLOAD_DIR: $UPLOAD_DIR"
33
34#create an id for this test
35dateid=`date +'%Y-%m-%d'`
36
37echo "Starting test '$dateid'"
38
39#set classpath
40CLASSPATH=
41for file in $TASK_HOME/lib/*.jar; do
42 CLASSPATH=$file:$CLASSPATH
43done
44export CLASSPATH
45
46#set the location of the full report
47xmlout=$DATA_DIR'/full-report-'$dateid'.xml'
48
49function setup_greenstone() {
50
51 #clean up from previous tests
52 echo -n "about to clean up any old tests (Ctrl-C to cancel)"
53 for i in x x x x x; do sleep 1; echo -n .; done
54 echo
55
56 echo "cleaning up previous tests"
57 rm -rf $DATA_DIR
58
59 echo "creating the data dir"
60 mkdir -p $DATA_DIR || exit
61
62 cd $DATA_DIR
63
64 #svn checkout of main gsdl directory
65 echo "checkout gsdl:"
66 svn co http://svn.greenstone.org/main/trunk/greenstone2 gsdl
67 echo "done"
68
69 cd $DATA_DIR/gsdl
70
71
72 # since this is a bash script, we're on linux/darwin, need gnome-lib
73 # for the correct architecture. Assume all darwin is intel, not ppc
74 echo "setting up gnome-lib-minimal for compilation"
75
76# http://stackoverflow.com/questions/394230/detect-the-os-from-a-bash-script
77 os='linux';
78 gl_suffix=$os;
79 if [[ "$OSTYPE" == "darwin"* ]]; then
80 os='darwin';
81 gl_suffix=$os'-intel';
82 else
83 # linux, worl out the bit arch
84 arch=`uname -m`
85 if [[ "$arch" == *"64"* ]]; then
86 arch='64';
87 gl_suffix=$gl_suffix'-x64';
88 else
89 arch='32';
90 fi
91 fi
92
93
94 #svn checkout gnome-lib for this linux/darwin
95 cd $DATA_DIR/gsdl/ext
96
97# svn export http://svn.greenstone.org/gs2-extensions/gnome-lib/trunk/gnome-lib-minimal-linux-x64.tar.gz gl.tar.gz
98 svn export http://svn.greenstone.org/gs2-extensions/gnome-lib/trunk/gnome-lib-minimal-$gl_suffix.tar.gz gl.tar.gz
99 tar xvzf gl.tar.gz
100 cd gnome-lib-minimal
101 source devel.bash
102
103 cd ../..
104
105
106 #configure
107 echo "configure gsdl: "
108 echo "<configure>" >> $xmlout
109 ./configure 2>> $DATA_DIR/compilation-errors
110 echo "</configure>" >> $xmlout
111 echo "done"
112
113 #make
114 echo "make gsdl: "
115 echo "<make>" >> $xmlout
116 make 2>> $DATA_DIR/compilation-errors
117 echo "</make>" >> $xmlout
118 echo "done"
119
120 #make install
121 echo "make install gsdl: "
122 echo "<make-install>" >> $xmlout
123 make install $DATA_DIR/compilation-errors
124 echo "</make-install>" >> $xmlout
125 echo "done"
126
127
128}
129
130
131function run_test() {
132
133 #perform the requested subcommands, outputting xml information
134 echo '<test time="'$dateid'" id="'$dateid'">' > $xmlout
135
136 cd $DATA_DIR/gsdl
137
138 #get svn info
139 echo "getting svn info: "
140 echo "<svn-info>" >> $xmlout
141 svn info >> $xmlout
142 echo "</svn-info>" >> $xmlout
143 echo "done"
144
145 #set up the gsdl environment with the setup.bash script
146 echo "setting up gsdl environment: "
147 export GSDLHOME=
148 source setup.bash
149 echo "done"
150
151 #make two copies of the model-collect directory in gsdl
152 #one to be rebuild and one as the basis for comparison
153 #strip both of all .svn directories
154
155 #copy the model collections to the collect folder to be rebuilt
156 echo -n "installing test collections and model collections to new gsdl installation... "
157
158 #clean up
159 rm -rf collect
160 rm -rf model-collect
161
162 #copy to collect and strip
163 cp -r $TASK_HOME/model-collect collect
164 find collect -type d -name .svn -exec rm -rf {} \;
165
166 #make the model copy
167 cp -r collect model-collect
168
169 echo "done"
170
171 #for each collection, import, build and diff with its model counterpart
172 for collection in collect/*; do
173
174 #escape the filename (in case of space)
175 collection=`echo $collection | sed 's@ @\\\ @g'`
176
177 #get just the basename
178 collection=`basename $collection`
179
180 echo '<collection-test name="'$collection'">' >> $xmlout
181
182 #import
183 echo $collection' - Importing:'
184 echo "<import>" >> $xmlout
185 import.pl $collection -removeold
186 echo "</import>" >> $xmlout
187 echo "done"
188
189 #build
190 echo $collection' - Building:'
191 echo "<build>" >> $xmlout
192 buildcol.pl $collection -removeold
193 echo "</build>" >> $xmlout
194 echo "done"
195
196 #rename the intermediate 'building' directory 'index'
197 echo -n $collection' - Move "building" to "index"... "'
198 rm -rf collect/$collection/index
199 mv collect/$collection/building collect/$collection/index
200 echo "done"
201
202 #diffcol
203 echo $collection' - Diffing:'
204 cd $TASK_HOME/diffcol
205 ./diffcol.pl -output xml -verbosity 10 $collection >> $xmlout
206 cd $DATA_DIR/gsdl
207 echo "done"
208
209 echo "</collection-test>" >> $xmlout
210 done
211
212 echo "</test>" >> $xmlout
213
214 # email out if failed
215 echo "Checking if failed... "
216 result=`java org.apache.xalan.xslt.Process -IN "$xmlout" -XSL "$TASK_HOME/xsl/passed-or-not.xsl"`
217 echo "result: "$result
218 if [ "$result" != "yes" ]; then
219 echo 'gsdl regression test for '$dateid' failed' | mail -s $1' Regression Test Failed' $MONITOR_EMAIL
220 #$WEBMASTER_EMAIL
221 fi
222 echo "done"
223
224}
225
226function upload() {
227 scp $DATA_DIR/*.xml $DATA_DIR/*.html $UPLOAD_DIR
228}
229
230function summarise() {
231
232 # make a summarised Xml report
233 echo -n "Summarizing the xml report... "
234 java org.apache.xalan.xslt.Process -IN $xmlout -XSL $TASK_HOME/xsl/xml-report.xsl -OUT $DATA_DIR/report-$dateid.xml
235 echo "done"
236
237 # make a summarised HTml report
238 echo -n "Creating an html summary report... "
239 java org.apache.xalan.xslt.Process -IN $DATA_DIR/report-$dateid.xml -XSL $TASK_HOME/xsl/html-report.xsl -OUT $DATA_DIR/report-$dateid.html
240 echo "done"
241
242}
243
244#parse arguments
245if [ "$1" == "" ]; then
246 action=all
247else
248 if [ "$1" == "setup_greenstone" ]; then
249 action=setup_greenstone
250 elif [ "$1" == "run_test" ]; then
251 action=run_test
252 elif [ "$1" == "summarise" ]; then
253 action=summarise
254 elif [ "$1" == "upload" ]; then
255 action=upload
256 elif [ "$1" == "all" ]; then
257 action=all
258 else
259 echo "bad subcommand"
260 exit
261 fi
262fi
263
264#do the requested action
265if [ "$action" == "setup_greenstone" ]; then
266 setup_greenstone
267elif [ "$action" == "run_test" ]; then
268 run_test
269elif [ "$action" == "summarise" ]; then
270 summarise
271elif [ "$action" == "upload" ]; then
272 upload
273elif [ "$action" == "all" ]; then
274 setup_greenstone
275 run_test
276 summarise
277 upload
278fi
279
Note: See TracBrowser for help on using the repository browser.