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