17535: Use the backport line only in the Debian family
[arvados-dev.git] / jenkins / run-diagnostics-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 diagnostics"
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 "!!!!!! DIAGNOSTICS 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 if [ $INSTANCE == '9tee4' ] 
83 then
84     RAILS_ENV=diagnostics bundle exec rake TEST=test/diagnostics/container_request_test.rb
85 else
86     RAILS_ENV=diagnostics bundle exec rake TEST=test/diagnostics/pipeline_test.rb
87 fi
88
89 ECODE=$?
90
91 if [[ "$REVISION" != '' ]]; then
92   git checkout main
93 fi
94
95 if [[ "$ECODE" != "0" ]]; then
96   title "!!!!!! DIAGNOSTICS FAILED (`timer`) !!!!!!"
97   EXITCODE=$(($EXITCODE + $ECODE))
98   exit $EXITCODE
99 fi
100
101 title "Diagnostics complete (`timer`)"
102
103 exit $EXITCODE