Skip to content

fix: PostgreSQL configuration mismatches between CI/CD and TestContainers #55

@dfcoffin

Description

@dfcoffin

Description

Critical configuration mismatches exist between the CI/CD pipeline and local TestContainers setup that prevent proper PostgreSQL integration testing. These mismatches explain why PostgreSQL tests may pass locally for some team members but fail in CI/CD environments.

Configuration Mismatches Identified

1. PostgreSQL Version Mismatch ⚠️

CI/CD Pipeline (.github/workflows/ci.yml:33):

postgres:
  image: postgres:15  # ← CI/CD uses PostgreSQL 15

TestContainers (openespi-common/src/test/java/.../DataCustodianApplicationPostgresTest.java:60):

static PostgreSQLContainer postgresContainer = new PostgreSQLContainer("postgres:18")

2. Flyway Migration Locations - CRITICAL 🔴

Incorrect Configuration in testcontainers profiles:

  • openespi-datacustodian/src/test/resources/application-testcontainers-postgresql.yml:29
  • openespi-thirdparty/src/test/resources/application-testcontainers-postgresql.yml:29
flyway:
  locations: classpath:db/migration/postgresql  # ← WRONG - this path does NOT exist!

Correct Configuration (openespi-common/src/test/resources/application-test-postgresql.yml:19):

flyway:
  locations: classpath:db/migration,classpath:db/vendor/postgres

Actual Migration Structure:

openespi-common/src/main/resources/db/
├── migration/
│   ├── V1__Create_Base_Tables.sql
│   └── V3__Create_additiional_Base_Tables.sql
└── vendor/
    ├── h2/V2__H2_Specific_Tables.sql
    ├── mysql/V2__MySQL_Specific_Tables.sql
    └── postgres/V2__PostgreSQL_Specific_Tables.sql

Why Tests Pass Locally

The DataCustodianApplicationPostgresTest programmatically overrides the incorrect testcontainers profile configuration:

@DynamicPropertySource
static void configureProperties(DynamicPropertyRegistry registry) {
    // Correct Flyway paths injected at runtime
    registry.add("spring.flyway.locations", 
        () -> "classpath:db/migration,classpath:db/vendor/postgres");
}

This means:

  • ✅ Running DataCustodianApplicationPostgresTest.java directly → PASSES (uses correct paths via @DynamicPropertySource)
  • ❌ Running with mvn verify -Pintegration-tests → FAILS (uses incorrect paths from application-testcontainers-postgresql.yml)
  • ⚠️ Currently disabled via @Disabled annotation due to Issue PostgreSQL TestContainers failing: UUID column type mismatch in migrations #53

Impact

  1. Integration tests using the testcontainers profile will fail because Flyway cannot find migrations
  2. PostgreSQL version inconsistency between CI/CD and local testing environments
  3. False positives - tests appear to pass locally because @DynamicPropertySource overrides broken configuration
  4. Hidden from CI/CD - PostgreSQL tests currently disabled due to Issue PostgreSQL TestContainers failing: UUID column type mismatch in migrations #53, masking these configuration issues

Recommended Resolution

Phase 1: Fix Flyway Configuration (Immediate)

Update the following files to use correct Flyway migration paths:

File 1: openespi-datacustodian/src/test/resources/application-testcontainers-postgresql.yml

flyway:
  enabled: true
  baseline-on-migrate: true
  locations: classpath:db/migration,classpath:db/vendor/postgres  # ← Fix path

File 2: openespi-thirdparty/src/test/resources/application-testcontainers-postgresql.yml

flyway:
  enabled: true
  baseline-on-migrate: true
  locations: classpath:db/migration,classpath:db/vendor/postgres  # ← Fix path

Phase 2: Align PostgreSQL Versions (Recommended)

Update CI/CD to match TestContainers version:

File: .github/workflows/ci.yml:33

postgres:
  image: postgres:18  # ← Upgrade from postgres:15 to postgres:18

Rationale:

  • Ensures environment consistency between CI/CD and local testing
  • PostgreSQL 18 is the latest stable release
  • Aligns with existing TestContainers configuration

Phase 3: Post-Issue #53 Resolution

After Issue #53 (UUID CHAR(36) type mismatch) is resolved via the MULTI_PHASE schema compliance plan:

  1. Remove @Disabled annotation from DataCustodianApplicationPostgresTest
  2. Verify integration tests pass with corrected Flyway paths
  3. Validate both CI/CD and local environments produce consistent results

Related Issues

Files Requiring Changes

  • .github/workflows/ci.yml - Update postgres image to version 18
  • openespi-datacustodian/src/test/resources/application-testcontainers-postgresql.yml - Fix Flyway locations
  • openespi-thirdparty/src/test/resources/application-testcontainers-postgresql.yml - Fix Flyway locations

Acceptance Criteria

  • All testcontainers-postgresql.yml files use correct Flyway migration paths
  • CI/CD PostgreSQL version matches TestContainers (postgres:18)
  • Integration tests run successfully with mvn verify -Pintegration-tests -Dspring.profiles.active=testcontainers-postgresql
  • Configuration mismatches documented and resolved
  • Tests remain disabled until Issue PostgreSQL TestContainers failing: UUID column type mismatch in migrations #53 is resolved (to avoid UUID type mismatch failures)

Priority

Medium - These issues are currently masked by disabled PostgreSQL tests, but must be resolved before re-enabling PostgreSQL integration testing after Issue #53 is fixed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions