-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.integration.yml
More file actions
219 lines (210 loc) · 5.77 KB
/
docker-compose.integration.yml
File metadata and controls
219 lines (210 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
services:
# PostgreSQL 16 - 专用于PostgreSQL压力测试
postgres:
image: postgres:16-alpine
container_name: batchflow-postgres-integration
environment:
POSTGRES_DB: batchflow_test
POSTGRES_USER: testuser
POSTGRES_PASSWORD: testpass123
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
- ./test/sql/postgres:/docker-entrypoint-initdb.d
# 优化配置 - 适合容器环境的资源分配
command: >
postgres
-c shared_buffers=256MB
-c max_connections=200
-c effective_cache_size=512MB
-c maintenance_work_mem=64MB
-c checkpoint_completion_target=0.9
-c wal_buffers=8MB
-c default_statistics_target=100
-c random_page_cost=1.1
-c effective_io_concurrency=200
-c work_mem=4MB
-c max_wal_size=1GB
-c min_wal_size=80MB
healthcheck:
test: ["CMD-SHELL", "pg_isready -U testuser -d batchflow_test"]
timeout: 20s
retries: 10
interval: 5s
networks:
- batchflow-network
# PostgreSQL 压力测试运行器
postgres-test:
build:
context: .
dockerfile: Dockerfile.integration
container_name: batchflow-postgres-test
depends_on:
postgres:
condition: service_healthy
env_file:
- .env.test
environment:
- POSTGRES_DSN=postgres://testuser:testpass123@postgres:5432/batchflow_test?sslmode=disable
- TEST_TYPE=postgres
ports:
- "8080:8080"
volumes:
- ./test/reports:/app/reports
networks:
- batchflow-network
command: ["./run-single-db-test.sh"]
# MySQL 8.0 - 专用于MySQL压力测试
mysql:
image: mysql:8.0-oracle
container_name: batchflow-mysql-integration
environment:
MYSQL_ROOT_PASSWORD: testpass123
MYSQL_DATABASE: batchflow_test
MYSQL_USER: testuser
MYSQL_PASSWORD: testpass123
ports:
- "3306:3306"
volumes:
- mysql_data:/var/lib/mysql
- ./test/sql/mysql:/docker-entrypoint-initdb.d
# 高性能配置 - 给MySQL分配更多资源
command: >
--default-authentication-plugin=mysql_native_password
--innodb-buffer-pool-size=1G
--innodb-redo-log-capacity=512M
--max-connections=500
--innodb-flush-log-at-trx-commit=2
--sync-binlog=0
--innodb-doublewrite=0
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-ptestpass123"]
timeout: 20s
retries: 10
interval: 5s
networks:
- batchflow-network
# MySQL 压力测试运行器
mysql-test:
build:
context: .
dockerfile: Dockerfile.integration
container_name: batchflow-mysql-test
depends_on:
mysql:
condition: service_healthy
env_file:
- .env.test
environment:
- MYSQL_DSN=testuser:testpass123@tcp(mysql:3306)/batchflow_test?parseTime=true&multiStatements=true
- TEST_TYPE=mysql
ports:
- "8081:8080"
volumes:
- ./test/reports:/app/reports
networks:
- batchflow-network
command: ["./run-single-db-test.sh"]
# Redis 7.0 - 专用于Redis压力测试
redis:
image: redis:7.0-alpine
container_name: batchflow-redis-integration
environment:
# Redis 不使用传统的用户名密码,可以设置 AUTH 密码
REDIS_PASSWORD: testpass123
ports:
- "6379:6379"
volumes:
- redis_data:/data
# Redis 配置文件(如果需要自定义配置)
# - ./redis/redis.conf:/usr/local/etc/redis/redis.conf
# 高性能配置 - Redis 优化参数
command: >
redis-server
--requirepass testpass123
--maxmemory 1gb
--maxmemory-policy allkeys-lru
--save 60 1000
--appendonly yes
--appendfsync everysec
--tcp-keepalive 300
--timeout 0
--databases 16
healthcheck:
test: ["CMD", "redis-cli", "-a", "testpass123", "ping"]
timeout: 20s
retries: 10
interval: 5s
networks:
- batchflow-network
# Redis 压力测试运行器
redis-test:
build:
context: .
dockerfile: Dockerfile.integration
container_name: batchflow-redis-test
depends_on:
redis:
condition: service_healthy
env_file:
- .env.test
environment:
# Redis DSN 格式:redis://[username:password@]host:port/database
- REDIS_DSN=redis://:testpass123@redis:6379/0
- TEST_TYPE=redis
# Redis 特有的测试参数
- REDIS_DB=0
- REDIS_POOL_SIZE=100
ports:
- "8082:8080"
volumes:
- ./test/reports:/app/reports
networks:
- batchflow-network
command: ["./run-single-db-test.sh"]
# SQLite
sqlite:
image: alpine/sqlite:latest
container_name: batchflow-sqlite-integration
volumes:
- sqlite_data:/apps
- ./test/sql/sqlite/init.sql:/apps/init.sql
command: ["-cmd", ".read /apps/init.sql", "-cmd", ".system tail -f /dev/null", "/apps/test.db"]
healthcheck:
test: ["CMD", "sqlite3", "/apps/test.db", ".tables"]
timeout: 20s
retries: 10
interval: 5s
networks:
- batchflow-network
#SQLite 压力测试运行器 - 使用 SQLite 优化配置
sqlite-test:
build:
context: .
dockerfile: Dockerfile.sqlite.integration
container_name: batchflow-sqlite-test
depends_on:
sqlite:
condition: service_healthy
env_file:
- .env.sqlite.test # 使用 SQLite 专用配置
environment:
- SQLITE_DSN=/apps/test.db
- TEST_TYPE=sqlite
ports:
- "8083:8080"
volumes:
- sqlite_data:/apps
- ./test/reports:/app/reports
networks:
- batchflow-network
command: ["./run-single-db-test.sh"]
volumes:
postgres_data:
mysql_data:
redis_data:
sqlite_data:
networks:
batchflow-network:
driver: bridge