Files
metabuilder/txt/MULTI_BACKEND_TESTING_2026-02-06.md
2026-03-09 22:30:41 +00:00

6.7 KiB

DBAL Multi-Backend Testing Infrastructure

Date: 2026-02-06
Status: Infrastructure Complete, Ready for Testing

Overview

Created comprehensive multi-backend testing infrastructure to validate DBAL daemon across all supported database backends.

Supported Backends

Backend Type Status Notes
sqlite SQL Tested In-memory, baseline tests passing (17/17)
sqlite_file SQL 🔧 Ready File-based persistence
postgres SQL 🔧 Ready PostgreSQL 15 direct connection
mysql SQL 🔧 Ready MySQL 8.0 direct connection
mongodb NoSQL 🔧 Ready MongoDB 7.0 document store
prisma_postgres ORM 🔧 Ready Prisma with auto-schema generation

Infrastructure Components

1. Enhanced docker-compose.yml

Added 3 new database services:

  • MySQL 8.0: Port 3306, user/pass: metabuilder/metabuilder
  • MongoDB 7.0: Port 27017, user/pass: metabuilder/metabuilder
  • Postgres (existing): Port 5432, for both direct and Prisma testing

Health Checks: All services have health checks to ensure readiness

Volumes: Persistent storage for each database:

  • postgres-data
  • mysql-data
  • mongodb-data

2. Test Matrix Script

File: dbal/production/tests/integration/test_matrix.py

Features:

  • Run same integration test suite against all backends
  • Automatic daemon restart per backend
  • Health check waiting before tests
  • Prisma schema auto-generation
  • Detailed result reporting
  • Stop-on-failure option

Usage:

# Test all backends
./dev-container.py test-matrix

# Test specific backend
./dev-container.py test-matrix --backend postgres
./dev-container.py test-matrix --backend mysql
./dev-container.py test-matrix --backend mongodb

# Stop on first failure
./dev-container.py test-matrix --stop-on-fail

3. Dev Container Commands

New Command: test-matrix

python3 dev-container.py test-matrix --help

Options:

  • --backend [all|sqlite|sqlite_file|postgres|mysql|mongodb|prisma_postgres]
  • --stop-on-fail - Stop testing on first backend failure

4. Backend Configurations

Each backend has specific configuration:

SQLite (Memory):

{
  "adapter": "sqlite",
  "database_url": ":memory:"
}

SQLite (File):

{
  "adapter": "sqlite",
  "database_url": "/tmp/metabuilder_test.db"
}

PostgreSQL:

{
  "adapter": "postgres",
  "database_url": "postgresql://metabuilder:metabuilder@postgres:5432/metabuilder"
}

MySQL:

{
  "adapter": "mysql",
  "database_url": "mysql://metabuilder:metabuilder@mysql:3306/metabuilder"
}

MongoDB:

{
  "adapter": "mongodb",
  "database_url": "mongodb://metabuilder:metabuilder@mongodb:27017/metabuilder?authSource=admin"
}

Prisma (PostgreSQL):

{
  "adapter": "prisma",
  "database_url": "postgresql://metabuilder:metabuilder@postgres:5432/metabuilder_prisma"
}

Test Matrix Workflow

  1. Start Databases:

    cd dockerconan
    docker-compose up -d
    
  2. Wait for Health:

    • PostgreSQL: pg_isready check
    • MySQL: mysqladmin ping check
    • MongoDB: mongosh ping check
  3. For Each Backend:

    • Stop existing daemon
    • Generate Prisma schema (if needed)
    • Write backend config to /tmp/test_config.json
    • Start daemon with config
    • Wait for daemon health check
    • Run integration test suite
    • Collect results (passed/failed/total)
    • Stop daemon
  4. Report Results:

    • Per-backend status (PASS/FAIL)
    • Test counts (passed/failed/total)
    • Overall success rate
    • Daemon logs on failure

Expected Test Matrix Output

🎯 DBAL Multi-Backend Test Matrix
Testing: sqlite, sqlite_file, postgres, mysql, mongodb, prisma_postgres

================================================================================
Testing Backend: sqlite
================================================================================
  ✓ sqlite is healthy
  🚀 Starting daemon with sqlite backend...
  ✓ Daemon is ready on port 8080
  🧪 Running tests for sqlite...
  ✓ 17/17 tests passed

================================================================================
Testing Backend: postgres
================================================================================
  ⏳ Waiting for postgres to be healthy...
  ✓ postgres is healthy
  🚀 Starting daemon with postgres backend...
  ✓ Daemon is ready on port 8080
  🧪 Running tests for postgres...
  ✓ 17/17 tests passed

[... continues for each backend ...]

================================================================================
DBAL MULTI-BACKEND TEST MATRIX SUMMARY
================================================================================

sqlite               ✅ PASS
  Tests: 17/17 passed

postgres             ✅ PASS
  Tests: 17/17 passed

mysql                ✅ PASS
  Tests: 17/17 passed

mongodb              ✅ PASS
  Tests: 17/17 passed

prisma_postgres      ✅ PASS
  Tests: 17/17 passed

--------------------------------------------------------------------------------
Total: 6/6 backends passing
================================================================================

Next Steps

  1. Start all databases:

    cd dockerconan
    docker-compose up -d
    
  2. Run test matrix:

    python3 dev-container.py test-matrix
    
  3. Investigate failures (if any):

    # Check specific backend
    python3 dev-container.py test-matrix --backend postgres
    
    # View daemon logs
    docker-compose exec dev tail -100 /tmp/daemon_postgres.log
    

Implementation Status

Docker Compose: MySQL, MongoDB services added
Test Matrix Script: Complete with all features
Dev Container Integration: test-matrix command added
Backend Configs: All 6 backends defined
Health Checks: Wait for readiness before tests
Prisma Support: Auto-schema generation from YAML

🔧 Ready to Test: All infrastructure in place, ready to execute full test matrix

Files Modified/Created

  1. dockerconan/docker-compose.yml - Added MySQL, MongoDB services
  2. dbal/production/tests/integration/test_matrix.py - Multi-backend test runner (NEW)
  3. dockerconan/dev-container.py - Added test-matrix command
  4. txt/MULTI_BACKEND_TESTING_2026-02-06.md - This documentation

Architecture Benefits

  • Single Test Suite: Same tests validate all backends
  • Automated: No manual configuration per backend
  • Reproducible: Docker ensures consistent environment
  • Comprehensive: Tests all supported adapters
  • CI/CD Ready: Can run in automated pipelines
  • Fast Feedback: Parallel testing possible