Add MIROIR_TEST_SKIP_DOCKER and MIROIR_TEST_REDIS_URL environment variables to allow Redis integration tests to run without Docker or use external Redis. Changes: - Modified setup_redis_store() to support external Redis via MIROIR_TEST_REDIS_URL - Added skip_if_no_redis!() macro for graceful test skipping - Tests now skip with clear message when Docker unavailable - Added docs/TESTING.md with test environment documentation Fixes bead bf-5qy60: Fix Redis integration tests infrastructure Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2.9 KiB
Testing Guide
This document explains how to run tests for Miroir, including requirements for integration tests.
Prerequisites
Unit Tests
Unit tests run without external dependencies:
cargo nextest run
Integration Tests
Integration tests require external services. Some tests can use either Docker containers or external services.
Redis Integration Tests
The Redis integration tests (task_store::redis::tests::integration) test the Redis-backed task store.
Option 1: Using Docker (testcontainers)
Requirements:
- Docker daemon running and accessible at
/var/run/docker.sockor viaDOCKER_HOST
Run tests:
cargo nextest run -E 'test(redis)'
The tests will automatically start a Redis container using testcontainers.
Option 2: Using External Redis
Requirements:
- Redis server running and accessible
Run tests:
export MIROIR_TEST_REDIS_URL=redis://localhost:6379
cargo nextest run -E 'test(redis)'
Option 3: Skip Docker Tests
If Docker is not available and you don't have an external Redis instance, you can skip these tests:
export MIROIR_TEST_SKIP_DOCKER=1
cargo nextest run -E 'test(redis)'
Tests will be skipped with a message indicating why.
Docker Compose Integration Tests
The docker_compose_integration tests require a full Meilisearch cluster.
Requirements:
- Docker and docker-compose installed
- Run
docker-compose up -din the project root first
Run tests:
cd docker-compose-env # or whatever the compose directory is
docker-compose up -d
cd ..
cargo nextest run -E 'test(docker_compose_integration)'
Phase Acceptance Tests
Phase acceptance tests (p10_, p3_) test specific feature integration.
Requirements:
- Docker for Redis (same as Redis integration tests)
- See individual test suites for specific requirements
Running All Tests
To run all tests (unit + integration) without Docker-dependent tests:
MIROIR_TEST_SKIP_DOCKER=1 cargo nextest run
To run only unit tests (no external dependencies):
cargo nextest run --exclude 'integration|docker_compose|p10_|p3_'
CI/CD
The Argo Workflows CI pipeline (see §7 CI/CD) runs all tests with:
- Docker daemon available for testcontainers
- Full docker-compose environment for integration tests
Troubleshooting
"SocketNotFoundError(/var/run/docker.sock)"
Docker is not running or not accessible. Options:
- Start Docker:
sudo systemctl start docker(Linux) or start Docker Desktop - Use external Redis:
export MIROIR_TEST_REDIS_URL=redis://... - Skip Docker tests:
export MIROIR_TEST_SKIP_DOCKER=1
"Failed to start Redis: Connection refused"
External Redis is not running. Start Redis:
docker run -d -p 6379:6379 redis:alpine
# or
redis-server
Tests timeout or hang
Some tests require proper cleanup. Use nextest's built-in timeout:
cargo nextest run --timeout 120