gravitino
gravitino copied to clipboard
[#9025] : fix(test): Fix PostgreSQL container connection issues in integration tests
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