diff --git a/scripts/test.sh b/scripts/test.sh index d2d866d33..6e7fab0ef 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -128,6 +128,7 @@ function build_pass { function unit_pass { run_for_all_workspace_modules \ run_go_tests -short \ + -failfast \ -timeout="${TIMEOUT:-3m}" \ "${COMMON_TEST_FLAGS[@]}" \ "${RUN_ARG[@]}" \ @@ -136,12 +137,11 @@ function unit_pass { function integration_extra { if [ -z "${PKG}" ] ; then - KEEP_GOING_TESTS=true \ - run_go_tests_expanding_packages ./tests/integration/v2store/... \ - -timeout="${TIMEOUT:-5m}" \ - "${COMMON_TEST_FLAGS[@]}" \ - "${RUN_ARG[@]}" \ - "$@" + run_go_tests_expanding_packages ./tests/integration/v2store/... \ + -timeout="${TIMEOUT:-5m}" \ + "${COMMON_TEST_FLAGS[@]}" \ + "${RUN_ARG[@]}" \ + "$@" else log_warning "integration_extra ignored when PKG is specified" fi @@ -150,6 +150,7 @@ function integration_extra { function integration_pass { run_go_tests ./tests/integration/... \ -p=2 \ + -failfast \ -timeout="${TIMEOUT:-15m}" \ "${COMMON_TEST_FLAGS[@]}" \ "${RUN_ARG[@]}" \ @@ -157,6 +158,7 @@ function integration_pass { run_go_tests ./tests/common/... \ -p=2 \ + -failfast \ -tags=integration \ -timeout="${TIMEOUT:-15m}" \ "${COMMON_TEST_FLAGS[@]}" \ @@ -168,26 +170,23 @@ function integration_pass { function e2e_pass { # e2e tests are running pre-build binary. Settings like --race,-cover,-cpu do not have any impact. - KEEP_GOING_TESTS=true \ - run_go_tests_expanding_packages ./tests/e2e/... \ - -timeout="${TIMEOUT:-30m}" \ - "${RUN_ARG[@]}" \ - "$@" - KEEP_GOING_TESTS=true \ - run_go_tests_expanding_packages ./tests/common/... \ - -tags=e2e \ - -timeout="${TIMEOUT:-30m}" \ - "${RUN_ARG[@]}" \ - "$@" + run_go_tests_expanding_packages ./tests/e2e/... \ + -timeout="${TIMEOUT:-30m}" \ + "${RUN_ARG[@]}" \ + "$@" + run_go_tests_expanding_packages ./tests/common/... \ + -tags=e2e \ + -timeout="${TIMEOUT:-30m}" \ + "${RUN_ARG[@]}" \ + "$@" } function robustness_pass { # e2e tests are running pre-build binary. Settings like --race,-cover,-cpu does not have any impact. - KEEP_GOING_TESTS=true \ - run_go_tests ./tests/robustness \ - -timeout="${TIMEOUT:-30m}" \ - "${RUN_ARG[@]}" \ - "$@" + run_go_tests ./tests/robustness \ + -timeout="${TIMEOUT:-30m}" \ + "${RUN_ARG[@]}" \ + "$@" } function integration_e2e_pass { diff --git a/scripts/test_lib.sh b/scripts/test_lib.sh index 7af7c7037..2b006a0d8 100644 --- a/scripts/test_lib.sh +++ b/scripts/test_lib.sh @@ -372,10 +372,6 @@ function run_go_tests_expanding_packages { # run_go_test [arguments to pass to go test] # The following environment variables affect how the tests run: -# - KEEP_GOING_TESTS: If set to true it will keep executing tests even after -# a failure. It collects all failures and reports them at -# the end, if there are failures the return code is 2. -# Defaults to false. # - JUNIT_REPORT_DIR/ARTIFACTS: Enables collecting JUnit XML reports. # - VERBOSE: Sets a verbose output. # @@ -386,18 +382,6 @@ function run_go_tests_expanding_packages { function run_go_tests { local go_test_flags=() - local packages=() - local args=() - for arg in "$@"; do - if [[ "${arg}" =~ ^\./ || "${arg}" =~ ^go\.etcd\.io/etcd ]]; then - packages+=("${arg}") - else - args+=("${arg}") - fi - done - - local keep_going=${KEEP_GOING_TESTS:-false} - # If JUNIT_REPORT_DIR is unset, and ARTIFACTS is set, then have them match. local junit_report_dir=${JUNIT_REPORT_DIR:-${ARTIFACTS:-}} @@ -411,29 +395,17 @@ function run_go_tests { go_test_flags+=("-v" "-json") fi - local failures=() - # execution of tests against packages: - for pkg in "${packages[@]}"; do - local cmd=(go test "${go_test_flags[@]}" "${pkg}" "${args[@]}") + local cmd=(go test "${go_test_flags[@]}" "$@") - local junit_filename_prefix - junit_filename_prefix=$(get_junit_filename_prefix "${junit_report_dir}") + local junit_filename_prefix + junit_filename_prefix=$(get_junit_filename_prefix "${junit_report_dir}") - if ! run env ETCD_VERIFY="${ETCD_VERIFY}" "${cmd[@]}" | tee ${junit_filename_prefix:+"${junit_filename_prefix}.stdout"} | grep --binary-files=text "${go_test_grep_pattern}" ; then - if [ "${keep_going}" = "true" ]; then - failures+=("${pkg}") - else - produce_junit_xmlreport "${junit_filename_prefix}" - return 2 - fi - fi + if ! run env ETCD_VERIFY="${ETCD_VERIFY}" "${cmd[@]}" | tee ${junit_filename_prefix:+"${junit_filename_prefix}.stdout"} | grep --binary-files=text "${go_test_grep_pattern}" ; then produce_junit_xmlreport "${junit_filename_prefix}" - done - - if [ -n "${failures[*]}" ]; then - log_error -e "FAIL: Tests for following packages failed:\\n ${failures[*]}" return 2 fi + + produce_junit_xmlreport "${junit_filename_prefix}" } #### Other ####