version: "3.8"
services:
postgres-test:
image: postgres:18-alpine
container_name: mpi-postgres-test
environment:
POSTGRES_DB: mpi_test
POSTGRES_USER: test_user
POSTGRES_PASSWORD: test_password
ports:
- "5433:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U test_user -d mpi_test"]
interval: 5s
timeout: 3s
retries: 5
networks:
- mpi-test-network
tmpfs:
- /var/lib/postgresql/data
test-runner:
build:
context: .
dockerfile: Dockerfile.test
container_name: mpi-test-runner
depends_on:
postgres-test:
condition: service_healthy
environment:
DATABASE_URL: postgresql://test_user:test_password@postgres-test:5432/worker_service_test
DATABASE_MAX_CONNECTIONS: 5
DATABASE_MIN_CONNECTIONS: 1
SEARCH_INDEX_PATH: /tmp/test_index
MATCHING_THRESHOLD: 0.7
RUST_LOG: info
RUST_BACKTRACE: 1
networks:
- mpi-test-network
command: >
sh -c "
echo 'Waiting for database to be ready...' &&
sleep 5 &&
echo 'Running database migrations...' &&
sea-orm-cli migrate up &&
echo 'Running unit tests...' &&
cargo test --lib &&
echo 'Running integration tests...' &&
cargo test --test api_integration_test
"
networks:
mpi-test-network:
driver: bridge