You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TrinoContainer.get_connection_url() returns the internal port, not the mapped host port #1111
TrinoContainer.get_connection_url() builds the URL as trino://{user}@{host}:{self.port}, and self.port is the fixed container-internal port set in __init__ (8080 by default). It's never resolved through get_exposed_port(). Since Docker maps that to a random host port, the URL this method returns can't actually connect to anything.
Repro (4.15.0):
fromtestcontainers.community.trinoimportTrinoContainerfromsqlalchemyimportcreate_engine, textwithTrinoContainer() astrino:
print(trino.port) # 8080print(trino.get_exposed_port(trino.port)) # the real mapped port, e.g. 58092print(trino.get_connection_url()) # trino://test@localhost:8080 - wrongengine=create_engine(trino.get_connection_url())
withengine.connect() asconn:
conn.execute(text("select 1")) # ConnectionRefusedError / TrinoConnectionError
Building the URL manually with get_exposed_port() instead of self.port connects fine.
For comparison, CockroachDBContainer/CrateDBContainer don't have this problem since they route through _create_connection_url(), which does resolve the exposed port. Looks like an isolated miss in the Trino module rather than a pattern elsewhere.
Suggested fix, matching how the other modules do it:
Activity
fix(trino): resolve the mapped host port in get_connection_url() (tes…