Skip to content

Commit d7e5925

Browse files
authored
Swith dq_file/hybrid_file to yt suites (#13153)
1 parent 7857771 commit d7e5925

File tree

35 files changed

+142
-81
lines changed

35 files changed

+142
-81
lines changed

ydb/library/yql/tests/sql/dq_file.make

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ DEPENDS(
3131
)
3232
DATA(
3333
arcadia/ydb/library/yql/tests/sql # python files
34-
arcadia/yql/essentials/tests/sql/suites
34+
arcadia/yt/yql/tests/sql/suites
3535
arcadia/yql/essentials/mount
3636
arcadia/yql/essentials/cfg/tests
3737
)

ydb/library/yql/tests/sql/dq_file.py

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,46 @@
88
dump_table_yson, get_gateway_cfg_suffix, do_custom_query_check, normalize_result, \
99
stable_result_file, stable_table_file, is_with_final_result_issues, log
1010

11-
from test_utils import get_config, DATA_PATH
11+
from test_utils import get_config
1212
from test_file_common import run_file, run_file_no_cache
1313

1414
ASTDIFF_PATH = yql_binary_path('yql/essentials/tools/astdiff/astdiff')
1515
DQRUN_PATH = yql_binary_path('ydb/library/yql/tools/dqrun/dqrun')
16+
DATA_PATH = yatest.common.source_path('yt/yql/tests/sql/suites')
17+
18+
19+
# TODO move to yql_utils
20+
def is_sorted_table(table):
21+
import cyson
22+
assert table.attr is not None
23+
for column in cyson.loads(table.attr)[b'schema']:
24+
if b'sort_order' in column:
25+
return True
26+
return False
27+
28+
29+
# TODO move to yql_utils
30+
def is_unordered_result(res):
31+
import cyson
32+
path = res.results_file
33+
assert os.path.exists(path)
34+
with open(path, 'rb') as f:
35+
res = f.read()
36+
res = cyson.loads(res)
37+
for r in res:
38+
for data in r[b'Write']:
39+
if b'Unordered' in data:
40+
return True
41+
return False
1642

1743

1844
def run_test(suite, case, cfg, tmpdir, what, yql_http_file_server):
1945
if get_gateway_cfg_suffix() != '' and what != 'Results':
2046
pytest.skip('non-trivial gateways.conf')
47+
if (suite, case) in [('result_types','containers')]:
48+
pytest.skip('TODO make sorted/stable dicts')
2149

22-
config = get_config(suite, case, cfg)
50+
config = get_config(suite, case, cfg, data_path=DATA_PATH)
2351

2452
program_sql = os.path.join(DATA_PATH, suite, '%s.sql' % case)
2553
with codecs.open(program_sql, encoding='utf-8') as program_file_descr:
@@ -41,17 +69,17 @@ def run_test(suite, case, cfg, tmpdir, what, yql_http_file_server):
4169
if is_with_final_result_issues(config):
4270
extra_args += ["--with-final-issues"]
4371

44-
(res, tables_res) = run_file('dq', suite, case, cfg, config, yql_http_file_server, DQRUN_PATH, extra_args=extra_args)
72+
(res, tables_res) = run_file('dq', suite, case, cfg, config, yql_http_file_server, DQRUN_PATH, extra_args=extra_args, data_path=DATA_PATH)
4573

4674
if what == 'Results' or force_blocks:
4775
if not xfail:
4876
if force_blocks:
4977
yqlrun_res, yqlrun_tables_res = run_file_no_cache('dq', suite, case, cfg, config, yql_http_file_server, DQRUN_PATH, \
50-
extra_args=["--emulate-yt"], force_blocks=True)
78+
extra_args=["--emulate-yt"], force_blocks=True, data_path=DATA_PATH)
5179
dq_result_name = 'Scalar'
5280
yqlrun_result_name = 'Block'
5381
else:
54-
yqlrun_res, yqlrun_tables_res = run_file_no_cache('yt', suite, case, cfg, config, yql_http_file_server)
82+
yqlrun_res, yqlrun_tables_res = run_file_no_cache('yt', suite, case, cfg, config, yql_http_file_server, data_path=DATA_PATH)
5583
dq_result_name = 'DQFILE'
5684
yqlrun_result_name = 'YQLRUN'
5785

