1
+ from __future__ import annotations
1
2
import pytest
2
3
import allure
3
4
import json
4
5
from ydb .tests .olap .lib .ydb_cli import YdbCliHelper , WorkloadType
5
6
from ydb .tests .olap .lib .allure_utils import allure_test_description
6
7
from ydb .tests .olap .lib .results_processor import ResultsProcessor
7
8
from time import time
9
+ from typing import Optional
8
10
from allure_commons ._core import plugin_manager
9
11
from allure_pytest .listener import AllureListener
10
12
11
13
12
14
class LoadSuiteBase :
15
+ class QuerySettings :
16
+ def __init__ (self , iterations : Optional [int ] = None , timeout : Optional [float ] = None ) -> None :
17
+ self .iterations = iterations
18
+ self .timeout = timeout
19
+
13
20
iterations : int = 5
14
21
workload_type : WorkloadType = None
15
22
timeout : float = 1800.
16
23
refference : str = ''
17
- check_canonical = False
24
+ check_canonical : bool = False
25
+ query_settings : dict [int , LoadSuiteBase .QuerySettings ]
18
26
19
27
@property
20
28
def suite (self ) -> str :
@@ -23,6 +31,16 @@ def suite(self) -> str:
23
31
return result [4 :]
24
32
return result
25
33
34
+ @classmethod
35
+ def _get_iterations (cls , query_num : int ) -> int :
36
+ q = cls .query_settings .get (query_num , None )
37
+ return q .iterations if q is not None and q .iterations is not None else cls .iterations
38
+
39
+ @classmethod
40
+ def _get_timeout (cls , query_num : int ) -> float :
41
+ q = cls .query_settings .get (query_num , None )
42
+ return q .timeout if q is not None and q .timeout is not None else cls .timeout
43
+
26
44
@classmethod
27
45
def _test_name (cls , query_num : int ) -> str :
28
46
return f'Query{ query_num :02d} '
@@ -58,7 +76,7 @@ def _attach_plans(plan: YdbCliHelper.QueryPlan) -> None:
58
76
_attach_plans (result .explain_plan )
59
77
60
78
if result .plans is not None :
61
- for i in range (iterations ):
79
+ for i in range (self . _get_iterations ( query_num ) ):
62
80
try :
63
81
with allure .step (f'Iteration { i } ' ):
64
82
_attach_plans (result .plans [i ])
@@ -123,9 +141,9 @@ def run_workload_test(self, path: str, query_num: int) -> None:
123
141
result = YdbCliHelper .workload_run (
124
142
path = path ,
125
143
query_num = query_num ,
126
- iterations = self .iterations ,
144
+ iterations = self ._get_iterations ( query_num ) ,
127
145
workload_type = self .workload_type ,
128
- timeout = self .timeout ,
146
+ timeout = self ._get_timeout ( query_num ) ,
129
147
check_canonical = self .check_canonical
130
148
)
131
149
allure_test_description (self .suite , self ._test_name (query_num ), refference_set = self .refference , start_time = start_time , end_time = time ())
0 commit comments