Skip to content

Commit 0165d45

Browse files
committed
feat(e2e): add Docker Compose test environment
Add docker-compose.test.yml for E2E testing with: - Test PostgreSQL database container - Test MySQL database container - Redis container for caching tests - E2E test runner container with all dependencies - Performance test runner (separate profile) - Health checks and networking Usage: docker-compose -f docker-compose.test.yml up -d Implements Issue #43 Phase 1.
1 parent 4ea1ac5 commit 0165d45

1 file changed

Lines changed: 168 additions & 0 deletions

File tree

docker-compose.test.yml

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
# Docker Compose configuration for E2E testing
2+
# Usage: docker-compose -f docker-compose.test.yml up -d
3+
4+
version: "3.8"
5+
6+
services:
7+
# Test PostgreSQL database
8+
test-postgres:
9+
image: postgres:15-alpine
10+
container_name: arctic-test-postgres
11+
environment:
12+
POSTGRES_USER: test_user
13+
POSTGRES_PASSWORD: test_password
14+
POSTGRES_DB: test_db
15+
ports:
16+
- "5433:5432"
17+
healthcheck:
18+
test: ["CMD-SHELL", "pg_isready -U test_user -d test_db"]
19+
interval: 5s
20+
timeout: 5s
21+
retries: 5
22+
volumes:
23+
- test-postgres-data:/var/lib/postgresql/data
24+
networks:
25+
- test-network
26+
27+
# Test MySQL database
28+
test-mysql:
29+
image: mysql:8.0
30+
container_name: arctic-test-mysql
31+
environment:
32+
MYSQL_ROOT_PASSWORD: root_password
33+
MYSQL_DATABASE: test_db
34+
MYSQL_USER: test_user
35+
MYSQL_PASSWORD: test_password
36+
ports:
37+
- "3307:3306"
38+
healthcheck:
39+
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "test_user", "-ptest_password"]
40+
interval: 5s
41+
timeout: 5s
42+
retries: 10
43+
volumes:
44+
- test-mysql-data:/var/lib/mysql
45+
networks:
46+
- test-network
47+
48+
# Redis for caching tests
49+
test-redis:
50+
image: redis:7-alpine
51+
container_name: arctic-test-redis
52+
ports:
53+
- "6380:6379"
54+
healthcheck:
55+
test: ["CMD", "redis-cli", "ping"]
56+
interval: 5s
57+
timeout: 5s
58+
retries: 5
59+
networks:
60+
- test-network
61+
62+
# E2E test runner
63+
e2e-runner:
64+
build:
65+
context: .
66+
dockerfile: Dockerfile
67+
target: development
68+
container_name: arctic-e2e-runner
69+
environment:
70+
# E2E Configuration
71+
E2E_TESTS_ENABLED: "true"
72+
E2E_DATABASE_URL: "postgresql+asyncpg://test_user:test_password@test-postgres:5432/test_db"
73+
E2E_USE_REAL_MODEL: "false"
74+
75+
# Application settings
76+
DATABASE_URL: "postgresql+asyncpg://test_user:test_password@test-postgres:5432/test_db"
77+
HUGGINGFACE_TOKEN: "${HUGGINGFACE_TOKEN:-dummy_token}"
78+
SECRET_KEY: "e2e-test-secret-key"
79+
80+
# Auth settings
81+
AUTH_ENABLED: "true"
82+
JWT_AUTH_ENABLED: "true"
83+
API_KEY_AUTH_ENABLED: "true"
84+
API_KEYS: "test-api-key:read|write|admin"
85+
86+
# Agent settings
87+
AGENT_ENABLED: "true"
88+
AGENT_MAX_STEPS: "5"
89+
AGENT_MIN_CONFIDENCE: "0.5"
90+
91+
# Multi-database settings
92+
MULTIDB_ENABLED: "true"
93+
94+
# Cache settings
95+
CACHE_ENABLED: "false"
96+
CACHE_REDIS_URL: "redis://test-redis:6379/0"
97+
98+
# Test databases
99+
TEST_POSTGRES_URL: "postgresql+asyncpg://test_user:test_password@test-postgres:5432/test_db"
100+
TEST_MYSQL_URL: "mysql+aiomysql://test_user:test_password@test-mysql:3306/test_db"
101+
volumes:
102+
- .:/app
103+
- /app/.venv # Exclude virtual environment
104+
depends_on:
105+
test-postgres:
106+
condition: service_healthy
107+
test-mysql:
108+
condition: service_healthy
109+
test-redis:
110+
condition: service_healthy
111+
networks:
112+
- test-network
113+
command: >
114+
sh -c "
115+
echo 'Waiting for databases to be ready...'
116+
sleep 5
117+
echo 'Running E2E tests...'
118+
pytest tests/e2e/ -v --tb=short -m 'e2e' 2>&1 | tee /app/e2e-test-results.log
119+
exit_code=$$?
120+
echo 'E2E tests completed with exit code: '$$exit_code
121+
exit $$exit_code
122+
"
123+
124+
# Performance test runner (separate for isolation)
125+
perf-runner:
126+
build:
127+
context: .
128+
dockerfile: Dockerfile
129+
target: development
130+
container_name: arctic-perf-runner
131+
environment:
132+
E2E_TESTS_ENABLED: "true"
133+
E2E_DATABASE_URL: "postgresql+asyncpg://test_user:test_password@test-postgres:5432/test_db"
134+
DATABASE_URL: "postgresql+asyncpg://test_user:test_password@test-postgres:5432/test_db"
135+
HUGGINGFACE_TOKEN: "${HUGGINGFACE_TOKEN:-dummy_token}"
136+
SECRET_KEY: "perf-test-secret-key"
137+
AUTH_ENABLED: "true"
138+
API_KEY_AUTH_ENABLED: "true"
139+
API_KEYS: "test-api-key:read|write|admin"
140+
AGENT_ENABLED: "true"
141+
MULTIDB_ENABLED: "true"
142+
CACHE_ENABLED: "false"
143+
volumes:
144+
- .:/app
145+
- /app/.venv
146+
depends_on:
147+
test-postgres:
148+
condition: service_healthy
149+
networks:
150+
- test-network
151+
profiles:
152+
- performance
153+
command: >
154+
sh -c "
155+
echo 'Running performance tests...'
156+
pytest tests/e2e/test_performance_e2e.py -v --tb=short -m 'e2e_performance' 2>&1 | tee /app/perf-test-results.log
157+
exit_code=$$?
158+
echo 'Performance tests completed with exit code: '$$exit_code
159+
exit $$exit_code
160+
"
161+
162+
volumes:
163+
test-postgres-data:
164+
test-mysql-data:
165+
166+
networks:
167+
test-network:
168+
driver: bridge

0 commit comments

Comments
 (0)