Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: Get container host addresses from testcontainers (#3946)
* fix: get container host addresses from testcontainers

Signed-off-by: tokoko <togurg14@freeuni.edu.ge>

* resolve trino container host with testcontainers

Signed-off-by: tokoko <togurg14@freeuni.edu.ge>

---------

Signed-off-by: tokoko <togurg14@freeuni.edu.ge>
  • Loading branch information
tokoko authored Mar 5, 2024
commit 2cf1a0fa9efbceca2e79c5e375796696e248e3d9
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,11 @@ def __init__(
"must be include into pytest plugins"
)
self.exposed_port = self.container.get_exposed_port("8080")
self.container_host = self.container.get_container_host_ip()
self.client = Trino(
user="user",
catalog="memory",
host="localhost",
host=self.container_host,
port=self.exposed_port,
source="trino-python-client",
http_scheme="http",
Expand Down Expand Up @@ -123,7 +124,7 @@ def get_prefixed_table_name(self, suffix: str) -> str:

def create_offline_store_config(self) -> FeastConfigBaseModel:
return TrinoOfflineStoreConfig(
host="localhost",
host=self.container_host,
port=self.exposed_port,
catalog="memory",
dataset=self.project_name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ def create_online_store(self) -> Dict[str, str]:
container=self.container, predicate=log_string_to_wait_for, timeout=10
)
exposed_port = self.container.get_exposed_port("6379")
return {"type": "redis", "connection_string": f"localhost:{exposed_port},db=0"}
container_host = self.container.get_container_host_ip()
return {
"type": "redis",
"connection_string": f"{container_host}:{exposed_port},db=0",
}

def teardown(self):
self.container.stop()
6 changes: 4 additions & 2 deletions sdk/python/tests/unit/test_sql_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,11 @@ def pg_registry():
)
logger.info("Waited for %s seconds until postgres container was up", waited)
container_port = container.get_exposed_port(5432)
container_host = container.get_container_host_ip()

registry_config = RegistryConfig(
registry_type="sql",
path=f"postgresql://{POSTGRES_USER}:{POSTGRES_PASSWORD}@127.0.0.1:{container_port}/{POSTGRES_DB}",
path=f"postgresql://{POSTGRES_USER}:{POSTGRES_PASSWORD}@{container_host}:{container_port}/{POSTGRES_DB}",
)

yield SqlRegistry(registry_config, "project", None)
Expand Down Expand Up @@ -100,10 +101,11 @@ def mysql_registry():
)
logger.info("Waited for %s seconds until mysql container was up", waited)
container_port = container.get_exposed_port(3306)
container_host = container.get_container_host_ip()

registry_config = RegistryConfig(
registry_type="sql",
path=f"mysql+pymysql://{POSTGRES_USER}:{POSTGRES_PASSWORD}@127.0.0.1:{container_port}/{POSTGRES_DB}",
path=f"mysql+pymysql://{POSTGRES_USER}:{POSTGRES_PASSWORD}@{container_host}:{container_port}/{POSTGRES_DB}",
)

yield SqlRegistry(registry_config, "project", None)
Expand Down