Do not try to add packages to the repository that are already in it.
[arvados-dev.git] / jenkins / run-performance-suite.sh
1 #!/bin/bash
2
3 # Copyright (C) The Arvados Authors. All rights reserved.
4 #
5 # SPDX-License-Identifier: AGPL-3.0
6
7 EXITCODE=0
8
9 INSTANCE=$1
10 REVISION=$2
11
12 if [[ "$INSTANCE" == '' ]]; then
13   echo "Syntax: $0 <instance> [revision]"
14   exit 1
15 fi
16
17 if [[ "$REVISION" == '' ]]; then
18   # See if there's a configuration file with the revision?
19   CONFIG_PATH=/home/jenkins/configuration/$INSTANCE.arvadosapi.com-versions.conf
20   if [[ -f $CONFIG_PATH ]]; then
21     echo "Loading git revision from $CONFIG_PATH"
22     . $CONFIG_PATH
23     REVISION=$ARVADOS_GIT_REVISION
24   fi
25 fi
26
27 if [[ "$REVISION" != '' ]]; then
28   echo "Git revision is $REVISION"
29 else
30   echo "No valid git revision found, proceeding with what is in place."
31 fi
32
33 # Sanity check
34 if ! [[ -n "$WORKSPACE" ]]; then
35   echo "WORKSPACE environment variable not set"
36   exit 1
37 fi
38
39 title () {
40     txt="********** $1 **********"
41     printf "\n%*s%s\n\n" $((($COLUMNS-${#txt})/2)) "" "$txt"
42 }
43
44 timer_reset() {
45     t0=$SECONDS
46 }
47
48 timer() {
49     echo -n "$(($SECONDS - $t0))s"
50 }
51
52 source /etc/profile.d/rvm.sh
53 echo $WORKSPACE
54
55 title "Starting performance test"
56 timer_reset
57
58 cd $WORKSPACE
59
60 if [[ "$REVISION" != '' ]]; then
61   git checkout $REVISION
62 fi
63
64 ECODE=$?
65
66 if [[ "$ECODE" != "0" ]]; then
67   title "!!!!!! PERFORMANCE TESTS FAILED (`timer`) !!!!!!"
68   EXITCODE=$(($EXITCODE + $ECODE))
69   exit $EXITCODE
70 fi
71
72 cp -f /home/jenkins/diagnostics/arvados-workbench/$INSTANCE-application.yml $WORKSPACE/apps/workbench/config/application.yml
73
74 cd $WORKSPACE/apps/workbench
75
76 HOME="$GEMHOME" bundle install --no-deployment
77
78 if [[ ! -d tmp ]]; then
79   mkdir tmp
80 fi
81
82 mkdir -p tmp/cache
83
84 RAILS_ENV=performance bundle exec rake test:benchmark
85
86 ECODE=$?
87
88 if [[ "$REVISION" != '' ]]; then
89   git checkout master
90 fi
91
92 if [[ "$ECODE" != "0" ]]; then
93   title "!!!!!! PERFORMANCE TESTS FAILED (`timer`) !!!!!!"
94   EXITCODE=$(($EXITCODE + $ECODE))
95   exit $EXITCODE
96 fi
97
98 title "Performance tests complete (`timer`)"
99
100 exit $EXITCODE