video-processor/.github/workflows/integration-tests.yml
Ryan Malloy 1a7d48f171 Add comprehensive end-to-end Docker integration tests
Implements complete integration test suite that validates the entire
video processing system in a containerized environment.

## Core Features
- **Video Processing Pipeline Tests**: Complete E2E validation including
  encoding, thumbnails, sprites, and metadata extraction
- **Procrastinate Worker Integration**: Async job processing, queue
  management, and error handling with version compatibility
- **Database Migration Testing**: Schema creation, version compatibility,
  and production-like migration workflows
- **Docker Orchestration**: Dedicated test environment with PostgreSQL,
  workers, and proper service dependencies

## Test Infrastructure
- **43 integration test cases** covering all major functionality
- **Containerized test environment** isolated from development
- **Automated CI/CD pipeline** with GitHub Actions
- **Performance benchmarking** and resource usage validation
- **Comprehensive error scenarios** and edge case handling

## Developer Tools
- `./scripts/run-integration-tests.sh` - Full-featured test runner
- `Makefile` - Simplified commands for common tasks
- `docker-compose.integration.yml` - Dedicated test environment
- GitHub Actions workflow with test matrix and artifact upload

## Test Coverage
- Multi-format video encoding (MP4, WebM, OGV)
- Quality preset validation (low, medium, high, ultra)
- Async job submission and processing
- Worker version compatibility (Procrastinate 2.x/3.x)
- Database schema migrations and rollbacks
- Concurrent processing scenarios
- Performance benchmarks and timeouts

Files Added:
- tests/integration/ - Complete test suite with fixtures
- docker-compose.integration.yml - Test environment configuration
- scripts/run-integration-tests.sh - Test runner with advanced options
- .github/workflows/integration-tests.yml - CI/CD pipeline
- Makefile - Development workflow automation
- Enhanced pyproject.toml with integration test dependencies

Usage:
```bash
make test-integration                    # Run all integration tests
./scripts/run-integration-tests.sh -v   # Verbose output
./scripts/run-integration-tests.sh -k   # Keep containers for debugging
make docker-test                        # Clean Docker test run
```
2025-09-05 11:24:08 -06:00

196 lines
5.1 KiB
YAML

name: Integration Tests
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
schedule:
# Run daily at 02:00 UTC
- cron: '0 2 * * *'
env:
DOCKER_BUILDKIT: 1
COMPOSE_DOCKER_CLI_BUILD: 1
jobs:
integration-tests:
name: Docker Integration Tests
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
matrix:
test-suite:
- "video_processing"
- "procrastinate_worker"
- "database_migration"
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y ffmpeg postgresql-client
- name: Verify Docker and FFmpeg
run: |
docker --version
docker-compose --version
ffmpeg -version
- name: Run integration tests
run: |
./scripts/run-integration-tests.sh \
--test-filter "test_${{ matrix.test-suite }}" \
--timeout 1200 \
--verbose
- name: Upload test logs
if: failure()
uses: actions/upload-artifact@v3
with:
name: integration-test-logs-${{ matrix.test-suite }}
path: test-reports/
retention-days: 7
- name: Upload test results
if: always()
uses: actions/upload-artifact@v3
with:
name: integration-test-results-${{ matrix.test-suite }}
path: htmlcov/
retention-days: 7
full-integration-test:
name: Full Integration Test Suite
runs-on: ubuntu-latest
timeout-minutes: 45
needs: integration-tests
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y ffmpeg postgresql-client
- name: Run complete integration test suite
run: |
./scripts/run-integration-tests.sh \
--timeout 2400 \
--verbose
- name: Generate test report
if: always()
run: |
mkdir -p test-reports
echo "# Integration Test Report" > test-reports/summary.md
echo "- Date: $(date)" >> test-reports/summary.md
echo "- Commit: ${{ github.sha }}" >> test-reports/summary.md
echo "- Branch: ${{ github.ref_name }}" >> test-reports/summary.md
- name: Upload complete test results
if: always()
uses: actions/upload-artifact@v3
with:
name: complete-integration-test-results
path: |
test-reports/
htmlcov/
retention-days: 30
performance-test:
name: Performance & Load Testing
runs-on: ubuntu-latest
timeout-minutes: 20
if: github.event_name == 'schedule' || contains(github.event.pull_request.labels.*.name, 'performance')
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y ffmpeg postgresql-client
- name: Run performance tests
run: |
./scripts/run-integration-tests.sh \
--test-filter "performance" \
--timeout 1200 \
--verbose
- name: Upload performance results
if: always()
uses: actions/upload-artifact@v3
with:
name: performance-test-results
path: test-reports/
retention-days: 14
docker-security-scan:
name: Docker Security Scan
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Build Docker image
run: |
docker build -t video-processor:test .
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: 'video-processor:test'
format: 'sarif'
output: 'trivy-results.sarif'
- name: Upload Trivy scan results
uses: github/codeql-action/upload-sarif@v2
if: always()
with:
sarif_file: 'trivy-results.sarif'
notify-status:
name: Notify Test Status
runs-on: ubuntu-latest
needs: [integration-tests, full-integration-test]
if: always()
steps:
- name: Notify success
if: needs.integration-tests.result == 'success' && needs.full-integration-test.result == 'success'
run: |
echo "✅ All integration tests passed successfully!"
- name: Notify failure
if: needs.integration-tests.result == 'failure' || needs.full-integration-test.result == 'failure'
run: |
echo "❌ Integration tests failed. Check the logs for details."
exit 1