Allow specification of revision to test with diagnostics suite.
[arvados-dev.git] / jenkins / run-diagnostics-suite.sh
1 #!/bin/bash
2
3 EXITCODE=0
4
5 INSTANCE=$1
6 REVISION=$2
7
8 if [[ "$INSTANCE" == '' ]]; then
9   echo "Syntax: $0 <instance> [revision]"
10   exit 1
11 fi
12
13 # Sanity check
14 if ! [[ -n "$WORKSPACE" ]]; then
15   echo "WORKSPACE environment variable not set"
16   exit 1
17 fi
18
19 title () {
20     txt="********** $1 **********"
21     printf "\n%*s%s\n\n" $((($COLUMNS-${#txt})/2)) "" "$txt"
22 }
23
24 timer_reset() {
25     t0=$SECONDS
26 }
27
28 timer() {
29     echo -n "$(($SECONDS - $t0))s"
30 }
31
32 source /etc/profile.d/rvm.sh
33 echo $WORKSPACE
34
35 title "Starting diagnostics"
36 timer_reset
37
38 cd $WORKSPACE
39
40 if [[ "$REVISION" != '' ]]; then
41   git checkout $REVISION
42 fi
43
44 cp -f /home/jenkins/diagnostics/arvados-workbench/$INSTANCE-application.yml $WORKSPACE/apps/workbench/config/application.yml
45
46 cd $WORKSPACE/apps/workbench
47
48 HOME="$GEMHOME" bundle install --no-deployment
49
50 if [[ ! -d tmp ]]; then
51   mkdir tmp
52 fi
53
54 RAILS_ENV=diagnostics bundle exec rake TEST=test/diagnostics/pipeline_test.rb
55
56 ECODE=$?
57
58 if [[ "$REVISION" != '' ]]; then
59   git checkout master
60 fi
61
62 if [[ "$ECODE" != "0" ]]; then
63   title "!!!!!! DIAGNOSTICS FAILED (`timer`) !!!!!!"
64   EXITCODE=$(($EXITCODE + $ECODE))
65   exit $EXITCODE
66 fi
67
68 title "Diagnostics complete (`timer`)"
69
70 exit $EXITCODE