Skip to content

Commit 57c031c

Browse files
committed
fix: Correct YugabyteDB container startup command and update connection URI with proper credentials.
1 parent 35a6b07 commit 57c031c

3 files changed

Lines changed: 6 additions & 4 deletions

File tree

docs/supported-databases/yugabyte.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Usage Example
2424
@pytest.fixture(scope="session")
2525
def yugabyte_uri(yugabyte_service: YugabyteService) -> str:
2626
opts = "&".join(f"{k}={v}" for k, v in yugabyte_service.driver_opts.items())
27-
return f"postgresql://root@{yugabyte_service.host}:{yugabyte_service.port}/{yugabyte_service.database}?{opts}"
27+
return f"postgresql://yugabyte:yugabyte@{yugabyte_service.host}:{yugabyte_service.port}/{yugabyte_service.database}?{opts}"
2828
2929
def test_yugabyte_service(yugabyte_uri: str) -> None:
3030
with psycopg.connect(yugabyte_uri) as conn:

src/pytest_databases/docker/yugabyte.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def yugabyte_responsive(_service: ServiceContainer) -> bool:
7272
check=yugabyte_responsive,
7373
name=container_name,
7474
command="bin/yugabyted start --background=false",
75-
exec_after_start=f'bin/ysqlsh -U yugabyte -c "CREATE DATABASE {db_name};"',
75+
exec_after_start=f"sh -c 'bin/ysqlsh -h $(hostname) -U yugabyte -d yugabyte -c \"CREATE DATABASE {db_name};\"'",
7676
transient=xdist_yugabyte_isolation_level == "server",
7777
timeout=60, # YugabyteDB needs longer startup time
7878
) as service:

tests/test_yugabyte.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,16 @@ def xdist_yugabyte_isolation_level():
8888
def test_one(yugabyte_service) -> None:
8989
opts = "&".join(f"{k}={v}" for k, v in yugabyte_service.driver_opts.items())
9090
with psycopg.connect(
91-
f"postgresql://yugabyte:yugabyte@{yugabyte_service.host}:{yugabyte_service.port}/{yugabyte_service.database}?{opts}"
91+
f"postgresql://yugabyte:yugabyte@{yugabyte_service.host}:{yugabyte_service.port}/{yugabyte_service.database}?{opts}",
92+
autocommit=True,
9293
) as conn:
9394
conn.execute("CREATE DATABASE foo")
9495
9596
def test_two(yugabyte_service) -> None:
9697
opts = "&".join(f"{k}={v}" for k, v in yugabyte_service.driver_opts.items())
9798
with psycopg.connect(
98-
f"postgresql://yugabyte:yugabyte@{yugabyte_service.host}:{yugabyte_service.port}/{yugabyte_service.database}?{opts}"
99+
f"postgresql://yugabyte:yugabyte@{yugabyte_service.host}:{yugabyte_service.port}/{yugabyte_service.database}?{opts}",
100+
autocommit=True,
99101
) as conn:
100102
conn.execute("CREATE DATABASE foo")
101103
""")

0 commit comments

Comments
 (0)