SentinAI Test Guide
Version: 1.1
Date: 2026-02-22
1. Project overview
SentinAI is an AI-based monitoring and auto-scaling dashboard for Optimism L2 nodes.
1.1 Current implementation status
| Phase | Features | status | file location |
|---|
| P1 | Predictive Scaling | β
μλ£ | src/lib/predictive-scaler.ts |
| P2 | Anomaly Detection | β
μλ£ | src/lib/anomaly-detector.ts |
| P3 | RCA Engine | β
μλ£ | src/lib/rca-engine.ts |
| P4 | Cost Optimizer | β
μλ£ | src/lib/cost-optimizer.ts |
| P5 | NLOps | β
μλ£ | src/lib/nlops-engine.ts, src/app/api/nlops/route.ts |
| P6 | Zero-Downtime | β
μλ£ | src/lib/zero-downtime-scaler.ts |
| P7 | Return to the State β
completed | src/lib/redis-store.ts | |
| P8 | Auto-Remediation | β
μλ£ | docs/done/proposal-8-auto-remediation.md |
1.2 Unit Test Coverage
Latest execution standard (2026-02-22): 59 files, 898 tests 100% passed, lines coverage 62.22%
Note: The detailed table below is a 2026-02-10 extended operations snapshot.
Test status (2026-02-10 snapshot: 23 files, 541 tests)
Phase 1-2: Core business logic (10 modules, 211 tests)
| module | test | Coverage | Description |
|---|
anomaly-detector.test.ts | 24 | 98.92% | Z-Score, CPU zero-drop, block plateau |
metrics-store.test.ts | 19 | 100% | Ring buffer, stats, trend detection |
scaling-decision.test.ts | 36 | 100% | Hybrid scoring, vCPU tiers |
predictive-scaler.test.ts | 20 | ~75% | Rate limiting, AI parsing, fallback |
rca-engine.test.ts | 25 | ~60% | Dependency graph, fault propagation |
cost-optimizer.test.ts | 23 | ~75% | Fargate pricing, recommendations |
anomaly-ai-analyzer.test.ts | 16 | ~75% | AI semantic analysis, fallback |
usage-tracker.test.ts | 19 | ~85% | Usage patterns, stress filtering |
alert-dispatcher.test.ts | 18 | ~80% | Slack formatting, cooldown |
daily-accumulator.test.ts | 36 | 97.6% | Snapshot capture, hourly summaries |
Phase 3: System module (2 modules, 80 tests)
| module | test | Coverage | Description |
|---|
scheduler.test.ts | 27 | ~90% | Cron scheduling, idempotency |
redis-store.test.ts | 53 | ~95% | InMemory/Redis state management |
Round 2: Data/Tracking Module (3 modules, 93 tests)
| module | test | Coverage | Description |
|---|
ai-response-parser.test.ts | 37 | ~85% | JSON extraction, error handling |
prediction-tracker.test.ts | 30 | ~90% | Prediction accuracy tracking |
anomaly-event-store.test.ts | 27 | ~88% | Event lifecycle management |
Round 3: Log/Reporting Module (3 modules, 50 tests) β¨ NEW
| module | test | Coverage | Description |
|---|
ai-analyzer.test.ts | 12 | ~80% | Log chunk AI analysis |
log-ingester.test.ts | 19 | ~85% | K8s log fetching |
daily-report-generator.test.ts | 20 | ~80% | Report generation + fallback |
Existing modules (5 modules, 56 tests)
| module | test | Coverage | Description |
|---|
ai-client.test.ts | 17 | ~90% | Multi-provider AI fallback |
k8s-scaler.test.ts | 11 | ~85% | StatefulSet patching |
k8s-config.test.ts | 7 | ~80% | kubectl configuration |
nlops-engine.test.ts | 31 | ~90% | Natural language intent classification |
zero-downtime-scaler.test.ts | 21 | ~95% | Pod swap orchestration |
Overall testing status
| indicators | 2026-02-09 | 2026-02-10 | growth rate |
|---|
| ν
μ€νΈ νμΌ | 10 | 23 | +130% |
| Number of tests | 211 | 541 | +156% |
| 컀λ²λ¦¬μ§ | 23% | ~51% (Total), ~70% (Core) | +50% |
| Running Time | 0.4s | 1.0s | - |
2. Preferences
2.1 Required environment variables
L2_RPC_URL=https://mainnet.optimism.io
L1_RPC_URLS=https://ethereum-sepolia-rpc.publicnode.com,https://sepolia.drpc.org
AI_GATEWAY_URL=https://api.ai.tokamak.network
ANTHROPIC_API_KEY=sk-xxx
AWS_CLUSTER_NAME=op-celestia-dev
K8S_NAMESPACE=optimism
2.2 Install dependencies
cd /home/theo/SentinAI
npm install
3. Local testing
3.1 Running the development server
npm run dev
3.2 Unit testing
npm run test:run
npm run test:coverage
npx vitest run src/lib/__tests__/ai-client.test.ts
npx vitest run src/lib/__tests__/k8s-scaler.test.ts
npx vitest run src/lib/__tests__/k8s-config.test.ts
npx vitest run src/lib/__tests__/nlops-engine.test.ts
npx vitest run src/lib/__tests__/zero-downtime-scaler.test.ts
npx vitest run src/lib/__tests__/anomaly-detector.test.ts
npx vitest run src/lib/__tests__/metrics-store.test.ts
npx vitest run src/lib/__tests__/scaling-decision.test.ts
npx vitest run src/lib/__tests__/predictive-scaler.test.ts
npx vitest run src/lib/__tests__/rca-engine.test.ts
npx vitest run src/lib/__tests__/cost-optimizer.test.ts
npx vitest run src/lib/__tests__/anomaly-ai-analyzer.test.ts
npx vitest run src/lib/__tests__/usage-tracker.test.ts
npx vitest run src/lib/__tests__/alert-dispatcher.test.ts
npx vitest run src/lib/__tests__/daily-accumulator.test.ts
npx vitest run src/lib/__tests__/scheduler.test.ts
npx vitest run src/lib/__tests__/redis-store.test.ts
npx vitest run src/lib/__tests__/ai-response-parser.test.ts
npx vitest run src/lib/__tests__/prediction-tracker.test.ts
npx vitest run src/lib/__tests__/anomaly-event-store.test.ts
npx vitest run src/lib/__tests__/ai-analyzer.test.ts
npx vitest run src/lib/__tests__/log-ingester.test.ts
npx vitest run src/lib/__tests__/daily-report-generator.test.ts
npm test
npx vitest run -t "should detect spike"
3.3 E2E testing
npx playwright install
npm run test:e2e
npx playwright test --ui
3.4 Tier 3 Gate Test (Coverage/E2E/Bundle/CWV)
Run integration (recommended)
npm run prod:gate:tier3
Run script: scripts/prod-gate-tier3.sh
Individual execution
npm run test:coverage
node scripts/check-coverage.mjs
npm run build
node scripts/check-bundle-size.mjs
npx playwright install --with-deps chromium
npm run test:e2e
npx @lhci/cli@0.15.x autorun --config=.lighthouserc.cwv.json
Threshold adjustment (for local experiments)
TIER3_MIN_COVERAGE_PCT=55 node scripts/check-coverage.mjs
TIER3_FIRST_LOAD_JS_MAX_BYTES=230400 node scripts/check-bundle-size.mjs
Check order in case of failure
- Check if
npm run build succeeds first.
- Check whether Playwright browser is installed (
npx playwright install --with-deps chromium)
- Check whether
.next/build-manifest.json is created (Bundle gate prerequisite)
- Check whether
coverage/coverage-summary.json is created (Coverage gate prerequisite)
- Check if the CWV measurement URL is opened (
http://localhost:3002/v2)
CI status
- Browser-based Tier 3 CI (
Playwright + Lighthouse) workflow was removed on 2026-02-24.
- Use local/manual execution instead:
npm run prod:gate:tier3
- or run each gate command individually (Coverage/Bundle/E2E/CWV)
4. API testing
4.1 Core API endpoints
| Endpoint | method | Description |
|---|
/api/health | GET | system status |
/api/metrics | GET | L2 metrics query |
/api/metrics?stress=true | GET | stress mode metrics |
/api/metrics/seed?scenario=rising | POST | Seed test data |
/api/anomalies | GET | Anomaly detection results |
/api/rca | POST | Root Cause Analysis |
/api/cost-report?days=7 | GET | Cost Analysis Report |
/api/scaler | GET | scaler status |
/api/scaler | POST | Running Scaling |
4.2 curl test example
curl http://localhost:3002/api/health | jq
curl http://localhost:3002/api/metrics | jq
curl "http://localhost:3002/api/metrics?stress=true" | jq
curl http://localhost:3002/api/anomalies | jq
curl -X POST http://localhost:3002/api/rca \
-H "Content-Type: application/json" \
-d '{"autoTriggered": false}' | jq
curl "http://localhost:3002/api/cost-report?days=7" | jq
curl -X POST "http://localhost:3002/api/metrics/seed?scenario=rising" | jq
5. Test dashboard functionality
5.1 Main dashboard (page.tsx)
| Features | Test Method | Expected results |
|---|
| network status | Check the top bar | L1/L2 block height, TxPool, Sync status |
| stress mode | Click the βSimulate Loadβ button | CPU surges, costs increase |
| Predictive Scaling | Check out Resource Center | Show current β predicted vCPUs |
| Anomaly Detection | Anomaly Banner | Red banner when detecting CPU spike, etc. |
| RCA analysis | βCHECK HEALTHβ button | Display AI analysis results |
| cost analysis | βCOST ANALYSISβ button | Usage pattern heatmap, recommendation display |
5.2 Test scenario
Scenario 1: Verify healthy state
- Access dashboard
- Check the L2 Block increase in the network status bar
- Check Health Score 90+
- Click βCHECK HEALTHβ β βSystem Healthyβ message
Scenario 2: Stress Mode
- Click the βSimulate Loadβ button
- Check CPU Usage surge (50% β 80%+)
- Check the Anomaly Banner display
- Check vCPU scale-up (1 β 2 or 4)
Scenario 3: RCA Analysis
- Activate stress mode
- Click βCHECK HEALTHβ or βAnalyze Nowβ on the Anomaly Banner
- Check AI analysis results:
- Root Cause (component, description, confidence)
- Causal Chain (event sequence)
- Remediation (immediate action, preventive action)
Scenario 4: Cost Analysis
- Click the βCOST ANALYSISβ button
- Check usage pattern heatmap (7 days x 24 hours)
- Check AI recommendations (downscale, schedule, etc.)
- Check expected savings
6. Code structure
6.1 Core libraries
src/lib/
βββ ai-client.ts # Claude API integration
βββ anomaly-detector.ts # Anomaly detection (Z-Score, Rules)
βββ anomaly-event-store.ts # anomaly event store
βββ cost-optimizer.ts # AI cost optimization
βββ k8s-scaler.ts # K8s scaling
βββ metrics-store.ts # Store metrics time series
βββ prediction-tracker.ts # prediction tracking
βββ predictive-scaler.ts # AI predictive scaling
βββ rca-engine.ts # Root cause analysis
βββ usage-tracker.ts # Track usage patterns
βββ zero-downtime-scaler.ts# Non-stop scaling
6.2 Type definition
src/types/
βββ anomaly.ts # AnomalyResult, AnomalyMetric
βββ cost.ts # CostReport, CostRecommendation, UsagePattern
βββ daily-report.ts # DailyReport
βββ prediction.ts # MetricDataPoint, PredictionResult
βββ rca.ts # RCAResult, RCAEvent, RCAComponent
βββ redis.ts # Redis state type
βββ scaling.ts # ScalingDecision, AISeverity
βββ zero-downtime.ts# ZeroDowntimeConfig
6.3 API Route
src/app/api/
βββ anomalies/
β βββ config/route.ts # Anomaly detection settings
β βββ route.ts # Anomaly detection query
βββ cost-report/route.ts # Cost analysis report
βββ health/route.ts # Health check
βββ metrics/
β βββ route.ts # Metric query
β βββ seed/route.ts # Seed test data
βββ rca/route.ts # Root cause analysis
βββ reports/daily/route.ts# Daily report
βββ scaler/route.ts # Scaler status/execution
7. AI testing
7.1 Check AI Gateway integration
curl -X POST http://localhost:3002/api/rca \
-H "Content-Type: application/json" \
-d '{"autoTriggered": false}'
{
"success": true,
"result": {
"id": "rca-xxx",
"rootCause": {
"component": "op-geth",
"description": "CPU usage spike...",
"confidence": 0.85
},
...
}
}
7.2 Check fallback in case of AI failure
Check whether the fallback logic operates even when AI Gateway connection fails:
export ANTHROPIC_API_KEY=invalid
curl -X POST http://localhost:3002/api/rca -H "Content-Type: application/json" -d '{}'
8. Build and Deploy
8.1 Production build
npm run build
npm run start
8.2 Cloud Run Deployment
./deploy-cloudrun.sh
gcloud run deploy sentinai \
--source . \
--region asia-northeast3 \
--allow-unauthenticated
9. Troubleshooting
9.1 General issues
| Symptoms | Cause | Solved |
|---|
| API not responding | Development server not running | Run npm run dev |
| AI analysis failure | API key not set | Check .env.local |
| Show Metric 0 | RPC connection failure | Check L2_RPC_URL |
| Build failed | type error | npx tsc --noEmit |
9.2 Check log
npm run dev 2>&1 | tee dev.log
grep "\[RCA Engine\]" dev.log
grep "\[Cost Optimizer\]" dev.log
grep "\[AI Client\]" dev.log
10. Next steps
10.1 Awaiting implementation
- P5 NLOps: System control with natural language commands
- P6 Zero-Downtime: Non-disruptive scaling strategy
- P7 Redis State: distributed state storage
- P8 Auto-Remediation: Auto-remediation system
- Telegram Bot: Mobile monitoring
- Universal Platform: Multi-blockchain support
10.2 Document location
docs/
βββ done/ # Proposal that has been implemented
β βββ proposal-1-predictive-scaling.md
β βββ proposal-2-anomaly-detection.md
β βββ proposal-3-rca-engine.md
β βββ proposal-4-cost-optimizer.md
βββ todo/ # Waiting for implementation
β βββ proposal-5-nlops.md
β βββ proposal-6-zero-downtime-scaling.md
β βββ proposal-7-redis-state-store.md
β βββ proposal-8-auto-remediation.md
β βββ telegram-bot-integration.md
β βββ universal-blockchain-platform.md
β βββ testing-guide.md # This document
βββ spec/ # technical specification
βββ verification/ # verification report