3 # Copyright (C) The Arvados Authors. All rights reserved.
5 # SPDX-License-Identifier: AGPL-3.0
17 echo >&2 "usage: $0 [options] <identifier>"
19 echo >&2 " <identifier> Arvados cluster name"
21 echo >&2 "$0 options:"
22 echo >&2 " -p, --port <ssh port> SSH port to use (default 22)"
23 echo >&2 " --acct <username> Account to log in with"
24 echo >&2 " -d, --debug Enable debug output"
25 echo >&2 " -h, --help Display this help and exit"
26 echo >&2 " -s, --scopes Print required scopes to run tests"
27 echo >&2 " -j, --jobs <jobs> Allow N jobs at once; 1 job with no arg."
28 echo >&2 " -l, --local Run arvados-cwl-runner locally, not on shell.<identifier>"
32 function print_scopes {
33 echo >&2 " Required scope for the token used to run the tests:"
35 echo >&2 " arv api_client_authorization create_system_auth --scopes "
36 echo >&2 "[\"GET /arvados/v1/virtual_machines\","
37 echo >&2 "\"GET /arvados/v1/keep_services\","
38 echo >&2 "\"GET /arvados/v1/keep_services/\","
39 echo >&2 "\"GET /arvados/v1/groups\","
40 echo >&2 "\"GET /arvados/v1/groups/\","
41 echo >&2 "\"GET /arvados/v1/links\","
42 echo >&2 "\"GET /arvados/v1/collections\","
43 echo >&2 "\"POST /arvados/v1/collections\","
44 echo >&2 "\"POST /arvados/v1/links\","
45 echo >&2 "\"GET /arvados/v1/users/current\","
46 echo >&2 "\"POST /arvados/v1/users/current\","
47 echo >&2 "\"GET /arvados/v1/jobs\","
48 echo >&2 "\"POST /arvados/v1/jobs\","
49 echo >&2 "\"GET /arvados/v1/pipeline_instances\","
50 echo >&2 "\"GET /arvados/v1/pipeline_instances/\","
51 echo >&2 "\"POST /arvados/v1/pipeline_instances\","
52 echo >&2 "\"GET /arvados/v1/collections/\","
53 echo >&2 "\"POST /arvados/v1/collections/\","
54 echo >&2 "\"GET /arvados/v1/container_requests\","
55 echo >&2 "\"GET /arvados/v1/container_requests/\","
56 echo >&2 "\"POST /arvados/v1/container_requests\","
57 echo >&2 "\"POST /arvados/v1/container_requests/\","
58 echo >&2 "\"GET /arvados/v1/containers\","
59 echo >&2 "\"GET /arvados/v1/containers/\","
60 echo >&2 "\"GET /arvados/v1/repositories\","
61 echo >&2 "\"GET /arvados/v1/repositories/\","
62 echo >&2 "\"GET /arvados/v1/logs\" ]"
66 # NOTE: This requires GNU getopt (part of the util-linux package on Debian-based distros).
67 TEMP=`getopt -o hdlp:sj: \
68 --long help,scopes,debug,local,port:,acct:,jobs: \
71 if [ $? != 0 ] ; then echo "Use -h for help"; exit 1 ; fi
72 # Note the quotes around `$TEMP': they are essential!
79 SSH_PORT="$2"; shift 2
112 if [[ "$IDENTIFIER" == '' ]]; then
123 let endtime="$(now) + 600"
124 while [ "$endtime" -gt "$(now)" ]; do
125 puppet agent --test --detailed-exitcodes
127 if [ 0 = "$agent_exitcode" ] || [ 2 = "$agent_exitcode" ]; then
133 exit ${agent_exitcode:-99}
137 date=`date +'%Y-%m-%d %H:%M:%S'`
138 printf "%s\n" "$date $1"
141 function run_command() {
146 if [[ "$LOCAL" == "0" ]]; then
147 title "Running '${command/ARVADOS_API_TOKEN=* /ARVADOS_API_TOKEN=suppressed }' on $node"
149 if [[ "$DEBUG" != "0" ]]; then
150 echo ssh -t -p$SSH_PORT -o "StrictHostKeyChecking no" -o "ConnectTimeout 125" $ACCT@$node -C "$command" | tee $TMP_FILE
151 ssh -t -p$SSH_PORT -o "StrictHostKeyChecking no" -o "ConnectTimeout 125" $ACCT@$node -C "$command" | tee $TMP_FILE
154 ssh -t -p$SSH_PORT -o "StrictHostKeyChecking no" -o "ConnectTimeout 125" $ACCT@$node -C "$command" > $TMP_FILE 2>&1
158 if [[ "$ECODE" != "255" && "$ECODE" != "0" ]]; then
159 # Ssh exits 255 if the connection timed out. Just ignore that, it's possible that this node is
160 # a shell node that is down.
161 title "ERROR running command on $node: exit code $ECODE"
162 if [[ "$DEBUG" == "0" ]]; then
163 title "Command output follows:"
167 if [[ "$ECODE" == "255" ]]; then
168 title "Connection denied or timed out"
171 title "Running '${command/ARVADOS_API_TOKEN=* /ARVADOS_API_TOKEN=suppressed }' locally"
173 if [[ "$DEBUG" != "0" ]]; then
174 bash -c "$command" | tee $TMP_FILE
177 bash -c "$command" > $TMP_FILE 2>&1
181 if [[ "$ECODE" != "0" ]]; then
182 title "ERROR running command locally: exit code $ECODE"
183 if [[ "$DEBUG" == "0" ]]; then
184 title "Command output follows:"
190 eval "$return_var=$ECODE"
193 if [[ "$LOCAL" == "1" && "$ACCT" == "" ]]; then
197 if [[ "$LOCAL" == "0" && "$ACCT" == "" ]]; then
201 title "Loading ARVADOS_API_HOST and ARVADOS_API_TOKEN"
202 if [[ -f "$HOME/.config/arvados/$IDENTIFIER.arvadosapi.com.conf" ]]; then
203 . $HOME/.config/arvados/$IDENTIFIER.arvadosapi.com.conf
205 title "WARNING: $HOME/.config/arvados/$IDENTIFIER.arvadosapi.com.conf not found."
207 if [[ "$ARVADOS_API_HOST" == "" ]] || [[ "$ARVADOS_API_TOKEN" == "" ]]; then
208 title "ERROR: ARVADOS_API_HOST and/or ARVADOS_API_TOKEN environment variables are not set."
212 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"
214 if [[ "$ECODE" != "0" ]]; then
215 echo "Failed to git clone --depth 1 https://github.com/common-workflow-language/common-workflow-language.git"
219 run_command shell.$IDENTIFIER ECODE "printf \"%s\n%s\n\" '#!/bin/sh' 'exec arvados-cwl-runner --api containers --compute-checksum --disable-reuse --eval-timeout 60 \"\$@\"' > ~$ACCT/arvados-cwl-runner-with-checksum.sh; chmod 755 ~$ACCT/arvados-cwl-runner-with-checksum.sh"
221 if [[ "$ECODE" != "0" ]]; then
222 echo "Failed to create ~$ACCT/arvados-cwl-runner-with-checksum.sh"
226 run_command shell.$IDENTIFIER ECODE "cd common-workflow-language; git pull; ARVADOS_API_HOST=$ARVADOS_API_HOST ARVADOS_API_TOKEN=$ARVADOS_API_TOKEN ARVADOS_API_HOST_INSECURE=$ARVADOS_API_HOST_INSECURE ./run_test.sh -j$JOBS --timeout=900 RUNNER=/home/$ACCT/arvados-cwl-runner-with-checksum.sh"
228 if [[ "$ECODE" != "0" ]]; then
229 echo "Failed ./run_test.sh -j$JOBS RUNNER=/home/$ACCT/arvados-cwl-runner-with-checksum.sh"
233 run_command shell.$IDENTIFIER ECODE "if [[ ! -e arvados ]]; then ARVADOS_API_HOST=$ARVADOS_API_HOST ARVADOS_API_TOKEN=$ARVADOS_API_TOKEN ARVADOS_API_HOST_INSECURE=$ARVADOS_API_HOST_INSECURE git clone --depth 1 https://github.com/arvados/arvados.git; fi"
235 if [[ "$ECODE" != "0" ]]; then
236 echo "Failed to git clone --depth 1 https://git.arvados.org/arvados.git"
240 run_command shell.$IDENTIFIER ECODE "cd arvados/sdk/cwl/tests; export ARVADOS_API_HOST=$ARVADOS_API_HOST ARVADOS_API_TOKEN=$ARVADOS_API_TOKEN ARVADOS_API_HOST_INSECURE=$ARVADOS_API_HOST_INSECURE && git pull && ./arvados-tests.sh -j$JOBS"