diff --git a/test.sh b/test.sh index b0001369009..e361eddc0e4 100755 --- a/test.sh +++ b/test.sh @@ -82,7 +82,30 @@ function run_and_expect_silence() { # Testing Helpers # function run_unit_tests() { - go test "${UNIT_FLAGS[@]}" "${UNIT_PACKAGES[@]}" "${FILTER[@]}" + # Sleep 50ms instead of 1000ms at the end of each package's unittests. + # Speeds up running lots of small unittests. + # https://go.dev/doc/articles/race_detector#Options + export GORACE="atexit_sleep_ms=50" + # If unit test packages are not specified: set flags to run unit tests + # for all boulder packages + if [ -z "${UNIT_PACKAGES[@]+x}" ] + then + # The ra and sa unittests conflict because they both mutate the database. + # Exclude the ra from our first test run, then run on its own. + # https://github.com/letsencrypt/boulder/issues/1499 + go_test $(go list ./... | grep -v boulder/ra) + go_test ./ra + else + go_test "${UNIT_PACKAGES[@]}" + fi + +} + +# +# Run `go test` on a given set of packages. +# +function go_test() { + go test "${UNIT_FLAGS[@]}" "${FILTER[@]}" "$@" } # @@ -176,21 +199,6 @@ then FILTER=(--filter "${FILTER[@]}") fi -# If unit test packages are not specified: set flags to run unit tests -# for all boulder packages -if [ -z "${UNIT_PACKAGES[@]+x}" ] -then - # '-p=1' configures unit tests to run serially, rather than in parallel. Our - # unit tests depend on mutating a database and then cleaning up after - # themselves. If these test were run in parallel, they could fail spuriously - # due to one test modifying a table (especially registrations) while another - # test is reading from it. - # https://github.com/letsencrypt/boulder/issues/1499 - # https://pkg.go.dev/cmd/go#hdr-Testing_flags - UNIT_FLAGS+=("-p=1") - UNIT_PACKAGES+=("./...") -fi - print_heading "Boulder Test Suite CLI" print_heading "Settings:"