Symptoms: Tests fail locally but pass in CI, or vice versaSolutions:
Copy
# 1. Clean test environmentcargo cleancargo test# 2. Run specific test with outputcargo test test_name -- --nocapture# 3. Check test database# Tests should use isolated databaseDATABASE_URL=postgresql://test:test@localhost:5433/test_db cargo test# 4. Verify test data cleanup# Ensure tests clean up after themselves
Integration Test Issues:
Copy
# Start test environmentcd docker/testdocker-compose up -d# Run integration testscargo test --test '*' -- --test-threads=1# Debug integration testRUST_LOG=debug cargo test integration_test -- --nocapture
📊 Performance Test Issues
Symptoms: Performance benchmarks fail or are inconsistentSolutions:
Copy
# 1. Ensure stable environment# Close other applications# Use dedicated test hardware if possible# 2. Run benchmarks with proper flagscargo bench --bench authentication_bench# 3. Check system resourcestopiostat -x 1# 4. Compare with baselinegit checkout maincargo bench > baseline.txtgit checkout feature-branchcargo bench > current.txt
# Check rate limit headerscurl -I http://localhost:40401/api/v1/auth# Should include:# X-RateLimit-Limit: 100# X-RateLimit-Remaining: 99# X-RateLimit-Reset: 1640995200# If rate limited (429 error):# Wait for reset time or adjust limits in config
🔑 Authentication Issues
Symptoms: Authentication fails with valid credentialsSolutions:
Copy
# 1. Verify API key formatecho "API Key: sk_test_..." # Should start with sk_test_ or sk_live_# 2. Check authentication logsdocker-compose logs api-gateway | grep auth# 3. Test with different credentialscurl -X POST http://localhost:40401/api/v1/auth \ -H "X-API-Key: sk_test_valid_key" \ -H "Content-Type: application/json" \ -d '{}'# 4. Verify database has vendorsdocker-compose exec postgres psql -U boop -d boop \ -c "SELECT vendor_id, api_key_hash FROM vendors;"
API Key Management:
Copy
// Generate development API keyuse sha2::{Sha256, Digest};fn generate_api_key_hash(api_key: &str) -> String { let mut hasher = Sha256::new(); hasher.update(api_key.as_bytes()); format!("{:x}", hasher.finalize())}// For development, insert test vendor:// INSERT INTO vendors (vendor_id, api_key_hash)// VALUES ('test_vendor', 'hash_of_sk_test_key');
# Error: "could not find `Cargo.toml`"# Solution: Make sure you're in the right directorycd /path/to/boop-networkls Cargo.toml # Should exist# Error: "failed to select a version for `dependency`"# Solution: Update dependenciescargo update# Error: "linking with `cc` failed"# Solution: Install build dependenciesapt-get update && apt-get install -y build-essential pkg-config libssl-dev# Error: "could not compile `sqlx`"# Solution: Database URL needed for compile-time checksexport DATABASE_URL="postgresql://boop:password@localhost:5432/boop"
🔧 Runtime Errors
Copy
# Error: "Connection refused"# Check if service is runningdocker-compose psdocker-compose logs service-name# Error: "Permission denied"# Fix file permissionschmod +x scripts/*.shsudo chown -R $USER:$USER .# Error: "Port already in use"# Find and kill the processlsof -i :40401kill -9 $(lsof -t -i:40401)# Error: "No space left on device"# Clean Docker resourcesdocker system prune -adocker volume prune
-- Error: "role 'boop' does not exist"CREATE USER boop WITH PASSWORD 'password';CREATE DATABASE boop OWNER boop;-- Error: "relation does not exist"-- Run migrationssqlx migrate run --database-url $DATABASE_URL-- Error: "could not connect to server"-- Check PostgreSQL is running and accepting connectionspg_isready -h localhost -p 5432-- Error: "too many connections"-- Check current connectionsSELECT count(*) FROM pg_stat_activity;-- Adjust max_connections in postgresql.confALTER SYSTEM SET max_connections = 200;SELECT pg_reload_conf();