Merge branch '20877-trashed-priority' refs #20877
[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 devcwl=0
16 tag="latest"
17 pythoncmd=python3
18 suite=conformance
19 runapi=containers
20 reinstall=0
21
22 while test -n "$1" ; do
23     arg="$1"
24     case "$arg" in
25         --no-reset-container)
26             reset_container=0
27             shift
28             ;;
29         --leave-running)
30             leave_running=1
31             shift
32             ;;
33         --config)
34             config=$2
35             shift ; shift
36             ;;
37         --tag)
38             tag=$2
39             shift ; shift
40             ;;
41         --build)
42             build=1
43             shift
44             ;;
45         --devcwl)
46             devcwl=1
47             shift
48             ;;
49         --reinstall)
50             reinstall=1
51             shift
52             ;;
53         --pythoncmd)
54             pythoncmd=$2
55             shift ; shift
56             ;;
57         --suite)
58             suite=$2
59             shift ; shift
60             ;;
61         --api)
62             runapi=$2
63             shift ; shift
64             ;;
65         -h|--help)
66             echo "$0 [--no-reset-container] [--leave-running] [--config dev|localdemo] [--tag docker_tag] [--build] [--pythoncmd python(2|3)] [--suite (integration|conformance-v1.0|conformance-*)]"
67             exit
68             ;;
69         *)
70             break
71             ;;
72     esac
73 done
74
75 if test -z "$ARVBOX_CONTAINER" ; then
76    export ARVBOX_CONTAINER=cwltest
77 fi
78
79 if test "$suite" = "conformance" ; then
80   suite=conformance-v1.0
81 fi
82
83 if test $reset_container = 1 ; then
84     arvbox stop
85     docker rm $ARVBOX_CONTAINER
86     arvbox reset -f
87 fi
88
89 arvbox start $config $tag
90
91 # Copy the integration test suite from our local arvados clone instead
92 # of using the one inside the container, so we can make changes to the
93 # integration tests without necessarily having to rebuilding the
94 # container image.
95 docker cp -L $(readlink -f $(dirname $0)/tests) $ARVBOX_CONTAINER:/usr/src/arvados/sdk/cwl
96
97 arvbox pipe <<EOF
98 set -eu -o pipefail
99
100 . /usr/local/lib/arvbox/common.sh
101
102 export PYCMD=$pythoncmd
103
104 if test $config = dev -o $reinstall = 1; then
105   cd /usr/src/arvados/sdk/python
106   \$PYCMD setup.py sdist
107   pip_install \$(ls -r dist/arvados-python-client-*.tar.gz | head -n1)
108
109   cd /usr/src/arvados/sdk/cwl
110   \$PYCMD setup.py sdist
111   pip_install \$(ls -r dist/arvados-cwl-runner-*.tar.gz | head -n1)
112 fi
113
114 set -x
115
116 # 2.3.20230527113600 release of cwltest confirms that files exist on disk, since
117 # our files are in Keep, all the tests fail.
118 # We should add [optional] Arvados support to cwltest so it can access
119 # Keep but for the time being just install the last working version.
120 if [ "\$PYCMD" = "python3" ]; then
121     pip3 install 'cwltest<2.3.20230527113600'
122 else
123     pip install 'cwltest<2.3.20230527113600'
124 fi
125
126 mkdir -p /tmp/cwltest
127 cd /tmp/cwltest
128
129 if [[ "$suite" = "conformance-v1.0" ]] ; then
130    if ! test -d common-workflow-language ; then
131      git clone https://github.com/common-workflow-language/common-workflow-language.git
132    fi
133    cd common-workflow-language
134 elif [[ "$suite" =~ conformance-(.*) ]] ; then
135    version=\${BASH_REMATCH[1]}
136    if ! test -d cwl-\${version} ; then
137      git clone https://github.com/common-workflow-language/cwl-\${version}.git
138    fi
139    cd cwl-\${version}
140    git checkout \${version}.0
141 elif [[ "$suite" != "integration" ]] ; then
142    echo "ERROR: unknown suite '$suite'"
143    exit 1
144 fi
145
146 if [[ "$suite" = "conformance-v1.1" ]] ; then
147    git checkout main
148 fi
149
150 if [[ "$suite" = "conformance-v1.2" ]] ; then
151    git checkout 1.2.1_proposed
152 fi
153
154 #if [[ "$suite" != "integration" ]] ; then
155 #  git pull
156 #fi
157
158 export ARVADOS_API_HOST=localhost:8000
159 export ARVADOS_API_HOST_INSECURE=1
160 export ARVADOS_API_TOKEN=\$(cat /var/lib/arvados-arvbox/superuser_token)
161
162 if test -n "$build" ; then
163   /usr/src/arvados/build/build-dev-docker-jobs-image.sh
164 fi
165
166 EXTRA=--compute-checksum
167
168 if [[ $devcwl -eq 1 ]] ; then
169    EXTRA="\$EXTRA --enable-dev"
170 fi
171
172 env
173
174 arvados-cwl-runner --version
175 cwltest --version
176
177 # Skip docker_entrypoint test because it fails on singularity
178 #
179 # Skip timelimit_invalid_wf test because the timeout is very short
180 # (5s) and singularity containers loading off an arv-mount take too long
181 # to start and get incorrectly terminated
182 #
183 # Skip test 199 in the v1.1 suite because it has different output
184 # depending on whether there is a pty associated with stdout (fixed in
185 # the v1.2 suite)
186 #
187 # Skip test 307 in the v1.2 suite because the test relied on
188 # secondary file behavior of cwltool that wasn't actually correct to specification
189
190 if [[ "$suite" = "integration" ]] ; then
191    cd /usr/src/arvados/sdk/cwl/tests
192    exec ./arvados-tests.sh $@
193 elif [[ "$suite" = "conformance-v1.2" ]] ; then
194    exec cwltest --tool arvados-cwl-runner --test conformance_tests.yaml -Sdocker_entrypoint,timelimit_invalid_wf -N307 $@ -- \$EXTRA
195 elif [[ "$suite" = "conformance-v1.1" ]] ; then
196    exec cwltest --tool arvados-cwl-runner --test conformance_tests.yaml -Sdocker_entrypoint,timelimit_invalid_wf -N199 $@ -- \$EXTRA
197 elif [[ "$suite" = "conformance-v1.0" ]] ; then
198    exec cwltest --tool arvados-cwl-runner --test v1.0/conformance_test_v1.0.yaml -Sdocker_entrypoint $@ -- \$EXTRA
199 fi
200 EOF
201
202 CODE=$?
203
204 if test $leave_running = 0 ; then
205     arvbox stop
206 fi
207
208 exit $CODE