mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-26 21:17:23 +00:00
now that go test runs iteration loops, use that instead of custom executor
This commit is contained in:
parent
38d5be4f36
commit
d046275a36
@ -74,7 +74,6 @@ usage: $0 [OPTIONS] [TARGETS]
|
|||||||
|
|
||||||
OPTIONS:
|
OPTIONS:
|
||||||
-p <number> : number of parallel workers, must be >= 1
|
-p <number> : number of parallel workers, must be >= 1
|
||||||
-i <number> : number of times to run each test per worker, must be >= 1
|
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,7 +81,6 @@ isnum() {
|
|||||||
[[ "$1" =~ ^[0-9]+$ ]]
|
[[ "$1" =~ ^[0-9]+$ ]]
|
||||||
}
|
}
|
||||||
|
|
||||||
iterations=1
|
|
||||||
parallel=1
|
parallel=1
|
||||||
while getopts "hp:i:" opt ; do
|
while getopts "hp:i:" opt ; do
|
||||||
case $opt in
|
case $opt in
|
||||||
@ -99,12 +97,9 @@ while getopts "hp:i:" opt ; do
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
i)
|
i)
|
||||||
iterations="$OPTARG"
|
kube::log::usage "'$0': use GOFLAGS='-count <num-iterations>'"
|
||||||
if ! isnum "${iterations}" || [[ "${iterations}" -le 0 ]]; then
|
kube::test::usage
|
||||||
kube::log::usage "'$0': argument to -i must be numeric and greater than 0"
|
exit 1
|
||||||
kube::test::usage
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
?)
|
?)
|
||||||
kube::test::usage
|
kube::test::usage
|
||||||
@ -180,50 +175,7 @@ produceJUnitXMLReport() {
|
|||||||
kube::log::status "Saved JUnit XML test report to ${junit_xml_filename}"
|
kube::log::status "Saved JUnit XML test report to ${junit_xml_filename}"
|
||||||
}
|
}
|
||||||
|
|
||||||
runTestIterations() {
|
|
||||||
local worker=$1
|
|
||||||
shift
|
|
||||||
kube::log::status "Worker ${worker}: Running ${iterations} times"
|
|
||||||
for arg; do
|
|
||||||
trap 'exit 1' SIGINT
|
|
||||||
local pkg=${KUBE_GO_PACKAGE}/${arg}
|
|
||||||
kube::log::status "${pkg}"
|
|
||||||
# keep going, even if there are failures
|
|
||||||
local pass=0
|
|
||||||
local count=0
|
|
||||||
for i in $(seq 1 ${iterations}); do
|
|
||||||
if go test "${goflags[@]:+${goflags[@]}}" \
|
|
||||||
${KUBE_RACE} ${KUBE_TIMEOUT} "${pkg}" \
|
|
||||||
"${testargs[@]:+${testargs[@]}}"; then
|
|
||||||
pass=$((pass + 1))
|
|
||||||
else
|
|
||||||
ITERATION_FAILURES=$((ITERATION_FAILURES + 1))
|
|
||||||
fi
|
|
||||||
count=$((count + 1))
|
|
||||||
done 2>&1
|
|
||||||
kube::log::status "Worker ${worker}: ${pass} / ${count} passed"
|
|
||||||
done
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
runTests() {
|
runTests() {
|
||||||
# TODO: this should probably be refactored to avoid code duplication with the
|
|
||||||
# coverage version.
|
|
||||||
if [[ $iterations -gt 1 ]]; then
|
|
||||||
ITERATION_FAILURES=0 # purposely non-local
|
|
||||||
if [[ $# -eq 0 ]]; then
|
|
||||||
set -- $(kube::test::find_dirs)
|
|
||||||
fi
|
|
||||||
for p in $(seq 1 ${parallel}); do
|
|
||||||
runTestIterations ${p} "$@" &
|
|
||||||
done
|
|
||||||
wait
|
|
||||||
if [[ ${ITERATION_FAILURES} -gt 0 ]]; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
local junit_filename_prefix
|
local junit_filename_prefix
|
||||||
junit_filename_prefix=$(junitFilenamePrefix)
|
junit_filename_prefix=$(junitFilenamePrefix)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user