From 3c44b86ad654c6b7b5b137d5377f97b4ea6e9214 Mon Sep 17 00:00:00 2001 From: Benjamin Elder Date: Thu, 17 Jun 2021 11:52:18 -0700 Subject: [PATCH 1/5] enable race detector by default in make test --- hack/make-rules/test.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hack/make-rules/test.sh b/hack/make-rules/test.sh index 21cd65c4922..acdce78a57a 100755 --- a/hack/make-rules/test.sh +++ b/hack/make-rules/test.sh @@ -71,7 +71,10 @@ KUBE_COVER_REPORT_DIR="${KUBE_COVER_REPORT_DIR:-}" # How many 'go test' instances to run simultaneously when running tests in # coverage mode. KUBE_COVERPROCS=${KUBE_COVERPROCS:-4} -KUBE_RACE=${KUBE_RACE:-} # use KUBE_RACE="-race" to enable race testing +# use KUBE_RACE="" to disable the race detector +# this is defaulted to "-race" in make test as well +# NOTE: DO NOT ADD A COLON HERE. KUBE_RACE="" is meaningful! +KUBE_RACE=${KUBE_RACE-"-race"} # Set to the goveralls binary path to report coverage results to Coveralls.io. KUBE_GOVERALLS_BIN=${KUBE_GOVERALLS_BIN:-} # once we have multiple group supports From 55d2868e9d88b6e47bd0cb4f8d1de3343e381a23 Mon Sep 17 00:00:00 2001 From: Benjamin Elder Date: Thu, 17 Jun 2021 15:49:34 -0700 Subject: [PATCH 2/5] don't redundantly set KUBE_RACE in test-integration.sh --- hack/make-rules/test-integration.sh | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/hack/make-rules/test-integration.sh b/hack/make-rules/test-integration.sh index 88647f8afd2..9707fefd37d 100755 --- a/hack/make-rules/test-integration.sh +++ b/hack/make-rules/test-integration.sh @@ -66,16 +66,12 @@ runTests() { kube::etcd::start kube::log::status "Running integration test cases" - # export KUBE_RACE - # - # Enable the Go race detector. - export KUBE_RACE="-race" make -C "${KUBE_ROOT}" test \ WHAT="${WHAT:-$(kube::test::find_integration_test_dirs | paste -sd' ' -)}" \ GOFLAGS="${GOFLAGS:-}" \ KUBE_TEST_ARGS="--alsologtostderr=true ${KUBE_TEST_ARGS:-} ${SHORT:--short=true} --vmodule=${KUBE_TEST_VMODULE}" \ - KUBE_RACE="" \ - KUBE_TIMEOUT="${KUBE_TIMEOUT}" + KUBE_TIMEOUT="${KUBE_TIMEOUT}" \ + KUBE_RACE="" cleanup } From 4ee729ce5f231c090d4e18675e51f3fea7deb5d5 Mon Sep 17 00:00:00 2001 From: Benjamin Elder Date: Thu, 17 Jun 2021 22:49:49 -0700 Subject: [PATCH 3/5] disable race detector in test-cmd.sh --- hack/make-rules/test-cmd.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hack/make-rules/test-cmd.sh b/hack/make-rules/test-cmd.sh index 52b7a3f4893..f6edd1dee92 100755 --- a/hack/make-rules/test-cmd.sh +++ b/hack/make-rules/test-cmd.sh @@ -170,7 +170,8 @@ if [[ ${WHAT} == "" || ${WHAT} =~ .*kubeadm.* ]] ; then # invoke the tests make -C "${KUBE_ROOT}" test \ WHAT=k8s.io/kubernetes/cmd/kubeadm/test/cmd \ - KUBE_TIMEOUT=--timeout=240s + KUBE_TIMEOUT=--timeout=240s \ + KUBE_RACE="" # if we ONLY want to run kubeadm, then exit here. if [[ ${WHAT} == "kubeadm" ]]; then From 68d8bcb64fb75ed94ad5b522b1a9885639fee9ba Mon Sep 17 00:00:00 2001 From: Benjamin Elder Date: Thu, 17 Jun 2021 22:53:01 -0700 Subject: [PATCH 4/5] remove redundant bits from test-dockerized.sh --- hack/jenkins/test-dockerized.sh | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/hack/jenkins/test-dockerized.sh b/hack/jenkins/test-dockerized.sh index 69a9852dacd..b2e84778e87 100755 --- a/hack/jenkins/test-dockerized.sh +++ b/hack/jenkins/test-dockerized.sh @@ -19,17 +19,6 @@ set -o nounset set -o pipefail set -o xtrace -retry() { - for i in {1..5}; do - if "$@"; then - return 0 - else - sleep "${i}" - fi - done - "$@" -} - # Runs the unit and integration tests, producing JUnit-style XML test # reports in ${WORKSPACE}/artifacts. This script is intended to be run from # kubekins-test container with a kubernetes repo mapped in. See @@ -47,14 +36,10 @@ pushd "./hack/tools" >/dev/null GO111MODULE=on go install gotest.tools/gotestsum popd >/dev/null -# Enable the Go race detector. -export KUBE_RACE=-race # Disable coverage report export KUBE_COVER="n" # Set artifacts directory export ARTIFACTS=${ARTIFACTS:-"${WORKSPACE}/artifacts"} -# Produce a JUnit-style XML test report -export KUBE_JUNIT_REPORT_DIR="${ARTIFACTS}" # Save the verbose stdout as well. export KUBE_KEEP_VERBOSE_TEST_OUTPUT=y export KUBE_INTEGRATION_TEST_MAX_CONCURRENCY=4 From 8942cba24d455eb3b7c84ac2d5a6b02cee075b78 Mon Sep 17 00:00:00 2001 From: Benjamin Elder Date: Thu, 17 Jun 2021 22:57:10 -0700 Subject: [PATCH 5/5] log if we're running with -race --- hack/make-rules/test.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hack/make-rules/test.sh b/hack/make-rules/test.sh index acdce78a57a..3b9e5520cc6 100755 --- a/hack/make-rules/test.sh +++ b/hack/make-rules/test.sh @@ -253,7 +253,7 @@ runTests() { # If we're not collecting coverage, run all requested tests with one 'go test' # command, which is much faster. if [[ ! ${KUBE_COVER} =~ ^[yY]$ ]]; then - kube::log::status "Running tests without code coverage" + kube::log::status "Running tests without code coverage ${KUBE_RACE:+"and with ${KUBE_RACE}"}" go test "${goflags[@]:+${goflags[@]}}" \ "${KUBE_TIMEOUT}" "${@}" \ "${testargs[@]:+${testargs[@]}}" \ @@ -263,6 +263,8 @@ runTests() { return ${rc} fi + kube::log::status "Running tests with code coverage ${KUBE_RACE:+"and with ${KUBE_RACE}"}" + # Create coverage report directories. if [[ -z "${KUBE_COVER_REPORT_DIR}" ]]; then cover_report_dir="/tmp/k8s_coverage/$(kube::util::sortable_date)"