blob: 6a224925cd1870b2dee86e8ffbd9397995b49835 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
from __future__ import annotations
import os
from .conftest import LoadSuiteBase
from ydb.tests.olap.lib.ydb_cli import WorkloadType, CheckCanonicalPolicy
from ydb.tests.olap.lib.ydb_cluster import YdbCluster
class ExternalSuiteBase(LoadSuiteBase):
workload_type: WorkloadType = WorkloadType.EXTERNAL
iterations: int = 1
check_canonical: CheckCanonicalPolicy = CheckCanonicalPolicy.ERROR
__query_list: list[str] = None
@staticmethod
def __get_query_list(path: str, name_prefix: list[str]) -> list[str]:
if os.path.isfile(path):
return [f"{'.'.join(name_prefix)}"] if path.endswith('.sql') or path.endswith('.yql') else []
if os.path.isdir(path):
result = []
for child in sorted(os.listdir(path)):
result += ExternalSuiteBase.__get_query_list(os.path.join(path, child), name_prefix + [child])
return result
return []
@classmethod
def get_query_list(cls) -> list[str]:
if cls.__query_list is None:
cls.__query_list = ExternalSuiteBase.__get_query_list(os.path.join(cls.get_external_path(), 'run'), [])
return cls.__query_list
@classmethod
def do_setup_class(cls):
if not cls.verify_data or os.getenv('NO_VERIFY_DATA', '0') == '1':
return
cls.check_tables_size(folder=cls.external_folder, tables={})
def test(self, query_name: str):
self.run_workload_test(f'{YdbCluster.tables_path}/{self.external_folder}', query_name=query_name)
def pytest_generate_tests(metafunc):
if issubclass(metafunc.cls, ExternalSuiteBase):
metafunc.parametrize("query_name", metafunc.cls.get_query_list())
class TestExternalA1(ExternalSuiteBase):
external_folder: str = 'a1'
class TestExternalX1(ExternalSuiteBase):
external_folder: str = 'x1'
class TestExternalM1(ExternalSuiteBase):
external_folder: str = 'm1'
|