Skip to content

Commit 87e5017

Browse files
authored
25-1: tests/library: separate fixtures from harness (#16238)
Move module with pytest fixtures out of `ydb/tests/library/harness` and make it a separate (but dependent) library. Part of the `harness` (namely `ydbd` launching framework: `Daemon`, runner etc), is widely used outside of ydb tests, and some of that uses still require py2 compatibility (so that `harness` must run under py2). ydb's own tests (`ydb/tests/functional`) are all pure py3, so requirement for the test fixtures to be py2 compatible is excessive.
1 parent 621bc99 commit 87e5017

20 files changed

+32
-22
lines changed

ydb/tests/functional/audit/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
# but somehow it does not
33
#
44
# for ydb_{cluster, database, ...} fixture family
5-
pytest_plugins = 'ydb.tests.library.harness.ydb_fixtures'
5+
pytest_plugins = 'ydb.tests.library.fixtures'

ydb/tests/functional/audit/test_auditlog.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from ydb import Driver, DriverConfig, SessionPool
1414
from ydb.draft import DynamicConfigClient
1515
from ydb.tests.library.harness.util import LogLevels
16-
from ydb.tests.library.harness.ydb_fixtures import ydb_database_ctx
16+
from ydb.tests.library.fixtures import ydb_database_ctx
1717

1818
logger = logging.getLogger(__name__)
1919

ydb/tests/functional/audit/ya.make

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ DEPENDS(
2323

2424
PEERDIR(
2525
ydb/tests/library
26+
ydb/tests/library/fixtures
2627
ydb/tests/oss/ydb_sdk_import
2728
ydb/public/sdk/python
2829
)

ydb/tests/functional/rename/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
# but somehow it does not
33
#
44
# for ydb_{cluster, database, ...} fixture family
5-
pytest_plugins = 'ydb.tests.library.harness.ydb_fixtures'
5+
pytest_plugins = 'ydb.tests.library.fixtures'

ydb/tests/functional/rename/ya.make

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ DEPENDS(
3232

3333
PEERDIR(
3434
ydb/tests/library
35+
ydb/tests/library/fixtures
3536
ydb/tests/oss/ydb_sdk_import
3637
ydb/public/sdk/python
3738
contrib/python/tornado/tornado-4

ydb/tests/functional/serverless/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# but somehow it does not
1010
#
1111
# for ydb_{cluster, database, ...} fixture family
12-
pytest_plugins = 'ydb.tests.library.harness.ydb_fixtures'
12+
pytest_plugins = 'ydb.tests.library.fixtures'
1313

1414

1515
logger = logging.getLogger(__name__)

ydb/tests/functional/serverless/test_serverless.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def enable_alter_database_create_hive_first(request):
5757
return request.param
5858

5959

60-
# ydb_fixtures.ydb_cluster_configuration local override
60+
# fixtures.ydb_cluster_configuration local override
6161
@pytest.fixture(scope='module')
6262
def ydb_cluster_configuration(enable_alter_database_create_hive_first):
6363
conf = copy.deepcopy(CLUSTER_CONFIG)

ydb/tests/functional/serverless/ya.make

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ DEPENDS(
2222
PEERDIR(
2323
contrib/python/tornado/tornado-4
2424
ydb/tests/library
25+
ydb/tests/library/fixtures
2526
ydb/tests/oss/ydb_sdk_import
2627
ydb/public/sdk/python
2728
)

ydb/tests/functional/tenants/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# but somehow it does not
88
#
99
# for ydb_{cluster, database, ...} fixture family
10-
pytest_plugins = 'ydb.tests.library.harness.ydb_fixtures'
10+
pytest_plugins = 'ydb.tests.library.fixtures'
1111

1212

1313
@pytest.fixture(scope='module')

ydb/tests/functional/tenants/test_auth_system_views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
)
5050

5151

52-
# ydb_fixtures.ydb_cluster_configuration local override
52+
# fixtures.ydb_cluster_configuration local override
5353
@pytest.fixture(scope='module')
5454
def ydb_cluster_configuration():
5555
conf = copy.deepcopy(CLUSTER_CONFIG)

ydb/tests/functional/tenants/test_db_counters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from ydb.tests.library.harness.kikimr_runner import KiKiMR
1616
from ydb.tests.library.harness.kikimr_config import KikimrConfigGenerator
1717
from ydb.tests.library.harness.util import LogLevels
18-
from ydb.tests.library.harness.ydb_fixtures import ydb_database_ctx
18+
from ydb.tests.library.fixtures import ydb_database_ctx
1919
from ydb.tests.library.matchers.response_matchers import ProtobufWithStatusMatcher
2020
from ydb.tests.oss.ydb_sdk_import import ydb
2121

ydb/tests/functional/tenants/test_dynamic_tenants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def enable_alter_database_create_hive_first(request):
5050
return request.param
5151

5252

53-
# ydb_fixtures.ydb_cluster_configuration local override
53+
# fixtures.ydb_cluster_configuration local override
5454
@pytest.fixture(scope='module')
5555
def ydb_cluster_configuration(enable_alter_database_create_hive_first):
5656
conf = copy.deepcopy(CLUSTER_CONFIG)

ydb/tests/functional/tenants/test_tenants.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from ydb.tests.oss.ydb_sdk_import import ydb
1212
from ydb.tests.library.harness.util import LogLevels
13-
from ydb.tests.library.harness.ydb_fixtures import ydb_database_ctx
13+
from ydb.tests.library.fixtures import ydb_database_ctx
1414

1515

1616
logger = logging.getLogger(__name__)
@@ -45,7 +45,7 @@ def enable_alter_database_create_hive_first(request):
4545
return request.param
4646

4747

48-
# ydb_fixtures.ydb_cluster_configuration local override
48+
# fixtures.ydb_cluster_configuration local override
4949
@pytest.fixture(scope='module')
5050
def ydb_cluster_configuration(enable_alter_database_create_hive_first):
5151
conf = copy.deepcopy(CLUSTER_CONFIG)

ydb/tests/functional/tenants/test_users_groups_with_acl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import logging
44
import pytest
55
from ydb.tests.library.harness.kikimr_config import KikimrConfigGenerator
6-
from ydb.tests.library.harness.ydb_fixtures import ydb_database_ctx
6+
from ydb.tests.library.fixtures import ydb_database_ctx
77
from ydb.tests.oss.ydb_sdk_import import ydb
88

99

ydb/tests/functional/tenants/ya.make

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ DEPENDS(
2626
PEERDIR(
2727
contrib/python/requests
2828
ydb/tests/library
29+
ydb/tests/library/fixtures
2930
ydb/tests/library/clients
3031
ydb/tests/oss/ydb_sdk_import
3132
ydb/public/sdk/python

ydb/tests/functional/ydb_cli/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
# but somehow it does not
33
#
44
# for ydb_{cluster, database, ...} fixture family
5-
pytest_plugins = 'ydb.tests.library.harness.ydb_fixtures'
5+
pytest_plugins = 'ydb.tests.library.fixtures'

ydb/tests/functional/ydb_cli/ya.make

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ DEPENDS(
3030
PEERDIR(
3131
contrib/python/pyarrow
3232
ydb/tests/library
33+
ydb/tests/library/fixtures
3334
ydb/tests/oss/canonical
3435
ydb/tests/oss/ydb_sdk_import
3536
)

ydb/tests/library/harness/ydb_fixtures.py renamed to ydb/tests/library/fixtures/__init__.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,21 +114,15 @@ def _ydb_database(cluster, database_path_base, unique_name):
114114

115115
@pytest.fixture(scope='function')
116116
def ydb_database(ydb_cluster, ydb_root, ydb_safe_test_name):
117-
# FIXME: PY2 syntax compatibility quirk: "yield from" emulation
118-
# Can't use py3 syntax here cause there are nasty dependencies on
119-
# tests/library/harness from some py2-only code in some other repositories
120-
for i in _ydb_database(ydb_cluster, ydb_root, ydb_safe_test_name):
121-
yield i
117+
yield from _ydb_database(ydb_cluster, ydb_root, ydb_safe_test_name)
122118

123119

124120
@pytest.fixture(scope='module')
125121
def ydb_database_module_scope(ydb_cluster, ydb_root, request):
126122
# make unique database name from the test module name, ensuring that
127123
# it does not contains the dots
128124
unique_name = request.module.__name__.split('.')[-1]
129-
# FIXME: PY2 syntax compatibility quirk: "yield from" emulation
130-
for i in _ydb_database(ydb_cluster, ydb_root, unique_name):
131-
yield i
125+
yield from _ydb_database(ydb_cluster, ydb_root, unique_name)
132126

133127

134128
@pytest.fixture(scope='module')

ydb/tests/library/fixtures/ya.make

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
PY3_LIBRARY()
2+
3+
PY_SRCS(
4+
__init__.py
5+
)
6+
7+
PEERDIR(
8+
ydb/tests/library
9+
ydb/public/sdk/python
10+
)
11+
12+
END()

ydb/tests/library/ya.make

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ PY_SRCS(
3232
harness/param_constants.py
3333
harness/util.py
3434
harness/tls_tools.py
35-
harness/ydb_fixtures.py
3635
matchers/__init__.py
3736
matchers/collection.py
3837
matchers/datashard_matchers.py

0 commit comments

Comments
 (0)