refactor(eventcore-postgres): replace testcontainers with docker-compose #224

Merged
jwilger merged 7 commits from refactor/remove-testcontainers into main 2025-12-27 13:39:27 -08:00
jwilger commented 2025-12-27 11:30:27 -08:00 (Migrated from github.com)

Summary

Replace testcontainers library with docker-compose for test infrastructure due to fundamental issues with container accumulation and years-old bugs.

Changes

  • Add docker-compose.yml with configurable POSTGRES_PORT and POSTGRES_VERSION
  • Add .env.example with default configuration values
  • Replace PostgresTestFixture to use docker-compose instead of testcontainers
  • Add IsolatedPostgresFixture for tests requiring database-level isolation
  • Move unit tests from src/lib.rs to new integration test file
  • Remove wasteful test that only validated Postgres functionality
  • Update .gitignore to exclude postgres-data volume and .env files
  • Remove testcontainers dependencies from Cargo.toml

Benefits

  • Simpler: No testcontainers complexity, just docker-compose
  • Faster: Container persists between test runs
  • Debuggable: Can connect to localhost:5432 during test failures
  • Reliable: No container accumulation or name conflicts
  • Standard: docker-compose is industry-standard and well-understood

Test Results

All 151 tests pass with the new infrastructure.

🤖 Generated with Claude Code

## Summary Replace testcontainers library with docker-compose for test infrastructure due to fundamental issues with container accumulation and years-old bugs. ## Changes - Add docker-compose.yml with configurable POSTGRES_PORT and POSTGRES_VERSION - Add .env.example with default configuration values - Replace PostgresTestFixture to use docker-compose instead of testcontainers - Add IsolatedPostgresFixture for tests requiring database-level isolation - Move unit tests from src/lib.rs to new integration test file - Remove wasteful test that only validated Postgres functionality - Update .gitignore to exclude postgres-data volume and .env files - Remove testcontainers dependencies from Cargo.toml ## Benefits - **Simpler**: No testcontainers complexity, just docker-compose - **Faster**: Container persists between test runs - **Debuggable**: Can connect to localhost:5432 during test failures - **Reliable**: No container accumulation or name conflicts - **Standard**: docker-compose is industry-standard and well-understood ## Test Results All 151 tests pass with the new infrastructure. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
claude[bot] (Migrated from github.com) approved these changes 2025-12-27 11:41:01 -08:00
claude[bot] (Migrated from github.com) left a comment

Clean refactoring. Tests passing across all Postgres versions.

Clean refactoring. Tests passing across all Postgres versions.
claude[bot] (Migrated from github.com) requested changes 2025-12-27 11:42:01 -08:00
claude[bot] (Migrated from github.com) left a comment

Critical resource leak: contract tests create ~20 databases per test run that never get cleaned up.

Critical resource leak: contract tests create ~20 databases per test run that never get cleaned up.
@ -180,3 +210,71 @@ impl Event for TestEvent {
&self.stream_id
claude[bot] (Migrated from github.com) commented 2025-12-27 11:42:01 -08:00

Databases accumulate indefinitely. Consider: (1) document cleanup command in struct docs, (2) add explicit cleanup function, (3) evaluate if this fixture is needed vs PostgresTestFixture with unique stream IDs.

Databases accumulate indefinitely. Consider: (1) document cleanup command in struct docs, (2) add explicit cleanup function, (3) evaluate if this fixture is needed vs PostgresTestFixture with unique stream IDs.
claude[bot] (Migrated from github.com) commented 2025-12-27 11:42:01 -08:00

String formatting for CREATE DATABASE is acceptable since database_name is UUID-based. Document that this can't use sqlx parameters (identifiers aren't parameterizable).

String formatting for CREATE DATABASE is acceptable since database_name is UUID-based. Document that this can't use sqlx parameters (identifiers aren't parameterizable).
claude[bot] (Migrated from github.com) commented 2025-12-27 11:42:01 -08:00

Critical resource leak: Each contract test invocation calls IsolatedPostgresFixture::new(), creating a new database. With ~20 contract tests, this creates 20 databases per test run that never get cleaned up.

The contract tests use unique stream IDs (via UUIDs in contract.rs:76), so they don't need database-level isolation. Use PostgresTestFixture instead - stream isolation is sufficient.

**Critical resource leak:** Each contract test invocation calls IsolatedPostgresFixture::new(), creating a new database. With ~20 contract tests, this creates 20 databases per test run that never get cleaned up. The contract tests use unique stream IDs (via UUIDs in contract.rs:76), so they don't need database-level isolation. Use PostgresTestFixture instead - stream isolation is sufficient.
claude[bot] (Migrated from github.com) reviewed 2025-12-27 11:51:23 -08:00
claude[bot] (Migrated from github.com) left a comment
No description provided.
Resource leak fixed with cleanup_old_test_databases().
claude[bot] (Migrated from github.com) approved these changes 2025-12-27 13:35:45 -08:00
claude[bot] (Migrated from github.com) left a comment

Clean refactoring with proper resource management. Previous leak issue resolved.

Clean refactoring with proper resource management. Previous leak issue resolved.
Sign in to join this conversation.
No description provided.