Merge branch 'master' into 10576-cwl-keep-fetcher
[arvados.git] / build / run-tests.sh
index 31d8c0c6c1c297b964d1dce1401bbb5a5dca69a6..560a6933e8afe63e48f963dfa8c990a2da2b9897 100755 (executable)
@@ -58,7 +58,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
@@ -90,9 +93,13 @@ sdk/go/streamer
 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
 
 # First make sure to remove any ARVADOS_ variables from the calling
@@ -149,11 +156,17 @@ 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 '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 6 ]] \
-        || fatal "Go >= 1.6 required. 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"
@@ -205,7 +218,13 @@ 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
@@ -489,7 +508,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
@@ -502,6 +527,8 @@ do_test_once() {
             # 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
@@ -512,7 +539,7 @@ do_test_once() {
                 # empty, so use this form in such cases:
                 go test ${short:+-short} ${coverflags[@]} "git.curoverse.com/arvados.git/$1"
             fi
-            result="$?"
+            result=${result:-$?}
             if [[ -f "$WORKSPACE/tmp/.$covername.tmp" ]]
             then
                 go tool cover -html="$WORKSPACE/tmp/.$covername.tmp" -o "$WORKSPACE/tmp/$covername.html"
@@ -520,10 +547,22 @@ do_test_once() {
             fi
         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 ${short:+--short-tests-only} 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"
@@ -725,15 +764,12 @@ gostuff=(
     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
-    tools/keep-rsync
     tools/keep-block-check
+    tools/keep-exercise
+    tools/keep-rsync
     )
 for g in "${gostuff[@]}"
 do
@@ -807,12 +843,27 @@ 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 TESTOPTS=-v ${testargs[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 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" \
+        && 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 \