X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/9c6598596ae99cfea9ab8ced51c58d32ca306764..b8977c89db2707dd713cd4eeb11d595717fcff75:/build/run-tests.sh diff --git a/build/run-tests.sh b/build/run-tests.sh index 041c7c2f90..00987a8efa 100755 --- a/build/run-tests.sh +++ b/build/run-tests.sh @@ -1,6 +1,9 @@ #!/bin/bash +# Copyright (C) The Arvados Authors. All rights reserved. +# +# SPDX-License-Identifier: AGPL-3.0 -. `dirname "$(readlink -f "$0")"`/libcloud-pin +. `dirname "$(readlink -f "$0")"`/libcloud-pin.sh COLUMNS=80 . `dirname "$(readlink -f "$0")"`/run-library.sh @@ -22,10 +25,13 @@ Options: --leave-temp Do not remove GOPATH, virtualenv, and other temp dirs at exit. Instead, show the path to give as --temp to reuse them in subsequent invocations. +--repeat N Repeat each install/test step until it succeeds N times. +--retry Prompt to retry if an install or test suite fails. --skip-install Do not run any install steps. Just run tests. You should provide GOPATH, GEMHOME, and VENVDIR options from a previous invocation if you use this option. --only-install Run specific install step +--short Skip (or scale down) some slow tests. WORKSPACE=path Arvados source tree to test. CONFIGSRC=path Dir with api server config files to copy into source tree. (If none given, leave config files alone in source tree.) @@ -57,7 +63,10 @@ https://arvados.org/projects/arvados/wiki/Running_tests Available tests: -apps/workbench +apps/workbench (*) +apps/workbench_units (*) +apps/workbench_functionals (*) +apps/workbench_integration (*) apps/workbench_benchmark apps/workbench_profile doc @@ -69,24 +78,37 @@ services/fuse services/keep-web services/keepproxy services/keepstore +services/keep-balance services/login-sync services/nodemanager +services/nodemanager-integration services/crunch-run services/crunch-dispatch-local services/crunch-dispatch-slurm +services/ws sdk/cli sdk/pam sdk/python +sdk/python:py3 sdk/ruby +sdk/go/arvados sdk/go/arvadosclient +sdk/go/dispatch sdk/go/keepclient +sdk/go/httpserver sdk/go/manifest sdk/go/blockdigest sdk/go/streamer +sdk/go/stats sdk/go/crunchrunner sdk/cwl tools/crunchstat-summary +tools/keep-exercise tools/keep-rsync +tools/keep-block-check + +(*) apps/workbench is shorthand for apps/workbench_units + + apps/workbench_functionals + apps/workbench_integration EOF @@ -104,7 +126,8 @@ PYTHONPATH= GEMHOME= PERLINSTALLBASE= -skip_install= +short= +only_install= temp= temp_preserve= @@ -143,18 +166,29 @@ sanity_checks() { echo -n 'virtualenv: ' virtualenv --version \ || fatal "No virtualenv. Try: apt-get install virtualenv (on ubuntu: python-virtualenv)" + echo -n 'ruby: ' + ruby -v \ + || fatal "No ruby. Install >=2.1.9 (using rbenv, rvm, or source)" echo -n 'go: ' go version \ || fatal "No go binary. See http://golang.org/doc/install" + [[ $(go version) =~ go1.([0-9]+) ]] && [[ ${BASH_REMATCH[1]} -ge 8 ]] \ + || fatal "Go >= 1.8 required. See http://golang.org/doc/install" echo -n 'gcc: ' gcc --version | egrep ^gcc \ || fatal "No gcc. Try: apt-get install build-essential" echo -n 'fuse.h: ' - find /usr/include -wholename '*fuse/fuse.h' \ + find /usr/include -path '*fuse/fuse.h' | egrep --max-count=1 . \ || fatal "No fuse/fuse.h. Try: apt-get install libfuse-dev" - echo -n 'pyconfig.h: ' - find /usr/include -name pyconfig.h | egrep --max-count=1 . \ - || fatal "No pyconfig.h. Try: apt-get install python-dev" + echo -n 'gnutls.h: ' + find /usr/include -path '*gnutls/gnutls.h' | egrep --max-count=1 . \ + || fatal "No gnutls/gnutls.h. Try: apt-get install libgnutls28-dev" + echo -n 'Python2 pyconfig.h: ' + find /usr/include -path '*/python2*/pyconfig.h' | egrep --max-count=1 . \ + || fatal "No Python2 pyconfig.h. Try: apt-get install python2.7-dev" + echo -n 'Python3 pyconfig.h: ' + find /usr/include -path '*/python3*/pyconfig.h' | egrep --max-count=1 . \ + || fatal "No Python3 pyconfig.h. Try: apt-get install python3-dev" echo -n 'nginx: ' PATH="$PATH:/sbin:/usr/sbin:/usr/local/sbin" nginx -v \ || fatal "No nginx. Try: apt-get install nginx" @@ -196,17 +230,18 @@ do exit 1 ;; --skip) - skipwhat="$1"; shift - skip[$skipwhat]=1 + skip[$1]=1; shift ;; --only) only="$1"; skip[$1]=""; shift ;; + --short) + short=1 + ;; --skip-install) - skip_install=1 + only_install=nothing ;; --only-install) - skip_install=1 only_install="$1"; shift ;; --temp) @@ -216,6 +251,9 @@ do --leave-temp) temp_preserve=1 ;; + --repeat) + repeat=$((${1}+0)); shift + ;; --retry) retry=1 ;; @@ -240,15 +278,18 @@ start_api() { && eval $(python sdk/python/tests/run_test_server.py start --auth admin) \ && export ARVADOS_TEST_API_HOST="$ARVADOS_API_HOST" \ && export ARVADOS_TEST_API_INSTALLED="$$" \ + && python sdk/python/tests/run_test_server.py start_ws \ + && python sdk/python/tests/run_test_server.py start_nginx \ && (env | egrep ^ARVADOS) } start_nginx_proxy_services() { - echo 'Starting keepproxy, keep-web, arv-git-httpd, and nginx ssl proxy...' + echo 'Starting keepproxy, keep-web, ws, arv-git-httpd, and nginx ssl proxy...' cd "$WORKSPACE" \ && python sdk/python/tests/run_test_server.py start_keep_proxy \ && python sdk/python/tests/run_test_server.py start_keep-web \ && python sdk/python/tests/run_test_server.py start_arv-git-httpd \ + && python sdk/python/tests/run_test_server.py start_ws \ && python sdk/python/tests/run_test_server.py start_nginx \ && export ARVADOS_TEST_PROXY_SERVICES=1 } @@ -259,12 +300,15 @@ stop_services() { cd "$WORKSPACE" \ && python sdk/python/tests/run_test_server.py stop_nginx \ && python sdk/python/tests/run_test_server.py stop_arv-git-httpd \ + && python sdk/python/tests/run_test_server.py stop_ws \ && python sdk/python/tests/run_test_server.py stop_keep-web \ && python sdk/python/tests/run_test_server.py stop_keep_proxy fi if [[ -n "$ARVADOS_TEST_API_HOST" ]]; then unset ARVADOS_TEST_API_HOST cd "$WORKSPACE" \ + && python sdk/python/tests/run_test_server.py stop_nginx \ + && python sdk/python/tests/run_test_server.py stop_ws \ && python sdk/python/tests/run_test_server.py stop fi } @@ -305,13 +349,13 @@ done setup_ruby_environment() { if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then - source "$HOME/.rvm/scripts/rvm" - using_rvm=true + source "$HOME/.rvm/scripts/rvm" + using_rvm=true elif [[ -s "/usr/local/rvm/scripts/rvm" ]] ; then - source "/usr/local/rvm/scripts/rvm" - using_rvm=true + source "/usr/local/rvm/scripts/rvm" + using_rvm=true else - using_rvm=false + using_rvm=false fi if [[ "$using_rvm" == true ]]; then @@ -331,9 +375,12 @@ setup_ruby_environment() { # complaint about not being in first place already. rvm use @default 2>/dev/null - # Create (if needed) and switch to an @arvados-tests - # gemset. (Leave the choice of ruby to the caller.) - rvm use @arvados-tests --create \ + # Create (if needed) and switch to an @arvados-tests-* gemset, + # salting the gemset name so it doesn't interfere with + # concurrent builds in other workspaces. Leave the choice of + # ruby to the caller. + gemset="arvados-tests-$(echo -n "${WORKSPACE}" | md5sum | head -c16)" + rvm use "@${gemset}" --create \ || fatal 'rvm gemset setup' rvm env @@ -357,12 +404,14 @@ setup_ruby_environment() { tmpdir_gem_home="$(env - PATH="$PATH" HOME="$GEMHOME" gem env gempath | cut -f1 -d:)" PATH="$tmpdir_gem_home/bin:$PATH" - export GEM_PATH="$tmpdir_gem_home:$(gem env gempath)" + export GEM_PATH="$tmpdir_gem_home" echo "Will install dependencies to $(gem env gemdir)" echo "Will install arvados gems to $tmpdir_gem_home" echo "Gem search path is GEM_PATH=$GEM_PATH" fi + bundle config || gem install bundler \ + || fatal 'install bundler' } with_test_gemset() { @@ -384,7 +433,12 @@ setup_virtualenv() { if ! [[ -e "$venvdest/bin/activate" ]] || ! [[ -e "$venvdest/bin/pip" ]]; then virtualenv --setuptools "$@" "$venvdest" || fatal "virtualenv $venvdest failed" fi - "$venvdest/bin/pip" install 'setuptools>=18' 'pip>=7' + if [[ $("$venvdest/bin/python" --version 2>&1) =~ \ 3\.[012]\. ]]; then + # pip 8.0.0 dropped support for python 3.2, e.g., debian wheezy + "$venvdest/bin/pip" install 'setuptools>=18.5' 'pip>=7,<8' + else + "$venvdest/bin/pip" install 'setuptools>=18.5' 'pip>=7' + fi # ubuntu1404 can't seem to install mock via tests_require, but it can do this. "$venvdest/bin/pip" install 'mock>=1.0' 'pbr<1.7.0' } @@ -394,8 +448,10 @@ export PERLLIB="$PERLINSTALLBASE/lib/perl5:${PERLLIB:+$PERLLIB}" export GOPATH mkdir -p "$GOPATH/src/git.curoverse.com" -ln -sfn "$WORKSPACE" "$GOPATH/src/git.curoverse.com/arvados.git" \ +ln -sfT "$WORKSPACE" "$GOPATH/src/git.curoverse.com/arvados.git" \ || fatal "symlink failed" +go get -v github.com/kardianos/govendor \ + || fatal "govendor install failed" setup_virtualenv "$VENVDIR" --python python2.7 . "$VENVDIR/bin/activate" @@ -411,30 +467,37 @@ pip freeze 2>/dev/null | egrep ^apache-libcloud==$LIBCLOUD_PIN \ || pip install --pre --ignore-installed https://github.com/curoverse/libcloud/archive/apache-libcloud-$LIBCLOUD_PIN.zip >/dev/null \ || fatal "pip install apache-libcloud failed" -# This will help people who reuse --temp dirs when we upgrade to llfuse 0.42 -if egrep -q 'llfuse.*>= *0\.42' "$WORKSPACE/services/fuse/setup.py"; then - # Uninstall old llfuse, because services/fuse "pip install" won't - # upgrade it by default. - if pip freeze | egrep '^llfuse==0\.41\.'; then - yes | pip uninstall 'llfuse<0.42' - fi +# Uninstall old llfuse (<1.0), because services/fuse "pip install" +# won't upgrade it by default. +if pip freeze | egrep '^llfuse==0'; then + yes | pip uninstall 'llfuse<1.0' fi # Deactivate Python 2 virtualenv deactivate +declare -a pythonstuff +pythonstuff=( + sdk/pam + sdk/python + sdk/python:py3 + sdk/cwl + services/dockercleaner:py3 + services/fuse + services/nodemanager + tools/crunchstat-summary + ) + # If Python 3 is available, set up its virtualenv in $VENV3DIR. # Otherwise, skip dependent tests. PYTHON3=$(which python3) -if [ "0" = "$?" ]; then +if [[ ${?} = 0 ]]; then setup_virtualenv "$VENV3DIR" --python python3 else PYTHON3= - skip[services/dockercleaner]=1 cat >&2 </dev/null + mkdir -p "$WORKSPACE/services/api/tmp/pids" + cd "$WORKSPACE/services/api" \ && RAILS_ENV=test bundle exec rake db:drop \ && RAILS_ENV=test bundle exec rake db:setup \ @@ -688,28 +765,36 @@ install_apiserver() { } do_install services/api apiserver +cd "$GOPATH/src/git.curoverse.com/arvados.git" && \ + "$GOPATH/bin/govendor" sync -v || \ + fatal "govendor sync failed" declare -a gostuff gostuff=( + sdk/go/arvados sdk/go/arvadosclient sdk/go/blockdigest + sdk/go/dispatch + sdk/go/httpserver sdk/go/manifest sdk/go/streamer sdk/go/crunchrunner + sdk/go/stats + lib/crunchstat services/arv-git-httpd services/crunchstat services/keep-web services/keepstore sdk/go/keepclient + services/keep-balance services/keepproxy - services/datamanager/summary - services/datamanager/collection - services/datamanager/keep - services/datamanager services/crunch-dispatch-local services/crunch-dispatch-slurm services/crunch-run + services/ws + tools/keep-block-check + tools/keep-exercise tools/keep-rsync - ) +) for g in "${gostuff[@]}" do do_install "$g" go @@ -722,6 +807,8 @@ install_workbench() { } do_install apps/workbench workbench +unset http_proxy https_proxy no_proxy + test_doclinkchecker() { ( set -e @@ -739,7 +826,7 @@ stop_services test_apiserver() { rm -f "$WORKSPACE/services/api/git-commit.version" cd "$WORKSPACE/services/api" \ - && RAILS_ENV=test bundle exec rake test TESTOPTS=-v ${testargs[services/api]} + && env RAILS_ENV=test ${short:+RAILS_TEST_SHORT=1} bundle exec rake test TESTOPTS=-v ${testargs[services/api]} } do_test services/api apiserver @@ -750,7 +837,7 @@ if [ ! -z "$only" ] && [ "$only" == "services/api" ]; then exit_cleanly fi -start_api +start_api || { stop_services; fatal "start_api"; } test_ruby_sdk() { cd "$WORKSPACE/sdk/ruby" \ @@ -771,35 +858,64 @@ test_login-sync() { } do_test services/login-sync login-sync +test_nodemanager-integration() { + cd "$WORKSPACE/services/nodemanager" \ + && tests/integration_test.py ${testargs[services/nodemanager-integration]} +} +do_test services/nodemanager-integration nodemanager-integration + for p in "${pythonstuff[@]}" do - do_test "$p" pip + dir=${p%:py3} + if [[ ${dir} = ${p} ]]; then + if [[ -z ${skip[python2]} ]]; then + do_test ${dir} pip + fi + elif [[ -n ${PYTHON3} ]]; then + if [[ -z ${skip[python3]} ]]; then + do_test ${dir} pip "$VENV3DIR/bin/" + fi + fi done -do_test services/dockercleaner pip "$VENV3DIR/bin/" for g in "${gostuff[@]}" do do_test "$g" go done -test_workbench() { +test_workbench_units() { + start_nginx_proxy_services \ + && cd "$WORKSPACE/apps/workbench" \ + && env RAILS_ENV=test ${short:+RAILS_TEST_SHORT=1} bundle exec rake test:units TESTOPTS=-v ${testargs[apps/workbench]} +} +do_test apps/workbench_units workbench_units + +test_workbench_functionals() { + start_nginx_proxy_services \ + && cd "$WORKSPACE/apps/workbench" \ + && env RAILS_ENV=test ${short:+RAILS_TEST_SHORT=1} bundle exec rake test:functionals TESTOPTS=-v ${testargs[apps/workbench]} +} +do_test apps/workbench_functionals workbench_functionals + +test_workbench_integration() { start_nginx_proxy_services \ && cd "$WORKSPACE/apps/workbench" \ - && RAILS_ENV=test bundle exec rake test TESTOPTS=-v ${testargs[apps/workbench]} + && env RAILS_ENV=test ${short:+RAILS_TEST_SHORT=1} bundle exec rake test:integration TESTOPTS=-v ${testargs[apps/workbench]} } -do_test apps/workbench workbench +do_test apps/workbench_integration workbench_integration + test_workbench_benchmark() { start_nginx_proxy_services \ && cd "$WORKSPACE/apps/workbench" \ - && RAILS_ENV=test bundle exec rake test:benchmark ${testargs[apps/workbench_benchmark]} + && env RAILS_ENV=test ${short:+RAILS_TEST_SHORT=1} bundle exec rake test:benchmark ${testargs[apps/workbench_benchmark]} } do_test apps/workbench_benchmark workbench_benchmark test_workbench_profile() { start_nginx_proxy_services \ && cd "$WORKSPACE/apps/workbench" \ - && RAILS_ENV=test bundle exec rake test:profile ${testargs[apps/workbench_profile]} + && env RAILS_ENV=test ${short:+RAILS_TEST_SHORT=1} bundle exec rake test:profile ${testargs[apps/workbench_profile]} } do_test apps/workbench_profile workbench_profile