Skip to content

Commit

Permalink
retry
Browse files Browse the repository at this point in the history
  • Loading branch information
colin-ho committed Feb 23, 2024
1 parent d0a9eef commit 1e761a5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
19 changes: 19 additions & 0 deletions tests/integration/sql/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from __future__ import annotations

import pytest
import sqlalchemy
import tenacity

TRINO_URL = "trino://user@localhost:8080/tpch"


@tenacity.retry(
stop=tenacity.stop_after_delay(60),
retry=tenacity.retry_if_exception_type(sqlalchemy.exc.DBAPIError),
wait=tenacity.wait_fixed(5),
reraise=True,
)
@pytest.fixture(scope="session")
def check_db_server_initialized() -> None:
with sqlalchemy.create_engine(TRINO_URL).connect() as conn:
conn.execute(sqlalchemy.text("SELECT 1"))
9 changes: 4 additions & 5 deletions tests/integration/sql/test_trino.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
import pytest

import daft

URL = "trino://user@localhost:8080/tpch"
from tests.integration.sql.conftest import TRINO_URL


@pytest.mark.integration()
def test_trino_create_dataframe_ok() -> None:
df = daft.read_sql("SELECT * FROM tpch.sf1.nation", URL)
pd_df = pd.read_sql("SELECT * FROM tpch.sf1.nation", URL)
def test_trino_create_dataframe_ok(check_db_server_initialized) -> None:
df = daft.read_sql("SELECT * FROM tpch.sf1.nation", TRINO_URL)
pd_df = pd.read_sql("SELECT * FROM tpch.sf1.nation", TRINO_URL)
assert df.to_pandas().equals(pd_df)

0 comments on commit 1e761a5

Please sign in to comment.