Fix 2.4.2 upgrade notes formatting refs #19330
[arvados.git] / tools / salt-install / tests / run-test.sh
1 #!/bin/bash
2 # Copyright (C) The Arvados Authors. All rights reserved.
3 #
4 # SPDX-License-Identifier: Apache-2.0
5
6 export ARVADOS_API_TOKEN=__SYSTEM_ROOT_TOKEN__
7 export ARVADOS_API_HOST=__CLUSTER__.__DOMAIN__:__CONTROLLER_EXT_SSL_PORT__
8 export ARVADOS_API_HOST_INSECURE=true
9
10 set -o pipefail
11
12 # https://doc.arvados.org/v2.0/install/install-jobs-image.html
13 echo "Creating Arvados Standard Docker Images project"
14 uuid_prefix=$(arv --format=uuid user current | cut -d- -f1)
15 project_uuid=$(arv --format=uuid group list --filters '[["name", "=", "Arvados Standard Docker Images"]]')
16
17 if [ "x${project_uuid}" = "x" ]; then
18   project_uuid=$(arv --format=uuid group create --group "{\"owner_uuid\": \"${uuid_prefix}-tpzed-000000000000000\", \"group_class\":\"project\", \"name\":\"Arvados Standard Docker Images\"}")
19
20   read -rd $'\000' newlink <<EOF; arv link create --link "${newlink}"
21 {
22   "tail_uuid":"${uuid_prefix}-j7d0g-fffffffffffffff",
23   "head_uuid":"${project_uuid}",
24   "link_class":"permission",
25   "name":"can_read"
26 }
27 EOF
28 fi
29
30 echo "Arvados project uuid is '${project_uuid}'"
31
32 # Create the initial user
33 echo "Creating initial user '__INITIAL_USER__'"
34 user_uuid=$(arv --format=uuid user list --filters '[["email", "=", "__INITIAL_USER_EMAIL__"], ["username", "=", "__INITIAL_USER__"]]')
35
36 if [ "x${user_uuid}" = "x" ]; then
37   user_uuid=$(arv --format=uuid user create --user '{"email": "__INITIAL_USER_EMAIL__", "username": "__INITIAL_USER__"}')
38   echo "Setting up user '__INITIAL_USER__'"
39   arv user setup --uuid "${user_uuid}"
40 fi
41
42 echo "Activating user '__INITIAL_USER__'"
43 arv user update --uuid "${user_uuid}" --user '{"is_active": true}'
44
45 echo "Getting the user API TOKEN"
46 user_api_token=$(arv api_client_authorization list | jq -r ".items[] | select( .owner_uuid == \"${user_uuid}\" ).api_token" | head -1)
47
48 if [ "x${user_api_token}" = "x" ]; then
49   echo "No existing token found for user '__INITIAL_USER__' (user_uuid: '${user_uuid}'). Creating token"
50   user_api_token=$(arv api_client_authorization create --api-client-authorization "{\"owner_uuid\": \"${user_uuid}\"}" | jq -r .api_token)
51 fi
52
53 echo "API TOKEN FOR user '__INITIAL_USER__': '${user_api_token}'."
54
55 # Change to the user's token and run the workflow
56 echo "Switching to user '__INITIAL_USER__'"
57 export ARVADOS_API_TOKEN="${user_api_token}"
58
59 echo "Running test CWL workflow"
60 cwl-runner --debug hasher-workflow.cwl hasher-workflow-job.yml