Skip to content

Commit df96fa4

Browse files
authored
Fix balancing checking (#11540)
1 parent df88dac commit df96fa4

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

ydb/tests/olap/lib/ydb_cluster.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def _get_service_url(cls):
5555
@classmethod
5656
def get_cluster_nodes(cls, path=None):
5757
try:
58-
url = f'{cls._get_service_url()}/viewer/json/nodes?database={cls.ydb_database}'
58+
url = f'{cls._get_service_url()}/viewer/json/nodes?database=/{cls.ydb_database}'
5959
if path is not None:
6060
url += f'&path={path}&tablets=true'
6161
headers = {}
@@ -129,17 +129,16 @@ def get_ydb_driver(cls):
129129
return cls._ydb_driver
130130

131131
@classmethod
132-
def _list_directory_impl(cls, root_path: str, rel_path: str) -> List[ydb.SchemeEntry]:
133-
full_path = f'{root_path}/{rel_path}'
134-
LOGGER.info(f'list {full_path}')
132+
def _list_directory_impl(cls, path) -> List[ydb.SchemeEntry]:
133+
LOGGER.info(f'list {path}')
135134
result = []
136-
for child in cls.get_ydb_driver().scheme_client.list_directory(full_path).children:
135+
for child in cls.get_ydb_driver().scheme_client.list_directory(path).children:
137136
if child.name == '.sys':
138137
continue
139-
child.name = f'{rel_path}/{child.name}'
140-
if child.is_directory() or child.is_column_store():
141-
result += cls._list_directory_impl(root_path, child.name)
138+
child.name = f'{path}/{child.name}'
142139
result.append(child)
140+
if child.is_directory() or child.is_column_store():
141+
result += cls._list_directory_impl(child.name)
143142
return result
144143

145144
@classmethod
@@ -155,7 +154,7 @@ def _get_tables(cls, path):
155154
self_descr = cls._describe_path_impl(full_path)
156155
if self_descr is not None:
157156
if self_descr.is_directory():
158-
for descr in cls._list_directory_impl(full_path, '/'):
157+
for descr in cls._list_directory_impl(full_path):
159158
if descr.is_any_table():
160159
result.append(descr.name)
161160
elif self_descr.is_any_table():
@@ -246,10 +245,11 @@ def _check_node(n):
246245
errors.append(f'Node {tn.get("SystemState", {}).get("Host")}: {tablet.get("Count")} tablets of type {tablet.get("Type")} in {tablet.get("State")} state')
247246
if tablet.get("Type") in {"ColumnShard", "DataShard"}:
248247
tablet_count += tablet.get("Count")
249-
if min is None or tablet_count < min:
250-
min = tablet_count
251-
if max is None or tablet_count > max:
252-
max = tablet_count
248+
if tablet_count > 0:
249+
if min is None or tablet_count < min:
250+
min = tablet_count
251+
if max is None or tablet_count > max:
252+
max = tablet_count
253253
if min is None or max is None:
254254
errors.append(f'Table {p} has no tablets')
255255
elif max - min > 1:

0 commit comments

Comments
 (0)