16375: Add multinode testing code
[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 # # First, validate that the CA is installed and that we can query it with no errors.
13 # if ! curl -s -o /dev/null https://${ARVADOS_API_HOST}/users/welcome?return_to=%2F; then
14 #   echo "The Arvados CA was not correctly installed. Although some components will work,"
15 #   echo "others won't. Please verify that the CA cert file was installed correctly and"
16 #   echo "retry running these tests."
17 #   exit 1
18 # fi
19
20 # https://doc.arvados.org/v2.0/install/install-jobs-image.html
21 echo "Creating Arvados Standard Docker Images project"
22 uuid_prefix=$(arv --format=uuid user current | cut -d- -f1)
23 project_uuid=$(arv --format=uuid group list --filters '[["name", "=", "Arvados Standard Docker Images"]]')
24
25 if [ "x${project_uuid}" = "x" ]; then
26   project_uuid=$(arv --format=uuid group create --group "{\"owner_uuid\": \"${uuid_prefix}-tpzed-000000000000000\", \"group_class\":\"project\", \"name\":\"Arvados Standard Docker Images\"}")
27
28   read -rd $'\000' newlink <<EOF; arv link create --link "${newlink}"
29 {
30   "tail_uuid":"${uuid_prefix}-j7d0g-fffffffffffffff",
31   "head_uuid":"${project_uuid}",
32   "link_class":"permission",
33   "name":"can_read"
34 }
35 EOF
36 fi
37
38 echo "Arvados project uuid is '${project_uuid}'"
39
40 # Create the initial user
41 echo "Creating initial user '__INITIAL_USER__'"
42 user_uuid=$(arv --format=uuid user list --filters '[["email", "=", "__INITIAL_USER_EMAIL__"], ["username", "=", "__INITIAL_USER__"]]')
43
44 if [ "x${user_uuid}" = "x" ]; then
45   user_uuid=$(arv --format=uuid user create --user '{"email": "__INITIAL_USER_EMAIL__", "username": "__INITIAL_USER__"}')
46   echo "Setting up user '__INITIAL_USER__'"
47   arv user setup --uuid "${user_uuid}"
48 fi
49
50 echo "Activating user '__INITIAL_USER__'"
51 arv user update --uuid "${user_uuid}" --user '{"is_active": true}'
52
53 echo "Getting the user API TOKEN"
54 user_api_token=$(arv api_client_authorization list | jq -r ".items[] | select( .owner_uuid == \"${user_uuid}\" ).api_token" | head -1)
55
56 if [ "x${user_api_token}" = "x" ]; then
57   echo "No existing token found for user '__INITIAL_USER__' (user_uuid: '${user_uuid}'). Creating token"
58   user_api_token=$(arv api_client_authorization create --api-client-authorization "{\"owner_uuid\": \"${user_uuid}\"}" | jq -r .api_token)
59 fi
60
61 echo "API TOKEN FOR user '__INITIAL_USER__': '${user_api_token}'."
62
63 # Change to the user's token and run the workflow
64 echo "Switching to user '__INITIAL_USER__'"
65 export ARVADOS_API_TOKEN="${user_api_token}"
66
67 echo "Running test CWL workflow"
68 cwl-runner --debug hasher-workflow.cwl hasher-workflow-job.yml