itest: shuffle test cases to even out blocks mined in tranches

This commit adds a new flag to shuffle all the test cases before running
them so tests which require lots of blocks to be mined are less likely
to be run in the same tranch.

The other benefit is this approach provides a more efficient way to
figure which tests are broken since all the differnet backends are
running different tranches in their builds, we can identify more failed
tests in one push.
This commit is contained in:
yyforyongyu
2024-10-25 03:33:37 +08:00
parent 2c27df6c30
commit 88bd0cb806
6 changed files with 57 additions and 11 deletions

View File

@@ -3,9 +3,10 @@
# Get all the variables.
PROCESSES=$1
TRANCHES=$2
SHUFFLE_SEED=$3
# Here we also shift 2 times and get the rest of our flags to pass on in $@.
shift 2
# Here we also shift 3 times and get the rest of our flags to pass on in $@.
shift 3
# Create a variable to hold the final exit code.
exit_code=0
@@ -13,7 +14,7 @@ exit_code=0
# Run commands using xargs in parallel and capture their PIDs
pids=()
for ((i=0; i<PROCESSES; i++)); do
scripts/itest_part.sh $i $TRANCHES $@ &
scripts/itest_part.sh $i $TRANCHES $SHUFFLE_SEED $@ &
pids+=($!)
done

View File

@@ -5,11 +5,11 @@ WORKDIR=$(pwd)/itest
TRANCHE=$1
NUM_TRANCHES=$2
SHUFFLE_SEED_PARAM=$3
# Shift the passed parameters by two, giving us all remaining testing flags in
# Shift the passed parameters by three, giving us all remaining testing flags in
# the $@ special variable.
shift
shift
shift 3
# Windows insists on having the .exe suffix for an executable, we need to add
# that here if necessary.
@@ -18,9 +18,9 @@ LND_EXEC="$WORKDIR"/lnd-itest"$EXEC_SUFFIX"
BTCD_EXEC="$WORKDIR"/btcd-itest"$EXEC_SUFFIX"
export GOCOVERDIR="$WORKDIR/cover"
mkdir -p "$GOCOVERDIR"
echo $EXEC "$@" -logoutput -logdir=.logs-tranche$TRANCHE -lndexec=$LND_EXEC -btcdexec=$BTCD_EXEC -splittranches=$NUM_TRANCHES -runtranche=$TRANCHE
echo $EXEC "$@" -logoutput -logdir=.logs-tranche$TRANCHE -lndexec=$LND_EXEC -btcdexec=$BTCD_EXEC -splittranches=$NUM_TRANCHES -runtranche=$TRANCHE -shuffleseed=$SHUFFLE_SEED_PARAM
# Exit code 255 causes the parallel jobs to abort, so if one part fails the
# other is aborted too.
cd "$WORKDIR" || exit 255
$EXEC "$@" -logoutput -logdir=.logs-tranche$TRANCHE -lndexec=$LND_EXEC -btcdexec=$BTCD_EXEC -splittranches=$NUM_TRANCHES -runtranche=$TRANCHE || exit 255
$EXEC "$@" -logoutput -logdir=.logs-tranche$TRANCHE -lndexec=$LND_EXEC -btcdexec=$BTCD_EXEC -splittranches=$NUM_TRANCHES -runtranche=$TRANCHE -shuffleseed=$SHUFFLE_SEED_PARAM || exit 255