Merge branch '9705-crunch2-install-guide-wip'
[arvados.git] / sdk / cwl / test_with_arvbox.sh
1 #!/bin/sh
2
3 set -x
4
5 if ! which arvbox >/dev/null ; then
6     export PATH=$PATH:$(readlink -f $(dirname $0)/../../tools/arvbox/bin)
7 fi
8
9 reset_container=1
10 leave_running=0
11 config=dev
12 docker_pull=1
13 tag=""
14
15 while test -n "$1" ; do
16     arg="$1"
17     case "$arg" in
18         --no-reset-container)
19             reset_container=0
20             shift
21             ;;
22         --leave-running)
23             leave_running=1
24             shift
25             ;;
26         --config)
27             config=$2
28             shift ; shift
29             ;;
30         --no-docker-pull)
31             docker_pull=0
32             shift
33             ;;
34         --tag)
35             tag=$2
36             shift ; shift
37             ;;
38         -h|--help)
39             echo "$0 [--no-reset-container] [--leave-running] [--no-docker-pull] [--config dev|localdemo] [--tag docker_tag]"
40             exit
41             ;;
42         *)
43             break
44             ;;
45     esac
46 done
47
48 if test -z "$ARVBOX_CONTAINER" ; then
49    export ARVBOX_CONTAINER=cwltest
50 fi
51
52 if test $reset_container = 1 ; then
53     arvbox reset -f
54 fi
55
56 arvbox start $config $tag
57
58 arvbox pipe <<EOF
59 set -eu -o pipefail
60
61 . /usr/local/lib/arvbox/common.sh
62
63 cd /usr/src/arvados/sdk/cwl
64 python setup.py sdist
65 pip_install \$(ls -r dist/arvados-cwl-runner-*.tar.gz | head -n1)
66
67 mkdir -p /tmp/cwltest
68 cd /tmp/cwltest
69 if ! test -d common-workflow-language ; then
70   git clone https://github.com/common-workflow-language/common-workflow-language.git
71 fi
72 cd common-workflow-language
73 git pull
74 export ARVADOS_API_HOST=localhost:8000
75 export ARVADOS_API_HOST_INSECURE=1
76 export ARVADOS_API_TOKEN=\$(cat /var/lib/arvados/superuser_token)
77
78 if test $docker_pull = 1 ; then
79   arv-keepdocker --pull arvados/jobs $tag
80 fi
81
82 cat >/tmp/cwltest/arv-cwl-jobs <<EOF2
83 #!/bin/sh
84 exec arvados-cwl-runner --api=jobs --compute-checksum \\\$@
85 EOF2
86 chmod +x /tmp/cwltest/arv-cwl-jobs
87
88 cat >/tmp/cwltest/arv-cwl-containers <<EOF2
89 #!/bin/sh
90 exec arvados-cwl-runner --api=containers --compute-checksum \\\$@
91 EOF2
92 chmod +x /tmp/cwltest/arv-cwl-containers
93
94 env
95 exec ./run_test.sh $@
96 EOF
97
98 CODE=$?
99
100 if test $leave_running = 0 ; then
101     arvbox stop
102 fi
103
104 exit $CODE