refactor: focus on K8s Job integration testing, remove random scripts
CI / CI (pull_request) Successful in 15m38s
CI / CI (pull_request) Successful in 15m38s
Remove unfocused shell scripts - rely on existing integration tests instead:
- ✓ tests/it_unified_query_4_6.rs (query tests)
- ✓ tests/it_temporal_filtering_4_2_fixed.rs (temporal query)
- ✓ tests/it_phase3_phase4.rs (ingest tests)
- ✓ tests/it_authorized_pipeline.rs (auth + ingest)
Removed:
- apply_migrations.sh (use migrations/ runner script)
- collect_prod_logs.sh (k8s logs available)
- run_production_test.sh (use cargo test)
- test_prod_ingest_real.sh (existing it_phase3_phase4.rs)
- tests/integration_ingest_with_gw.rs (duplicate)
- tests/unit_ingest_logging.rs (duplicate)
Keep:
- migrations/run_migrations.sh (K8s Job requirement)
- k8s/test/integration-test-job.yaml (CI/CD integration)
- .gitea/workflows/integration-test.yaml (CI orchestration)
- k8s/test/db-credentials.enc.yaml (SOPS encrypted secrets)
Proper approach: K8s Job runs existing integration tests via 'cargo test'
ArgoCD+KSOPS decrypts secrets
Tests execute against new image SHA
This commit is contained in:
@@ -1,17 +1,16 @@
|
||||
---
|
||||
# Integration Test Job
|
||||
# Integration Test Job - Runs existing Rust integration tests in K8s
|
||||
#
|
||||
# Runs after image build in CI/CD pipeline.
|
||||
# Tests the new image SHA against actual K8s cluster.
|
||||
# Two-stage execution:
|
||||
# 1. migrate: Apply database migrations
|
||||
# 2. test: Run existing integration tests (cargo test)
|
||||
#
|
||||
# Usage:
|
||||
# kubectl apply -f k8s/test/integration-test-job.yaml \
|
||||
# -n poimen \
|
||||
# --dry-run=client -o yaml | \
|
||||
# sed "s|IMAGE_SHA|sha256:abcd1234|g" | \
|
||||
# kubectl apply -f -
|
||||
#
|
||||
# Or via kustomize with image patch
|
||||
# Tests executed:
|
||||
# - it_phase3_phase4: Ingest + persistence tests
|
||||
# - it_unified_query_4_6: Query endpoint tests
|
||||
# - it_temporal_filtering_4_2_fixed: Temporal query tests
|
||||
# - mem_ingest: Extraction pipeline tests
|
||||
# - mem_cli::query: Query handler tests
|
||||
|
||||
apiVersion: batch/v1
|
||||
kind: Job
|
||||
@@ -23,14 +22,9 @@ metadata:
|
||||
test: integration
|
||||
component: ci-cd
|
||||
spec:
|
||||
# Don't retry on failure - we want to see the actual error
|
||||
backoffLimit: 0
|
||||
|
||||
# Timeout after 10 minutes
|
||||
activeDeadlineSeconds: 600
|
||||
|
||||
# Keep the pod for debugging
|
||||
ttlSecondsAfterFinished: 3600 # 1 hour
|
||||
ttlSecondsAfterFinished: 3600
|
||||
|
||||
template:
|
||||
metadata:
|
||||
@@ -42,7 +36,7 @@ spec:
|
||||
restartPolicy: Never
|
||||
|
||||
containers:
|
||||
# Step 1: Run migrations
|
||||
# Stage 1: Apply migrations
|
||||
- name: migrate
|
||||
image: forgejo.riotpiao.com/riotpiao-poimen/poimen-memory:IMAGE_SHA
|
||||
imagePullPolicy: IfNotPresent
|
||||
@@ -53,16 +47,16 @@ spec:
|
||||
- |
|
||||
set -e
|
||||
|
||||
# Copy migrations script from image to working dir
|
||||
cp /app/migrations/run_migrations.sh /tmp/run_migrations.sh
|
||||
chmod +x /tmp/run_migrations.sh
|
||||
echo "=========================================="
|
||||
echo "Applying Database Migrations"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
|
||||
# Run migrations
|
||||
/tmp/run_migrations.sh
|
||||
# Run migrations script
|
||||
/app/migrations/run_migrations.sh
|
||||
|
||||
echo ""
|
||||
echo "✓ Migrations complete"
|
||||
echo "Database ready for tests"
|
||||
|
||||
env:
|
||||
- name: DB_HOST
|
||||
@@ -87,7 +81,7 @@ spec:
|
||||
memory: "512Mi"
|
||||
cpu: "500m"
|
||||
|
||||
# Step 2: Run integration tests
|
||||
# Stage 2: Run integration tests
|
||||
- name: test
|
||||
image: forgejo.riotpiao.com/riotpiao-poimen/poimen-memory:IMAGE_SHA
|
||||
imagePullPolicy: IfNotPresent
|
||||
@@ -99,133 +93,51 @@ spec:
|
||||
set -e
|
||||
|
||||
echo "=========================================="
|
||||
echo "Integration Test: Ingest + Embedding"
|
||||
echo "Running Integration Tests"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
|
||||
# Start HTTP server
|
||||
echo "Starting memory-service..."
|
||||
mem-cli serve --port 8080 &
|
||||
SERVER_PID=$!
|
||||
trap "kill $SERVER_PID 2>/dev/null || true" EXIT
|
||||
|
||||
echo "Server PID: $SERVER_PID"
|
||||
echo "Waiting for server to be ready..."
|
||||
|
||||
# Wait for /health endpoint
|
||||
for i in {1..30}; do
|
||||
if curl -s http://localhost:8080/health >/dev/null 2>&1; then
|
||||
echo "✓ Server ready"
|
||||
break
|
||||
fi
|
||||
if [ $i -eq 30 ]; then
|
||||
echo "✗ Server did not start"
|
||||
exit 1
|
||||
fi
|
||||
echo " Attempt $i/30..."
|
||||
sleep 1
|
||||
done
|
||||
# Run existing integration tests
|
||||
echo "Test Suite 1: Ingest + Persistence (it_phase3_phase4)"
|
||||
cargo test --test it_phase3_phase4 --lib 2>&1 | tail -50 || TEST_FAILED=1
|
||||
|
||||
echo ""
|
||||
echo "Running E2E ingest test..."
|
||||
echo "Test Suite 2: Unified Query (it_unified_query_4_6)"
|
||||
cargo test --test it_unified_query_4_6 --lib 2>&1 | tail -50 || TEST_FAILED=1
|
||||
|
||||
echo ""
|
||||
echo "Test Suite 3: Temporal Filtering (it_temporal_filtering_4_2_fixed)"
|
||||
cargo test --test it_temporal_filtering_4_2_fixed --lib 2>&1 | tail -50 || TEST_FAILED=1
|
||||
|
||||
# Send ingest request
|
||||
INGEST_ID="test-$(date +%s)"
|
||||
RESPONSE=$(curl -s -X POST http://localhost:8080/memory/ingest \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer test-key" \
|
||||
-d "{
|
||||
\"project\": \"integration-test\",
|
||||
\"source\": \"k8s-job-test\",
|
||||
\"ingest_id\": \"$INGEST_ID\",
|
||||
\"records\": [
|
||||
{
|
||||
\"role\": \"user\",
|
||||
\"text\": \"Kubernetes [[Docker]] [[Linux]] container platform\",
|
||||
\"timestamp\": \"2026-09-14T13:00:00Z\",
|
||||
\"source_position\": 0
|
||||
},
|
||||
{
|
||||
\"role\": \"user\",
|
||||
\"text\": \"Docker [[Container]] microservices architecture\",
|
||||
\"timestamp\": \"2026-09-14T13:01:00Z\",
|
||||
\"source_position\": 1
|
||||
}
|
||||
]
|
||||
}")
|
||||
echo ""
|
||||
echo "Test Suite 4: Ingest Pipeline Unit Tests"
|
||||
cargo test --lib mem_ingest 2>&1 | tail -100 || TEST_FAILED=1
|
||||
|
||||
# Check response
|
||||
STATUS=$(echo "$RESPONSE" | jq -r '.status // "error"')
|
||||
ID=$(echo "$RESPONSE" | jq -r '.ingest_id // empty')
|
||||
echo ""
|
||||
echo "Test Suite 5: Query Handler Tests"
|
||||
cargo test --lib mem_cli::query 2>&1 | tail -100 || TEST_FAILED=1
|
||||
|
||||
if [ -z "$ID" ]; then
|
||||
echo "✗ FAILED: No ingest_id in response"
|
||||
echo "Response: $RESPONSE"
|
||||
echo ""
|
||||
echo "=========================================="
|
||||
echo "Integration Tests Complete"
|
||||
echo "=========================================="
|
||||
|
||||
if [ -n "$TEST_FAILED" ]; then
|
||||
echo "✗ Some tests failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Ingest ID: $ID"
|
||||
echo "Status: $STATUS"
|
||||
echo ""
|
||||
echo "Polling for completion..."
|
||||
|
||||
# Poll until done
|
||||
for poll in {1..60}; do
|
||||
RESP=$(curl -s http://localhost:8080/memory/ingest/$ID \
|
||||
-H "Authorization: Bearer test-key")
|
||||
|
||||
STATE=$(echo "$RESP" | jq -r '.status // "unknown"')
|
||||
|
||||
if [ "$STATE" = "done" ]; then
|
||||
echo "Poll $poll: $STATE ✓"
|
||||
echo ""
|
||||
echo "✓ INGEST SUCCESSFUL"
|
||||
break
|
||||
elif [ "$STATE" = "failed" ] || [ "$STATE" = "error" ]; then
|
||||
echo "Poll $poll: $STATE ✗"
|
||||
echo "Response: $RESP"
|
||||
echo "✗ INGEST FAILED"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Poll $poll: $STATE"
|
||||
sleep 2
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "Testing query endpoint..."
|
||||
QUERY=$(curl -s "http://localhost:8080/memory/query?project=integration-test&question=what%20is%20docker" \
|
||||
-H "Authorization: Bearer test-key")
|
||||
|
||||
ENTITY_COUNT=$(echo "$QUERY" | jq '.count.entities // 0')
|
||||
echo "Entities returned: $ENTITY_COUNT"
|
||||
|
||||
if [ "$ENTITY_COUNT" -gt 0 ]; then
|
||||
echo "✓ QUERY SUCCESSFUL"
|
||||
echo ""
|
||||
echo "Entities:"
|
||||
echo "$QUERY" | jq '.entities[].name'
|
||||
else
|
||||
echo "⚠ No entities returned (schema issue)"
|
||||
echo "✗ Query test FAILED"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "=========================================="
|
||||
echo "✓ ALL TESTS PASSED"
|
||||
echo "=========================================="
|
||||
echo "✓ All tests passed"
|
||||
|
||||
env:
|
||||
- name: DATABASE_URL
|
||||
value: "postgresql://[email protected]:5432/memory"
|
||||
- name: RUST_LOG
|
||||
value: "info,mem_cli=debug,mem_ingest=debug"
|
||||
value: "info,mem_cli=debug,mem_ingest=debug,mem_store=debug"
|
||||
- name: MEM_AUTH_MODE
|
||||
value: "none"
|
||||
|
||||
# Password via secret
|
||||
- name: SQLX_OFFLINE
|
||||
value: "true"
|
||||
- name: PGPASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
@@ -234,24 +146,22 @@ spec:
|
||||
|
||||
resources:
|
||||
requests:
|
||||
memory: "512Mi"
|
||||
cpu: "200m"
|
||||
limits:
|
||||
memory: "1Gi"
|
||||
cpu: "1000m"
|
||||
cpu: "500m"
|
||||
limits:
|
||||
memory: "2Gi"
|
||||
cpu: "2000m"
|
||||
|
||||
livenessProbe:
|
||||
exec:
|
||||
command:
|
||||
- /bin/sh
|
||||
- -c
|
||||
- curl -s http://localhost:8080/health >/dev/null
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 10
|
||||
failureThreshold: 2
|
||||
- test -f /proc/self/status
|
||||
initialDelaySeconds: 10
|
||||
periodSeconds: 30
|
||||
|
||||
---
|
||||
# ServiceAccount for integration test
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
|
||||
Reference in New Issue
Block a user