This directory includes specialized testing scripts for validating SQLite database access patterns across Docker container boundaries.
Tests multiple Docker containers reading from the same SQLite database.
Purpose: Validate that SQLite's WAL mode works correctly when multiple containers mount and read from the same database file.
Usage:
# Test with 3 reader containers for 30 seconds
uv run scripts/testing/test_readers_containerized.py
# Test with 5 containers reading every 0.2 seconds
uv run scripts/testing/test_readers_containerized.py -c 5 -i 0.2
# Use existing database
uv run scripts/testing/test_readers_containerized.py -p data/sensor_data.dbWhat it does:
- Builds a lightweight Python container image with SQLite
- Spawns N reader containers that mount the database read-only
- Each container performs continuous reads (COUNT, SELECT, AVG queries)
- Displays real-time statistics in a rich UI dashboard
- Reports success rates and performance metrics
Tests concurrent read/write operations across containers.
Purpose: Validate SQLite's WAL mode with one writer and multiple readers in separate containers.
Usage:
# Default: 1 writer + 3 readers for 30 seconds
uv run scripts/testing/test_containers_rw.py
# Higher write rate with more readers
uv run scripts/testing/test_containers_rw.py -r 5 -w 20
# Longer test with faster reads
uv run scripts/testing/test_containers_rw.py -d 60 -i 0.2What it does:
- Builds two container images: reader and writer
- Spawns 1 writer container (read-write mount)
- Spawns N reader containers (read-only mounts)
- Writer generates sensor data at specified rate
- Readers perform continuous queries
- Live dashboard shows both writer and reader statistics
- Final report shows write/read ratios and success rates
- Mount database directory as read-only (
/data:ro) - Use SQLite read-only connection mode (
file:db?mode=ro) - Set
PRAGMA query_only = ONfor safety - Perform various SELECT queries
- Mounts database directory as read-write (
/data) - Uses standard SQLite connection with WAL mode
- Writes sensor data in batches
- Commits periodically for consistency
- Docker installed and running
- Python 3.11+ with uv
- At least 100MB free disk space for container images
- Image Building: Scripts build minimal Python containers (~50MB) on first run
- Volume Mounting: Database directory is mounted into containers
- Process Isolation: Each container runs as separate process
- Statistics Collection: JSON output from containers is parsed in real-time
- Dashboard Display: Rich UI shows live statistics
- Success Rate: > 99%
- Read Errors: 0 (WAL mode handles concurrent access)
- Write Errors: 0 (single writer, no conflicts)
- Performance:
- Reads: < 10ms average
- Writes: < 5ms average (batched)
- "Database is locked": Should NOT occur with WAL mode
- "Permission denied": Check file permissions on database
- "No such file": Ensure database exists before testing
- High read latency: Normal during checkpointing
# Test with increasing reader count
for readers in 1 2 5 10 20; do
uv run scripts/testing/test_readers_containerized.py -c $readers -d 10
done# Test with varying write rates
for rate in 10 50 100 200; do
uv run scripts/testing/test_containers_rw.py -w $rate -d 20
done# Long-running test with realistic rates
uv run scripts/testing/test_containers_rw.py -r 10 -w 30 -d 300 -i 1.0Both scripts provide:
- Real-time dashboard with color-coded status
- Per-container statistics
- Average latency measurements
- Error tracking and reporting
- Final summary with success rates
Containers are automatically removed (--rm flag) when stopped.
To manually clean up:
# Stop all test containers
docker stop $(docker ps -q --filter "name=sensor-")
# Remove test images
docker rmi sensor-reader-test sensor-writer-test- WAL mode is essential for cross-container access
- Read-only mounts prevent accidental writes
- Containers provide perfect process isolation for testing
- Performance may vary based on Docker storage driver