Skip to content

Commit 93b71f1

Browse files
authored
Run olap scenario tests on local ydb cluster (#12512)
1 parent bd3e3a5 commit 93b71f1

File tree

4 files changed

+65
-2
lines changed

4 files changed

+65
-2
lines changed

.github/config/muted_ya.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ ydb/tests/functional/tenants test_tenants.py.TestTenants.test_list_database_abov
144144
ydb/tests/functional/tenants test_tenants.py.TestTenants.test_list_database_above[enable_alter_database_create_hive_first--true]
145145
ydb/tests/functional/tenants test_tenants.py.TestTenants.test_stop_start[enable_alter_database_create_hive_first--false]
146146
ydb/tests/functional/tenants test_tenants.py.TestTenants.test_stop_start[enable_alter_database_create_hive_first--true]
147+
ydb/tests/olap/scenario test_alter_tiering.py.TestAlterTiering.test[many_tables]
147148
ydb/tests/postgres_integrations/go-libpq docker_wrapper_test.py.test_pg_generated[Test64BitErrorChecking]
148149
ydb/tests/postgres_integrations/go-libpq docker_wrapper_test.py.test_pg_generated[TestArrayValueBackend]
149150
ydb/tests/postgres_integrations/go-libpq docker_wrapper_test.py.test_pg_generated[TestBinaryByteSliceToInt]

ydb/tests/olap/lib/ydb_cluster.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,13 @@ def _create_ydb_driver(endpoint, database, oauth=None, iam_file=None):
153153
)
154154
raise
155155

156+
@classmethod
157+
def reset(cls, ydb_endpoint, ydb_database, ydb_mon_port):
158+
cls.ydb_endpoint = ydb_endpoint
159+
cls.ydb_database = ydb_database
160+
cls.ydb_mon_port = ydb_mon_port
161+
cls._ydb_driver = None
162+
156163
@classmethod
157164
def get_ydb_driver(cls):
158165
if cls._ydb_driver is None:

ydb/tests/olap/scenario/conftest.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,77 @@
44
import time
55
from ydb.tests.olap.lib.results_processor import ResultsProcessor
66
from ydb.tests.olap.scenario.helpers.scenario_tests_helper import TestContext, ScenarioTestHelper
7+
from ydb.tests.olap.lib.ydb_cluster import YdbCluster
78
from ydb.tests.olap.lib.utils import external_param_is_true
9+
from ydb.tests.olap.lib.utils import get_external_param
810
from ydb.tests.olap.lib.allure_utils import allure_test_description
11+
from ydb.tests.library.harness.kikimr_runner import KiKiMR
12+
from ydb.tests.library.harness.kikimr_config import KikimrConfigGenerator
13+
914

1015
LOGGER = logging.getLogger()
1116

1217
SCENARIO_PREFIX = 'scenario_'
1318

1419

20+
class YdbClusterInstance():
21+
'''
22+
Represents either long-running external cluster or create temporary cluster for local run
23+
'''
24+
_temp_ydb_cluster = None
25+
_endpoint = None
26+
_database = None
27+
28+
def __init__(self, endpoint, database):
29+
if endpoint is not None:
30+
self._endpoint = endpoint
31+
self._database = database
32+
self._mon_port = 8765
33+
else:
34+
config = KikimrConfigGenerator()
35+
cluster = KiKiMR(configurator=config)
36+
cluster.start()
37+
node = cluster.nodes[1]
38+
self._endpoint = "grpc://%s:%d" % (node.host, node.port)
39+
self._database = config.domain_name
40+
self._mon_port = node.mon_port
41+
self._temp_ydb_cluster = cluster
42+
LOGGER.info(f'Using YDB, endpoint:{self._endpoint}, database:{self._database}')
43+
44+
def endpoint(self):
45+
return self._endpoint
46+
47+
def database(self):
48+
return self._database
49+
50+
def mon_port(self):
51+
return self._mon_port
52+
53+
def stop(self):
54+
if self._temp_ydb_cluster is not None:
55+
self._temp_ydb_cluster.stop()
56+
self._temp_ydb_cluster = None
57+
58+
1559
class BaseTestSet:
1660
@classmethod
1761
def get_suite_name(cls):
1862
return cls.__name__
1963

2064
@classmethod
2165
def setup_class(cls):
66+
ydb_endpoint = get_external_param('ydb-endpoint', None)
67+
ydb_database = get_external_param('ydb-db', "").lstrip('/')
68+
cls._ydb_instance = YdbClusterInstance(ydb_endpoint, ydb_database)
69+
YdbCluster.reset(cls._ydb_instance.endpoint(), cls._ydb_instance.database(), cls._ydb_instance.mon_port())
2270
if not external_param_is_true('reuse-tables'):
2371
ScenarioTestHelper(None).remove_path(cls.get_suite_name())
2472

2573
@classmethod
2674
def teardown_class(cls):
2775
if not external_param_is_true('keep-tables'):
2876
ScenarioTestHelper(None).remove_path(cls.get_suite_name())
77+
cls._ydb_instance.stop()
2978

3079
def test(self, ctx: TestContext):
3180
start_time = time.time()

ydb/tests/olap/scenario/ya.make

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
PY3TEST()
22

3-
TAG(ya:manual)
4-
53
PY_SRCS (
64
conftest.py
75
)
@@ -13,6 +11,11 @@ PY3TEST()
1311
test_insert.py
1412
)
1513

14+
ENV(YDB_DRIVER_BINARY="ydb/apps/ydbd/ydbd")
15+
DEPENDS(
16+
ydb/apps/ydbd
17+
)
18+
1619
PEERDIR(
1720
contrib/python/allure-pytest
1821
contrib/python/allure-python-commons
@@ -22,8 +25,11 @@ PY3TEST()
2225
ydb/public/sdk/python
2326
ydb/public/sdk/python/enable_v3_new_behavior
2427
ydb/tests/olap/lib
28+
ydb/tests/library
2529
ydb/tests/olap/scenario/helpers
2630
library/python/testing/yatest_common
2731
)
2832

33+
SIZE(MEDIUM)
34+
2935
END()

0 commit comments

Comments
 (0)