Add MIROIR_TEST_SKIP_DOCKER and MIROIR_TEST_MIROIR_URL environment variables to allow docker-compose integration tests to run without Docker or use external Miroir. Changes: - Modified HttpClient::new() to accept base_url parameter - Added get_miroir_base_url() to support external Miroir via MIROIR_TEST_MIROIR_URL - Added skip_if_no_miroir!() macro for graceful test skipping - Tests now skip with clear message when Docker unavailable - Updated docs/TESTING.md with docker-compose test environment documentation Acceptance criteria met: ✓ Tests skip gracefully when Docker unavailable (MIROIR_TEST_SKIP_DOCKER=1) ✓ Tests can run against external Miroir instance (MIROIR_TEST_MIROIR_URL) ✓ Test setup documented in docs/TESTING.md ✓ All docker_compose_integration tests pass with skip flag Fixes bead bf-3a6dx: Fix docker-compose integration tests Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
155 lines
3.8 KiB
Markdown
155 lines
3.8 KiB
Markdown
# 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:
|
|
```bash
|
|
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.sock` or via `DOCKER_HOST`
|
|
|
|
**Run tests:**
|
|
```bash
|
|
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:**
|
|
```bash
|
|
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:
|
|
|
|
```bash
|
|
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 run against a full Miroir + Meilisearch stack.
|
|
|
|
### Option 1: Using Docker Compose
|
|
|
|
**Requirements:**
|
|
- Docker and docker-compose installed
|
|
- Start the stack: `docker compose -f examples/docker-compose-dev.yml up -d`
|
|
|
|
**Run tests:**
|
|
```bash
|
|
docker compose -f examples/docker-compose-dev.yml up -d
|
|
cargo nextest run -E 'test(docker_compose_integration)'
|
|
```
|
|
|
|
### Option 2: Using External Miroir
|
|
|
|
**Requirements:**
|
|
- A running Miroir instance accessible via HTTP
|
|
|
|
**Run tests:**
|
|
```bash
|
|
export MIROIR_TEST_MIROIR_URL=http://your-miroir-host:7700
|
|
cargo nextest run -E 'test(docker_compose_integration)'
|
|
```
|
|
|
|
### Option 3: Skip Docker Tests
|
|
|
|
If Docker is not available and you don't have an external Miroir instance, you can skip these tests:
|
|
|
|
```bash
|
|
export MIROIR_TEST_SKIP_DOCKER=1
|
|
cargo nextest run -E 'test(docker_compose_integration)'
|
|
```
|
|
|
|
Tests will be skipped with a message indicating why.
|
|
|
|
### Node Failure Test (RF=2)
|
|
|
|
The `test_node_failure_rf2` test requires the RF=2 docker-compose stack:
|
|
|
|
```bash
|
|
docker compose -f examples/docker-compose-dev-rf2.yml up -d
|
|
cargo nextest run -E 'test(node_failure_rf2)' --ignored
|
|
```
|
|
|
|
Or use an external RF=2 Miroir instance:
|
|
|
|
```bash
|
|
export MIROIR_TEST_MIROIR_URL=http://your-rf2-miroir:7710
|
|
cargo nextest run -E 'test(node_failure_rf2)' --ignored
|
|
```
|
|
|
|
## 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:
|
|
```bash
|
|
MIROIR_TEST_SKIP_DOCKER=1 cargo nextest run
|
|
```
|
|
|
|
To run only unit tests (no external dependencies):
|
|
```bash
|
|
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:
|
|
1. Start Docker: `sudo systemctl start docker` (Linux) or start Docker Desktop
|
|
2. Use external Redis: `export MIROIR_TEST_REDIS_URL=redis://...`
|
|
3. Skip Docker tests: `export MIROIR_TEST_SKIP_DOCKER=1`
|
|
|
|
### "Failed to start Redis: Connection refused"
|
|
External Redis is not running. Start Redis:
|
|
```bash
|
|
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:
|
|
```bash
|
|
cargo nextest run --timeout 120
|
|
```
|