This document describes the comprehensive testing strategy for the MCP Context Engine project, including integration tests, performance tests, and security validation.
The testing suite validates:
- End-to-end user journeys from signup to context queries
- Multi-platform data ingestion and processing
- Performance and scalability under load
- Security and compliance requirements
- Tenant isolation and data security
test/
├── e2e_integration_test.go # End-to-end integration tests
├── performance_test.go # Performance and load tests
├── security_test.go # Security and compliance tests
└── system_test.go # System-level tests
tests/web/
├── auth.integration.test.ts # Authentication flow tests
├── dashboard.integration.test.ts # Dashboard functionality tests
├── integration-wizard.integration.test.ts # Integration wizard tests
└── e2e-user-journey.integration.test.ts # Complete user journey tests
Run all tests:
./scripts/run-integration-tests.shGo Backend Tests:
# Unit tests only
go test ./internal/... -v -short
# End-to-end integration tests
go test ./test/e2e_integration_test.go -v
# Performance tests
go test ./test/performance_test.go -v
# Security tests
go test ./test/security_test.go -vTypeScript/Node.js Tests:
# All tests
npm test
# Specific test files
npm test tests/web/auth.integration.test.ts
npm test tests/web/e2e-user-journey.integration.test.ts
# Watch mode
npm run test:watchFile: test/e2e_integration_test.go
Tests the complete user journey:
- User signup and email verification
- User login and JWT token generation
- Project workspace creation
- Platform integration connection (GitHub, Slack, Discord)
- Data ingestion and processing
- Context queries via MCP tools
- File context retrieval
- Decision history queries
Key Tests:
TestEndToEndUserJourney- Complete user flowTestMultiPlatformIngestion- Multi-platform data ingestionTestTenantIsolation- Tenant data isolationTestSecurityBoundaries- Authentication and authorization
Run:
go test ./test/e2e_integration_test.go -v -timeout 5mFile: test/performance_test.go
Validates performance requirements:
- Response times under 1 second for MCP tool queries
- Caching improves performance by 30%+
- System handles 50+ concurrent users
- Sustained load of 20 req/s for 30 seconds
- Graceful degradation under stress
Key Tests:
TestResponseTimeRequirements- Response time validationTestLoadHandling- Concurrent and sustained loadTestGracefulDegradation- Stress testingTestHorizontalScaling- Multi-instance deployment
Run:
go test ./test/performance_test.go -v -timeout 10mPerformance Metrics:
- P50 response time: < 500ms
- P95 response time: < 1s
- P99 response time: < 2s
- Success rate: > 99%
- Throughput: > 10 req/s
File: test/security_test.go
Validates security controls:
- Password strength requirements
- JWT token security and expiration
- OAuth CSRF protection
- Session management
- Data encryption
- Role-based access control
- Tenant isolation
- Input validation (SQL injection, XSS, path traversal)
- Error handling
- GDPR compliance
Key Tests:
TestAuthenticationFlows- Auth mechanismsTestDataEncryption- Sensitive data protectionTestAuthorizationControls- RBAC validationTestTenantIsolationSecurity- Tenant data isolationTestInputValidation- Injection preventionTestErrorHandling- Secure error handlingTestComplianceRequirements- GDPR compliance
Run:
go test ./test/security_test.go -v -timeout 5mFiles: tests/web/*.integration.test.ts
Tests web platform functionality:
- Authentication flows (signup, login, OAuth, password reset)
- Dashboard operations (project CRUD, metrics, activity)
- Integration wizard (platform connection, source selection)
- Complete user journeys
Run:
npm test tests/web/-
Test Database:
createdb contextkeeper_test psql contextkeeper_test < schema.sql -
Environment Variables:
cp .env.example .env.test # Edit .env.test with test configuration -
Dependencies:
# Go dependencies go mod download # Node.js dependencies npm install
Tests use mock data and in-memory databases where possible. For integration tests requiring real databases:
# Setup test database
make setup-test-db
# Seed test data
make seed-test-data
# Clean test data
make clean-test-dataTests run automatically on:
- Pull requests
- Pushes to main branch
- Nightly builds
Workflow: .github/workflows/test.yml
name: Tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run tests
run: ./scripts/run-integration-tests.shTarget coverage: 80%+
Generate coverage reports:
# Go coverage
go test ./... -coverprofile=coverage.out
go tool cover -html=coverage.out
# TypeScript coverage
npm test -- --coverage# Go tests with verbose output
go test -v ./test/...
# TypeScript tests with verbose output
npm test -- --verbose# Go - run specific test
go test -v -run TestEndToEndUserJourney ./test/
# TypeScript - run specific test
npm test -- -t "should complete user signup"Increase timeout for slow tests:
go test -timeout 30m ./test/performance_test.go- Isolation: Each test should be independent and not rely on other tests
- Cleanup: Always clean up test data after tests complete
- Mocking: Use mocks for external services (GitHub API, Slack API, etc.)
- Assertions: Use clear, descriptive assertion messages
- Performance: Keep unit tests fast (< 1s), integration tests reasonable (< 5m)
Database Connection Errors:
# Check database is running
psql -h localhost -U test -d contextkeeper_test -c "SELECT 1"
# Reset test database
dropdb contextkeeper_test
createdb contextkeeper_testPort Conflicts:
# Check if port is in use
lsof -i :8080
# Kill process using port
kill -9 <PID>Test Timeouts:
- Increase timeout with
-timeoutflag - Check for deadlocks or infinite loops
- Verify external services are responding
All tests must pass before merging to main:
- ✅ All unit tests pass
- ✅ All integration tests pass
- ✅ Performance requirements met
- ✅ Security tests pass
- ✅ Code coverage > 80%
- ✅ No critical security vulnerabilities