Skip to content

drop scheme entries in order in scenario tests #15254

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions ydb/tests/olap/lib/ydb_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from ydb.tests.olap.lib.utils import get_external_param
from copy import deepcopy
from time import sleep, time
from typing import List, Optional
from typing import List, Optional, Callable
from enum import Enum

LOGGER = logging.getLogger()
Expand Down Expand Up @@ -172,17 +172,20 @@ def get_ydb_driver(cls):
return cls._ydb_driver

@classmethod
def list_directory(cls, root_path: str, rel_path: str) -> List[ydb.SchemeEntry]:
def list_directory(cls, root_path: str, rel_path: str, kind_order_key: Optional[Callable[[ydb.SchemeEntryType], int]] = None) -> List[ydb.SchemeEntry]:
path = f'{root_path}/{rel_path}' if root_path else rel_path
LOGGER.info(f'list {path}')
result = []
for child in cls.get_ydb_driver().scheme_client.list_directory(path).children:
entries = cls.get_ydb_driver().scheme_client.list_directory(path).children
if kind_order_key is not None:
entries = sorted(entries, key=lambda x: kind_order_key(x.type))
for child in entries:
if child.name == '.sys':
continue
child.name = f'{rel_path}/{child.name}'
result.append(child)
if child.is_directory() or child.is_column_store():
result += cls.list_directory(root_path, child.name)
result += cls.list_directory(root_path, child.name, kind_order_key)
return result

@classmethod
Expand Down
14 changes: 13 additions & 1 deletion ydb/tests/olap/scenario/helpers/scenario_tests_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,8 +679,20 @@ def list_path(self, path: str, folder: str) -> List[ydb.SchemeEntry]:
if self_descr is None:
return []

kind_order = [
ydb.SchemeEntryType.COLUMN_TABLE,
ydb.SchemeEntryType.COLUMN_STORE,
ydb.SchemeEntryType.EXTERNAL_DATA_SOURCE,
]

def kind_order_key_reversed(kind):
try:
return -kind_order.index(kind)
except ValueError:
return -len(kind_order)

if self_descr.is_directory():
return list(reversed(YdbCluster.list_directory(root_path, path))) + [self_descr]
return list(reversed(YdbCluster.list_directory(root_path, path, kind_order_key_reversed))) + [self_descr]
else:
return self_descr

Expand Down