diff --git a/hack/test-all.sh b/hack/test-all.sh index 42d64f006f..e538e78b63 100755 --- a/hack/test-all.sh +++ b/hack/test-all.sh @@ -20,7 +20,19 @@ 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 without any limits (spins up around 10+ environments). +# +# To avoid flakes, set we're setting the go-test parallel flag to +# to limit the number of parallel 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