Skip to content

Commit 272b273

Browse files
committed
fix: prevent premature cleanup in parallel multinode tests
- Don't add node PIDs to CLEANUP_PIDS in parallel mode - Return error code instead of calling error() in parallel execution - Handle test exit code properly in main function - This prevents nodes from being killed before they can timeout naturally
1 parent 052e02d commit 272b273

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

scripts/multinode-runner.sh

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ run_node() {
722722
fi
723723

724724
local node_pid=$!
725-
725+
726726
# Docker compatibility: Check if PID capture worked
727727
if [[ "$node_pid" == "\$!" ]] || ! [[ "$node_pid" =~ ^[0-9]+$ ]]; then
728728
log "Warning: PID capture failed for node $node_id (Docker issue)"
@@ -733,8 +733,10 @@ run_node() {
733733
node_pid="unknown"
734734
fi
735735
fi
736-
737-
if [[ "$node_pid" != "unknown" ]]; then
736+
737+
# Only add to cleanup PIDs if not in parallel mode
738+
# In parallel mode, we wait for all processes explicitly
739+
if [[ "$node_pid" != "unknown" ]] && [[ "$in_parallel" != "true" ]]; then
738740
CLEANUP_PIDS+=("$node_pid")
739741
fi
740742

@@ -872,14 +874,21 @@ run_test() {
872874

873875
# Wait for all nodes
874876
local failed=false
875-
for pid in "${node_pids[@]}"; do
877+
local failed_nodes=()
878+
for ((i=0; i<${#node_pids[@]}; i++)); do
879+
local pid="${node_pids[$i]}"
876880
if ! wait "$pid"; then
877881
failed=true
882+
local node_id=$(jq -r ".nodes[$i].id" "$config_file")
883+
failed_nodes+=("$node_id")
878884
fi
879885
done
880886

881887
if [[ "$failed" == "true" ]]; then
882-
error "One or more nodes failed"
888+
echo "Error: The following nodes failed: ${failed_nodes[*]}" >&2
889+
# Don't call error() here as it triggers cleanup prematurely
890+
# Just return failure to the caller
891+
return 1
883892
fi
884893
;;
885894
"sequential")
@@ -930,7 +939,15 @@ main() {
930939
fi
931940

932941
parse_config "$TEST_CONFIG"
942+
943+
# Temporarily disable set -e for run_test since it handles its own errors
944+
set +e
933945
run_test "$TEST_CONFIG"
946+
local test_result=$?
947+
set -e
948+
949+
# Exit with the test result (cleanup will be triggered by trap)
950+
exit $test_result
934951
}
935952

936953
main "$@"

0 commit comments

Comments
 (0)