Commit 9919f229 authored by Brad Davidson's avatar Brad Davidson Committed by Brad Davidson

Add variable to enforce max test concurrency

parent 247298a2
ARG GOLANG=golang:1.16.10-alpine3.13 ARG GOLANG=golang:1.16.10-alpine3.13
FROM ${GOLANG} FROM ${GOLANG}
RUN apk -U --no-cache add bash git gcc musl-dev docker curl jq coreutils python3 openssl py3-pip RUN apk -U --no-cache add bash git gcc musl-dev docker curl jq coreutils python3 openssl py3-pip procps
ENV SONOBUOY_VERSION 0.55.0 ENV SONOBUOY_VERSION 0.55.0
......
...@@ -492,12 +492,12 @@ provision-cluster() { ...@@ -492,12 +492,12 @@ provision-cluster() {
done done
fi fi
[ -f "$PROVISION_LOCK" ] && rm $PROVISION_LOCK
timeout --foreground 2m bash -c "wait-for-nodes $(( NUM_SERVERS + NUM_AGENTS ))" timeout --foreground 2m bash -c "wait-for-nodes $(( NUM_SERVERS + NUM_AGENTS ))"
timeout --foreground 4m bash -c "wait-for-services $WAIT_SERVICES" timeout --foreground 4m bash -c "wait-for-services $WAIT_SERVICES"
run-function cluster-post-hook run-function cluster-post-hook
[ -f "$PROVISION_LOCK" ] && rm $PROVISION_LOCK
} }
export -f provision-cluster export -f provision-cluster
...@@ -556,21 +556,45 @@ export -f early-exit ...@@ -556,21 +556,45 @@ export -f early-exit
# --- # ---
run-test() { run-test() {
local delay=15
(
set +x
while [ $(count-running-tests) -ge ${MAX_CONCURRENT_TESTS:-4} ]; do
sleep $delay
done
)
export PROVISION_LOCK=$(mktemp) export PROVISION_LOCK=$(mktemp)
./scripts/test-runner $@ & ./scripts/test-runner $@ &
pids+=($!) pids+=($!)
( (
set +x set +x
# busy-wait on the provisioning lock before imposing a final inter-test delay
while [ -f "$PROVISION_LOCK" ]; do while [ -f "$PROVISION_LOCK" ]; do
sleep 1 sleep 1
done done
sleep 5 sleep $delay
) )
} }
export -f run-test export -f run-test
# --- # ---
count-running-tests(){
local count=0
for pid in ${pids[@]}; do
if [ $(pgrep -c -P $pid) -gt 0 ]; then
((count++))
fi
done
echo "Currently running ${count} tests" 1>&2
echo ${count}
}
export -f count-running-tests
# ---
e2e-test() { e2e-test() {
local label=$label local label=$label
if [ -n "$LABEL_SUFFIX" ]; then if [ -n "$LABEL_SUFFIX" ]; then
......
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