Commit 447750f1 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #31853 from thockin/faster-tests

Automatic merge from submit-queue Make unit test runs MUCH faster Running tests rebuilds almost everything. Most unit tests do not need to be rebuilt. This installs test artifacts and makes subsequent test runs as much as 6x faster. I saw pkg/apiserver tests drop from 30+ seconds to 5 seconds.
parents 17ee588c a7ab2da8
...@@ -194,6 +194,12 @@ runTests() { ...@@ -194,6 +194,12 @@ runTests() {
# command, which is much faster. # command, which is much faster.
if [[ ! ${KUBE_COVER} =~ ^[yY]$ ]]; then if [[ ! ${KUBE_COVER} =~ ^[yY]$ ]]; then
kube::log::status "Running tests without code coverage" kube::log::status "Running tests without code coverage"
# `go test` does not install the things it builds. `go test -i` installs
# the build artifacts but doesn't run the tests. The two together provide
# a large speedup for tests that do not need to be rebuilt.
go test -i "${goflags[@]:+${goflags[@]}}" \
${KUBE_RACE} ${KUBE_TIMEOUT} "${@+${@/#/${KUBE_GO_PACKAGE}/}}" \
"${testargs[@]:+${testargs[@]}}"
go test "${goflags[@]:+${goflags[@]}}" \ go test "${goflags[@]:+${goflags[@]}}" \
${KUBE_RACE} ${KUBE_TIMEOUT} "${@+${@/#/${KUBE_GO_PACKAGE}/}}" \ ${KUBE_RACE} ${KUBE_TIMEOUT} "${@+${@/#/${KUBE_GO_PACKAGE}/}}" \
"${testargs[@]:+${testargs[@]}}" \ "${testargs[@]:+${testargs[@]}}" \
...@@ -220,8 +226,19 @@ runTests() { ...@@ -220,8 +226,19 @@ runTests() {
# separate files. # separate files.
# cmd/libs/go2idl/generator is fragile when run under coverage, so ignore it for now. # cmd/libs/go2idl/generator is fragile when run under coverage, so ignore it for now.
# see: https://github.com/kubernetes/kubernetes/issues/24967 # see: https://github.com/kubernetes/kubernetes/issues/24967
#
# `go test` does not install the things it builds. `go test -i` installs
# the build artifacts but doesn't run the tests. The two together provide
# a large speedup for tests that do not need to be rebuilt.
printf "%s\n" "${@}" | grep -v "cmd/libs/go2idl/generator"| xargs -I{} -n1 -P${KUBE_COVERPROCS} \ printf "%s\n" "${@}" | grep -v "cmd/libs/go2idl/generator"| xargs -I{} -n1 -P${KUBE_COVERPROCS} \
bash -c "set -o pipefail; _pkg=\"{}\"; _pkg_out=\${_pkg//\//_}; \ bash -c "set -o pipefail; _pkg=\"{}\"; _pkg_out=\${_pkg//\//_}; \
go test -i ${goflags[@]:+${goflags[@]}} \
${KUBE_RACE} \
${KUBE_TIMEOUT} \
-cover -covermode=\"${KUBE_COVERMODE}\" \
-coverprofile=\"${cover_report_dir}/\${_pkg}/${cover_profile}\" \
\"${KUBE_GO_PACKAGE}/\${_pkg}\" \
${testargs[@]:+${testargs[@]}}
go test ${goflags[@]:+${goflags[@]}} \ go test ${goflags[@]:+${goflags[@]}} \
${KUBE_RACE} \ ${KUBE_RACE} \
${KUBE_TIMEOUT} \ ${KUBE_TIMEOUT} \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment