feat: production ingest test suite with detailed logging

Add comprehensive E2E test scripts and logging for production testing:

- test_prod_ingest_real.sh: Full ingest test against K8s cluster with api-gw
- apply_migrations.sh: Manual database schema migration (backup method)
- collect_prod_logs.sh: Pod log collection before/after tests
- run_production_test.sh: Orchestrates full test + log collection
- tests/integration_ingest_with_gw.rs: Integration test with embeddings
- tests/unit_ingest_logging.rs: Unit tests for extraction pipeline

Enhanced logging in ingest_worker.rs:
- Per-record event tracking (extraction, save)
- Entity and edge operation logging
- Error accumulation and reporting
- Structured logging for observability

Production testing identified root cause:
- Ingest + embedding pipeline working correctly
- Entity extraction functional
- Database schema missing (migration not applied)
- Logs clearly show: relation "memory_entity" does not exist

Next: Trigger DB Migration workflow in Forgejo Actions to apply
crates/mem-store/migrations/*.sql files.
This commit is contained in:
2026-09-14 22:33:16 +09:00
parent 5fd3ac826b
commit 6915dc2462
7 changed files with 1151 additions and 22 deletions
+114
View File
@@ -0,0 +1,114 @@
#!/bin/bash
# Collect logs from production pods for debugging ingest errors
#
# Usage:
# ./collect_prod_logs.sh before # Capture baseline
# ./test_production_ingest.sh # Run test
# ./collect_prod_logs.sh after # Capture post-test logs
# ./collect_prod_logs.sh analyze # Show diff + errors
set -e
NAMESPACE="poimen"
TIMESTAMP=$(date +%Y%m%d-%H%M%S)
LOG_DIR="prod_logs_${TIMESTAMP}"
case "${1:-all}" in
before)
echo "Collecting pre-test baseline logs..."
mkdir -p "$LOG_DIR/before"
kubectl -n "$NAMESPACE" get pods > "$LOG_DIR/before/pods.txt"
for pod in $(kubectl -n "$NAMESPACE" get pods -l app=memory-service -o jsonpath='{.items[*].metadata.name}'); do
echo " Collecting logs from $pod..."
kubectl -n "$NAMESPACE" logs "$pod" --all-containers=true > "$LOG_DIR/before/${pod}.log" 2>&1 || true
done
echo "✓ Baseline logs saved to $LOG_DIR/before/"
;;
after)
echo "Collecting post-test logs..."
mkdir -p "$LOG_DIR/after"
kubectl -n "$NAMESPACE" get pods > "$LOG_DIR/after/pods.txt"
for pod in $(kubectl -n "$NAMESPACE" get pods -l app=memory-service -o jsonpath='{.items[*].metadata.name}'); do
echo " Collecting logs from $pod..."
kubectl -n "$NAMESPACE" logs "$pod" --all-containers=true > "$LOG_DIR/after/${pod}.log" 2>&1 || true
done
echo "✓ Post-test logs saved to $LOG_DIR/after/"
;;
analyze)
if [ ! -d "$LOG_DIR/before" ] || [ ! -d "$LOG_DIR/after" ]; then
echo "✗ Before/after log directories not found"
echo "Run: ./collect_prod_logs.sh before && ./test_production_ingest.sh && ./collect_prod_logs.sh after"
exit 1
fi
echo "=========================================="
echo "Log Analysis"
echo "=========================================="
echo ""
# Find errors
echo "ERRORS found in logs:"
echo "-----"
grep -h "error\|Error\|ERROR" "$LOG_DIR/after"/*.log 2>/dev/null | tail -20 || echo " (none)"
echo ""
# Find warnings
echo "WARNINGS found in logs:"
echo "-----"
grep -h "warn\|Warn\|WARN" "$LOG_DIR/after"/*.log 2>/dev/null | tail -10 || echo " (none)"
echo ""
# Find ingest events
echo "INGEST events:"
echo "-----"
grep -h "ingest\|Ingest" "$LOG_DIR/after"/*.log 2>/dev/null | tail -20 || echo " (none)"
echo ""
# Find embedding calls
echo "EMBEDDING events:"
echo "-----"
grep -h "embed\|Embed" "$LOG_DIR/after"/*.log 2>/dev/null | tail -20 || echo " (none)"
echo ""
# Show new logs (after only)
echo "NEW LOG ENTRIES (post-test only):"
echo "-----"
for before_file in "$LOG_DIR/before"/*.log; do
after_file="${before_file//\/before\//\/after\/}"
if [ -f "$after_file" ]; then
pod_name=$(basename "$before_file" .log)
before_lines=$(wc -l < "$before_file" 2>/dev/null || echo 0)
after_lines=$(wc -l < "$after_file" 2>/dev/null || echo 0)
new_lines=$((after_lines - before_lines))
if [ $new_lines -gt 0 ]; then
echo ""
echo "Pod: $pod_name (new: $new_lines lines)"
tail -$new_lines "$after_file" | grep -E "error|warn|ingest|embed" || true
fi
fi
done
echo ""
echo "Full logs in: $LOG_DIR/"
;;
*)
echo "Usage: $0 {before|after|analyze}"
echo ""
echo "Steps:"
echo " 1. ./collect_prod_logs.sh before"
echo " 2. ./test_production_ingest.sh"
echo " 3. ./collect_prod_logs.sh after"
echo " 4. ./collect_prod_logs.sh analyze"
exit 1
;;
esac