@@ -60,8 +88,8 @@ def run_test(suite, case, cfg, tmpdir, what, yql_http_file_server):
6088

6189
if os.path.exists(yqlrun_res.results_file):
6290
assert os.path.exists(res.results_file)
63-
dq_res_yson = normalize_result(stable_result_file(res), False)
64-
yqlrun_res_yson = normalize_result(stable_result_file(yqlrun_res), False)
91+
dq_res_yson = normalize_result(stable_result_file(res), is_unordered_result(res))
92+
yqlrun_res_yson = normalize_result(stable_result_file(yqlrun_res), is_unordered_result(yqlrun_res))
6593

6694
# Compare results
6795
assert dq_res_yson == yqlrun_res_yson, 'RESULTS_DIFFER\n' \
@@ -73,8 +101,10 @@ def run_test(suite, case, cfg, tmpdir, what, yql_http_file_server):
73101

74102
if os.path.exists(yqlrun_tables_res[table].file):
75103
assert os.path.exists(tables_res[table].file)
76-
yqlrun_table_yson = dump_table_yson(stable_table_file(yqlrun_tables_res[table]), False)
77-
dq_table_yson = dump_table_yson(stable_table_file(tables_res[table]), False)
104+
yqlrun_table_yson = dump_table_yson(stable_table_file(yqlrun_tables_res[table]), \
105+
not is_sorted_table(yqlrun_tables_res[table]))
106+
dq_table_yson = dump_table_yson(stable_table_file(tables_res[table]), \
107+
not is_sorted_table(tables_res[table]))
78108

79109
assert yqlrun_table_yson == dq_table_yson, \
80110
'OUT_TABLE_DIFFER: %(table)s\n' \

ydb/library/yql/tests/sql/dq_file/part0/test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import pytest
22
import yatest
33

4-
from dq_file import run_test
4+
from dq_file import run_test, DATA_PATH
55
from test_utils import pytest_generate_tests_for_part
66
from yql_utils import pytest_get_current_part
77

88

99
def pytest_generate_tests(metafunc):
1010
current_part, part_count = pytest_get_current_part(yatest.common.source_path(__file__))
11-
return pytest_generate_tests_for_part(metafunc, current_part, part_count)
11+
return pytest_generate_tests_for_part(metafunc, current_part, part_count, data_path=DATA_PATH)
1212

1313

1414
@pytest.mark.parametrize('what', ['Results', 'ForceBlocks'])

ydb/library/yql/tests/sql/dq_file/part1/test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import pytest
22
import yatest
33

4-
from dq_file import run_test
4+
from dq_file import run_test, DATA_PATH
55
from test_utils import pytest_generate_tests_for_part
66
from yql_utils import pytest_get_current_part
77

88

99
def pytest_generate_tests(metafunc):
1010
current_part, part_count = pytest_get_current_part(yatest.common.source_path(__file__))
11-
return pytest_generate_tests_for_part(metafunc, current_part, part_count)
11+
return pytest_generate_tests_for_part(metafunc, current_part, part_count, data_path=DATA_PATH)
1212

1313

1414
@pytest.mark.parametrize('what', ['Results', 'ForceBlocks'])

ydb/library/yql/tests/sql/dq_file/part10/test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import pytest
22
import yatest
33

4-
from dq_file import run_test
4+
from dq_file import run_test, DATA_PATH
55
from test_utils import pytest_generate_tests_for_part
66
from yql_utils import pytest_get_current_part
77

88

99
def pytest_generate_tests(metafunc):
1010
current_part, part_count = pytest_get_current_part(yatest.common.source_path(__file__))
11-
return pytest_generate_tests_for_part(metafunc, current_part, part_count)
11+
return pytest_generate_tests_for_part(metafunc, current_part, part_count, data_path=DATA_PATH)
1212

