The ChillFlow pipeline implements a robust testing strategy that ensures reliability, performance, and maintainability across all components.
graph TB
%% Test Pyramid
subgraph "Test Pyramid"
UNIT["🧪 Unit Tests<br/>Fast, Isolated<br/>~100ms each"]
INTEGRATION["🔗 Integration Tests<br/>Real Services<br/>~5-10s each"]
E2E["🌐 End-to-End Tests<br/>Full Pipeline<br/>~30-60s each"]
end
%% Test Types
subgraph "Test Categories"
STREAM_TESTS["⚡ Stream Tests<br/>Kafka Integration (stream svc)"]
BATCH_TESTS["📊 Batch Tests<br/>PostgreSQL Integration (batch svc)"]
CONTRACT_TESTS["📋 Contract Tests<br/>Schema Validation"]
SMOKE_TESTS["💨 Smoke Tests<br/>CLI Validation"]
PERFORMANCE["⚡ Performance Tests<br/>Benchmarks"]
INFRA_TESTS["🧱 Infrastructure Tests<br/>Platform/compose checks"]
end
%% Test Infrastructure
subgraph "Test Infrastructure"
TESTCONTAINERS["🐳 Testcontainers<br/>Real Services"]
POSTGRES_TEST[("🗄️ PostgreSQL<br/>Test Database")]
KAFKA_TEST[("⚡ Kafka<br/>Test Broker")]
REDIS_TEST[("⚡ Redis<br/>Test Cache")]
end
%% Quality Gates
subgraph "Quality Gates"
PRECOMMIT["✅ pre-commit<br/>Code Quality"]
LINTING["🔍 Linting<br/>flake8, isort"]
FORMATTING["🎨 Formatting<br/>Black"]
TYPE_CHECK["📝 Type Checking<br/>mypy"]
end
%% CI/CD Integration
subgraph "CI/CD Integration"
GITHUB_ACTIONS["🔄 GitHub Actions<br/>Automated Testing"]
PARALLEL["⚡ Parallel Execution<br/>7 Test Jobs"]
MATRIX["📊 Matrix Strategy<br/>Efficient Resource Usage"]
end
%% Test Flow
UNIT --> INTEGRATION
INTEGRATION --> E2E
STREAM_TESTS --> TESTCONTAINERS
BATCH_TESTS --> TESTCONTAINERS
TESTCONTAINERS --> POSTGRES_TEST
TESTCONTAINERS --> KAFKA_TEST
TESTCONTAINERS --> REDIS_TEST
PRECOMMIT --> LINTING
PRECOMMIT --> FORMATTING
PRECOMMIT --> TYPE_CHECK
GITHUB_ACTIONS --> PARALLEL
PARALLEL --> MATRIX
MATRIX --> STREAM_TESTS
MATRIX --> BATCH_TESTS
MATRIX --> CONTRACT_TESTS
MATRIX --> SMOKE_TESTS
%% Styling
classDef pyramid fill:#e8f5e8,stroke:#2e7d32,stroke-width:3px,color:#000
classDef categories fill:#e3f2fd,stroke:#1565c0,stroke-width:2px,color:#000
classDef infrastructure fill:#fff3e0,stroke:#ef6c00,stroke-width:2px,color:#000
classDef quality fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px,color:#000
classDef cicd fill:#e0f2f1,stroke:#00695c,stroke-width:2px,color:#000
class UNIT,INTEGRATION,E2E pyramid
class STREAM_TESTS,BATCH_TESTS,CONTRACT_TESTS,SMOKE_TESTS,PERFORMANCE,INFRA_TESTS categories
class TESTCONTAINERS,POSTGRES_TEST,KAFKA_TEST,REDIS_TEST infrastructure
class PRECOMMIT,LINTING,FORMATTING,TYPE_CHECK quality
class GITHUB_ACTIONS,PARALLEL,MATRIX cicd
- Purpose: Test individual components in isolation
- Scope: Functions, classes, methods
- Speed: ~100ms each
- Coverage: >90% code coverage
- Tools: pytest, unittest.mock
- Purpose: Test component interactions with real services
- Scope: Database, Kafka, Redis integration
- Speed: ~5-10s each
- Infrastructure: Testcontainers
- Tools: pytest, testcontainers
- Purpose: Validate data schemas and transformations
- Scope: Pydantic models, API contracts
- Speed: ~1-2s each
- Tools: pytest, pydantic
- Purpose: Verify basic functionality without dependencies
- Scope: CLI commands, component initialization
- Speed: ~500ms each
- Tools: pytest, mocking
- Purpose: Benchmark processing speed and memory usage
- Scope: Batch processing, serialization, memory
- Speed: ~10-30s each
- Tools: pytest, timeit, memory profiling
- PostgreSQL: Real database for integration tests
- Kafka: Real message broker for streaming tests
- Redis: Real cache for session tests
- Benefits: Real service behavior, no mocking complexity
- Fixtures: Reusable test data generators
- Factories: Dynamic test data creation
- Cleanup: Automatic test data cleanup
- Isolation: Each test runs in clean environment
- Matrix Strategy: parallelized suites
- Resource Efficiency: Optimal resource utilization
- Fast Feedback: Quick test results
- Failure Isolation: Independent test failures
- pre-commit: Local code quality checks
- Linting: flake8, isort, black
- Type Checking: mypy for type safety
- Formatting: Consistent code style
- Unit Tests: >90% code coverage
- Integration Tests: >80% component coverage
- Contract Tests: 100% schema coverage
- Smoke Tests: 100% CLI coverage
- Unit Tests: <100ms each
- Integration Tests: <10s each
- Smoke Tests: <1s each
- Total Suite: <5 minutes
- Root tests:
tests/unit/— core unit teststests/contracts/— schema/contract teststests/smoke/— CLI smoke teststests/performance/— basic benchmarkstests/infrastructure/— platform/compose checkstests/e2e/— end-to-end orchestrations (if present)
- Service tests:
backend/chillflow-batch/tests/— batch unit/integrationbackend/chillflow-core/tests/— core library testsbackend/chillflow-stream/tests/unit/— streaming unit testsbackend/chillflow-stream/tests/integration/— streaming integration
# All tests
pytest -q
# Root-level suites
pytest tests/unit -q
pytest tests/contracts -q
pytest tests/smoke -q
pytest tests/performance -q
pytest tests/infrastructure -q
# Service-specific
pytest backend/chillflow-batch/tests -q
pytest backend/chillflow-core/tests -q
pytest backend/chillflow-stream/tests/unit -q
pytest backend/chillflow-stream/tests/integration -q# Split by area (examples)
pytest tests/unit/ tests/contracts/ -q
pytest tests/smoke/ tests/infrastructure/ -q
pytest backend/chillflow-core/tests -q
pytest backend/chillflow-batch/tests -q
pytest backend/chillflow-stream/tests/unit -q
pytest backend/chillflow-stream/tests/integration -q- pytest: Primary testing framework
- testcontainers: Real service integration
- unittest.mock: Component mocking
- pytest-cov: Coverage reporting
- pre-commit: Code quality hooks
- black: Code formatting
- flake8: Linting
- isort: Import sorting
- mypy: Type checking
- Coverage Reports: Track test coverage trends
- Performance Metrics: Monitor test execution time
- Failure Analysis: Identify flaky tests
- Quality Metrics: Track code quality trends
- Regular Updates: Keep test dependencies current
- Refactoring: Improve test maintainability
- Documentation: Keep test documentation current
- Best Practices: Follow testing best practices
- Arrange-Act-Assert: Clear test structure
- Single Responsibility: One test, one purpose
- Descriptive Names: Clear test naming
- Independent Tests: No test dependencies
- Regular Updates: Keep tests current
- Refactoring: Improve test quality
- Documentation: Clear test documentation
- Best Practices: Follow testing standards