Skip to content

Commit ff49aa7

Browse files
committed
Try sequential
1 parent 1bf0113 commit ff49aa7

File tree

1 file changed

+45
-58
lines changed

1 file changed

+45
-58
lines changed

scripts/run_integration_tests.sh

Lines changed: 45 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,42 @@ fail() { echo -e "${RED}[FAIL]${NC} $1"; }
2020

2121
cd "$CLI_DIR"
2222

23+
# Require a prebuilt release binary (from the build job) to avoid rebuilds during CI.
24+
resolve_prebuilt_binary() {
25+
HOST_TRIPLE=$(rustc -vV | awk '/host/ {print $2}')
26+
BIN_PATH="target/${HOST_TRIPLE}/release/nexus-network"
27+
if [ -f "${BIN_PATH}.exe" ]; then
28+
echo "${BIN_PATH}.exe"
29+
return 0
30+
fi
31+
if [ -f "$BIN_PATH" ]; then
32+
echo "$BIN_PATH"
33+
return 0
34+
fi
35+
# Also check default target dir (without explicit target), just in case
36+
if [ -f "target/release/nexus-network" ]; then
37+
echo "target/release/nexus-network"
38+
return 0
39+
fi
40+
if [ -f "target/release/nexus-network.exe" ]; then
41+
echo "target/release/nexus-network.exe"
42+
return 0
43+
fi
44+
# No prebuilt binary found
45+
echo ""
46+
}
47+
48+
run_cli() {
49+
BIN=$(resolve_prebuilt_binary)
50+
if [ -z "$BIN" ] || [ ! -x "$BIN" ]; then
51+
fail "Prebuilt binary not found. Please run the Build step first."
52+
exit 1
53+
fi
54+
RUST_LOG=warn "$BIN" start "$@"
55+
}
56+
2357
run_positive_test() {
24-
info "Starting positive integration test (cargo run --release)..."
58+
info "Starting positive integration test (prebuilt binary required)..."
2559
ulimit -c 0 || true
2660

2761
# Node IDs
@@ -46,43 +80,17 @@ run_positive_test() {
4680
trap "rm -f $TEMP_RAW_OUTPUT" EXIT
4781
info "Running CLI (attempt $ATTEMPT_COUNT) with node $node_id..."
4882

49-
RATE_LIMITED=false
50-
(
51-
set -o pipefail
52-
ulimit -c 0 || true
53-
RUST_LOG=warn cargo run --release -- start --headless --max-tasks 1 --node-id $node_id 2>&1 | tee "$TEMP_RAW_OUTPUT"
54-
) &
55-
CLI_PID=$!
56-
57-
TIMEOUT=150
58-
for i in $(seq 1 $TIMEOUT); do
59-
if ! kill -0 "$CLI_PID" 2>/dev/null; then
60-
set +e
61-
wait "$CLI_PID"; CLI_EXIT_CODE=$?
62-
set -e
63-
break
64-
fi
65-
if [ $((i % 5)) -eq 0 ] && [ -f "$TEMP_RAW_OUTPUT" ]; then
66-
if grep -q "Rate limit exceeded" "$TEMP_RAW_OUTPUT" 2>/dev/null || grep -q '"httpCode":429' "$TEMP_RAW_OUTPUT" 2>/dev/null; then
67-
RATE_LIMITED=true
68-
fi
69-
fi
70-
sleep 1
71-
done
72-
73-
if kill -0 "$CLI_PID" 2>/dev/null; then
74-
info "CLI process timed out after $TIMEOUT seconds, terminating..."
75-
kill -TERM "$CLI_PID" 2>/dev/null || true
76-
wait "$CLI_PID" 2>/dev/null || true
77-
CLI_EXIT_CODE=$?
78-
fi
83+
set +e
84+
run_cli --headless --max-tasks 1 --node-id $node_id 2>&1 | tee "$TEMP_RAW_OUTPUT"
85+
CLI_EXIT_CODE=$?
86+
set -e
7987

8088
if [ "$CLI_EXIT_CODE" -eq 0 ]; then
8189
pass "Positive test passed"
8290
return 0
8391
fi
8492

85-
if [ "$RATE_LIMITED" = true ]; then
93+
if grep -q "Rate limit exceeded" "$TEMP_RAW_OUTPUT" 2>/dev/null || grep -q '"httpCode":429' "$TEMP_RAW_OUTPUT" 2>/dev/null; then
8694
if [ $ATTEMPT_COUNT -lt 2 ]; then
8795
info "Rate limited (attempt $ATTEMPT_COUNT). Retrying with next node id..."
8896
rm -f "$TEMP_RAW_OUTPUT"
@@ -109,31 +117,10 @@ run_negative_test() {
109117
TMP_OUT=$(mktemp)
110118
trap "rm -f $TMP_OUT" EXIT
111119

112-
(
113-
set -o pipefail
114-
ulimit -c 0 || true
115-
cargo run --release -- start --headless --max-tasks 1 --node-id "$INVALID_NODE_ID" 2>&1 | tee "$TMP_OUT"
116-
) &
117-
PID=$!
118-
119-
EXIT_CODE=0
120-
for i in $(seq 1 150); do
121-
if ! kill -0 "$PID" 2>/dev/null; then
122-
set +e
123-
wait "$PID"; EXIT_CODE=$?
124-
set -e
125-
break
126-
fi
127-
sleep 1
128-
done
129-
130-
if kill -0 "$PID" 2>/dev/null; then
131-
info "Process still running after timeout; terminating..."
132-
kill -TERM "$PID" 2>/dev/null || true
133-
wait "$PID" 2>/dev/null || true
134-
pass "Negative test passed (CLI did not exit successfully)"
135-
return 0
136-
fi
120+
set +e
121+
run_cli --headless --max-tasks 1 --node-id "$INVALID_NODE_ID" 2>&1 | tee "$TMP_OUT"
122+
EXIT_CODE=$?
123+
set -e
137124

138125
if [ "$EXIT_CODE" -ne 0 ]; then
139126
pass "Negative test passed (non-zero exit: $EXIT_CODE)"
@@ -145,7 +132,7 @@ run_negative_test() {
145132
fi
146133
}
147134

148-
# Run tests
135+
# Run tests sequentially in foreground
149136
run_positive_test
150137
POSITIVE_CODE=$?
151138
if [ $POSITIVE_CODE -ne 0 ]; then

0 commit comments

Comments
 (0)