1313

1414
@pytest.mark.parametrize('what', ['Results', 'ForceBlocks'])

ydb/library/yql/tests/sql/dq_file/part11/test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import pytest
22
import yatest
33

4-
from dq_file import run_test
4+
from dq_file import run_test, DATA_PATH
55
from test_utils import pytest_generate_tests_for_part
66
from yql_utils import pytest_get_current_part
77

88

99
def pytest_generate_tests(metafunc):
1010
current_part, part_count = pytest_get_current_part(yatest.common.source_path(__file__))
11-
return pytest_generate_tests_for_part(metafunc, current_part, part_count)
11+
return pytest_generate_tests_for_part(metafunc, current_part, part_count, data_path=DATA_PATH)
1212

1313

1414
@pytest.mark.parametrize('what', ['Results', 'ForceBlocks'])

ydb/library/yql/tests/sql/dq_file/part12/test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import pytest
22
import yatest
33

4-
from dq_file import run_test
4+
from dq_file import run_test, DATA_PATH
55
from test_utils import pytest_generate_tests_for_part
66
from yql_utils import pytest_get_current_part
77

88

99
def pytest_generate_tests(metafunc):
1010
current_part, part_count = pytest_get_current_part(yatest.common.source_path(__file__))
11-
return pytest_generate_tests_for_part(metafunc, current_part, part_count)
11+
return pytest_generate_tests_for_part(metafunc, current_part, part_count, data_path=DATA_PATH)
1212

1313

1414
@pytest.mark.parametrize('what', ['Results', 'ForceBlocks'])

ydb/library/yql/tests/sql/dq_file/part13/test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import pytest
22
import yatest
33

4-
from dq_file import run_test
4+
from dq_file import run_test, DATA_PATH
55
from test_utils import pytest_generate_tests_for_part
66
from yql_utils import pytest_get_current_part
77

88

99
def pytest_generate_tests(metafunc):
1010
current_part, part_count = pytest_get_current_part(yatest.common.source_path(__file__))
11-
return pytest_generate_tests_for_part(metafunc, current_part, part_count)
11+
return pytest_generate_tests_for_part(metafunc, current_part, part_count, data_path=DATA_PATH)
1212

1313

1414
@pytest.mark.parametrize('what', ['Results', 'ForceBlocks'])

ydb/library/yql/tests/sql/dq_file/part14/test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import pytest
22
import yatest
33

4-
from dq_file import run_test
4+
from dq_file import run_test, DATA_PATH
55
from test_utils import pytest_generate_tests_for_part
66
from yql_utils import pytest_get_current_part
77

88

99
def pytest_generate_tests(metafunc):
1010
current_part, part_count = pytest_get_current_part(yatest.common.source_path(__file__))
11-
return pytest_generate_tests_for_part(metafunc, current_part, part_count)
11+
return pytest_generate_tests_for_part(metafunc, current_part, part_count, data_path=DATA_PATH)
1212

1313

1414
@pytest.mark.parametrize('what', ['Results', 'ForceBlocks'])

ydb/library/yql/tests/sql/dq_file/part15/test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import pytest
22
import yatest
33

4-
from dq_file import run_test
4+
from dq_file import run_test, DATA_PATH
55
from test_utils import pytest_generate_tests_for_part
66
from yql_utils import pytest_get_current_part
77

88

99
def pytest_generate_tests(metafunc):
1010
current_part, part_count = pytest_get_current_part(yatest.common.source_path(__file__))
11-
return pytest_generate_tests_for_part(metafunc, current_part, part_count)
11+
return pytest_generate_tests_for_part(metafunc, current_part, part_count, data_path=DATA_PATH)
1212

1313

1414
@pytest.mark.parametrize('what', ['Results', 'ForceBlocks'])

0 commit comments

Comments
 (0)