21700: Install Bundler system-wide in Rails postinst
[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 /opt/arvados-py/bin/pip install 'cwltest<2.3.20230527113600'
114
115 mkdir -p /tmp/cwltest
116 cd /tmp/cwltest
117
118 if [[ "$suite" = "conformance-v1.0" ]] ; then
119    if ! test -d common-workflow-language ; then
120      git clone https://github.com/common-workflow-language/common-workflow-language.git
121    fi
122    cd common-workflow-language
123 elif [[ "$suite" =~ conformance-(.*) ]] ; then
124    version=\${BASH_REMATCH[1]}
125    if ! test -d cwl-\${version} ; then
126      git clone https://github.com/common-workflow-language/cwl-\${version}.git
127    fi
128    cd cwl-\${version}
129    git checkout \${version}.0
130 elif [[ "$suite" != "integration" ]] ; then
131    echo "ERROR: unknown suite '$suite'"
132    exit 1
133 fi
134
135 if [[ "$suite" = "conformance-v1.1" ]] ; then
136    git checkout main
137 fi
138
139 if [[ "$suite" = "conformance-v1.2" ]] ; then
140    git checkout v1.2.1
141 fi
142
143 #if [[ "$suite" != "integration" ]] ; then
144 #  git pull
145 #fi
146
147 export ARVADOS_API_HOST=localhost:8000
148 export ARVADOS_API_HOST_INSECURE=1
149 export ARVADOS_API_TOKEN=\$(cat /var/lib/arvados-arvbox/superuser_token)
150
151 if test -n "$build" ; then
152   /usr/src/arvados/build/build-dev-docker-jobs-image.sh
153 fi
154
155 EXTRA=--compute-checksum
156
157 if [[ $devcwl -eq 1 ]] ; then
158    EXTRA="\$EXTRA --enable-dev"
159 fi
160
161 env
162
163 arvados-cwl-runner --version
164 cwltest --version
165
166 # Skip docker_entrypoint test because it fails on singularity
167 #
168 # Skip timelimit_invalid_wf test because the timeout is very short
169 # (5s) and singularity containers loading off an arv-mount take too long
170 # to start and get incorrectly terminated
171 #
172 # Skip test 199 in the v1.1 suite because it has different output
173 # depending on whether there is a pty associated with stdout (fixed in
174 # the v1.2 suite)
175
176 if [[ "$suite" = "integration" ]] ; then
177    cd /usr/src/arvados/sdk/cwl/tests
178    exec ./arvados-tests.sh $@
179 elif [[ "$suite" = "conformance-v1.2" ]] ; then
180    exec cwltest --tool arvados-cwl-runner --test conformance_tests.yaml -Sdocker_entrypoint --badgedir /tmp/badges $@ -- \$EXTRA
181 elif [[ "$suite" = "conformance-v1.1" ]] ; then
182    exec cwltest --tool arvados-cwl-runner --test conformance_tests.yaml -Sdocker_entrypoint,timelimit_invalid_wf -N199 --badgedir /tmp/badges $@ -- \$EXTRA
183 elif [[ "$suite" = "conformance-v1.0" ]] ; then
184    exec cwltest --tool arvados-cwl-runner --test v1.0/conformance_test_v1.0.yaml -Sdocker_entrypoint --badgedir /tmp/badges $@ -- \$EXTRA
185 fi
186 EOF
187
188 CODE=$?
189
190 docker cp -L $ARVBOX_CONTAINER:/tmp/badges $cwldir/badges
191
192 if test $leave_running = 0 ; then
193     arvbox stop
194 fi
195
196 exit $CODE