mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-23 14:40:30 +01:00
itest: fix itest logs upload
When one of the itest tranches fails, because we are running tests in parallel, other tranches will still be running, which caused 7z to fail at zipping the logs because race reads. This commit fixes it by making sure we are waiting other tranches to finish before moving to zipping and uploading the logs.
This commit is contained in:
parent
3549e329df
commit
ba007d9373
2 changed files with 39 additions and 1 deletions
2
Makefile
2
Makefile
|
@ -174,7 +174,7 @@ itest-race: build-itest-race itest-only
|
||||||
itest-parallel: build-itest db-instance
|
itest-parallel: build-itest db-instance
|
||||||
@$(call print, "Running tests")
|
@$(call print, "Running tests")
|
||||||
rm -rf itest/*.log itest/.logs-*; date
|
rm -rf itest/*.log itest/.logs-*; date
|
||||||
EXEC_SUFFIX=$(EXEC_SUFFIX) echo "$$(seq 0 $$(expr $(ITEST_PARALLELISM) - 1))" | xargs -P $(ITEST_PARALLELISM) -n 1 -I {} scripts/itest_part.sh {} $(NUM_ITEST_TRANCHES) $(TEST_FLAGS) $(ITEST_FLAGS)
|
EXEC_SUFFIX=$(EXEC_SUFFIX) scripts/itest_parallel.sh $(ITEST_PARALLELISM) $(NUM_ITEST_TRANCHES) $(TEST_FLAGS) $(ITEST_FLAGS)
|
||||||
|
|
||||||
itest-clean:
|
itest-clean:
|
||||||
@$(call print, "Cleaning old itest processes")
|
@$(call print, "Cleaning old itest processes")
|
||||||
|
|
38
scripts/itest_parallel.sh
Executable file
38
scripts/itest_parallel.sh
Executable file
|
@ -0,0 +1,38 @@
|
||||||
|
#!/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_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
|
Loading…
Add table
Reference in a new issue