3 # Copyright (C) The Arvados Authors. All rights reserved.
5 # SPDX-License-Identifier: AGPL-3.0
15 echo >&2 "usage: $0 [options] <identifier>"
17 echo >&2 " <identifier> Arvados cluster name"
19 echo >&2 "$0 options:"
20 echo >&2 " -p, --port <ssh port> SSH port to use (default 22)"
21 echo >&2 " --acct <username> Account to log in with"
22 echo >&2 " -d, --debug Enable debug output"
23 echo >&2 " -h, --help Display this help and exit"
24 echo >&2 " -s, --scopes Print required scopes to run tests"
28 function print_scopes {
29 echo >&2 " Required scope for the token used to run the tests:"
31 echo >&2 " arv api_client_authorization create_system_auth --scopes "
32 echo >&2 "[\"GET /arvados/v1/virtual_machines\","
33 echo >&2 "\"GET /arvados/v1/keep_services\","
34 echo >&2 "\"GET /arvados/v1/keep_services/\","
35 echo >&2 "\"GET /arvados/v1/groups\","
36 echo >&2 "\"GET /arvados/v1/groups/\","
37 echo >&2 "\"GET /arvados/v1/links\","
38 echo >&2 "\"GET /arvados/v1/collections\","
39 echo >&2 "\"POST /arvados/v1/collections\","
40 echo >&2 "\"POST /arvados/v1/links\","
41 echo >&2 "\"GET /arvados/v1/users/current\","
42 echo >&2 "\"POST /arvados/v1/users/current\","
43 echo >&2 "\"GET /arvados/v1/jobs\","
44 echo >&2 "\"POST /arvados/v1/jobs\","
45 echo >&2 "\"GET /arvados/v1/pipeline_instances\","
46 echo >&2 "\"GET /arvados/v1/pipeline_instances/\","
47 echo >&2 "\"POST /arvados/v1/pipeline_instances\","
48 echo >&2 "\"GET /arvados/v1/collections/\","
49 echo >&2 "\"POST /arvados/v1/collections/\","
50 echo >&2 "\"GET /arvados/v1/container_requests\","
51 echo >&2 "\"GET /arvados/v1/container_requests/\","
52 echo >&2 "\"POST /arvados/v1/container_requests\","
53 echo >&2 "\"POST /arvados/v1/container_requests/\","
54 echo >&2 "\"GET /arvados/v1/containers\","
55 echo >&2 "\"GET /arvados/v1/containers/\","
56 echo >&2 "\"GET /arvados/v1/repositories\","
57 echo >&2 "\"GET /arvados/v1/repositories/\","
58 echo >&2 "\"GET /arvados/v1/logs\" ]"
62 # NOTE: This requires GNU getopt (part of the util-linux package on Debian-based distros).
63 TEMP=`getopt -o hdp:s \
64 --long help,scopes,debug,port:,acct: \
67 if [ $? != 0 ] ; then echo "Use -h for help"; exit 1 ; fi
68 # Note the quotes around `$TEMP': they are essential!
75 SSH_PORT="$2"; shift 2
101 if [[ "$IDENTIFIER" == '' ]]; then
112 let endtime="$(now) + 600"
113 while [ "$endtime" -gt "$(now)" ]; do
114 puppet agent --test --detailed-exitcodes
116 if [ 0 = "$agent_exitcode" ] || [ 2 = "$agent_exitcode" ]; then
122 exit ${agent_exitcode:-99}
126 date=`date +'%Y-%m-%d %H:%M:%S'`
127 printf "%s\n" "$date $1"
130 function run_command() {
135 title "Running '${command/ARVADOS_API_TOKEN=*/ARVADOS_API_TOKEN=suppressed}' on $node"
137 if [[ "$DEBUG" != "0" ]]; then
138 ssh -t -p$SSH_PORT -o "StrictHostKeyChecking no" -o "ConnectTimeout 125" $ACCT@$node -C "$command" | tee $TMP_FILE
141 ssh -t -p$SSH_PORT -o "StrictHostKeyChecking no" -o "ConnectTimeout 125" $ACCT@$node -C "$command" > $TMP_FILE 2>&1
145 if [[ "$ECODE" != "255" && "$ECODE" != "0" ]]; then
146 # Ssh exists 255 if the connection timed out. Just ignore that, it's possible that this node is
147 # a shell node that is down.
148 title "ERROR running command on $node: exit code $ECODE"
149 if [[ "$DEBUG" == "0" ]]; then
150 title "Command output follows:"
154 if [[ "$ECODE" == "255" ]]; then
155 title "Connection denied or timed out"
158 eval "$return_var=$ECODE"
161 title "Loading ARVADOS_API_HOST and ARVADOS_API_TOKEN"
162 if [[ -f "$HOME/.config/arvados/$IDENTIFIER.arvadosapi.com.conf" ]]; then
163 . $HOME/.config/arvados/$IDENTIFIER.arvadosapi.com.conf
165 title "WARNING: $HOME/.config/arvados/$IDENTIFIER.arvadosapi.com.conf not found."
167 if [[ "$ARVADOS_API_HOST" == "" ]] || [[ "$ARVADOS_API_TOKEN" == "" ]]; then
168 title "ERROR: ARVADOS_API_HOST and/or ARVADOS_API_TOKEN environment variables are not set."
172 run_command shell.$IDENTIFIER ECODE "if [[ ! -e common-workflow-language ]]; then git clone --depth 1 https://github.com/common-workflow-language/common-workflow-language.git; fi"
174 if [[ "$ECODE" != "0" ]]; then
175 echo "Failed to git clone --depth 1 https://github.com/common-workflow-language/common-workflow-language.git"
179 run_command shell.$IDENTIFIER ECODE "printf \"%s\n%s\n\" '#!/bin/sh' 'exec arvados-cwl-runner --compute-checksum --disable-reuse \"\$@\"' > arvados-cwl-runner-with-checksum.sh; chmod 755 arvados-cwl-runner-with-checksum.sh"
181 if [[ "$ECODE" != "0" ]]; then
182 echo "Failed to create ~$ACCT/arvados-cwl-runner-with-checksum.sh"
186 run_command shell.$IDENTIFIER ECODE "cd common-workflow-language; git pull; ARVADOS_API_HOST=$ARVADOS_API_HOST ARVADOS_API_TOKEN=$ARVADOS_API_TOKEN ./run_test.sh RUNNER=/home/$ACCT/arvados-cwl-runner-with-checksum.sh "
188 if [[ "$ECODE" != "0" ]]; then
189 echo "Failed ./run_test.sh RUNNER=/home/$ACCT/arvados-cwl-runner-with-checksum.sh"
193 run_command shell.$IDENTIFIER ECODE "if [[ ! -e arvados ]]; then ARVADOS_API_HOST=$ARVADOS_API_HOST ARVADOS_API_TOKEN=$ARVADOS_API_TOKEN git clone --depth 1 https://git.$IDENTIFIER.arvadosapi.com/arvados.git; fi"
195 if [[ "$ECODE" != "0" ]]; then
196 echo "Failed to git clone --depth 1 git@git.$IDENTIFIER.arvadosapi.com:arvados.git"
200 run_command shell.$IDENTIFIER ECODE "cd arvados/sdk/cwl/tests; export ARVADOS_API_HOST=$ARVADOS_API_HOST ARVADOS_API_TOKEN=$ARVADOS_API_TOKEN && git pull && ./arvados-tests.sh"