1
0
mirror of https://github.com/etcd-io/etcd.git synced 2026-02-05 15:46:51 +01:00

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>
This commit is contained in:
Ivan Valdes
2026-01-08 10:54:49 -08:00
parent 65b1be4e2f
commit 64f366f2a7
2 changed files with 27 additions and 56 deletions

View File

@@ -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 {

View File

@@ -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 ####