Skip to content

Commit bcc45ba

Browse files
committed
fixed startup container and wait it
1 parent 83d700f commit bcc45ba

File tree

7 files changed

+30
-2
lines changed

7 files changed

+30
-2
lines changed

docker-compose-tls.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,4 @@ services:
1010
volumes:
1111
- ./ydb_certs:/ydb_certs
1212
environment:
13-
- YDB_USE_IN_MEMORY_PDISKS=true
1413
- YDB_ENABLE_COLUMN_TABLES=true

docker-compose.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@ services:
77
- 2136:2136
88
hostname: localhost
99
environment:
10-
- YDB_USE_IN_MEMORY_PDISKS=true
1110
- YDB_ENABLE_COLUMN_TABLES=true

tests/aio/query/test_query_session_pool.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from typing import Optional
88

9+
from tests.conftest import wait_container_ready_async
910
from ydb.aio.query.pool import QuerySessionPool
1011
from ydb.aio.query.session import QuerySession, QuerySessionStateEnum
1112
from ydb.aio.query.transaction import QueryTxContext
@@ -164,6 +165,7 @@ async def test_no_session_leak(self, driver, docker_project):
164165

165166
docker_project.start()
166167
await pool.stop()
168+
await wait_container_ready_async(driver)
167169

168170
@pytest.mark.asyncio
169171
async def test_acquire_no_race_condition(self, driver):

tests/aio/test_connection_pool.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import asyncio
22
from unittest.mock import MagicMock
33

4+
from tests.conftest import wait_container_ready_async
45
from ydb.aio.driver import Driver
56
import pytest
67
import ydb
@@ -109,6 +110,7 @@ async def restart_docker():
109110

110111
docker_project.start()
111112
await driver.stop()
113+
await wait_container_ready_async(driver)
112114

113115

114116
@pytest.mark.asyncio
@@ -133,6 +135,7 @@ async def test_disconnect_by_call(endpoint, database, docker_project):
133135
assert len(driver._store.connections) == 0
134136
docker_project.start()
135137
await driver.stop()
138+
await wait_container_ready_async(driver)
136139

137140

138141
@pytest.mark.asyncio

tests/aio/test_session_pool.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import pytest
44
import ydb
5+
from tests.conftest import wait_container_ready_async
56

67

78
@pytest.mark.asyncio
@@ -90,6 +91,7 @@ async def test_no_cluster_endpoints_no_failure(driver, docker_project):
9091
await pool.release(sess)
9192
assert pool._active_count == 0
9293
await pool.stop()
94+
await wait_container_ready_async(driver)
9395

9496

9597
@pytest.mark.asyncio
@@ -144,3 +146,4 @@ async def test_no_session_leak(driver, docker_project):
144146

145147
docker_project.start()
146148
await pool.stop()
149+
await wait_container_ready_async(driver)

tests/conftest.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import asyncio
12
import os
23

34
import pytest
@@ -30,6 +31,25 @@ def wait_container_ready(driver):
3031
raise RuntimeError("Container is not ready after timeout.")
3132

3233

34+
async def wait_container_ready_async(driver):
35+
await driver.wait(timeout=30)
36+
37+
async with ydb.aio.SessionPool(driver, 1) as pool:
38+
39+
started_at = time.time()
40+
while time.time() - started_at < 120:
41+
try:
42+
async with pool.checkout() as session:
43+
await session.execute_scheme("create table `.sys_health/test_table` (A int32, primary key(A));")
44+
45+
return True
46+
47+
except ydb.Error:
48+
await asyncio.sleep(1)
49+
50+
raise RuntimeError("Container is not ready after timeout.")
51+
52+
3353
@pytest.fixture(scope="module")
3454
def endpoint(pytestconfig, module_scoped_container_getter):
3555
with ydb.Driver(endpoint="localhost:2136", database="/local") as driver:

tests/query/test_query_session_pool.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
from typing import Optional
99

10+
from tests.conftest import wait_container_ready
1011
from ydb.query.pool import QuerySessionPool
1112
from ydb.query.session import QuerySession, QuerySessionStateEnum
1213
from ydb.query.transaction import QueryTxContext
@@ -150,6 +151,7 @@ def test_no_session_leak(self, driver_sync, docker_project):
150151

151152
docker_project.start()
152153
pool.stop()
154+
wait_container_ready(driver)
153155

154156
def test_execute_with_retries_async(self, pool: QuerySessionPool):
155157
fut = pool.execute_with_retries_async("select 1;")

0 commit comments

Comments
 (0)