From 46304c03cabe6340704b86ee96685ce6d25220c7 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 20 Oct 2025 13:45:10 +0100 Subject: [PATCH] [Test] Add detailed error output for integration test failures When rspamc commands fail, now show: - Exit code - Full stderr output saved to error log files - Partial results if available - Sample scan result for debugging This makes it much easier to diagnose test failures instead of just seeing 'exit code 1' with no context. --- test/integration/scripts/integration-test.sh | 46 ++++++++++++++++---- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/test/integration/scripts/integration-test.sh b/test/integration/scripts/integration-test.sh index 9fd90687f6..bd42d5097b 100755 --- a/test/integration/scripts/integration-test.sh +++ b/test/integration/scripts/integration-test.sh @@ -167,11 +167,21 @@ echo "" echo "Scanning $TOTAL_EMAILS emails (parallelism: $PARALLEL)..." # Scan the same files we used for training (from shuffled list) -# Use xargs with -a to read from file and avoid argument list too long -xargs -a "$DATA_DIR/shuffled_files.txt" rspamc -h "$RSPAMD_HOST:$CONTROLLER_PORT" \ - -P "$PASSWORD" -n "$PARALLEL" -j > "$DATA_DIR/results.json" 2>&1 - -echo "✓ Scanning complete" +# Use xargs with -a to read from file and avoid argument list too +if xargs -a "$DATA_DIR/shuffled_files.txt" rspamc -h "$RSPAMD_HOST:$CONTROLLER_PORT" \ + -P "$PASSWORD" -n "$PARALLEL" -j > "$DATA_DIR/results.json" 2> "$DATA_DIR/scan_errors.log"; then + echo "✓ Scanning complete" +else + EXIT_CODE=$? + echo "✗ Scanning FAILED with exit code $EXIT_CODE" + echo "" + echo "=== Scan Error Output ===" + cat "$DATA_DIR/scan_errors.log" + echo "" + echo "=== Partial Results (if any) ===" + head -20 "$DATA_DIR/results.json" 2>/dev/null || echo "(no output)" + exit 1 +fi echo "" # Analyze results @@ -217,6 +227,13 @@ echo "Bayes SPAM: $BAYES_SPAM_COUNT ($BAYES_SPAM_RATE%)" echo "Bayes HAM: $BAYES_HAM_COUNT ($BAYES_HAM_RATE%)" echo "" +# Show sample result for debugging +if command -v jq &> /dev/null && [ -f "$DATA_DIR/results.json" ]; then + echo "Sample scan result (first entry):" + jq '.[0] | {symbols: .symbols | keys, score: .score}' "$DATA_DIR/results.json" 2>/dev/null || echo " (cannot parse)" + echo "" +fi + # Validation (fuzzy should detect ~10% since we trained on 10%) echo "Validation:" FUZZY_RATE_INT=$(echo "$FUZZY_RATE" | cut -d. -f1) @@ -244,10 +261,21 @@ if [ "$TEST_PROXY" = "true" ]; then echo "Testing via proxy worker ($PROXY_PORT)..." # Use corpus directory for proxy test too - ASAN_OPTIONS=detect_leaks=0 rspamc -h "$RSPAMD_HOST:$PROXY_PORT" -n "$PARALLEL" -j \ - "$CORPUS_DIR" > "$DATA_DIR/proxy_results.json" 2>&1 - echo "✓ Proxy test complete" - echo "Results saved to $DATA_DIR/proxy_results.json" + if ASAN_OPTIONS=detect_leaks=0 rspamc -h "$RSPAMD_HOST:$PROXY_PORT" -n "$PARALLEL" -j \ + "$CORPUS_DIR" > "$DATA_DIR/proxy_results.json" 2> "$DATA_DIR/proxy_errors.log"; then + echo "✓ Proxy test complete" + echo "Results saved to $DATA_DIR/proxy_results.json" + else + EXIT_CODE=$? + echo "✗ Proxy test FAILED with exit code $EXIT_CODE" + echo "" + echo "=== Proxy Error Output ===" + cat "$DATA_DIR/proxy_errors.log" + echo "" + echo "=== Proxy Results (if any) ===" + cat "$DATA_DIR/proxy_results.json" 2>/dev/null || echo "(no output)" + exit 1 + fi fi echo "" -- 2.47.3