Skip to content

Commit c27fcad

Browse files
committed
feat: add comprehensive testing infrastructure for Docker images
- Add docker-compose.test.yml for easy local testing - Add test-images.sh script for automated testing - Support testing both Ubuntu and slim variants - Include health checks and performance monitoring - Add TEST.md with detailed testing documentation - Enable database initialization testing - Support testing from different registries
1 parent ea7cbfb commit c27fcad

File tree

3 files changed

+574
-0
lines changed

3 files changed

+574
-0
lines changed

TEST.md

Lines changed: 218 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,218 @@
1+
# Testing OpenSPP Docker Images
2+
3+
This guide provides instructions for testing OpenSPP Docker images after they're built.
4+
5+
## Quick Start
6+
7+
### Automated Testing
8+
9+
Use the provided test script for comprehensive testing:
10+
11+
```bash
12+
# Make script executable
13+
chmod +x test-images.sh
14+
15+
# Test Ubuntu image (default)
16+
./test-images.sh
17+
18+
# Test slim image
19+
./test-images.sh slim
20+
21+
# Test both variants
22+
./test-images.sh both
23+
24+
# Test with database initialization
25+
./test-images.sh ubuntu --init-db
26+
```
27+
28+
### Manual Testing with Docker Compose
29+
30+
1. **Test the latest images from registry:**
31+
```bash
32+
# Start services
33+
docker-compose -f docker-compose.test.yml up -d
34+
35+
# Watch logs
36+
docker-compose -f docker-compose.test.yml logs -f
37+
38+
# Access OpenSPP
39+
open http://localhost:8069
40+
41+
# Stop services
42+
docker-compose -f docker-compose.test.yml down -v
43+
```
44+
45+
2. **Test specific image tags:**
46+
```bash
47+
# Test weekly build
48+
IMAGE_TAG=weekly docker-compose -f docker-compose.test.yml up -d
49+
50+
# Test specific version
51+
IMAGE_TAG=v1.0.0 docker-compose -f docker-compose.test.yml up -d
52+
53+
# Test slim variant
54+
IMAGE_TAG=latest-slim docker-compose -f docker-compose.test.yml up -d
55+
```
56+
57+
3. **Test with database initialization:**
58+
```bash
59+
INIT_DATABASE=true docker-compose -f docker-compose.test.yml up -d
60+
```
61+
62+
## Test Scenarios
63+
64+
### 1. Basic Functionality Test
65+
- ✅ Image pulls successfully
66+
- ✅ Container starts without errors
67+
- ✅ Health endpoint responds
68+
- ✅ Web interface is accessible
69+
- ✅ Can connect to PostgreSQL
70+
71+
### 2. Database Operations Test
72+
```bash
73+
# Initialize database with modules
74+
docker-compose -f docker-compose.test.yml exec openspp \
75+
openspp-server --database=openspp_test --init=base,web --stop-after-init
76+
77+
# Test database connection
78+
docker-compose -f docker-compose.test.yml exec openspp \
79+
openspp-shell --database=openspp_test -c "print('Connected')"
80+
```
81+
82+
### 3. Performance Test
83+
```bash
84+
# Check response time
85+
time curl -s http://localhost:8069 > /dev/null
86+
87+
# Monitor resource usage
88+
docker stats openspp-test-app
89+
90+
# Load test (requires apache2-utils)
91+
ab -n 100 -c 10 http://localhost:8069/
92+
```
93+
94+
### 4. Module Installation Test
95+
```bash
96+
# Install OpenSPP modules
97+
docker-compose -f docker-compose.test.yml exec openspp \
98+
openspp-server --database=openspp_test \
99+
--init=spp_base,g2p_registry_base \
100+
--stop-after-init
101+
```
102+
103+
### 5. Multi-Architecture Test
104+
```bash
105+
# Test on different architectures (if available)
106+
docker run --rm --platform linux/amd64 \
107+
docker.acn.fr/openspp/openspp:latest \
108+
openspp-server --version
109+
```
110+
111+
## Validation Checklist
112+
113+
### Image Build Validation
114+
- [ ] Image size is reasonable (~1.5GB for Ubuntu, ~1.0GB for slim)
115+
- [ ] No security vulnerabilities in base image
116+
- [ ] All required files are present
117+
- [ ] Proper user permissions (non-root)
118+
119+
### Runtime Validation
120+
- [ ] Container starts successfully
121+
- [ ] No critical errors in logs
122+
- [ ] Health check passes
123+
- [ ] Web interface loads
124+
- [ ] Database connection works
125+
- [ ] Queue jobs run (with workers > 0)
126+
- [ ] Custom addons can be loaded
127+
128+
### Security Validation
129+
- [ ] Running as non-root user (openspp)
130+
- [ ] No exposed secrets in environment
131+
- [ ] Proper file permissions
132+
- [ ] Network isolation works
133+
134+
## Debugging Failed Tests
135+
136+
### Container Won't Start
137+
```bash
138+
# Check logs
139+
docker-compose -f docker-compose.test.yml logs openspp
140+
141+
# Check detailed error
142+
docker-compose -f docker-compose.test.yml up openspp
143+
144+
# Shell into container
145+
docker-compose -f docker-compose.test.yml run openspp /bin/bash
146+
```
147+
148+
### Database Connection Issues
149+
```bash
150+
# Test database connectivity
151+
docker-compose -f docker-compose.test.yml exec openspp \
152+
pg_isready -h db -U openspp
153+
154+
# Check database logs
155+
docker-compose -f docker-compose.test.yml logs db
156+
```
157+
158+
### Module Import Errors
159+
```bash
160+
# Check Python environment
161+
docker-compose -f docker-compose.test.yml exec openspp \
162+
python3 -c "import odoo; print(odoo.__version__)"
163+
164+
# List available modules
165+
docker-compose -f docker-compose.test.yml exec openspp \
166+
openspp-server --database=openspp_test --list-modules
167+
```
168+
169+
## Test Different Registry
170+
171+
To test images from a different registry:
172+
173+
```bash
174+
# Test from Docker Hub
175+
REGISTRY=docker.io docker-compose -f docker-compose.test.yml up -d
176+
177+
# Test from local registry
178+
REGISTRY=localhost:5000 docker-compose -f docker-compose.test.yml up -d
179+
```
180+
181+
## Automated CI Testing
182+
183+
The GitHub Actions workflow automatically tests images on:
184+
- Pull requests
185+
- Weekly scheduled builds
186+
- Manual workflow dispatches
187+
188+
To manually trigger tests:
189+
1. Go to [Actions](https://github.com/OpenSPP/openspp-packaging-docker/actions)
190+
2. Select "Docker Build and Push"
191+
3. Click "Run workflow"
192+
4. Select branch and options
193+
194+
## Clean Up
195+
196+
After testing:
197+
198+
```bash
199+
# Stop and remove containers
200+
docker-compose -f docker-compose.test.yml down
201+
202+
# Remove volumes
203+
docker-compose -f docker-compose.test.yml down -v
204+
205+
# Remove test images
206+
docker rmi $(docker images | grep openspp | awk '{print $3}')
207+
208+
# Full cleanup
209+
./test-images.sh clean
210+
```
211+
212+
## Reporting Issues
213+
214+
If tests fail:
215+
1. Capture the error logs
216+
2. Note the image tag and registry
217+
3. Document the test scenario
218+
4. Report at [GitHub Issues](https://github.com/OpenSPP/openspp-packaging-docker/issues)

docker-compose.test.yml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# ABOUTME: Docker Compose configuration for testing OpenSPP images
2+
# ABOUTME: Quick validation that built images work correctly with database
3+
4+
version: '3.8'
5+
6+
services:
7+
# PostgreSQL Database
8+
db:
9+
image: postgres:15-alpine
10+
container_name: openspp-test-db
11+
environment:
12+
POSTGRES_USER: openspp
13+
POSTGRES_PASSWORD: openspp
14+
POSTGRES_DB: openspp_test
15+
volumes:
16+
- test-db-data:/var/lib/postgresql/data
17+
networks:
18+
- openspp-test
19+
healthcheck:
20+
test: ["CMD-SHELL", "pg_isready -U openspp"]
21+
interval: 10s
22+
timeout: 5s
23+
retries: 5
24+
25+
# OpenSPP Application (Ubuntu variant)
26+
openspp:
27+
image: ${REGISTRY:-docker.acn.fr}/openspp/openspp:${IMAGE_TAG:-latest}
28+
container_name: openspp-test-app
29+
depends_on:
30+
db:
31+
condition: service_healthy
32+
environment:
33+
# Database Configuration
34+
DB_HOST: db
35+
DB_PORT: 5432
36+
DB_USER: openspp
37+
DB_PASSWORD: openspp
38+
DB_NAME: openspp_test
39+
40+
# Odoo Configuration
41+
ODOO_ADMIN_PASSWORD: admin
42+
ODOO_LIST_DB: True
43+
ODOO_LOG_LEVEL: info
44+
ODOO_WORKERS: 2
45+
ODOO_WITHOUT_DEMO: false
46+
47+
# Initialize database on first run
48+
INIT_DATABASE: ${INIT_DATABASE:-false}
49+
INSTALL_MODULES: ${INSTALL_MODULES:-base,web}
50+
ports:
51+
- "8069:8069"
52+
- "8072:8072"
53+
volumes:
54+
- test-openspp-data:/var/lib/openspp
55+
- ./custom-addons:/mnt/extra-addons:ro
56+
networks:
57+
- openspp-test
58+
healthcheck:
59+
test: ["CMD", "curl", "-fs", "http://localhost:8069/web/health"]
60+
interval: 30s
61+
timeout: 10s
62+
retries: 3
63+
start_period: 60s
64+
65+
# Alternative: OpenSPP Slim variant (commented out by default)
66+
# Uncomment to test slim image instead
67+
# openspp-slim:
68+
# image: ${REGISTRY:-docker.acn.fr}/openspp/openspp:${IMAGE_TAG:-latest}-slim
69+
# container_name: openspp-test-slim
70+
# depends_on:
71+
# db:
72+
# condition: service_healthy
73+
# environment:
74+
# DB_HOST: db
75+
# DB_PORT: 5432
76+
# DB_USER: openspp
77+
# DB_PASSWORD: openspp
78+
# DB_NAME: openspp_test_slim
79+
# ODOO_ADMIN_PASSWORD: admin
80+
# ODOO_LIST_DB: True
81+
# ODOO_LOG_LEVEL: info
82+
# ODOO_WORKERS: 2
83+
# INIT_DATABASE: ${INIT_DATABASE:-false}
84+
# ports:
85+
# - "8070:8069"
86+
# - "8073:8072"
87+
# volumes:
88+
# - test-openspp-slim-data:/var/lib/openspp
89+
# - ./custom-addons:/mnt/extra-addons:ro
90+
# networks:
91+
# - openspp-test
92+
# healthcheck:
93+
# test: ["CMD", "curl", "-fs", "http://localhost:8069/web/health"]
94+
# interval: 30s
95+
# timeout: 10s
96+
# retries: 3
97+
# start_period: 60s
98+
99+
volumes:
100+
test-db-data:
101+
test-openspp-data:
102+
test-openspp-slim-data:
103+
104+
networks:
105+
openspp-test:
106+
driver: bridge
107+
name: openspp-test-network

0 commit comments

Comments
 (0)