Fix hardcoded initial user name and email
[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=changemesystemroottoken
7 export ARVADOS_API_HOST=__CLUSTER__.__DOMAIN__:__HOST_SSL_PORT__
8 export ARVADOS_API_HOST_INSECURE=true
9
10
11 # https://doc.arvados.org/v2.0/install/install-jobs-image.html
12 echo "Creating Arvados Standard Docker Images project"
13 uuid_prefix=$(arv --format=uuid user current | cut -d- -f1)
14 project_uuid=$(arv --format=uuid group list --filters '[["name", "=", "Arvados Standard Docker Images"]]')
15
16 if [ "x${project_uuid}" = "x" ]; then
17   project_uuid=$(arv --format=uuid group create --group "{\"owner_uuid\": \"${uuid_prefix}-tpzed-000000000000000\", \"group_class\":\"project\", \"name\":\"Arvados Standard Docker Images\"}")
18
19   read -rd $'\000' newlink <<EOF; arv link create --link "${newlink}"
20 {
21   "tail_uuid":"${uuid_prefix}-j7d0g-fffffffffffffff",
22   "head_uuid":"${project_uuid}",
23   "link_class":"permission",
24   "name":"can_read"
25 }
26 EOF
27 fi
28
29 echo "Arvados project uuid is '${project_uuid}'"
30
31 echo "Uploading arvados/jobs' docker image to the project"
32 VERSION="2.1.1"
33 arv-keepdocker --pull arvados/jobs "${VERSION}" --project-uuid "${project_uuid}"
34
35 # Create the initial user
36 echo "Creating initial user '__INITIAL_USER__'"
37 user_uuid=$(arv --format=uuid user list --filters '[["email", "=", "__INITIAL_USER_EMAIL__"], ["username", "=", "__INITIAL_USER__"]]')
38
39 if [ "x${user_uuid}" = "x" ]; then
40   user_uuid=$(arv --format=uuid user create --user '{"email": "__INITIAL_USER_EMAIL__", "username": "__INITIAL_USER__"}')
41   echo "Setting up user '__INITIAL_USER__'"
42   arv user setup --uuid "${user_uuid}"
43 fi
44
45 echo "Activating user '__INITIAL_USER__'"
46 arv user update --uuid "${user_uuid}" --user '{"is_active": true}'
47
48 echo "Getting the user API TOKEN"
49 user_api_token=$(arv api_client_authorization list --filters "[[\"owner_uuid\", \"=\", \"${user_uuid}\"],[\"kind\", \"==\", \"arvados#apiClientAuthorization\"]]" --limit=1 |jq -r .items[].api_token)
50
51 if [ "x${user_api_token}" = "x" ]; then
52   user_api_token=$(arv api_client_authorization create --api-client-authorization "{\"owner_uuid\": \"${user_uuid}\"}" | jq -r .api_token)
53 fi
54
55 # Change to the user's token and run the workflow
56 export ARVADOS_API_TOKEN="${user_api_token}"
57
58 echo "Running test CWL workflow"
59 cwl-runner hasher-workflow.cwl hasher-workflow-job.yml