3 # Install and test Arvados components.
5 # Exit non-zero if any tests fail.
8 # --skip FOO Do not test the FOO component.
9 # --only FOO Do not test anything except the FOO component.
10 # envvar=value Set $envvar to value
12 # Regardless of which components are tested, install all components in
13 # the usual sequence. (Many test suites depend on other components
16 # To run a specific Ruby test, set $workbench_test, $apiserver_test or
17 # $cli_test on the command line:
19 # $ run-tests.sh --only workbench workbench_test=TEST=test/integration/pipeline_instances_test.rb
22 # To run a specific Python test set $python_sdk_test or $fuse_test.
24 # $ run-tests.sh --only python_sdk python_sdk_test="--test-suite tests.test_keep_locator"
27 # You can also pass "export ARVADOS_DEBUG=1" to enable additional debugging output:
29 # $ run-tests.sh "export ARVADOS_DEBUG=1"
32 # Finally, you can skip the installation steps on subsequent runs this way:
35 # $ run-tests.sh --leave-temp
37 ## Subsequent runs: record the values of VENVDIR and GOPATH from the first run, and
38 # provide them on the command line in subsequent runs:
40 # $ run-tests.sh --skip-install VENVDIR="/tmp/tmp.y3tsTmigio" GOPATH="/tmp/tmp.3r4sSA9F3l"
43 # First make sure to remove any ARVADOS_ variables from the calling environment
44 # that could interfer with the tests.
45 unset $(env | cut -d= -f1 | grep \^ARVADOS_)
49 export GOPATH=$(mktemp -d)
59 if [[ -f /etc/profile.d/rvm.sh ]]
61 source /etc/profile.d/rvm.sh
66 echo >&2 "Fatal: $* in ${FUNCNAME[1]} at ${BASH_SOURCE[1]} line ${BASH_LINENO[0]}"
71 echo "WORKSPACE=$WORKSPACE"
72 [[ -n "$WORKSPACE" ]] || fatal "WORKSPACE not set"
74 # Set up temporary install dirs
75 mkdir -p "$GOPATH/src/git.curoverse.com"
76 ln -sfn "$WORKSPACE" "$GOPATH/src/git.curoverse.com/arvados.git" \
77 || fatal "symlink failed"
79 virtualenv --setuptools "$VENVDIR" || fatal "virtualenv $VENVDIR failed"
80 PATH="$VENVDIR/bin:$PATH"
85 # Always skip CLI tests. They don't know how to use run_test_server.py.
106 eval $(echo $arg | cut -d= -f1)=\"$(echo $arg | cut -d= -f2)\"
109 echo >&2 "$0: Unrecognized option: '$arg'"
116 if [[ "$?" != "0" ]]; then
117 title "!!!!!! $1 FAILED !!!!!!"
118 failures+=("$1 (`timer`)")
120 successes+=("$1 (`timer`)")
129 echo -n "$(($SECONDS - $t0))s"
133 if [[ -z "${skip[$1]}" ]] && ( [[ -z "$only" ]] || [[ "$only" == "$1" ]] )
135 title "Running $1 tests"
137 if [[ "$2" == "go" ]]
139 go test "git.curoverse.com/arvados.git/$1"
144 title "End of $1 tests (`timer`)"
146 title "Skipping $1 tests"
151 if [[ -z "$skip_install" ]]
153 title "Running $1 install"
155 if [[ "$2" == "go" ]]
157 go get -t "git.curoverse.com/arvados.git/$1"
161 checkexit "$1 install"
162 title "End of $1 install (`timer`)"
164 title "Skipping $1 install"
169 txt="********** $1 **********"
170 printf "\n%*s%s\n\n" $((($COLUMNS-${#txt})/2)) "" "$txt"
174 if [[ -n "$t" && -z "$leave_temp" ]]
176 for t in "$VENVDIR" "$GOPATH"
181 echo "Leaving VENVDIR=\"$VENVDIR\""
182 echo "Leaving GOPATH=\"$GOPATH\""
188 bundle install --deployment
190 # Make sure python-epydoc is installed or the next line won't do much good!
191 ARVADOS_API_HOST=qr1hi.arvadosapi.com
192 PYTHONPATH=$WORKSPACE/sdk/python/ bundle exec rake generate baseurl=file://$WORKSPACE/doc/.site/ arvados_workbench_host=workbench.$ARVADOS_API_HOST arvados_api_host=$ARVADOS_API_HOST
193 unset ARVADOS_API_HOST
197 test_doclinkchecker() {
199 bundle exec rake linkchecker baseurl=file://$WORKSPACE/doc/.site/
201 do_test doclinkchecker
203 install_apiserver() {
204 cd "$WORKSPACE/services/api"
205 bundle install --deployment
207 rm -f config/environments/test.rb
208 cp config/environments/test.rb.example config/environments/test.rb
210 cp $HOME/arvados-api-server/database.yml config/ || fatal "database.yml"
211 cp $HOME/arvados-api-server/application.yml config/ || fatal "application.yml"
213 # Fill in a random secret_token and blob_signing_key for testing
214 SECRET_TOKEN=`echo 'puts rand(2**512).to_s(36)' |ruby`
215 BLOB_SIGNING_KEY=`echo 'puts rand(2**512).to_s(36)' |ruby`
217 sed -i'' -e "s:SECRET_TOKEN:$SECRET_TOKEN:" config/application.yml
218 sed -i'' -e "s:BLOB_SIGNING_KEY:$BLOB_SIGNING_KEY:" config/application.yml
220 export RAILS_ENV=test
222 # Set up empty git repo (for git tests)
223 GITDIR="$WORKSPACE/tmpgit"
224 sed -i'' -e "s:/var/cache/git:$GITDIR:" config/application.default.yml
227 mkdir -p $GITDIR/test
230 && git config user.email "jenkins@ci.curoverse.com" \
231 && git config user.name "Jenkins, CI" \
234 && git commit -m 'initial commit'
236 cd "$WORKSPACE/services/api" \
237 && bundle exec rake db:drop \
238 && bundle exec rake db:create \
239 && bundle exec rake db:setup
244 cd "$WORKSPACE/services/api"
245 bundle exec rake test $apiserver_test
250 cd "$WORKSPACE/sdk/cli"
251 bundle install --deployment
263 for g in "${gostuff[@]}"
268 install_python_sdk() {
269 # Install the Python SDK early. Various other test suites (like
270 # keepproxy) bring up run_test_server.py, which imports the arvados
271 # module. We can't actually *test* the Python SDK yet though, because
272 # its own test suite brings up some of those other programs (like
275 cd "$WORKSPACE/sdk/python" \
276 && python setup.py egg_info -b ".$(git log --format=format:%ct.%h -n1 .)" sdist rotate --keep=1 --match .tar.gz \
277 && pip install dist/arvados-python-client-0.1.*.tar.gz
279 do_install python_sdk
282 cd "$WORKSPACE/services/fuse" \
283 && python setup.py egg_info -b ".$(git log --format=format:%ct.%h -n1 .)" sdist rotate --keep=1 --match .tar.gz \
284 && pip install dist/arvados_fuse-0.1.*.tar.gz
289 # Python SDK. We test this before testing keepproxy: keepproxy runs
290 # run_test_server.py, which depends on the yaml package, which is in
291 # tests_require but not install_requires, and therefore does not get
292 # installed by setuptools until we run "setup.py test" *and* install
293 # the .egg files that setup.py downloads.
295 cd "$WORKSPACE/sdk/python" \
296 && python setup.py test $python_sdk_test
304 # Install test dependencies here too, in case run_test_server needs them.
305 cd "$WORKSPACE/services/fuse" \
306 && python setup.py test $fuse_test
313 for g in "${gostuff[@]}"
319 cd "$WORKSPACE/apps/workbench" \
320 && bundle install --deployment \
321 && bundle exec rake test $workbench_test
326 title "Starting SDK CLI tests"
327 cd "$WORKSPACE/sdk/cli" \
328 && bundle install --deployment \
329 && mkdir -p /tmp/keep \
330 && KEEP_LOCAL_STORE=/tmp/keep bundle exec rake test $cli_test
336 for x in "${successes[@]}"
341 if [[ ${#failures[@]} == 0 ]]
343 echo "All test suites passed."
345 echo "Failures (${#failures[@]}):"
346 for x in "${failures[@]}"