Skip to content

Commit

Permalink
Run olap scenario tests on local ydb cluster (#12512)
Browse files Browse the repository at this point in the history
  • Loading branch information
zverevgeny authored Dec 16, 2024
1 parent bd3e3a5 commit 93b71f1
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/config/muted_ya.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ ydb/tests/functional/tenants test_tenants.py.TestTenants.test_list_database_abov
ydb/tests/functional/tenants test_tenants.py.TestTenants.test_list_database_above[enable_alter_database_create_hive_first--true]
ydb/tests/functional/tenants test_tenants.py.TestTenants.test_stop_start[enable_alter_database_create_hive_first--false]
ydb/tests/functional/tenants test_tenants.py.TestTenants.test_stop_start[enable_alter_database_create_hive_first--true]
ydb/tests/olap/scenario test_alter_tiering.py.TestAlterTiering.test[many_tables]
ydb/tests/postgres_integrations/go-libpq docker_wrapper_test.py.test_pg_generated[Test64BitErrorChecking]
ydb/tests/postgres_integrations/go-libpq docker_wrapper_test.py.test_pg_generated[TestArrayValueBackend]
ydb/tests/postgres_integrations/go-libpq docker_wrapper_test.py.test_pg_generated[TestBinaryByteSliceToInt]
Expand Down
7 changes: 7 additions & 0 deletions ydb/tests/olap/lib/ydb_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,13 @@ def _create_ydb_driver(endpoint, database, oauth=None, iam_file=None):
)
raise

@classmethod
def reset(cls, ydb_endpoint, ydb_database, ydb_mon_port):
cls.ydb_endpoint = ydb_endpoint
cls.ydb_database = ydb_database
cls.ydb_mon_port = ydb_mon_port
cls._ydb_driver = None

@classmethod
def get_ydb_driver(cls):
if cls._ydb_driver is None:
Expand Down
49 changes: 49 additions & 0 deletions ydb/tests/olap/scenario/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,77 @@
import time
from ydb.tests.olap.lib.results_processor import ResultsProcessor
from ydb.tests.olap.scenario.helpers.scenario_tests_helper import TestContext, ScenarioTestHelper
from ydb.tests.olap.lib.ydb_cluster import YdbCluster
from ydb.tests.olap.lib.utils import external_param_is_true
from ydb.tests.olap.lib.utils import get_external_param
from ydb.tests.olap.lib.allure_utils import allure_test_description
from ydb.tests.library.harness.kikimr_runner import KiKiMR
from ydb.tests.library.harness.kikimr_config import KikimrConfigGenerator


LOGGER = logging.getLogger()

SCENARIO_PREFIX = 'scenario_'


class YdbClusterInstance():
'''
Represents either long-running external cluster or create temporary cluster for local run
'''
_temp_ydb_cluster = None
_endpoint = None
_database = None

def __init__(self, endpoint, database):
if endpoint is not None:
self._endpoint = endpoint
self._database = database
self._mon_port = 8765
else:
config = KikimrConfigGenerator()
cluster = KiKiMR(configurator=config)
cluster.start()
node = cluster.nodes[1]
self._endpoint = "grpc://%s:%d" % (node.host, node.port)
self._database = config.domain_name
self._mon_port = node.mon_port
self._temp_ydb_cluster = cluster
LOGGER.info(f'Using YDB, endpoint:{self._endpoint}, database:{self._database}')

def endpoint(self):
return self._endpoint

def database(self):
return self._database

def mon_port(self):
return self._mon_port

def stop(self):
if self._temp_ydb_cluster is not None:
self._temp_ydb_cluster.stop()
self._temp_ydb_cluster = None


class BaseTestSet:
@classmethod
def get_suite_name(cls):
return cls.__name__

@classmethod
def setup_class(cls):
ydb_endpoint = get_external_param('ydb-endpoint', None)
ydb_database = get_external_param('ydb-db', "").lstrip('/')
cls._ydb_instance = YdbClusterInstance(ydb_endpoint, ydb_database)
YdbCluster.reset(cls._ydb_instance.endpoint(), cls._ydb_instance.database(), cls._ydb_instance.mon_port())
if not external_param_is_true('reuse-tables'):
ScenarioTestHelper(None).remove_path(cls.get_suite_name())

@classmethod
def teardown_class(cls):
if not external_param_is_true('keep-tables'):
ScenarioTestHelper(None).remove_path(cls.get_suite_name())
cls._ydb_instance.stop()

def test(self, ctx: TestContext):
start_time = time.time()
Expand Down
10 changes: 8 additions & 2 deletions ydb/tests/olap/scenario/ya.make
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
PY3TEST()

TAG(ya:manual)

PY_SRCS (
conftest.py
)
Expand All @@ -13,6 +11,11 @@ PY3TEST()
test_insert.py
)

ENV(YDB_DRIVER_BINARY="ydb/apps/ydbd/ydbd")
DEPENDS(
ydb/apps/ydbd
)

PEERDIR(
contrib/python/allure-pytest
contrib/python/allure-python-commons
Expand All @@ -22,8 +25,11 @@ PY3TEST()
ydb/public/sdk/python
ydb/public/sdk/python/enable_v3_new_behavior
ydb/tests/olap/lib
ydb/tests/library
ydb/tests/olap/scenario/helpers
library/python/testing/yatest_common
)

SIZE(MEDIUM)

END()

0 comments on commit 93b71f1

Please sign in to comment.