-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathdocker-compose.test.yml
More file actions
148 lines (138 loc) · 4 KB
/
docker-compose.test.yml
File metadata and controls
148 lines (138 loc) · 4 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
version: '3.8'
# Docker Compose configuration for testing
# This extends the base docker-compose.yml for testing scenarios
services:
# Test application with coverage
app-test:
build:
context: .
dockerfile: Dockerfile
target: development
container_name: it-asset-manager-test
environment:
- FLASK_ENV=testing
- SECRET_KEY=test-secret-key
- DATABASE_URL=postgresql://test_user:test_password@postgres-test:5432/test_db
- REDIS_URL=redis://redis-test:6379/0
- COVERAGE_PROCESS_START=.coveragerc
volumes:
- .:/app
- test_coverage:/app/htmlcov
depends_on:
postgres-test:
condition: service_healthy
redis-test:
condition: service_healthy
networks:
- test-network
command: >
sh -c "
echo 'Waiting for database...' &&
python -c 'from it_asset_manager.core.database import db; from it_asset_manager.core.app import create_app; app = create_app(\"testing\"); app.app_context().push(); db.create_all(); print(\"Database ready\")' &&
echo 'Running tests with coverage...' &&
pytest tests/ -v --cov=it_asset_manager --cov-report=html --cov-report=term-missing --cov-fail-under=80
"
# Test PostgreSQL database
postgres-test:
image: postgres:15-alpine
container_name: it-asset-manager-postgres-test
environment:
- POSTGRES_DB=test_db
- POSTGRES_USER=test_user
- POSTGRES_PASSWORD=test_password
volumes:
- postgres_test_data:/var/lib/postgresql/data
- ./docker/postgres/init.sql:/docker-entrypoint-initdb.d/init.sql
networks:
- test-network
healthcheck:
test: ["CMD-SHELL", "pg_isready -U test_user -d test_db"]
interval: 10s
timeout: 5s
retries: 5
# Test Redis
redis-test:
image: redis:7-alpine
container_name: it-asset-manager-redis-test
networks:
- test-network
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
# Selenium for browser testing
selenium:
image: selenium/standalone-chrome:latest
container_name: it-asset-manager-selenium
ports:
- "4444:4444"
networks:
- test-network
shm_size: 2gb
environment:
- SE_OPTS=--disable-dev-shm-usage
# Load testing with k6
k6:
image: grafana/k6:latest
container_name: it-asset-manager-k6
volumes:
- ./tests/performance:/scripts
- k6_results:/results
networks:
- test-network
environment:
- BASE_URL=http://app-dev:5000
command: run --out json=/results/results.json /scripts/load-test.js
depends_on:
- app-dev
# Test database migration
migration-test:
build:
context: .
dockerfile: Dockerfile
target: development
container_name: it-asset-manager-migration-test
environment:
- FLASK_ENV=testing
- DATABASE_URL=postgresql://test_user:test_password@postgres-test:5432/test_db
volumes:
- .:/app
depends_on:
postgres-test:
condition: service_healthy
networks:
- test-network
command: >
sh -c "
echo 'Testing database migrations...' &&
python -c 'from it_asset_manager.core.database import db; from it_asset_manager.core.app import create_app; app = create_app(\"testing\"); app.app_context().push(); db.create_all(); print(\"Migration test completed\")'
"
# Security testing with OWASP ZAP
zap:
image: owasp/zap2docker-stable
container_name: it-asset-manager-zap
volumes:
- zap_results:/zap/wrk
networks:
- test-network
command: >
sh -c "
echo 'Starting security scan...' &&
zap-baseline.py -t http://app-dev:5000 -J zap-report.json -r zap-report.html || true &&
echo 'Security scan completed'
"
depends_on:
- app-dev
volumes:
postgres_test_data:
driver: local
test_coverage:
driver: local
k6_results:
driver: local
zap_results:
driver: local
networks:
test-network:
driver: bridge