apache / apache/gravitino

[Bug report] PostgreSQL integration tests fail due to incorrect container port mapping

Open
#9,025 7 comments 0 reactions 1 assignee Claimed by @bharos View on GitHub
improvement
Dominant language
Java
Stars
3.2k
Forks
935
Avg merge
1d 17h
Merged PRs (30d)
339

Description

### Version

main branch

### Describe what's wrong

PostgreSQL integration tests fail to connect to the container because the code uses internal container networking instead of host-mapped ports.

**Issue:**
- Tests use `getContainerIpAddress():5432` which points to internal Docker network (e.g., `172.17.0.2:5432`)
- This address is not accessible from the host running the tests
- Docker maps container port 5432 to a random host port, but tests don't use the mapped port

**Expected:** Tests should connect using host-accessible endpoints
**Actual:** Connection failures and test timeouts

### Error message and/or stacktrace

java.sql.SQLException: Connection to 172.17.0.2:5432 refused.
Check that the hostname and port are correct and that the
postmaster is accepting TCP/IP connections.

OR

[Test hangs indefinitely due to connection timeout]

Logs show:
2025-11-05 ERROR PostgreSQLContainer - Command [pg_isready, -h, localhost, -U, root] exited with 2
2025-11-05 ERROR PostgreSQLContainer - stderr: pg_isready: could not connect to server: Connection refused

### How to reproduce

```
# What Docker actually does:
docker run -p 32768:5432 postgres:13
# ↑ ↑
# host port container port

# Old code tries: 172.17.0.2:5432
# Should use: localhost:32768
```

### Additional context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.