|
| 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) |
0 commit comments