3 read -rd "\000" helpmessage <<EOF
4 $(basename $0): Install and test Arvados components.
6 Exit non-zero if any tests fail.
9 $(basename $0) WORKSPACE=/path/to/arvados [options]
13 --skip FOO Do not test the FOO component.
14 --only FOO Do not test anything except the FOO component.
15 --leave-temp Do not remove GOPATH, virtualenv, and other temp dirs at exit.
16 Instead, show which directories were used this time so they
17 can be reused in subsequent invocations.
18 --skip-install Do not run any install steps. Just run tests.
19 You should provide GOPATH, GEMHOME, and VENVDIR options
20 from a previous invocation if you use this option.
21 WORKSPACE=path Arvados source tree to test.
22 CONFIGSRC=path Dir with api server config files to copy into source tree.
23 apiserver_test="TEST=test/functional/arvados/v1/collections_test.rb"
24 Restrict apiserver tests to the given file
25 python_sdk_test="--test-suite test.test_keep_locator"
26 Restrict Python SDK tests to the given class
27 workbench_test="TEST=test/integration/pipeline_instances_test.rb"
28 Restrict Workbench tests to the given file
30 Print more debug messages
31 envvar=value Set \$envvar to value. Primarily useful for WORKSPACE,
32 *_test, and other examples shown above.
34 Assuming --skip-install is not given, all components are installed
35 into \$GOPATH, \$VENDIR, and \$GEMHOME before running any tests. Many
36 test suites depend on other components being installed, and installing
37 everything tends to be quicker than debugging dependencies.
39 More information and background:
41 https://arvados.org/projects/arvados/wiki/Running_tests
44 # First make sure to remove any ARVADOS_ variables from the calling
45 # environment that could interfere with the tests.
46 unset $(env | cut -d= -f1 | grep \^ARVADOS_)
63 if [[ -f /etc/profile.d/rvm.sh ]]
65 source /etc/profile.d/rvm.sh
71 for var in VENVDIR GOPATH GITDIR
73 if [[ -z "${leave_temp[$var]}" ]]
80 leaving+=" $var=\"${!var}\""
83 if [[ -z "$leaving" ]]; then
84 echo "Leaving behind temp dirs: $leaving"
90 echo >&2 "Fatal: $* in ${FUNCNAME[1]} at ${BASH_SOURCE[1]} line ${BASH_LINENO[0]}"
97 # Always skip CLI tests. They don't know how to use run_test_server.py.
109 echo >&2 "$helpmessage"
120 leave_temp[VENVDIR]=1
124 eval $(echo $arg | cut -d= -f1)=\"$(echo $arg | cut -d= -f2-)\"
127 echo >&2 "$0: Unrecognized option: '$arg'. Try: $0 --help"
134 echo "WORKSPACE=$WORKSPACE"
135 [[ -n "$WORKSPACE" ]] || fatal "WORKSPACE not set"
137 if [[ -n "$CONFIGSRC" ]]; then
138 if [[ -d "$HOME/arvados-api-server" ]]; then
139 # Jenkins expects us to use this by default.
140 CONFIGSRC="$HOME/arvados-api-server"
144 # Set up temporary install dirs (unless existing dirs were supplied)
145 if [[ -n "$VENVDIR" ]]; then
146 leave_temp[VENVDIR]=1
150 if [[ -n "$GOPATH" ]]; then
156 mkdir -p "$GOPATH/src/git.curoverse.com"
157 ln -sfn "$WORKSPACE" "$GOPATH/src/git.curoverse.com/arvados.git" \
158 || fatal "symlink failed"
160 virtualenv --setuptools "$VENVDIR" || fatal "virtualenv $VENVDIR failed"
161 PATH="$VENVDIR/bin:$PATH"
164 if [[ "$?" != "0" ]]; then
165 title "!!!!!! $1 FAILED !!!!!!"
166 failures+=("$1 (`timer`)")
168 successes+=("$1 (`timer`)")
177 echo -n "$(($SECONDS - $t0))s"
181 if [[ -z "${skip[$1]}" ]] && ( [[ -z "$only" ]] || [[ "$only" == "$1" ]] )
183 title "Running $1 tests"
185 if [[ "$2" == "go" ]]
187 go test "git.curoverse.com/arvados.git/$1"
192 title "End of $1 tests (`timer`)"
194 title "Skipping $1 tests"
199 if [[ -z "$skip_install" ]]
201 title "Running $1 install"
203 if [[ "$2" == "go" ]]
205 go get -t "git.curoverse.com/arvados.git/$1"
209 checkexit "$1 install"
210 title "End of $1 install (`timer`)"
212 title "Skipping $1 install"
217 txt="********** $1 **********"
218 printf "\n%*s%s\n\n" $((($COLUMNS-${#txt})/2)) "" "$txt"
223 bundle install --no-deployment
225 # Make sure python-epydoc is installed or the next line won't do much good!
226 ARVADOS_API_HOST=qr1hi.arvadosapi.com
227 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
228 unset ARVADOS_API_HOST
233 cd "$WORKSPACE/sdk/ruby" \
234 && gem build arvados.gemspec \
235 && gem install --user-install --no-ri --no-rdoc `ls -t arvados-*.gem|head -n1`
240 cd "$WORKSPACE/sdk/cli" \
241 && gem build arvados-cli.gemspec \
242 && gem install --user-install --no-ri --no-rdoc `ls -t arvados-cli-*.gem|head -n1`
246 install_python_sdk() {
247 # Install the Python SDK early. Various other test suites (like
248 # keepproxy) bring up run_test_server.py, which imports the arvados
249 # module. We can't actually *test* the Python SDK yet though, because
250 # its own test suite brings up some of those other programs (like
253 cd "$WORKSPACE/sdk/python" \
254 && python setup.py egg_info -b ".$(git log --format=format:%ct.%h -n1 .)" sdist rotate --keep=1 --match .tar.gz \
255 && pip install dist/arvados-python-client-0.1.*.tar.gz
257 do_install python_sdk
260 cd "$WORKSPACE/services/fuse" \
261 && python setup.py egg_info -b ".$(git log --format=format:%ct.%h -n1 .)" sdist rotate --keep=1 --match .tar.gz \
262 && pip install dist/arvados_fuse-0.1.*.tar.gz
266 install_apiserver() {
267 cd "$WORKSPACE/services/api"
268 bundle install --no-deployment
270 rm -f config/environments/test.rb
271 cp config/environments/test.rb.example config/environments/test.rb
273 if [ -n "$CONFIGSRC" ]
275 for f in database.yml application.yml
277 cp "$CONFIGSRC/$f" config/ || fatal "$f"
281 # Fill in a random secret_token and blob_signing_key for testing
282 SECRET_TOKEN=`echo 'puts rand(2**512).to_s(36)' |ruby`
283 BLOB_SIGNING_KEY=`echo 'puts rand(2**512).to_s(36)' |ruby`
285 sed -i'' -e "s:SECRET_TOKEN:$SECRET_TOKEN:" config/application.yml
286 sed -i'' -e "s:BLOB_SIGNING_KEY:$BLOB_SIGNING_KEY:" config/application.yml
288 export RAILS_ENV=test
290 # Set up empty git repo (for git tests)
292 sed -i'' -e "s:/var/cache/git:$GITDIR:" config/application.default.yml
295 mkdir -p $GITDIR/test
298 && git config user.email "jenkins@ci.curoverse.com" \
299 && git config user.name "Jenkins, CI" \
302 && git commit -m 'initial commit'
304 # Clear out any lingering postgresql connections to arvados_test, so that we can drop it
305 # This assumes the current user is a postgresql superuser
306 psql arvados_test -c "SELECT pg_terminate_backend (pg_stat_activity.procpid::int) FROM pg_stat_activity WHERE pg_stat_activity.datname = 'arvados_test';" 2>/dev/null
308 cd "$WORKSPACE/services/api" \
309 && bundle exec rake db:drop \
310 && bundle exec rake db:create \
311 && bundle exec rake db:setup
323 for g in "${gostuff[@]}"
328 test_doclinkchecker() {
330 bundle exec rake linkchecker baseurl=file://$WORKSPACE/doc/.site/
332 do_test doclinkchecker
335 cd "$WORKSPACE/sdk/ruby" \
336 && bundle install --no-deployment \
337 && bundle exec rake test
342 title "Starting SDK CLI tests"
343 cd "$WORKSPACE/sdk/cli" \
344 && bundle install --no-deployment \
345 && mkdir -p /tmp/keep \
346 && KEEP_LOCAL_STORE=/tmp/keep bundle exec rake test $cli_test
351 cd "$WORKSPACE/services/api"
352 bundle exec rake test $apiserver_test
357 # Python SDK. We test this before testing keepproxy: keepproxy runs
358 # run_test_server.py, which depends on the yaml package, which is in
359 # tests_require but not install_requires, and therefore does not get
360 # installed by setuptools until we run "setup.py test" *and* install
361 # the .egg files that setup.py downloads.
363 cd "$WORKSPACE/sdk/python" \
364 && python setup.py test $python_sdk_test
372 # Install test dependencies here too, in case run_test_server needs them.
373 cd "$WORKSPACE/services/fuse" \
374 && python setup.py test $fuse_test
381 for g in "${gostuff[@]}"
387 cd "$WORKSPACE/apps/workbench" \
388 && bundle install --no-deployment \
389 && bundle exec rake test $workbench_test
395 for x in "${successes[@]}"
400 if [[ ${#failures[@]} == 0 ]]
402 echo "All test suites passed."
404 echo "Failures (${#failures[@]}):"
405 for x in "${failures[@]}"