Skip to content

Conversation

@bharos
Copy link
Collaborator

@bharos bharos commented Nov 5, 2025

What changes were proposed in this pull request?

  • Use getMappedPort() instead of hardcoded PG_PORT for proper Docker port mapping
  • Replace getContainerIpAddress() with container.getHost() for host accessibility
  • Add connection timeouts (30s) to prevent hanging connections

Why are the changes needed?

Fixes PostgreSQL connection failures where tests tried to connect to internal container network instead of host-mapped ports.

The Problem:

  • Tests were using getContainerIpAddress():5432 which points to internal Docker network (e.g., 172.17.0.2:5432)
  • This internal address is not accessible from the host running the tests
  • Docker maps container port 5432 to a random host port (e.g., localhost:32768)
  • Without timeouts, failed connections would hang indefinitely, causing test timeouts

The Solution:

  • Use container.getHost():getMappedPort(5432) to get the actual accessible endpoint
  • Add connection timeouts to fail fast instead of hanging

Does this PR introduce any user-facing change?

No user-facing changes. This is an internal test infrastructure fix.

How was this patch tested?

Local Testing:

Ran PostgreSQL integration tests locally to verify connectivity works
Confirmed JDBC URLs now generate correct host-mapped ports
Verified connection timeouts prevent hanging

… in integration tests

- Use getMappedPort() instead of hardcoded PG_PORT for proper Docker port mapping
- Replace getContainerIpAddress() with container.getHost() for host accessibility
- Add connection timeouts (30s) to prevent hanging connections

Fixes PostgreSQL connection failures where tests tried to connect to internal
container network instead of host-mapped ports.
@bharos bharos changed the title [9025] : fix(test): Fix PostgreSQL container connection issues in integration tests [#9025] : fix(test): Fix PostgreSQL container connection issues in integration tests Nov 5, 2025
@bharos bharos force-pushed the postgres-container-port branch from d6b3747 to 74a249f Compare November 5, 2025 21:40
@bharos bharos requested review from FANNG1 and jerqi November 5, 2025 21:43
@bharos bharos self-assigned this Nov 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant