-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker-compose.test.yml
More file actions
125 lines (118 loc) · 3.38 KB
/
docker-compose.test.yml
File metadata and controls
125 lines (118 loc) · 3.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# Docker Compose configuration for Villa test infrastructure
# Usage: docker compose -f docker-compose.test.yml up --abort-on-container-exit
#
# Services:
# - postgres-test: Ephemeral PostgreSQL for integration tests
# - test-unit: Unit tests with vitest
# - test-integration: Integration tests with MSW
# - test-e2e: E2E tests with Playwright (4 replicas for parallel execution)
services:
# Ephemeral PostgreSQL for integration tests (no persistent volume)
postgres-test:
image: postgres:17-alpine
container_name: villa-postgres-test
environment:
POSTGRES_USER: villa_test
POSTGRES_PASSWORD: villa_test_password
POSTGRES_DB: villa_test
tmpfs:
- /var/lib/postgresql/data # In-memory database for speed
healthcheck:
test: ["CMD-SHELL", "pg_isready -U villa_test -d villa_test"]
interval: 2s
timeout: 5s
retries: 5
networks:
- test-net
# Unit tests - fast, no external dependencies
test-unit:
build:
context: .
dockerfile: Dockerfile.test
target: test-runner
container_name: villa-test-unit
environment:
- CI=true
- NODE_ENV=test
- TEST_TYPE=unit
command: ["pnpm", "--filter", "@villa/hub", "test:unit"]
volumes:
# Mount test results for CI artifacts
- ./apps/hub/coverage:/app/apps/hub/coverage
networks:
- test-net
profiles:
- unit
- all
# Integration tests - uses MSW for API mocking
test-integration:
build:
context: .
dockerfile: Dockerfile.test
target: test-runner
container_name: villa-test-integration
environment:
- CI=true
- NODE_ENV=test
- TEST_TYPE=integration
- DATABASE_URL=postgresql://villa_test:villa_test_password@postgres-test:5432/villa_test
command: ["pnpm", "--filter", "@villa/hub", "test:integration"]
depends_on:
postgres-test:
condition: service_healthy
volumes:
- ./apps/hub/coverage:/app/apps/hub/coverage
networks:
- test-net
profiles:
- integration
- all
# E2E tests - parallel execution with 4 workers
test-e2e:
build:
context: .
dockerfile: Dockerfile.test
target: test-runner
environment:
- CI=true
- NODE_ENV=test
- TEST_TYPE=e2e
- DATABASE_URL=postgresql://villa_test:villa_test_password@postgres-test:5432/villa_test
- BASE_URL=http://localhost:3000
command: ["pnpm", "--filter", "@villa/hub", "test:e2e:chromium"]
depends_on:
postgres-test:
condition: service_healthy
volumes:
- ./apps/hub/test-results:/app/apps/hub/test-results
- ./apps/hub/playwright-report:/app/apps/hub/playwright-report
networks:
- test-net
profiles:
- e2e
- all
deploy:
replicas: 4 # Parallel E2E execution (matches CI sharding strategy)
# Security tests - validate shell scripts and auth flows
test-security:
build:
context: .
dockerfile: Dockerfile.test
target: test-runner
container_name: villa-test-security
environment:
- CI=true
- NODE_ENV=test
- TEST_TYPE=security
command: ["pnpm", "--filter", "@villa/hub", "test:security"]
volumes:
- ./apps/hub/coverage:/app/apps/hub/coverage
networks:
- test-net
profiles:
- security
- all
networks:
test-net:
driver: bridge
# No volumes defined - ephemeral testing only