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

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

Haven't run diffcol yet, but making the basic changes necessary to get the task file up to date.

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