diff --git a/hack/test-all.sh b/hack/test-all.sh index 42d64f006f..d2680c25ce 100755 --- a/hack/test-all.sh +++ b/hack/test-all.sh @@ -20,7 +20,18 @@ source $(dirname ${BASH_SOURCE})/common.sh header_text "running go test" -go test -race ${MOD_OPT} ./... +# On MacOS there is a strange race condition +# between port allocation of envtest suites when go test +# runs all the tests in parallel (spins up around 10 or so environments). +# +# To avoid flakes, set -p=1 to disable parallel go test executions. +# +# TODO(community): Investigate this behavior further. +if [[ "${OSTYPE}" == "darwin"* ]]; then + P_FLAG="-p=1" +fi + +go test -race ${P_FLAG} ${MOD_OPT} ./... if [[ -n ${ARTIFACTS:-} ]]; then if grep -Rin '' ${ARTIFACTS}/*; then exit 1; fi