Abort performance suite with prejudice if the git checkout fails.
[arvados-dev.git] / jenkins / run-performance-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 performance test"
52 timer_reset
53
54 cd $WORKSPACE
55
56 if [[ "$REVISION" != '' ]]; then
57   git checkout $REVISION
58 fi
59
60 ECODE=$?
61
62 if [[ "$ECODE" != "0" ]]; then
63   title "!!!!!! PERFORMANCE TESTS FAILED (`timer`) !!!!!!"
64   EXITCODE=$(($EXITCODE + $ECODE))
65   exit $EXITCODE
66 fi
67
68 cp -f /home/jenkins/diagnostics/arvados-workbench/$INSTANCE-application.yml $WORKSPACE/apps/workbench/config/application.yml
69
70 cd $WORKSPACE/apps/workbench
71
72 HOME="$GEMHOME" bundle install --no-deployment
73
74 if [[ ! -d tmp ]]; then
75   mkdir tmp
76 fi
77
78 mkdir -p tmp/cache
79
80 RAILS_ENV=performance bundle exec rake test:benchmark
81
82 ECODE=$?
83
84 if [[ "$REVISION" != '' ]]; then
85   git checkout master
86 fi
87
88 if [[ "$ECODE" != "0" ]]; then
89   title "!!!!!! PERFORMANCE TESTS FAILED (`timer`) !!!!!!"
90   EXITCODE=$(($EXITCODE + $ECODE))
91   exit $EXITCODE
92 fi
93
94 title "Performance tests complete (`timer`)"
95
96 exit $EXITCODE