15028: Fix test on python3. Add conformance-v1.1 to run_in_arvbox suites.
[arvados.git] / sdk / cwl / test_with_arvbox.sh
1 #!/bin/sh
2 # Copyright (C) The Arvados Authors. All rights reserved.
3 #
4 # SPDX-License-Identifier: Apache-2.0
5
6 set -x
7
8 if ! which arvbox >/dev/null ; then
9     export PATH=$PATH:$(readlink -f $(dirname $0)/../../tools/arvbox/bin)
10 fi
11
12 reset_container=1
13 leave_running=0
14 config=dev
15 tag="latest"
16 pythoncmd=python
17 suite=conformance
18 runapi=containers
19
20 while test -n "$1" ; do
21     arg="$1"
22     case "$arg" in
23         --no-reset-container)
24             reset_container=0
25             shift
26             ;;
27         --leave-running)
28             leave_running=1
29             shift
30             ;;
31         --config)
32             config=$2
33             shift ; shift
34             ;;
35         --tag)
36             tag=$2
37             shift ; shift
38             ;;
39         --build)
40             build=1
41             shift
42             ;;
43         --pythoncmd)
44             pythoncmd=$2
45             shift ; shift
46             ;;
47         --suite)
48             suite=$2
49             shift ; shift
50             ;;
51         --api)
52             runapi=$2
53             shift ; shift
54             ;;
55         -h|--help)
56             echo "$0 [--no-reset-container] [--leave-running] [--config dev|localdemo] [--tag docker_tag] [--build] [--pythoncmd python(2|3)] [--suite (integration|conformance-v1.0|conformance-v1.1)]"
57             exit
58             ;;
59         *)
60             break
61             ;;
62     esac
63 done
64
65 if test -z "$ARVBOX_CONTAINER" ; then
66    export ARVBOX_CONTAINER=cwltest
67 fi
68
69 if test $reset_container = 1 ; then
70     arvbox stop
71     docker rm $ARVBOX_CONTAINER
72     arvbox reset -f
73 fi
74
75 arvbox start $config $tag
76
77 arvbox pipe <<EOF
78 set -eu -o pipefail
79
80 . /usr/local/lib/arvbox/common.sh
81
82 export PYCMD=$pythoncmd
83
84 if test $config = dev ; then
85   cd /usr/src/arvados/sdk/cwl
86   \$PYCMD setup.py sdist
87   pip_install \$(ls -r dist/arvados-cwl-runner-*.tar.gz | head -n1)
88 fi
89
90 set -x
91
92 if [ \$PYCMD = "python3" ]; then
93     pip3 install cwltest
94 else
95     pip install cwltest
96 fi
97
98 mkdir -p /tmp/cwltest
99 cd /tmp/cwltest
100
101 if [[ "$suite" = "conformance-v1.0" ]] ; then
102    if ! test -d common-workflow-language ; then
103      git clone https://github.com/common-workflow-language/common-workflow-language.git
104    fi
105    cd common-workflow-language
106 elif [[ "$suite" = "conformance-v1.1" ]] ; then
107    if ! test -d cwl-v1.1 ; then
108      git clone https://github.com/common-workflow-language/cwl-v1.1.git
109    fi
110    cd cwl-v1.1
111 fi
112
113 if [[ "$suite" != "integration" ]] ; then
114   git pull
115 fi
116
117 export ARVADOS_API_HOST=localhost:8000
118 export ARVADOS_API_HOST_INSECURE=1
119 export ARVADOS_API_TOKEN=\$(cat /var/lib/arvados/superuser_token)
120
121 if test -n "$build" ; then
122   /usr/src/arvados/build/build-dev-docker-jobs-image.sh
123 elif test "$tag" = "latest" ; then
124   arv-keepdocker --pull arvados/jobs $tag
125 else
126   jobsimg=\$(curl https://versions.arvados.org/v1/commit/$tag | python -c "import json; import sys; sys.stdout.write(json.load(sys.stdin)['Versions']['Docker']['arvados/jobs'])")
127   arv-keepdocker --pull arvados/jobs \$jobsimg
128   docker tag arvados/jobs:\$jobsimg arvados/jobs:latest
129   arv-keepdocker arvados/jobs latest
130 fi
131
132 cat >/tmp/cwltest/arv-cwl-jobs <<EOF2
133 #!/bin/sh
134 exec arvados-cwl-runner --api=jobs \\\$@
135 EOF2
136 chmod +x /tmp/cwltest/arv-cwl-jobs
137
138 cat >/tmp/cwltest/arv-cwl-containers <<EOF2
139 #!/bin/sh
140 exec arvados-cwl-runner --api=containers \\\$@
141 EOF2
142 chmod +x /tmp/cwltest/arv-cwl-containers
143
144 env
145 if [[ "$suite" = "integration" ]] ; then
146    cd /usr/src/arvados/sdk/cwl/tests
147    exec ./arvados-tests.sh $@
148 else
149    exec ./run_test.sh RUNNER=/tmp/cwltest/arv-cwl-${runapi} EXTRA=--compute-checksum $@
150 fi
151 EOF
152
153 CODE=$?
154
155 if test $leave_running = 0 ; then
156     arvbox stop
157 fi
158
159 exit $CODE