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