Skip to content

Commit 3297bd9

Browse files
authored
Add policity for check canonical results. Check some as warning (#12654)
1 parent 82d7c68 commit 3297bd9

File tree

7 files changed

+46
-24
lines changed

7 files changed

+46
-24
lines changed

ydb/tests/olap/lib/allure_utils.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
from ydb.tests.olap.lib.ydb_cluster import YdbCluster
44
from ydb.tests.olap.lib.results_processor import ResultsProcessor
55
from urllib.parse import urlencode
6-
from datetime import datetime, UTC
6+
from datetime import datetime
77
from copy import deepcopy
8+
from pytz import timezone
89

910

1011
def _set_monitoring(test_info: dict[str, str], start_time: float, end_time: float) -> None:
@@ -55,10 +56,11 @@ def _set_logs_command(test_info: dict[str, str], start_time: float, end_time: fl
5556
if node.role == YdbCluster.Node.Role.STORAGE:
5657
hosts.append(node.host)
5758
hosts_cmd = ' '.join([f'-H {h}' for h in hosts])
58-
start = datetime.fromtimestamp(start_time, UTC).isoformat()
59-
end = datetime.fromtimestamp(end_time, UTC).isoformat()
59+
tz = timezone('Europe/Moscow')
60+
start = datetime.fromtimestamp(start_time, tz).isoformat()
61+
end = datetime.fromtimestamp(end_time, tz).isoformat()
6062
time_cmd = f'-S "{start}" -U "{end}"'
61-
cmd = f"parallel-ssh {hosts_cmd} -o . 'unified_agent select {time_cmd} -s kikimr'"
63+
cmd = f"parallel-ssh {hosts_cmd} -o . 'ulimit -n 100500;unified_agent select {time_cmd} -s kikimr'"
6264
test_info['logs_command'] = f'<code>{cmd}</code>'
6365

6466

ydb/tests/olap/lib/ya.make

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ PY3_LIBRARY()
1111
PEERDIR(
1212
contrib/python/allure-pytest
1313
contrib/python/allure-python-commons
14+
contrib/python/pytz
1415
contrib/python/requests
1516
library/python/testing/yatest_common
1617
ydb/public/api/client/yc_public/iam

ydb/tests/olap/lib/ydb_cli.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import re
77
from ydb.tests.olap.lib.ydb_cluster import YdbCluster
88
from ydb.tests.olap.lib.utils import get_external_param
9-
from enum import StrEnum
9+
from enum import StrEnum, Enum
1010
from types import TracebackType
1111

1212

@@ -16,6 +16,12 @@ class WorkloadType(StrEnum):
1616
TPC_DS = 'tpcds'
1717

1818

19+
class CheckCanonicalPolicy(Enum):
20+
NO = 0
21+
WARNING = 1
22+
ERROR = 2
23+
24+
1925
class YdbCliHelper:
2026
@staticmethod
2127
def get_cli_command() -> list[str]:
@@ -46,6 +52,7 @@ def __init__(self):
4652
self.stdout: str = ''
4753
self.stderr: str = ''
4854
self.error_message: str = ''
55+
self.warning_message: str = ''
4956
self.plans: Optional[list[YdbCliHelper.QueryPlan]] = None
5057
self.explain_plan: Optional[YdbCliHelper.QueryPlan] = None
5158
self.errors_by_iter: dict[int, str] = {}
@@ -63,7 +70,7 @@ def __init__(self,
6370
query_num: int,
6471
iterations: int,
6572
timeout: float,
66-
check_canonical: bool,
73+
check_canonical: CheckCanonicalPolicy,
6774
query_syntax: str,
6875
scale: Optional[int]):
6976
def _get_output_path(ext: str) -> str:
@@ -90,6 +97,13 @@ def _add_error(self, msg: Optional[str]):
9097
else:
9198
self.result.error_message = msg
9299

100+
def _add_warning(self, msg: Optional[str]):
101+
if msg is not None and len(msg) > 0:
102+
if len(self.result.warning_message) > 0:
103+
self.result.warning_message += f'\n\n{msg}'
104+
else:
105+
self.result.warning_message = msg
106+
93107
def _process_returncode(self, returncode) -> None:
94108
begin_str = f'{self.query_num}:'
95109
end_str = 'Query text:'
@@ -147,7 +161,10 @@ def _load_stats(self):
147161
self.result.stats[q] = {}
148162
self.result.stats[q][signal['sensor']] = signal['value']
149163
if self.result.stats.get(f'Query{self.query_num:02d}', {}).get("DiffsCount", 0) > 0:
150-
self._add_error('There is diff in query results')
164+
if self.check_canonical == CheckCanonicalPolicy.WARNING:
165+
self._add_warning('There is diff in query results')
166+
else:
167+
self._add_error('There is diff in query results')
151168

152169
def _load_query_out(self) -> None:
153170
if (os.path.exists(self._query_output_path)):
@@ -196,7 +213,7 @@ def _get_cmd(self) -> list[str]:
196213
query_preffix = get_external_param('query-prefix', '')
197214
if query_preffix:
198215
cmd += ['--query-settings', query_preffix]
199-
if self.check_canonical:
216+
if self.check_canonical != CheckCanonicalPolicy.NO:
200217
cmd.append('--check-canonical')
201218
if self.query_syntax:
202219
cmd += ['--syntax', self.query_syntax]
@@ -230,7 +247,7 @@ def process(self) -> YdbCliHelper.WorkloadRunResult:
230247

231248
@staticmethod
232249
def workload_run(workload_type: WorkloadType, path: str, query_num: int, iterations: int = 5,
233-
timeout: float = 100., check_canonical: bool = False, query_syntax: str = '',
250+
timeout: float = 100., check_canonical: CheckCanonicalPolicy = CheckCanonicalPolicy.NO, query_syntax: str = '',
234251
scale: Optional[int] = None) -> YdbCliHelper.WorkloadRunResult:
235252
return YdbCliHelper.WorkloadProcessor(
236253
workload_type,

ydb/tests/olap/load/lib/clickbench.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import pytest
33
from .conftest import LoadSuiteBase
44
from os import getenv
5-
from ydb.tests.olap.lib.ydb_cli import WorkloadType, YdbCliHelper
5+
from ydb.tests.olap.lib.ydb_cli import WorkloadType, YdbCliHelper, CheckCanonicalPolicy
66
from ydb.tests.olap.lib.ydb_cluster import YdbCluster
77
from ydb.tests.olap.lib.utils import get_external_param
88

@@ -29,7 +29,7 @@ def do_setup_class(cls):
2929
iterations=1,
3030
workload_type=cls.workload_type,
3131
timeout=cls._get_timeout(query_num),
32-
check_canonical=True
32+
check_canonical=CheckCanonicalPolicy.ERROR
3333
)
3434
cls.process_query_result(result=result, query_num=query_num, iterations=1, upload=False)
3535
except BaseException:

ydb/tests/olap/load/lib/conftest.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import pytest
33
import allure
44
import json
5-
from ydb.tests.olap.lib.ydb_cli import YdbCliHelper, WorkloadType
5+
from ydb.tests.olap.lib.ydb_cli import YdbCliHelper, WorkloadType, CheckCanonicalPolicy
66
from ydb.tests.olap.lib.ydb_cluster import YdbCluster
77
from ydb.tests.olap.lib.allure_utils import allure_test_description
88
from ydb.tests.olap.lib.results_processor import ResultsProcessor
@@ -23,7 +23,7 @@ def __init__(self, iterations: Optional[int] = None, timeout: Optional[float] =
2323
workload_type: WorkloadType = None
2424
timeout: float = 1800.
2525
refference: str = ''
26-
check_canonical: bool = False
26+
check_canonical: CheckCanonicalPolicy = CheckCanonicalPolicy.NO
2727
query_syntax: str = ''
2828
query_settings: dict[int, LoadSuiteBase.QuerySettings] = {}
2929
scale: Optional[int] = None
@@ -165,10 +165,12 @@ def _attach_plans(plan: YdbCliHelper.QueryPlan) -> None:
165165
statistics=stats,
166166
)
167167
if not success:
168-
exc = pytest.fail.Exception(error_message)
168+
exc = pytest.fail.Exception('\n'.join([error_message, result.warning_message]))
169169
if result.traceback is not None:
170170
exc = exc.with_traceback(result.traceback)
171171
raise exc
172+
if result.warning_message:
173+
raise Exception(result.warning_message)
172174

173175
@classmethod
174176
def setup_class(cls) -> None:

ydb/tests/olap/load/lib/tpcds.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import pytest
33
from .conftest import LoadSuiteBase
44
from os import getenv
5-
from ydb.tests.olap.lib.ydb_cli import WorkloadType
5+
from ydb.tests.olap.lib.ydb_cli import WorkloadType, CheckCanonicalPolicy
66
from ydb.tests.olap.lib.utils import get_external_param
77
from ydb.tests.olap.lib.ydb_cluster import YdbCluster
88

@@ -46,7 +46,7 @@ def test_tpcds(self, query_num: int):
4646

4747
class TestTpcds1(TpcdsSuiteBase):
4848
scale: int = 1
49-
check_canonical: bool = True
49+
check_canonical: bool = CheckCanonicalPolicy.ERROR
5050
tables_size: dict[str, int] = {
5151
'call_center': 6,
5252
'catalog_page': 11718,
@@ -71,7 +71,7 @@ class TestTpcds1(TpcdsSuiteBase):
7171

7272
class TestTpcds10(TpcdsSuiteBase):
7373
scale: int = 10
74-
check_canonical: bool = True
74+
check_canonical: bool = CheckCanonicalPolicy.WARNING
7575
timeout = max(TpcdsSuiteBase.timeout, 300.)
7676
tables_size: dict[str, int] = {
7777
'call_center': 24,
@@ -97,7 +97,7 @@ class TestTpcds10(TpcdsSuiteBase):
9797

9898
class TestTpcds100(TpcdsSuiteBase):
9999
scale: int = 100
100-
check_canonical: bool = True
100+
check_canonical: bool = CheckCanonicalPolicy.WARNING
101101
iterations: int = 2
102102
timeout = max(TpcdsSuiteBase.timeout, 3600.)
103103
query_settings = {

ydb/tests/olap/load/lib/tpch.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import pytest
33
from .conftest import LoadSuiteBase
44
from os import getenv
5-
from ydb.tests.olap.lib.ydb_cli import WorkloadType
5+
from ydb.tests.olap.lib.ydb_cli import WorkloadType, CheckCanonicalPolicy
66
from ydb.tests.olap.lib.utils import get_external_param
77
from ydb.tests.olap.lib.ydb_cluster import YdbCluster
88

@@ -50,23 +50,23 @@ class TestTpch1(TpchSuiteBase):
5050
'lineitem': 6001215,
5151
}
5252
scale: int = 1
53-
check_canonical: bool = True
53+
check_canonical: bool = CheckCanonicalPolicy.ERROR
5454

5555

5656
class TestTpch10(TpchSuiteBase):
5757
tables_size: dict[str, int] = {
5858
'lineitem': 59986052,
5959
}
6060
scale: int = 10
61-
check_canonical: bool = True
61+
check_canonical: bool = CheckCanonicalPolicy.ERROR
6262

6363

6464
class TestTpch100(TpchSuiteBase):
6565
tables_size: dict[str, int] = {
6666
'lineitem': 600037902,
6767
}
6868
scale: int = 100
69-
check_canonical: bool = True
69+
check_canonical: bool = CheckCanonicalPolicy.ERROR
7070
timeout = max(TpchSuiteBase.timeout, 300.)
7171

7272

@@ -75,7 +75,7 @@ class TestTpch1000(TpchSuiteBase):
7575
'lineitem': 5999989709,
7676
}
7777
scale: int = 1000
78-
check_canonical: bool = True
78+
check_canonical: bool = CheckCanonicalPolicy.WARNING
7979
timeout = max(TpchSuiteBase.timeout, 3600.)
8080

8181

@@ -85,5 +85,5 @@ class TestTpch10000(TpchSuiteBase):
8585
}
8686
scale: int = 10000
8787
iterations: int = 2
88-
check_canonical: bool = True
88+
check_canonical: bool = CheckCanonicalPolicy.WARNING
8989
timeout = max(TpchSuiteBase.timeout, 3600.)

0 commit comments

Comments
 (0)