8750: parallel deploy is working
[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 if [[ "$REVISION" == '' ]]; then
14   # See if there's a configuration file with the revision?
15   CONFIG_PATH=/home/jenkins/configuration/$INSTANCE.arvadosapi.com-versions.conf
16   if [[ -f $CONFIG_PATH ]]; then
17     echo "Loading git revision from $CONFIG_PATH"
18     . $CONFIG_PATH
19     REVISION=$ARVADOS_GIT_REVISION
20   fi
21 fi
22
23 if [[ "$REVISION" != '' ]]; then
24   echo "Git revision is $REVISION"
25 else
26   echo "No valid git revision found, proceeding with what is in place."
27 fi
28
29 # Sanity check
30 if ! [[ -n "$WORKSPACE" ]]; then
31   echo "WORKSPACE environment variable not set"
32   exit 1
33 fi
34
35 title () {
36     txt="********** $1 **********"
37     printf "\n%*s%s\n\n" $((($COLUMNS-${#txt})/2)) "" "$txt"
38 }
39
40 timer_reset() {
41     t0=$SECONDS
42 }
43
44 timer() {
45     echo -n "$(($SECONDS - $t0))s"
46 }
47
48 source /etc/profile.d/rvm.sh
49 echo $WORKSPACE
50
51 title "Starting diagnostics"
52 timer_reset
53
54 cd $WORKSPACE
55
56 if [[ "$REVISION" != '' ]]; then
57   git checkout $REVISION
58 fi
59
60 cp -f /home/jenkins/diagnostics/arvados-workbench/$INSTANCE-application.yml $WORKSPACE/apps/workbench/config/application.yml
61
62 cd $WORKSPACE/apps/workbench
63
64 HOME="$GEMHOME" bundle install --no-deployment
65
66 if [[ ! -d tmp ]]; then
67   mkdir tmp
68 fi
69
70 RAILS_ENV=diagnostics bundle exec rake TEST=test/diagnostics/pipeline_test.rb
71
72 ECODE=$?
73
74 if [[ "$REVISION" != '' ]]; then
75   git checkout master
76 fi
77
78 if [[ "$ECODE" != "0" ]]; then
79   title "!!!!!! DIAGNOSTICS FAILED (`timer`) !!!!!!"
80   EXITCODE=$(($EXITCODE + $ECODE))
81   exit $EXITCODE
82 fi
83
84 title "Diagnostics complete (`timer`)"
85
86 exit $EXITCODE