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