Skip to content

Commit 3d764be

Browse files
authored
Merge 370cb8c into 1f60fc8
2 parents 1f60fc8 + 370cb8c commit 3d764be

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

ydb/tests/olap/lib/ydb_cluster.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,17 +172,21 @@ def get_ydb_driver(cls):
172172
return cls._ydb_driver
173173

174174
@classmethod
175-
def list_directory(cls, root_path: str, rel_path: str) -> List[ydb.SchemeEntry]:
175+
def list_directory_tree(cls, root_path: str, rel_path: str, kind_order_key = None) -> List[ydb.SchemeEntry]:
176+
"""
177+
kind_order_key: Optional[SchemeEntryType -> int]
178+
"""
176179
path = f'{root_path}/{rel_path}' if root_path else rel_path
177180
LOGGER.info(f'list {path}')
178181
result = []
179-
for child in cls.get_ydb_driver().scheme_client.list_directory(path).children:
182+
entries = cls.get_ydb_driver().scheme_client.list_directory(path).children
183+
for child in sorted(entries, key=lambda x: kind_order_key(x.type)):
180184
if child.name == '.sys':
181185
continue
182186
child.name = f'{rel_path}/{child.name}'
183187
result.append(child)
184188
if child.is_directory() or child.is_column_store():
185-
result += cls.list_directory(root_path, child.name)
189+
result += cls.list_directory_tree(root_path, child.name, kind_order_key)
186190
return result
187191

188192
@classmethod

ydb/tests/olap/scenario/helpers/scenario_tests_helper.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ def describe_table(self, path: str, settings: ydb.DescribeTableSettings = None)
657657
)
658658

659659
@allure.step('List path {path}')
660-
def list_path(self, path: str, folder: str) -> List[ydb.SchemeEntry]:
660+
def list_path_tree(self, path: str, folder: str) -> List[ydb.SchemeEntry]:
661661
"""Recursively describe the path in the database under test.
662662
663663
If the path is a directory or TableStore, then all subpaths are included in the description.
@@ -679,8 +679,19 @@ def list_path(self, path: str, folder: str) -> List[ydb.SchemeEntry]:
679679
if self_descr is None:
680680
return []
681681

682+
kind_order = [
683+
ydb.SchemeEntryType.COLUMN_TABLE,
684+
ydb.SchemeEntryType.COLUMN_STORE,
685+
ydb.SchemeEntryType.EXTERNAL_DATA_SOURCE,
686+
]
687+
def kind_order_key_reversed(kind):
688+
try:
689+
return -kind_order.index(kind)
690+
except ValueError:
691+
return -len(kind_order)
692+
682693
if self_descr.is_directory():
683-
return list(reversed(YdbCluster.list_directory(root_path, path))) + [self_descr]
694+
return list(reversed(YdbCluster.list_directory_tree(root_path, path, kind_order_key_reversed))) + [self_descr]
684695
else:
685696
return self_descr
686697

@@ -701,7 +712,7 @@ def remove_path(self, path: str, folder: str = '') -> None:
701712
import ydb.tests.olap.scenario.helpers.drop_helper as dh
702713

703714
root_path = self.get_full_path(folder)
704-
for e in self.list_path(path, folder):
715+
for e in self.list_path_tree(path, folder):
705716
if e.is_any_table():
706717
self.execute_scheme_query(dh.DropTable(os.path.join(folder, e.name)))
707718
elif e.is_column_store():

0 commit comments

Comments
 (0)