[21711] | 1 | #!/bin/bash
|
---|
| 2 |
|
---|
[27524] | 3 | export DATA_DIR=$TASK_HOME/diffcol-data
|
---|
| 4 | export UPLOAD_DIR=$TASK_HOME/diffcol-reports
|
---|
| 5 | export [email protected]
|
---|
| 6 |
|
---|
[21711] | 7 | #check key environment vars are set
|
---|
| 8 | if [ "$UPLOAD_DIR" == "" ]; then
|
---|
| 9 | echo "Please set a UPLOAD_DIR for the test in an environment.sh file"
|
---|
| 10 | exit
|
---|
| 11 | fi
|
---|
| 12 | if [ "$DATA_DIR" == "" ]; then
|
---|
| 13 | echo "Please set a DATA_DIR for the test in an environment.sh file"
|
---|
| 14 | exit
|
---|
| 15 | fi
|
---|
| 16 | if [ "$MONITOR_EMAIL" == "" ]; then
|
---|
| 17 | echo "Please set a MONITOR_EMAIL for the test in an environment.sh file"
|
---|
| 18 | exit
|
---|
| 19 | fi
|
---|
| 20 |
|
---|
| 21 |
|
---|
| 22 | if [ "$DATA_DIR" == "/" ]; then
|
---|
| 23 | echo "DATA_DIR should not be the fs root"
|
---|
| 24 | exit
|
---|
| 25 | fi
|
---|
| 26 |
|
---|
| 27 | echo "DATA_DIR: $DATA_DIR"
|
---|
| 28 | echo "UPLOAD_DIR: $UPLOAD_DIR"
|
---|
| 29 |
|
---|
| 30 | #create an id for this test
|
---|
| 31 | dateid=`date +'%Y-%m-%d'`
|
---|
| 32 |
|
---|
| 33 | echo "Starting test '$dateid'"
|
---|
| 34 |
|
---|
| 35 | #set classpath
|
---|
| 36 | CLASSPATH=
|
---|
| 37 | for file in $TASK_HOME/lib/*.jar; do
|
---|
| 38 | CLASSPATH=$file:$CLASSPATH
|
---|
| 39 | done
|
---|
| 40 | export CLASSPATH
|
---|
| 41 |
|
---|
| 42 | #set the location of the full report
|
---|
| 43 | xmlout=$DATA_DIR'/full-report-'$dateid'.xml'
|
---|
| 44 |
|
---|
| 45 | function 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:"
|
---|
[27524] | 62 | svn co http://svn.greenstone.org/main/trunk/greenstone2 gsdl
|
---|
[21711] | 63 | echo "done"
|
---|
| 64 |
|
---|
| 65 | cd $DATA_DIR/gsdl
|
---|
| 66 |
|
---|
| 67 |
|
---|
[27524] | 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 |
|
---|
[21711] | 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 |
|
---|
| 127 | function 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
|
---|
[27524] | 215 | echo 'gsdl regression test for '$dateid' failed' | mail -s $1' Regression Test Failed' $MONITOR_EMAIL
|
---|
| 216 | #$WEBMASTER_EMAIL
|
---|
[21711] | 217 | fi
|
---|
| 218 | echo "done"
|
---|
| 219 |
|
---|
| 220 | }
|
---|
| 221 |
|
---|
| 222 | function upload() {
|
---|
| 223 | scp $DATA_DIR/*.xml $DATA_DIR/*.html $UPLOAD_DIR
|
---|
| 224 | }
|
---|
| 225 |
|
---|
| 226 | function 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
|
---|
| 241 | if [ "$1" == "" ]; then
|
---|
| 242 | action=all
|
---|
| 243 | else
|
---|
| 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
|
---|
| 258 | fi
|
---|
| 259 |
|
---|
| 260 | #do the requested action
|
---|
| 261 | if [ "$action" == "setup_greenstone" ]; then
|
---|
| 262 | setup_greenstone
|
---|
| 263 | elif [ "$action" == "run_test" ]; then
|
---|
| 264 | run_test
|
---|
| 265 | elif [ "$action" == "summarise" ]; then
|
---|
| 266 | summarise
|
---|
| 267 | elif [ "$action" == "upload" ]; then
|
---|
| 268 | upload
|
---|
| 269 | elif [ "$action" == "all" ]; then
|
---|
| 270 | setup_greenstone
|
---|
| 271 | run_test
|
---|
| 272 | summarise
|
---|
| 273 | upload
|
---|
| 274 | fi
|
---|
| 275 |
|
---|