itest: make parallel itest runner for litd itests

This commit is contained in:
Olaoluwa Osuntokun 2024-07-18 19:19:20 -07:00
parent a17f7701ad
commit 9295d0f8cb
2 changed files with 44 additions and 0 deletions

View File

@ -228,6 +228,13 @@ itest-parallel: build-itest db-instance
EXEC_SUFFIX=$(EXEC_SUFFIX) scripts/itest_parallel.sh $(ITEST_PARALLELISM) $(NUM_ITEST_TRANCHES) $(TEST_FLAGS) $(ITEST_FLAGS)
$(COLLECT_ITEST_COVERAGE)
#? itest-litd-parallel: Build and run integration tests in parallel mode, running up to ITEST_PARALLELISM test tranches in parallel (default 4)
itest-litd-parallel: build-itest db-instance
@$(call print, "Running tests")
rm -rf itest/*.log itest/.logs-*; date
EXEC_SUFFIX=$(EXEC_SUFFIX) scripts/itest_litd_parallel.sh $(ITEST_PARALLELISM) $(NUM_ITEST_TRANCHES) $(TEST_FLAGS) $(ITEST_FLAGS)
$(COLLECT_ITEST_COVERAGE)
#? itest-clean: Kill all running itest processes
itest-clean:
@$(call print, "Cleaning old itest processes")

37
scripts/itest_litd_parallel.sh Executable file
View File

@ -0,0 +1,37 @@
#!/bin/bash
# Get all the variables.
PROCESSES=$1
TRANCHES=$2
TEST_FLAGS=$3
ITEST_FLAGS=$4
# Create a variable to hold the final exit code.
exit_code=0
# Run commands using xargs in parallel and capture their PIDs
pids=()
for ((i=0; i<PROCESSES; i++)); do
scripts/itest_litd_part.sh $i $TRANCHES $TEST_FLAGS $ITEST_FLAGS &
pids+=($!)
done
# Wait for the processes created by xargs to finish.
for pid in "${pids[@]}"; do
wait $pid
# Once finished, grab its exit code.
current_exit_code=$?
# Overwrite the exit code if current itest doesn't return 0.
if [ $current_exit_code -ne 0 ]; then
# Only write the exit code of the first failing itest.
if [ $exit_code -eq 0 ]; then
exit_code=$current_exit_code
fi
fi
done
# Exit with the exit code of the first failing itest or 0.
exit $exit_code