|
4 | 4 | import os |
5 | 5 | import requests |
6 | 6 | from ydb.tests.olap.lib.utils import get_external_param |
| 7 | +from ydb.tests.library.harness.kikimr_runner import KiKiMR |
| 8 | +from ydb.tests.library.harness.kikimr_config import KikimrConfigGenerator |
| 9 | + |
7 | 10 | import ydb |
8 | 11 | from copy import deepcopy |
9 | 12 | from time import sleep, time |
@@ -48,11 +51,13 @@ def __init__(self, desc: dict): |
48 | 51 | self.role = YdbCluster.Node.Role.UNKNOWN |
49 | 52 | self.tablets = [YdbCluster.Node.Tablet(t) for t in desc.get('Tablets', [])] |
50 | 53 |
|
| 54 | + _ydb_cluster = None |
51 | 55 | _ydb_driver = None |
52 | 56 | _results_driver = None |
53 | 57 | _cluster_info = None |
54 | | - ydb_endpoint = get_external_param('ydb-endpoint', 'grpc://ydb-olap-testing-vla-0002.search.yandex.net:2135') |
55 | | - ydb_database = get_external_param('ydb-db', 'olap-testing/kikimr/testing/acceptance-2').lstrip('/') |
| 58 | + |
| 59 | + ydb_endpoint = get_external_param('ydb-endpoint', "") |
| 60 | + ydb_database = get_external_param('ydb-db', "/Root").lstrip('/') |
56 | 61 | ydb_mon_port = 8765 |
57 | 62 | tables_path = get_external_param('tables-path', 'olap_yatests') |
58 | 63 | _monitoring_urls: list[YdbCluster.MonitoringUrl] = None |
@@ -126,6 +131,13 @@ def get_cluster_info(cls): |
126 | 131 | } |
127 | 132 | return deepcopy(cls._cluster_info) |
128 | 133 |
|
| 134 | + @staticmethod |
| 135 | + def _start_ydb_cluster(): |
| 136 | + config = KikimrConfigGenerator(extra_feature_flags=[]) |
| 137 | + cluster = KiKiMR(configurator=config) |
| 138 | + cluster.start() |
| 139 | + return cluster |
| 140 | + |
129 | 141 | @staticmethod |
130 | 142 | def _create_ydb_driver(endpoint, database, oauth=None, iam_file=None): |
131 | 143 | credentials = None |
@@ -156,8 +168,15 @@ def _create_ydb_driver(endpoint, database, oauth=None, iam_file=None): |
156 | 168 | @classmethod |
157 | 169 | def get_ydb_driver(cls): |
158 | 170 | if cls._ydb_driver is None: |
| 171 | + endpoint = cls.ydb_endpoint |
| 172 | + if not endpoint: |
| 173 | + if cls._ydb_cluster is not None: |
| 174 | + raise "Double temporary cluster initialization attempt" |
| 175 | + cls._ydb_cluster = cls._start_ydb_cluster() |
| 176 | + node = cls._ydb_cluster.nodes[1] |
| 177 | + endpoint = "%s:%d" % (node.host, node.port) |
159 | 178 | cls._ydb_driver = cls._create_ydb_driver( |
160 | | - cls.ydb_endpoint, cls.ydb_database, oauth=os.getenv('OLAP_YDB_OAUTH', None) |
| 179 | + endpoint, cls.ydb_database, oauth=os.getenv('OLAP_YDB_OAUTH', None) |
161 | 180 | ) |
162 | 181 | return cls._ydb_driver |
163 | 182 |
|
|
0 commit comments