SPECTRE Fleet - Testing Quick Reference
π Run All Tests (Batch Execution)β
# Automated test suite (recommended)
./scripts/run-tests.sh
# Expected duration: ~5 minutes
# Tests: 10 integration + unit tests + clippy + format check
π Test Checklist (Execute in Order)β
β Phase 1: Infrastructure Setup (1 min)β
# Start services
docker-compose up -d
# Verify NATS
curl http://localhost:8222/healthz
# Verify TimescaleDB
docker-compose exec timescaledb pg_isready -U spectre
# Verify Neo4j
docker-compose exec neo4j cypher-shell -u neo4j -p spectre_dev_password "RETURN 1"
β Phase 2: Build Check (2 min)β
# Enter Nix shell
nix develop
# Build workspace
cargo build
# Check individual crates
cargo check -p spectre-core
cargo check -p spectre-events
β Phase 3: Unit Tests (1 min)β
# Test spectre-core
cargo test -p spectre-core --lib
# Test spectre-events
cargo test -p spectre-events --lib
β Phase 4: Integration Tests (2 min)β
# All integration tests
cargo test --test test_event_bus -- --test-threads=1 --nocapture
# Individual test
cargo test --test test_event_bus test_03_subscribe_and_receive -- --nocapture
β Phase 5: Code Quality (1 min)β
# Clippy (linting)
cargo clippy --all-targets --all-features -- -D warnings
# Format check
cargo fmt -- --check
π Expected Resultsβ
Test Countsβ
- Unit tests: ~20 tests
- Integration tests: 10 tests
- Total: ~30 tests
Success Criteriaβ
test result: ok. 30 passed; 0 failed; 0 ignored
Performance Benchmarksβ
- Event publish latency: < 5ms
- Event throughput: > 50 events/sec (test_10)
- Queue load balancing: 10 events distributed across 2 workers
π Troubleshootingβ
Issue: "Connection refused (os error 111)"β
Cause: NATS not running Fix:
docker-compose up -d nats
sleep 5 # Wait for startup
cargo test --test test_event_bus
Issue: "Test hangs indefinitely"β
Cause: Deadlock or blocking operation Fix:
# Run with timeout
cargo test -- --test-threads=1 --timeout=30
Issue: "Address already in use"β
Cause: Port 4222 occupied Fix:
# Find process
sudo lsof -i :4222
# Stop docker-compose
docker-compose down
docker-compose up -d
Issue: Tests fail on CI but pass locallyβ
Cause: Race condition or timing issue Fix:
# Run multiple times
for i in {1..5}; do cargo test --test test_event_bus; done
# Use single thread
cargo test -- --test-threads=1
π Test Output Exampleβ
βββββββββββββββββββββββββββββββββββββββ
SPECTRE Fleet Test Suite
βββββββββββββββββββββββββββββββββββββββ
[INFO] Starting infrastructure...
[SUCCESS] NATS is ready
[SUCCESS] TimescaleDB is ready
[SUCCESS] Neo4j is ready
βββββββββββββββββββββββββββββββββββββββ
PHASE 1: Unit Tests
βββββββββββββββββββββββββββββββββββββββ
Running unit tests for spectre-core...
test tests::test_service_id ... ok
test tests::test_correlation_id ... ok
test tests::test_trace_id ... ok
β
spectre-core unit tests passed
Running unit tests for spectre-events...
test tests::test_event_creation ... ok
test tests::test_event_serialization ... ok
β
spectre-events unit tests passed
βββββββββββββββββββββββββββββββββββββββ
PHASE 2: Integration Tests
βββββββββββββββββββββββββββββββββββββββ
test test_01_connect_to_nats ... ok
test test_02_publish_event ... ok
test test_03_subscribe_and_receive ... ok
test test_04_request_reply ... ok
test test_05_queue_group_load_balancing ... ok
β
Integration tests passed
βββββββββββββββββββββββββββββββββββββββ
TEST SUMMARY
βββββββββββββββββββββββββββββββββββββββ
Total Tests: 5
Passed: 5
Failed: 0
Skipped: 0
π All tests passed!
π§ Advanced Testingβ
Run with loggingβ
RUST_LOG=debug cargo test -- --nocapture
Run specific test patternβ
cargo test subscribe -- --nocapture
Run ignored tests (manual setup required)β
cargo test -- --ignored
Generate coverage reportβ
# Install tarpaulin
cargo install cargo-tarpaulin
# Generate report
cargo tarpaulin --out Html --output-dir coverage
Run benchmarksβ
RUN_BENCHMARKS=1 ./scripts/run-tests.sh
π Test Log Locationsβ
/tmp/spectre-test-spectre-core.log
/tmp/spectre-test-spectre-events.log
/tmp/spectre-test-integration.log
/tmp/spectre-clippy.log
/tmp/spectre-fmt.log
π― Next Steps After Tests Passβ
- β Tests pass β Phase 0 complete
- β Start Phase 1: Security Infrastructure
- Implement
spectre-proxy - Implement
spectre-secrets
- Implement
- β Continue Phase 2: Observability
- Implement
spectre-observability - Build Tauri dashboard
- Implement
π Supportβ
If tests fail consistently:
- Check logs in
/tmp/spectre-test-*.log - Verify infrastructure is running:
docker-compose ps - Review test output for specific failure
- Consult
tests/README.mdfor detailed info
Quick Command Reference:
# One-line test execution
./scripts/run-tests.sh
# Keep infrastructure running
KEEP_INFRA=1 ./scripts/run-tests.sh
# Cleanup
docker-compose down && cargo clean
Last Updated: 2026-01-08 Test Suite Version: 0.1.0 (Phase 0)