fix runner calculation to exclude the top level directory as part of the calculation

pull/17090/head
John Murret 2023-04-21 15:59:52 -06:00
parent a011d8c944
commit 07d9aeb851
1 changed files with 17 additions and 5 deletions

View File

@ -159,10 +159,14 @@ jobs:
JQ_SLICER: '[ inputs ] | [_nwise(length / $runnercount | floor)]' JQ_SLICER: '[ inputs ] | [_nwise(length / $runnercount | floor)]'
run: | run: |
NUM_RUNNERS=$TOTAL_RUNNERS NUM_RUNNERS=$TOTAL_RUNNERS
NUM_DIRS=$(find ./test/integration/connect/envoy -maxdepth 1 -type d | wc -l) NUM_DIRS=$(find ./test -maxdepth 2 -type d | wc -l)
#remove on for the top level directory
NUM_DIRS=$((NUM_DIRS-1))
if [ "$NUM_DIRS" -lt "$NUM_RUNNERS" ]; then if [ "$NUM_DIRS" -lt "$NUM_RUNNERS" ]; then
echo "TOTAL_RUNNERS is larger than the number of tests/packages to split." echo "TOTAL_RUNNERS is larger than the number of tests/packages to split."
NUM_RUNNERS=$NUM_DIRS NUM_RUNNERS=$((NUM_DIRS-1))
fi fi
# fix issue where test splitting calculation generates 1 more split than TOTAL_RUNNERS. # fix issue where test splitting calculation generates 1 more split than TOTAL_RUNNERS.
NUM_RUNNERS=$((NUM_RUNNERS-1)) NUM_RUNNERS=$((NUM_RUNNERS-1))
@ -274,9 +278,13 @@ jobs:
cd ./test/integration/consul-container cd ./test/integration/consul-container
NUM_RUNNERS=$TOTAL_RUNNERS NUM_RUNNERS=$TOTAL_RUNNERS
NUM_DIRS=$(find ./test -maxdepth 2 -type d | wc -l) NUM_DIRS=$(find ./test -maxdepth 2 -type d | wc -l)
#remove on for the top level directory
NUM_DIRS=$((NUM_DIRS-1))
if [ "$NUM_DIRS" -lt "$NUM_RUNNERS" ]; then if [ "$NUM_DIRS" -lt "$NUM_RUNNERS" ]; then
echo "TOTAL_RUNNERS is larger than the number of tests/packages to split." echo "TOTAL_RUNNERS is larger than the number of tests/packages to split."
NUM_RUNNERS=$NUM_DIRS NUM_RUNNERS=$((NUM_DIRS-1))
fi fi
# fix issue where test splitting calculation generates 1 more split than TOTAL_RUNNERS. # fix issue where test splitting calculation generates 1 more split than TOTAL_RUNNERS.
NUM_RUNNERS=$((NUM_RUNNERS-1)) NUM_RUNNERS=$((NUM_RUNNERS-1))
@ -378,10 +386,14 @@ jobs:
run: | run: |
cd ./test/integration/consul-container/test/upgrade cd ./test/integration/consul-container/test/upgrade
NUM_RUNNERS=$TOTAL_RUNNERS NUM_RUNNERS=$TOTAL_RUNNERS
NUM_DIRS=$(go test ./... -list=. -json | jq -r '.Output | select (. !=null) | select(. | startswith("Test")) | gsub("[\\n\\t]"; "")' | wc -l) NUM_DIRS=$(find ./test -maxdepth 2 -type d | wc -l)
#remove on for the top level directory
NUM_DIRS=$((NUM_DIRS-1))
if [ "$NUM_DIRS" -lt "$NUM_RUNNERS" ]; then if [ "$NUM_DIRS" -lt "$NUM_RUNNERS" ]; then
echo "TOTAL_RUNNERS is larger than the number of tests/packages to split." echo "TOTAL_RUNNERS is larger than the number of tests/packages to split."
NUM_RUNNERS=$NUM_DIRS NUM_RUNNERS=$((NUM_DIRS-1))
fi fi
# fix issue where test splitting calculation generates 1 more split than TOTAL_RUNNERS. # fix issue where test splitting calculation generates 1 more split than TOTAL_RUNNERS.
NUM_RUNNERS=$((NUM_RUNNERS-1)) NUM_RUNNERS=$((NUM_RUNNERS-1))