X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/7bb66fca9371232cc32dd6b365ceb33e926eb0e7..bdb92619b5f6d920119b8c32c3027cf4b751ed16:/build/run-tests.sh diff --git a/build/run-tests.sh b/build/run-tests.sh index f56e46ab8b..e0e1ce2852 100755 --- a/build/run-tests.sh +++ b/build/run-tests.sh @@ -2,6 +2,9 @@ . `dirname "$(readlink -f "$0")"`/libcloud-pin +COLUMNS=80 +. `dirname "$(readlink -f "$0")"`/run-library.sh + read -rd "\000" helpmessage <=2.1.9 (using rbenv, rvm, or source)" + echo -n 'bundler: ' + bundle version \ + || fatal "No bundler. Try: gem install bundler" echo -n 'go: ' go version \ || fatal "No go binary. See http://golang.org/doc/install" + [[ $(go version) =~ go1.([0-9]+) ]] && [[ ${BASH_REMATCH[1]} -ge 7 ]] \ + || fatal "Go >= 1.7 required. See http://golang.org/doc/install" echo -n 'gcc: ' gcc --version | egrep ^gcc \ || fatal "No gcc. Try: apt-get install build-essential" @@ -214,11 +220,20 @@ do ;; --skip) skipwhat="$1"; shift - skip[$skipwhat]=1 + if [[ "$skipwhat" == "apps/workbench" ]]; then + skip["apps/workbench_units"]=1 + skip["apps/workbench_functionals"]=1 + skip["apps/workbench_integration"]=1 + else + skip[$skipwhat]=1 + fi ;; --only) only="$1"; skip[$1]=""; shift ;; + --short) + short=1 + ;; --skip-install) skip_install=1 ;; @@ -257,15 +272,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 } @@ -276,12 +294,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 } @@ -348,9 +369,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 @@ -401,7 +425,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' } @@ -470,23 +499,6 @@ then gem install --user-install bundler || fatal 'Could not install bundler' fi -checkexit() { - if [[ "$1" != "0" ]]; then - title "!!!!!! $2 FAILED !!!!!!" - failures+=("$2 (`timer`)") - else - successes+=("$2 (`timer`)") - fi -} - -timer_reset() { - t0=$SECONDS -} - -timer() { - echo -n "$(($SECONDS - $t0))s" -} - retry() { while ! ${@} && [[ "$retry" == 1 ]] do @@ -504,7 +516,13 @@ do_test() { do_test_once() { unset result - if [[ -z "${skip[$1]}" ]] && ( [[ -z "$only" ]] || [[ "$only" == "$1" ]] ) + to_test=$1 + if (( [[ "$only" == "apps/workbench" ]] ) && + ( [[ "$to_test" == "apps/workbench_units" ]] || [[ "$to_test" == "apps/workbench_functionals" ]] || + [[ "$to_test" == "apps/workbench_integration" ]])); then + to_test="apps/workbench" + fi + if [[ -z "${skip[$1]}" ]] && ( [[ -z "$only" ]] || [[ "$only" == "$to_test" ]] ) then title "Running $1 tests" timer_reset @@ -516,28 +534,43 @@ do_test_once() { # before trying "go test". Otherwise, coverage-reporting # mode makes Go show the wrong line numbers when reporting # compilation errors. + go get -t "git.curoverse.com/arvados.git/$1" || return 1 + cd "$WORKSPACE/$1" || return 1 + gofmt -e -d . | egrep . && result=1 if [[ -n "${testargs[$1]}" ]] then # "go test -check.vv giturl" doesn't work, but this # does: - cd "$WORKSPACE/$1" && \ - go get -t "git.curoverse.com/arvados.git/$1" && \ - go test ${coverflags[@]} ${testargs[$1]} + cd "$WORKSPACE/$1" && go test ${short:+-short} ${testargs[$1]} else # The above form gets verbose even when testargs is # empty, so use this form in such cases: - go get -t "git.curoverse.com/arvados.git/$1" && \ - go test ${coverflags[@]} "git.curoverse.com/arvados.git/$1" + go test ${short:+-short} ${coverflags[@]} "git.curoverse.com/arvados.git/$1" + fi + result=${result:-$?} + if [[ -f "$WORKSPACE/tmp/.$covername.tmp" ]] + then + go tool cover -html="$WORKSPACE/tmp/.$covername.tmp" -o "$WORKSPACE/tmp/$covername.html" + rm "$WORKSPACE/tmp/.$covername.tmp" fi - result="$?" - go tool cover -html="$WORKSPACE/tmp/.$covername.tmp" -o "$WORKSPACE/tmp/$covername.html" - rm "$WORKSPACE/tmp/.$covername.tmp" elif [[ "$2" == "pip" ]] then - # $3 can name a path directory for us to use, including trailing - # slash; e.g., the bin/ subdirectory of a virtualenv. - cd "$WORKSPACE/$1" \ - && "${3}python" setup.py test ${testargs[$1]} + tries=0 + cd "$WORKSPACE/$1" && while : + do + tries=$((${tries}+1)) + # $3 can name a path directory for us to use, including trailing + # slash; e.g., the bin/ subdirectory of a virtualenv. + "${3}python" setup.py ${short:+--short-tests-only} test ${testargs[$1]} + result=$? + if [[ ${tries} < 3 && ${result} == 137 ]] + then + printf '\n*****\n%s tests killed -- retrying\n*****\n\n' "$1" + continue + else + break + fi + done elif [[ "$2" != "" ]] then "test_$2" @@ -599,11 +632,6 @@ do_install_once() { fi } -title () { - txt="********** $1 **********" - printf "\n%*s%s\n\n" $((($COLUMNS-${#txt})/2)) "" "$txt" -} - bundle_install_trylocal() { ( set -e @@ -729,24 +757,28 @@ do_install services/api apiserver declare -a gostuff gostuff=( + sdk/go/arvados sdk/go/arvadosclient sdk/go/blockdigest + 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[@]}" @@ -778,7 +810,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 @@ -821,24 +853,39 @@ 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" \ - && 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:functionals TESTOPTS=-v ${testargs[apps/workbench]} } -do_test apps/workbench workbench +do_test apps/workbench_functionals workbench_functionals + +test_workbench_integration() { + start_nginx_proxy_services \ + && cd "$WORKSPACE/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_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