Skip to content

Commit 90cc2a3

Browse files
committed
Simplify running tests
* Remove iteration over packages; with the Go workspace, we don't need to iterate. * Replace `KEEP_GOING_TESTS` behavior by using the Go `-failfast` test flag. Signed-off-by: Ivan Valdes <ivan@vald.es>
1 parent 65b1be4 commit 90cc2a3

2 files changed

Lines changed: 27 additions & 44 deletions

File tree

scripts/test.sh

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ function build_pass {
128128
function unit_pass {
129129
run_for_all_workspace_modules \
130130
run_go_tests -short \
131+
-failfast \
131132
-timeout="${TIMEOUT:-3m}" \
132133
"${COMMON_TEST_FLAGS[@]}" \
133134
"${RUN_ARG[@]}" \
@@ -136,12 +137,11 @@ function unit_pass {
136137

137138
function integration_extra {
138139
if [ -z "${PKG}" ] ; then
139-
KEEP_GOING_TESTS=true \
140-
run_go_tests_expanding_packages ./tests/integration/v2store/... \
141-
-timeout="${TIMEOUT:-5m}" \
142-
"${COMMON_TEST_FLAGS[@]}" \
143-
"${RUN_ARG[@]}" \
144-
"$@"
140+
run_go_tests_expanding_packages ./tests/integration/v2store/... \
141+
-timeout="${TIMEOUT:-5m}" \
142+
"${COMMON_TEST_FLAGS[@]}" \
143+
"${RUN_ARG[@]}" \
144+
"$@"
145145
else
146146
log_warning "integration_extra ignored when PKG is specified"
147147
fi
@@ -150,13 +150,15 @@ function integration_extra {
150150
function integration_pass {
151151
run_go_tests ./tests/integration/... \
152152
-p=2 \
153+
-failfast \
153154
-timeout="${TIMEOUT:-15m}" \
154155
"${COMMON_TEST_FLAGS[@]}" \
155156
"${RUN_ARG[@]}" \
156157
"$@"
157158

158159
run_go_tests ./tests/common/... \
159160
-p=2 \
161+
-failfast \
160162
-tags=integration \
161163
-timeout="${TIMEOUT:-15m}" \
162164
"${COMMON_TEST_FLAGS[@]}" \
@@ -168,26 +170,23 @@ function integration_pass {
168170

169171
function e2e_pass {
170172
# e2e tests are running pre-build binary. Settings like --race,-cover,-cpu do not have any impact.
171-
KEEP_GOING_TESTS=true \
172-
run_go_tests_expanding_packages ./tests/e2e/... \
173-
-timeout="${TIMEOUT:-30m}" \
174-
"${RUN_ARG[@]}" \
175-
"$@"
176-
KEEP_GOING_TESTS=true \
177-
run_go_tests_expanding_packages ./tests/common/... \
178-
-tags=e2e \
179-
-timeout="${TIMEOUT:-30m}" \
180-
"${RUN_ARG[@]}" \
181-
"$@"
173+
run_go_tests_expanding_packages ./tests/e2e/... \
174+
-timeout="${TIMEOUT:-30m}" \
175+
"${RUN_ARG[@]}" \
176+
"$@"
177+
run_go_tests_expanding_packages ./tests/common/... \
178+
-tags=e2e \
179+
-timeout="${TIMEOUT:-30m}" \
180+
"${RUN_ARG[@]}" \
181+
"$@"
182182
}
183183

184184
function robustness_pass {
185185
# e2e tests are running pre-build binary. Settings like --race,-cover,-cpu does not have any impact.
186-
KEEP_GOING_TESTS=true \
187-
run_go_tests ./tests/robustness \
188-
-timeout="${TIMEOUT:-30m}" \
189-
"${RUN_ARG[@]}" \
190-
"$@"
186+
run_go_tests ./tests/robustness \
187+
-timeout="${TIMEOUT:-30m}" \
188+
"${RUN_ARG[@]}" \
189+
"$@"
191190
}
192191

193192
function integration_e2e_pass {

scripts/test_lib.sh

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -372,10 +372,6 @@ function run_go_tests_expanding_packages {
372372

373373
# run_go_test [arguments to pass to go test]
374374
# The following environment variables affect how the tests run:
375-
# - KEEP_GOING_TESTS: If set to true it will keep executing tests even after
376-
# a failure. It collects all failures and reports them at
377-
# the end, if there are failures the return code is 2.
378-
# Defaults to false.
379375
# - JUNIT_REPORT_DIR/ARTIFACTS: Enables collecting JUnit XML reports.
380376
# - VERBOSE: Sets a verbose output.
381377
#
@@ -411,29 +407,17 @@ function run_go_tests {
411407
go_test_flags+=("-v" "-json")
412408
fi
413409

414-
local failures=()
415-
# execution of tests against packages:
416-
for pkg in "${packages[@]}"; do
417-
local cmd=(go test "${go_test_flags[@]}" "${pkg}" "${args[@]}")
410+
local cmd=(go test "${go_test_flags[@]}" "$@")
418411

419-
local junit_filename_prefix
420-
junit_filename_prefix=$(get_junit_filename_prefix "${junit_report_dir}")
412+
local junit_filename_prefix
413+
junit_filename_prefix=$(get_junit_filename_prefix "${junit_report_dir}")
421414

422-
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
423-
if [ "${keep_going}" = "true" ]; then
424-
failures+=("${pkg}")
425-
else
426-
produce_junit_xmlreport "${junit_filename_prefix}"
427-
return 2
428-
fi
429-
fi
415+
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
430416
produce_junit_xmlreport "${junit_filename_prefix}"
431-
done
432-
433-
if [ -n "${failures[*]}" ]; then
434-
log_error -e "FAIL: Tests for following packages failed:\\n ${failures[*]}"
435417
return 2
436418
fi
419+
420+
produce_junit_xmlreport "${junit_filename_prefix}"
437421
}
438422

439423
#### Other ####

0 commit comments

Comments
 (0)