forked from ydb-platform/ydb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
YQ-2738 add integration tests for YT in KQP (ydb-platform#3150)
- Loading branch information
1 parent
b97ec75
commit de0e2d1
Showing
74 changed files
with
6,256 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
FeatureFlags { | ||
EnableExternalDataSources: true | ||
EnableScriptExecutionOperations: true | ||
} | ||
|
||
QueryServiceConfig { | ||
FileStorage { | ||
MaxFiles: 1000 | ||
MaxSizeMb: 512 | ||
RetryCount: 3 | ||
Threads: 2 | ||
} | ||
|
||
Yt { | ||
DefaultSettings { | ||
Name: "InferSchema" | ||
Value: "1" | ||
} | ||
DefaultSettings { | ||
Name: "_EnableYtPartitioning" | ||
Value: "true" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
CREATE OBJECT yt_token (TYPE SECRET) WITH (value = "token"); | ||
|
||
CREATE EXTERNAL DATA SOURCE plato WITH ( | ||
SOURCE_TYPE="YT", | ||
LOCATION="localhost", | ||
AUTH_METHOD="TOKEN", | ||
TOKEN_SECRET_NAME="yt_token" | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import os | ||
|
||
import yatest.common | ||
|
||
import yql_utils | ||
|
||
|
||
class KqpRun(object): | ||
def __init__(self, udfs_dir=None): | ||
self.kqprun_binary = yql_utils.yql_binary_path('ydb/tests/tools/kqprun/kqprun') | ||
|
||
self.config_file = yql_utils.yql_source_path(os.path.join('ydb/library/yql/cfg/tests', 'kqprun_config.conf')) | ||
self.scheme_file = yql_utils.yql_source_path(os.path.join('ydb/library/yql/cfg/tests', 'kqprun_scheme.sql')) | ||
|
||
self.res_dir = yql_utils.get_yql_dir(prefix='kqprun_') | ||
|
||
if udfs_dir is None: | ||
self.udfs_dir = yql_utils.get_udfs_path() | ||
else: | ||
self.udfs_dir = udfs_dir | ||
|
||
def __res_file_path(self, name): | ||
return os.path.join(self.res_dir, name) | ||
|
||
def yql_exec(self, program=None, program_file=None, verbose=False, check_error=True, tables=None): | ||
udfs_dir = self.udfs_dir | ||
|
||
config_file = self.config_file | ||
program_file = yql_utils.prepare_program(program, program_file, self.res_dir, ext='sql')[1] | ||
scheme_file = self.scheme_file | ||
|
||
results_file = self.__res_file_path('results.txt') | ||
log_file = self.__res_file_path('log.txt') | ||
|
||
cmd = self.kqprun_binary + ' ' | ||
|
||
cmd += '--emulate-yt ' \ | ||
'--clear-execution ' \ | ||
'--exclude-linked-udfs ' \ | ||
'--app-config=%(config_file)s ' \ | ||
'--script-query=%(program_file)s ' \ | ||
'--scheme-query=%(scheme_file)s ' \ | ||
'--result-file=%(results_file)s ' \ | ||
'--log-file=%(log_file)s ' \ | ||
'--udfs-dir=%(udfs_dir)s ' \ | ||
'--result-rows-limit 0 ' % locals() | ||
|
||
if tables is not None: | ||
for table in tables: | ||
cmd += '--table=yt.Root/%s@%s ' % (table.full_name, table.yqlrun_file) | ||
|
||
proc_result = yatest.common.process.execute(cmd.strip().split(), check_exit_code=False, cwd=self.res_dir) | ||
if proc_result.exit_code != 0 and check_error: | ||
assert 0, \ | ||
'Command\n%(command)s\n finished with exit code %(code)d, stderr:\n\n%(stderr)s\n\nlog file:\n%(log_file)s' % { | ||
'command': cmd, | ||
'code': proc_result.exit_code, | ||
'stderr': proc_result.std_err, | ||
'log_file': yql_utils.read_res_file(log_file)[1] | ||
} | ||
|
||
results, log_results = yql_utils.read_res_file(results_file) | ||
err, log_err = yql_utils.read_res_file(log_file) | ||
|
||
if verbose: | ||
yql_utils.log('PROGRAM:') | ||
yql_utils.log(program) | ||
yql_utils.log('RESULTS:') | ||
yql_utils.log(log_results) | ||
yql_utils.log('ERROR:') | ||
yql_utils.log(log_err) | ||
|
||
return yql_utils.YQLExecResult( | ||
proc_result.std_out, | ||
yql_utils.normalize_source_code_path(err.replace(self.res_dir, '<tmp_path>')), | ||
results, | ||
results_file, | ||
None, | ||
None, | ||
None, | ||
None, | ||
program, | ||
proc_result, | ||
None | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ PY23_LIBRARY() | |
|
||
PY_SRCS( | ||
TOP_LEVEL | ||
kqprun.py | ||
yql_utils.py | ||
yql_ports.py | ||
yqlrun.py | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,5 @@ RECURSE_FOR_TESTS( | |
restarts | ||
s3 | ||
yds | ||
yt | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
PY2TEST() | ||
|
||
TEST_SRCS( | ||
test.py | ||
) | ||
|
||
IF (SANITIZER_TYPE OR WITH_VALGRIND) | ||
TIMEOUT(1800) | ||
SIZE(LARGE) | ||
TAG(ya:fat sb:ttl=2) | ||
ELSE() | ||
TIMEOUT(600) | ||
SIZE(MEDIUM) | ||
TAG(sb:ttl=2) | ||
ENDIF() | ||
|
||
DEPENDS( | ||
ydb/library/yql/tests/common/test_framework/udfs_deps | ||
ydb/tests/tools/kqprun | ||
) | ||
|
||
DATA( | ||
arcadia/ydb/library/yql/cfg/tests | ||
arcadia/ydb/library/yql/tests/sql | ||
arcadia/ydb/tests/fq/yt | ||
) | ||
|
||
PEERDIR( | ||
ydb/library/yql/tests/common/test_framework | ||
) | ||
|
||
NO_CHECK_IMPORTS() | ||
|
||
REQUIREMENTS(ram:20) | ||
|
||
END() |
Oops, something went wrong.