-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdocker-compose.test.yaml
More file actions
227 lines (212 loc) · 5.77 KB
/
Copy pathdocker-compose.test.yaml
File metadata and controls
227 lines (212 loc) · 5.77 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
version: '3.8'
services:
# =========================================================================
# TEST DATABASES
# =========================================================================
test_db:
image: postgres:15-alpine
container_name: openrisk_test_db
environment:
POSTGRES_USER: test
POSTGRES_PASSWORD: test
POSTGRES_DB: openrisk_test
ports:
- "5436:5432"
volumes:
- openrisk_test_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U test"]
interval: 10s
timeout: 5s
retries: 5
networks:
- test_network
restart: unless-stopped
# Test Redis
test_redis:
image: redis:7-alpine
container_name: openrisk_test_redis
ports:
- "6380:6379"
command: redis-server --appendonly yes
volumes:
- openrisk_test_redis:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
networks:
- test_network
restart: unless-stopped
# =========================================================================
# BACKEND TEST SERVICE
# =========================================================================
test_backend:
build:
context: ./backend
dockerfile: Dockerfile
container_name: openrisk_test_backend
environment:
DB_HOST: test_db
DB_PORT: 5432
DB_USER: test
DB_PASSWORD: test
DB_NAME: openrisk_test
REDIS_HOST: test_redis
REDIS_PORT: 6379
# Without REDIS_URL the events client parses the localhost default and
# PANICS at boot, so the backend never starts (#728).
REDIS_URL: redis://test_redis:6379/0
ENVIRONMENT: test
API_PORT: 8081
ports:
- "8081:8081"
depends_on:
test_db:
condition: service_healthy
test_redis:
condition: service_healthy
networks:
- test_network
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8081/health"]
interval: 10s
timeout: 5s
retries: 5
# =========================================================================
# FRONTEND TEST SERVICE
# =========================================================================
test_frontend:
build:
context: ./frontend
dockerfile: Dockerfile
container_name: openrisk_test_frontend
environment:
VITE_API_URL: http://test_backend:8081
NODE_ENV: test
ports:
- "5174:5173"
depends_on:
- test_backend
networks:
- test_network
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:5173"]
interval: 10s
timeout: 5s
retries: 5
# =========================================================================
# TEST RUNNERS
# =========================================================================
# Integration tests
integration_tests:
image: golang:1.21-alpine
container_name: openrisk_integration_tests
working_dir: /workspace
environment:
TEST_DB_HOST: test_db
TEST_DB_PORT: 5432
TEST_DB_USER: test
TEST_DB_PASSWORD: test
TEST_DB_NAME: openrisk_test
REDIS_HOST: test_redis
REDIS_PORT: 6379
volumes:
- ./backend:/workspace
- ./tests:/workspace/tests
depends_on:
test_db:
condition: service_healthy
test_redis:
condition: service_healthy
networks:
- test_network
command: go test -v ./tests/integration_test.go ./tests/mocks.go -timeout 30m
restart: "no"
# Security tests
security_tests:
image: golang:1.21-alpine
container_name: openrisk_security_tests
working_dir: /workspace
environment:
API_URL: http://test_backend:8081
volumes:
- ./backend:/workspace
- ./tests:/workspace/tests
depends_on:
test_backend:
condition: service_healthy
networks:
- test_network
command: go test -v ./tests/security_test.go -timeout 30m
restart: "no"
# Performance benchmarks
performance_tests:
image: golang:1.21-alpine
container_name: openrisk_performance_tests
working_dir: /workspace
environment:
TEST_DB_HOST: test_db
TEST_DB_PORT: 5432
TEST_DB_USER: test
TEST_DB_PASSWORD: test
TEST_DB_NAME: openrisk_test
REDIS_HOST: test_redis
REDIS_PORT: 6379
volumes:
- ./backend:/workspace
- ./tests:/workspace/tests
depends_on:
test_db:
condition: service_healthy
test_redis:
condition: service_healthy
networks:
- test_network
command: go test -v -bench=. ./tests/performance_benchmark_test.go -timeout 30m
restart: "no"
# E2E tests with Playwright
e2e_tests:
image: mcr.microsoft.com/playwright:v1.40.0-jammy
container_name: openrisk_e2e_tests
working_dir: /workspace
environment:
E2E_BASE_URL: http://test_frontend:5173
API_URL: http://test_backend:8081
TEST_EMAIL: test@example.com
TEST_PASSWORD: password123
volumes:
- ./frontend:/workspace
- ./tests:/workspace/tests
depends_on:
test_frontend:
condition: service_healthy
networks:
- test_network
command: npm run test:e2e
restart: "no"
# Load testing with k6
load_tests:
image: grafana/k6:latest
container_name: openrisk_load_tests
working_dir: /workspace
environment:
API_BASE_URL: http://test_backend:8081
volumes:
- ./load_tests:/workspace/load_tests
depends_on:
test_backend:
condition: service_healthy
networks:
- test_network
command: run /workspace/load_tests/performance_baseline.js
restart: "no"
volumes:
openrisk_test_data:
openrisk_test_redis:
networks:
test_network:
driver: bridge