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