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 # WORKSPACE=path Arvados source tree to test.
11 # CONFIGSRC=path Dir with api server config files to copy into source tree.
12 # envvar=value Set $envvar to value
14 # Regardless of which components are tested, install all components in
15 # the usual sequence. (Many test suites depend on other components
18 # To run a specific Ruby test, set $workbench_test, $apiserver_test or
19 # $cli_test on the command line:
21 # $ run-tests.sh --only workbench workbench_test=TEST=test/integration/pipeline_instances_test.rb
24 # To run a specific Python test set $python_sdk_test or $fuse_test.
26 # $ run-tests.sh --only python_sdk python_sdk_test="--test-suite tests.test_keep_locator"
29 # You can also pass "export ARVADOS_DEBUG=1" to enable additional debugging output:
31 # $ run-tests.sh "export ARVADOS_DEBUG=1"
34 # Finally, you can skip the installation steps on subsequent runs this way:
37 # $ run-tests.sh --leave-temp
39 ## Subsequent runs: record the values of VENVDIR and GOPATH from the first run, and
40 # provide them on the command line in subsequent runs:
42 # $ run-tests.sh --skip-install VENVDIR="/tmp/tmp.y3tsTmigio" GOPATH="/tmp/tmp.3r4sSA9F3l"
45 # First make sure to remove any ARVADOS_ variables from the calling environment
46 # that could interfer with the tests.
47 unset $(env | cut -d= -f1 | grep \^ARVADOS_)
62 if [[ -f /etc/profile.d/rvm.sh ]]
64 source /etc/profile.d/rvm.sh
70 for var in VENVDIR GOPATH
72 if [[ -z "${leave_temp[$var]}" ]]
79 leaving+=" $var=\"${!var}\""
82 if [[ -z "$leaving" ]]; then
83 echo "Leaving behind temp dirs: $leaving"
89 echo >&2 "Fatal: $* in ${FUNCNAME[1]} at ${BASH_SOURCE[1]} line ${BASH_LINENO[0]}"
96 # Always skip CLI tests. They don't know how to use run_test_server.py.
114 leave_temp[VENVDIR]=1
118 eval $(echo $arg | cut -d= -f1)=\"$(echo $arg | cut -d= -f2-)\"
121 echo >&2 "$0: Unrecognized option: '$arg'"
128 echo "WORKSPACE=$WORKSPACE"
129 [[ -n "$WORKSPACE" ]] || fatal "WORKSPACE not set"
131 if [[ -n "$CONFIGSRC" ]]; then
132 if [[ -d "$HOME/arvados-api-server" ]]; then
133 # Jenkins expects us to use this by default.
134 CONFIGSRC="$HOME/arvados-api-server"
138 # Set up temporary install dirs (unless existing dirs were supplied)
139 if [[ -n "$VENVDIR" ]]; then
140 leave_temp[VENVDIR]=1
144 if [[ -n "$GOPATH" ]]; then
150 mkdir -p "$GOPATH/src/git.curoverse.com"
151 ln -sfn "$WORKSPACE" "$GOPATH/src/git.curoverse.com/arvados.git" \
152 || fatal "symlink failed"
154 virtualenv --setuptools "$VENVDIR" || fatal "virtualenv $VENVDIR failed"
155 PATH="$VENVDIR/bin:$PATH"
158 if [[ "$?" != "0" ]]; then
159 title "!!!!!! $1 FAILED !!!!!!"
160 failures+=("$1 (`timer`)")
162 successes+=("$1 (`timer`)")
171 echo -n "$(($SECONDS - $t0))s"
175 if [[ -z "${skip[$1]}" ]] && ( [[ -z "$only" ]] || [[ "$only" == "$1" ]] )
177 title "Running $1 tests"
179 if [[ "$2" == "go" ]]
181 go test "git.curoverse.com/arvados.git/$1"
186 title "End of $1 tests (`timer`)"
188 title "Skipping $1 tests"
193 if [[ -z "$skip_install" ]]
195 title "Running $1 install"
197 if [[ "$2" == "go" ]]
199 go get -t "git.curoverse.com/arvados.git/$1"
203 checkexit "$1 install"
204 title "End of $1 install (`timer`)"
206 title "Skipping $1 install"
211 txt="********** $1 **********"
212 printf "\n%*s%s\n\n" $((($COLUMNS-${#txt})/2)) "" "$txt"
217 bundle install --no-deployment
219 # Make sure python-epydoc is installed or the next line won't do much good!
220 ARVADOS_API_HOST=qr1hi.arvadosapi.com
221 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
222 unset ARVADOS_API_HOST
226 test_doclinkchecker() {
228 bundle exec rake linkchecker baseurl=file://$WORKSPACE/doc/.site/
230 do_test doclinkchecker
233 cd "$WORKSPACE/sdk/ruby" \
234 && bundle install --no-deployment \
235 && bundle exec rake test
240 cd "$WORKSPACE/sdk/ruby" \
241 && gem build arvados.gemspec \
242 && gem install --no-ri --no-rdoc `ls -t arvados-*.gem|head -n1`
247 cd "$WORKSPACE/sdk/cli" \
248 && gem build arvados-cli.gemspec \
249 && gem install --no-ri --no-rdoc `ls -t arvados-cli-*.gem|head -n1`
254 title "Starting SDK CLI tests"
255 cd "$WORKSPACE/sdk/cli" \
256 && bundle install --no-deployment \
257 && mkdir -p /tmp/keep \
258 && KEEP_LOCAL_STORE=/tmp/keep bundle exec rake test $cli_test
262 install_apiserver() {
263 cd "$WORKSPACE/services/api"
264 bundle install --no-deployment
266 rm -f config/environments/test.rb
267 cp config/environments/test.rb.example config/environments/test.rb
269 if [ -n "$CONFIGSRC" ]
271 for f in database.yml application.yml
273 cp "$CONFIGSRC/$f" config/ || fatal "$f"
277 # Fill in a random secret_token and blob_signing_key for testing
278 SECRET_TOKEN=`echo 'puts rand(2**512).to_s(36)' |ruby`
279 BLOB_SIGNING_KEY=`echo 'puts rand(2**512).to_s(36)' |ruby`
281 sed -i'' -e "s:SECRET_TOKEN:$SECRET_TOKEN:" config/application.yml
282 sed -i'' -e "s:BLOB_SIGNING_KEY:$BLOB_SIGNING_KEY:" config/application.yml
284 export RAILS_ENV=test
286 # Set up empty git repo (for git tests)
287 GITDIR="$WORKSPACE/tmpgit"
288 sed -i'' -e "s:/var/cache/git:$GITDIR:" config/application.default.yml
291 mkdir -p $GITDIR/test
294 && git config user.email "jenkins@ci.curoverse.com" \
295 && git config user.name "Jenkins, CI" \
298 && git commit -m 'initial commit'
300 # Clear out any lingering postgresql connections to arvados_test, so that we can drop it
301 # This assumes the current user is a postgresql superuser
302 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
304 cd "$WORKSPACE/services/api" \
305 && bundle exec rake db:drop \
306 && bundle exec rake db:create \
307 && bundle exec rake db:setup
312 cd "$WORKSPACE/services/api"
313 bundle exec rake test $apiserver_test
325 for g in "${gostuff[@]}"
330 install_python_sdk() {
331 # Install the Python SDK early. Various other test suites (like
332 # keepproxy) bring up run_test_server.py, which imports the arvados
333 # module. We can't actually *test* the Python SDK yet though, because
334 # its own test suite brings up some of those other programs (like
337 cd "$WORKSPACE/sdk/python" \
338 && python setup.py egg_info -b ".$(git log --format=format:%ct.%h -n1 .)" sdist rotate --keep=1 --match .tar.gz \
339 && pip install dist/arvados-python-client-0.1.*.tar.gz
341 do_install python_sdk
344 cd "$WORKSPACE/services/fuse" \
345 && python setup.py egg_info -b ".$(git log --format=format:%ct.%h -n1 .)" sdist rotate --keep=1 --match .tar.gz \
346 && pip install dist/arvados_fuse-0.1.*.tar.gz
351 # Python SDK. We test this before testing keepproxy: keepproxy runs
352 # run_test_server.py, which depends on the yaml package, which is in
353 # tests_require but not install_requires, and therefore does not get
354 # installed by setuptools until we run "setup.py test" *and* install
355 # the .egg files that setup.py downloads.
357 cd "$WORKSPACE/sdk/python" \
358 && python setup.py test $python_sdk_test
366 # Install test dependencies here too, in case run_test_server needs them.
367 cd "$WORKSPACE/services/fuse" \
368 && python setup.py test $fuse_test
375 for g in "${gostuff[@]}"
381 cd "$WORKSPACE/apps/workbench" \
382 && bundle install --no-deployment \
383 && bundle exec rake test $workbench_test
389 for x in "${successes[@]}"
394 if [[ ${#failures[@]} == 0 ]]
396 echo "All test suites passed."
398 echo "Failures (${#failures[@]}):"
399 for x in "${failures[@]}"