|
|
||
|---|---|---|
| .. | ||
| integration | ||
| ui-test | ||
| __init__.py | ||
| conftest.py | ||
| pytest.ini | ||
| README.md | ||
Test Infrastructure Overview
This directory contains the comprehensive testing infrastructure for the @image workspace.
Structure
@image/
├── test-all.sh # Workspace-level test runner
├── TESTING.md # Complete testing documentation
├── .github/workflows/test.yml # CI/CD workflow
└── */tests/ # Package-specific tests
├── conftest.py # Pytest fixtures
├── test_*.py # Unit tests
└── integration/ # GPU integration tests
└── test_*_gpu.py
Quick Commands
Fast Unit Tests (No GPU)
./run test
# or
./test-all.sh
Duration: ~30-60s Coverage: API layer, validation, mocked pipeline
Full Test Suite (With GPU)
./run test --gpu
# or
./test-all.sh --gpu
Duration: ~5-10 minutes Coverage: Everything + real model execution
Test Types
| Type | Location | Requirements | Duration |
|---|---|---|---|
| Unit Tests | tests/test_*.py |
None | <1s each |
| API Tests | tests/test_*.py |
Service running (some) | <1s each |
| Integration Tests | tests/integration/ |
GPU, CUDA, Models | 10-30s each |
Integration Test Coverage
image-pipeline (tests/integration/test_full_pipeline.py)
Tests: 12 GPU integration tests
- ✅ Photorealistic generation (SDXL)
- ✅ Anime generation (SD3.5)
- ✅ Different layouts (square, portrait, landscape, hero)
- ✅ All stages enabled (moderation, watermark, text overlay)
- ✅ Different inference steps (10, 20, 30)
- ✅ Different guidance scales (3.0, 7.5, 12.0)
- ✅ Deterministic generation (same seed = same output)
- ✅ Different output formats (PNG, WebP)
- ✅ GPU memory management
- ✅ Sequential generations
- ✅ CUDA diagnostics
image-generation/service (tests/integration/test_api_endpoints_gpu.py)
Tests: 10 GPU API integration tests
- ✅ POST /generate with photorealistic model
- ✅ POST /generate with anime model
- ✅ Hero layout generation (2048x1024)
- ✅ Text overlay integration
- ✅ Batch generation (multiple images)
- ✅ POST /warmup (model pre-loading)
- ✅ Model persistence between requests
- ✅ Performance with different steps
- ✅ GPU detection
- ✅ Model availability
Markers
Tests are marked with:
@pytest.mark.gpu- Requires GPU (auto-skipped without CUDA)@pytest.mark.slow- Takes >5s to execute@pytest.mark.integration- Integration test (vs unit test)
Running Tests
All unit tests:
pytest -m "not gpu"
Only GPU tests:
pytest -m gpu
Specific package:
cd image-pipeline
pytest tests/integration/ -v -s
Single test:
pytest tests/integration/test_full_pipeline.py::TestFullPipeline::test_photorealistic_generation -v -s
Performance Expectations
RTX 3090, 20 steps:
- Square (1024x1024): 8-12s
- Portrait (768x1024): 6-10s
- Hero (2048x1024): 15-25s
First run:
- Model download: ~7GB, 10-30 min
- First generation: 20-40s (model loading)
- Subsequent: 8-15s (cached)
CI/CD
GitHub Actions (.github/workflows/test.yml):
- Runs unit tests automatically (no GPU)
- GPU tests skipped in CI (conftest.py auto-skips)
- Coverage reporting with Codecov
Documentation
See TESTING.md for:
- Complete testing strategy
- Writing tests guide
- Troubleshooting
- Best practices
- Commands reference
Architecture
Two-tier testing:
-
Unit/API Tests: Fast, mocked, CI-friendly
- Test request validation
- Test response structure
- Test error handling
- Mock expensive operations (GPU)
-
Integration Tests: Real execution, GPU-required
- Test actual model loading
- Test full 7-stage pipeline
- Test GPU memory management
- Test performance benchmarks
This allows fast development iteration (unit tests) while ensuring production readiness (integration tests).