Skip to content

Commit 4167e84

Browse files
authored
Merge 908c1b3 into a877b3b
2 parents a877b3b + 908c1b3 commit 4167e84

File tree

71 files changed

+6158
-17
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+6158
-17
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FeatureFlags {
2+
EnableExternalDataSources: true
3+
EnableScriptExecutionOperations: true
4+
}
5+
6+
QueryServiceConfig {
7+
FileStorage {
8+
MaxFiles: 1000
9+
MaxSizeMb: 512
10+
RetryCount: 3
11+
Threads: 2
12+
}
13+
14+
Yt {
15+
DefaultSettings {
16+
Name: "InferSchema"
17+
Value: "1"
18+
}
19+
DefaultSettings {
20+
Name: "_EnableYtPartitioning"
21+
Value: "true"
22+
}
23+
}
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CREATE OBJECT yt_token (TYPE SECRET) WITH (value = "token");
2+
3+
CREATE EXTERNAL DATA SOURCE plato WITH (
4+
SOURCE_TYPE="YT",
5+
LOCATION="localhost",
6+
AUTH_METHOD="TOKEN",
7+
TOKEN_SECRET_NAME="yt_token"
8+
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import os
2+
3+
import yatest.common
4+
5+
import yql_utils
6+
7+
8+
class KqpRun(object):
9+
def __init__(self, udfs_dir=None):
10+
self.kqprun_binary = yql_utils.yql_binary_path('ydb/tests/tools/kqprun/kqprun')
11+
12+
self.config_file = yql_utils.yql_source_path(os.path.join('ydb/library/yql/cfg/tests', 'kqprun_config.conf'))
13+
self.scheme_file = yql_utils.yql_source_path(os.path.join('ydb/library/yql/cfg/tests', 'kqprun_scheme.sql'))
14+
15+
self.res_dir = yql_utils.get_yql_dir(prefix='kqprun_')
16+
17+
if udfs_dir is None:
18+
self.udfs_dir = yql_utils.get_udfs_path()
19+
else:
20+
self.udfs_dir = udfs_dir
21+
22+
def __res_file_path(self, name):
23+
return os.path.join(self.res_dir, name)
24+
25+
def yql_exec(self, program=None, program_file=None, verbose=False, check_error=True, tables=None):
26+
udfs_dir = self.udfs_dir
27+
28+
config_file = self.config_file
29+
program_file = yql_utils.prepare_program(program, program_file, self.res_dir, ext='sql')[1]
30+
scheme_file = self.scheme_file
31+
32+
results_file = self.__res_file_path('results.txt')
33+
log_file = self.__res_file_path('log.txt')
34+
35+
cmd = self.kqprun_binary + ' '
36+
37+
cmd += '--emulate-yt ' \
38+
'--clear-execution ' \
39+
'--app-config=%(config_file)s ' \
40+
'--script-query=%(program_file)s ' \
41+
'--scheme-query=%(scheme_file)s ' \
42+
'--result-file=%(results_file)s ' \
43+
'--log-file=%(log_file)s ' \
44+
'--udfs-dir=%(udfs_dir)s ' \
45+
'--result-rows-limit 0 ' % locals()
46+
47+
if tables is not None:
48+
for table in tables:
49+
cmd += '--table=yt.Root/%s@%s ' % (table.full_name, table.yqlrun_file)
50+
51+
proc_result = yatest.common.process.execute(cmd.strip().split(), check_exit_code=False, cwd=self.res_dir)
52+
if proc_result.exit_code != 0 and check_error:
53+
assert 0, \
54+
'Command\n%(command)s\n finished with exit code %(code)d, stderr:\n\n%(stderr)s\n\nlog file:\n%(log_file)s' % {
55+
'command': cmd,
56+
'code': proc_result.exit_code,
57+
'stderr': proc_result.std_err,
58+
'log_file': yql_utils.read_res_file(log_file)[1]
59+
}
60+
61+
results, log_results = yql_utils.read_res_file(results_file)
62+
err, log_err = yql_utils.read_res_file(log_file)
63+
64+
if verbose:
65+
yql_utils.log('PROGRAM:')
66+
yql_utils.log(program)
67+
yql_utils.log('RESULTS:')
68+
yql_utils.log(log_results)
69+
yql_utils.log('ERROR:')
70+
yql_utils.log(log_err)
71+
72+
return yql_utils.YQLExecResult(
73+
proc_result.std_out,
74+
yql_utils.normalize_source_code_path(err.replace(self.res_dir, '<tmp_path>')),
75+
results,
76+
results_file,
77+
None,
78+
None,
79+
None,
80+
None,
81+
program,
82+
proc_result,
83+
None
84+
)

ydb/library/yql/tests/common/test_framework/ya.make

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ PY23_LIBRARY()
22

33
PY_SRCS(
44
TOP_LEVEL
5+
kqprun.py
56
yql_utils.py
67
yql_ports.py
78
yqlrun.py

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

+52-11
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from google.protobuf import text_format
1212
from yql_utils import execute_sql, get_supported_providers, get_tables, get_files, get_http_files, \
1313
get_pragmas, log, KSV_ATTR, is_xfail, get_param, YQLExecResult, yql_binary_path
14+
from kqprun import KqpRun
1415
from yqlrun import YQLRun
1516

1617
from utils import get_config, get_parameters_json, DATA_PATH
@@ -41,7 +42,11 @@ def get_gateways_config(http_files, yql_http_file_server, force_blocks=False, is
4142
return config
4243

4344

44-
def run_file_no_cache(provider, suite, case, cfg, config, yql_http_file_server, yqlrun_binary=None, extra_args=[], force_blocks=False):
45+
def is_hybrid(provider):
46+
return provider == 'hybrid'
47+
48+
49+
def get_sql_query(provider, suite, case, config):
4550
if provider not in get_supported_providers(config):
4651
pytest.skip('%s provider is not supported here' % provider)
4752

@@ -51,30 +56,37 @@ def run_file_no_cache(provider, suite, case, cfg, config, yql_http_file_server,
5156
if "yson" in case or "regexp" in case or "match" in case:
5257
pytest.skip('yson/match/regexp is not supported on non-default target platform')
5358

54-
xfail = is_xfail(config)
55-
if get_param('TARGET_PLATFORM') and xfail:
59+
if get_param('TARGET_PLATFORM') and is_xfail(config):
5660
pytest.skip('xfail is not supported on non-default target platform')
5761

58-
in_tables, out_tables = get_tables(suite, config, DATA_PATH, def_attr=KSV_ATTR)
59-
files = get_files(suite, config, DATA_PATH)
60-
http_files = get_http_files(suite, config, DATA_PATH)
61-
http_files_urls = yql_http_file_server.register_files({}, http_files)
62-
6362
program_sql = os.path.join(DATA_PATH, suite, '%s.sql' % case)
64-
is_hybrid = provider == 'hybrid'
6563

6664
with codecs.open(program_sql, encoding='utf-8') as program_file_descr:
6765
sql_query = program_file_descr.read()
6866
if get_param('TARGET_PLATFORM'):
6967
if "Yson::" in sql_query:
7068
pytest.skip('yson udf is not supported on non-default target platform')
71-
if (provider + 'file can not' in sql_query) or (is_hybrid and ('ytfile can not' in sql_query)):
69+
if (provider + 'file can not' in sql_query) or (is_hybrid(provider) and ('ytfile can not' in sql_query)):
7270
pytest.skip(provider + ' can not execute this')
7371

7472
pragmas.append(sql_query)
7573
sql_query = ';\n'.join(pragmas)
7674
if 'Python' in sql_query or 'Javascript' in sql_query:
7775
pytest.skip('ScriptUdf')
76+
77+
return sql_query
78+
79+
80+
def run_file_no_cache(provider, suite, case, cfg, config, yql_http_file_server, yqlrun_binary=None, extra_args=[], force_blocks=False):
81+
sql_query = get_sql_query(provider, suite, case, config)
82+
83+
xfail = is_xfail(config)
84+
85+
in_tables, out_tables = get_tables(suite, config, DATA_PATH, def_attr=KSV_ATTR)
86+
files = get_files(suite, config, DATA_PATH)
87+
http_files = get_http_files(suite, config, DATA_PATH)
88+
http_files_urls = yql_http_file_server.register_files({}, http_files)
89+
7890
for table in in_tables:
7991
if cyson.loads(table.attr).get("type") == "document":
8092
content = table.content
@@ -89,7 +101,7 @@ def run_file_no_cache(provider, suite, case, cfg, config, yql_http_file_server,
89101
prov=provider,
90102
keep_temp=not re.search(r"yt\.ReleaseTempData", sql_query),
91103
binary=yqlrun_binary,
92-
gateway_config=get_gateways_config(http_files, yql_http_file_server, force_blocks=force_blocks, is_hybrid=is_hybrid),
104+
gateway_config=get_gateways_config(http_files, yql_http_file_server, force_blocks=force_blocks, is_hybrid=is_hybrid(provider)),
93105
extra_args=extra_args,
94106
udfs_dir=yql_binary_path('ydb/library/yql/tests/common/test_framework/udfs_deps')
95107
)
@@ -129,11 +141,40 @@ def run_file_no_cache(provider, suite, case, cfg, config, yql_http_file_server,
129141
return fixed_result, tables_res
130142

131143

144+
def run_file_kqp_no_cache(suite, case, cfg):
145+
config = get_config(suite, case, cfg)
146+
147+
if is_xfail(config):
148+
pytest.skip('skip fail tests')
149+
150+
sql_query = get_sql_query('yt', suite, case, config)
151+
in_tables = get_tables(suite, config, DATA_PATH, def_attr=KSV_ATTR)[0]
152+
153+
kqprun = KqpRun(
154+
udfs_dir=yql_binary_path('ydb/library/yql/tests/common/test_framework/udfs_deps')
155+
)
156+
157+
return kqprun.yql_exec(
158+
program=sql_query,
159+
verbose=True,
160+
check_error=True,
161+
tables=in_tables
162+
)
163+
164+
132165
def run_file(provider, suite, case, cfg, config, yql_http_file_server, yqlrun_binary=None, extra_args=[], force_blocks=False):
133166
if (suite, case, cfg) not in run_file.cache:
134167
run_file.cache[(suite, case, cfg)] = run_file_no_cache(provider, suite, case, cfg, config, yql_http_file_server, yqlrun_binary, extra_args, force_blocks=force_blocks)
135168

136169
return run_file.cache[(suite, case, cfg)]
137170

138171

172+
def run_file_kqp(suite, case, cfg):
173+
if (suite, case, cfg) not in run_file_kqp.cache:
174+
run_file_kqp.cache[(suite, case, cfg)] = run_file_kqp_no_cache(suite, case, cfg)
175+
176+
return run_file_kqp.cache[(suite, case, cfg)]
177+
178+
139179
run_file.cache = {}
180+
run_file_kqp.cache = {}
+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
PY2TEST()
2+
3+
TEST_SRCS(
4+
test.py
5+
)
6+
7+
IF (SANITIZER_TYPE OR WITH_VALGRIND)
8+
TIMEOUT(1800)
9+
SIZE(LARGE)
10+
TAG(ya:fat sb:ttl=2)
11+
ELSE()
12+
TIMEOUT(600)
13+
SIZE(MEDIUM)
14+
TAG(sb:ttl=2)
15+
ENDIF()
16+
17+
DEPENDS(
18+
ydb/library/yql/tests/common/test_framework/udfs_deps
19+
ydb/tests/tools/kqprun
20+
)
21+
22+
DATA(
23+
arcadia/ydb/library/yql/tests/sql # python files
24+
arcadia/ydb/library/yql/cfg/tests
25+
)
26+
27+
PEERDIR(
28+
ydb/library/yql/tests/common/test_framework
29+
)
30+
31+
NO_CHECK_IMPORTS()
32+
33+
REQUIREMENTS(ram:20)
34+
35+
END()

0 commit comments

Comments
 (0)