This document describes how to run integration tests for rusty-data database adapters using Podman containers.
- Podman installed
- podman-compose installed
# Install podman-compose (if not already installed)
pip3 install podman-composeThe compose.yml file provides test database containers for all supported database systems.
podman-compose up -dpodman-compose up -d postgres mysqlpodman-compose ps# All containers
podman-compose logs
# Specific container
podman-compose logs postgresAll databases are configured with test credentials:
- Host: localhost
- Port: 5432
- Database: test_db
- User: test_user
- Password: test_password
- Host: localhost
- Port: 3306
- Database: test_db
- User: test_user
- Password: test_password
- Root Password: root_password
- Host: localhost
- Port: 1433
- Database: master (default)
- User: sa
- Password: Test_Password123!
- Host: localhost
- Port: 1521
- Service Name: XE
- User: system
- Password: Test_Password123!
- Enterprise Manager: http://localhost:5500/em
- Host: localhost
- Port: 27017
- Database: test_db
- User: test_user
- Password: test_password
- Auth Database: admin
cargo test --features all-databases -- --test-threads=1# PostgreSQL
cargo test --features postgres -- --test-threads=1
# MySQL
cargo test --features mysql -- --test-threads=1
# SQLite (no container needed)
cargo test --features sqlite
# MongoDB
cargo test --features mongodb -- --test-threads=1
# SQL Server
cargo test --features mssql -- --test-threads=1
# Oracle
cargo test --features oracle -- --test-threads=1Note: The --test-threads=1 flag ensures tests run sequentially to avoid database connection conflicts.
All containers include health checks. Wait for all services to be healthy before running tests:
# Check health status
podman-compose ps
# Wait for all containers to be healthy
while ! podman-compose ps | grep -q "healthy"; do
echo "Waiting for databases to be healthy..."
sleep 2
donepodman-compose stoppodman-compose downpodman-compose down -vOracle XE requires significant memory and startup time (60+ seconds). Check:
# View Oracle logs
podman-compose logs oracle
# Increase shm_size if needed (already set to 1GB in compose.yml)MSSQL tools take time to initialize. Wait 30-60 seconds and check:
podman-compose logs mssqlIf ports are already in use, modify compose.yml to use different host ports:
ports:
- "15432:5432" # Use port 15432 instead of 5432Integration tests should:
- Check if the test database is available (skip if not)
- Create test data
- Run adapter operations
- Clean up test data
- Close connections
Example pattern:
#[tokio::test]
#[ignore] // Ignored by default, run with --ignored or --include-ignored
async fn test_postgres_integration() {
let config = ConnectionConfig {
// ... connection details from above
};
let mut adapter = PostgresAdapter::new();
// Test connection (skip if unavailable)
if !adapter.test_connection(&config, Some("test_password")).await.unwrap() {
println!("PostgreSQL not available, skipping test");
return;
}
// Run tests
adapter.connect(&config, Some("test_password")).await.unwrap();
// ... test operations ...
adapter.disconnect().await.unwrap();
}For CI pipelines, add a step to start test databases:
# Example GitHub Actions
steps:
- name: Start test databases
run: podman-compose up -d
- name: Wait for databases
run: |
timeout 120s bash -c 'until podman-compose ps | grep healthy; do sleep 2; done'
- name: Run integration tests
run: cargo test --features all-databases -- --test-threads=1
- name: Cleanup
run: podman-compose down -v