Skip to content

Commit c759dcc

Browse files
committed
Trying to debug kqprun pt. 2
1 parent 031bb5c commit c759dcc

File tree

4 files changed

+28
-33
lines changed

4 files changed

+28
-33
lines changed

ydb/library/yql/providers/generic/connector/tests/utils/run/dqrun.py

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -228,13 +228,25 @@ def run(self, test_name: str, script: str, generic_settings: GenericSettings) ->
228228

229229
# For debug add option --trace-opt to args
230230
cmd = f'{self.dqrun_path} -s -p {script_path} --fs-cfg={fs_conf_path} --gateways-cfg={gateways_conf_path} --result-file={result_path} --format="binary" -v 7'
231-
out = subprocess.run(cmd, shell=True, capture_output=True)
232231

232+
output = None
233233
data_out = None
234234
data_out_with_types = None
235235
schema = None
236+
returncode = 0
236237

237-
if out.returncode == 0:
238+
try:
239+
output = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT, timeout=60)
240+
except subprocess.CalledProcessError as e:
241+
LOGGER.error(
242+
'Execution failed:\n\nSTDOUT: %s\n\nSTDERR: %s\n\n',
243+
e.stdout.decode('utf-8') if e.stdout else None,
244+
e.stderr.decode('utf-8') if e.stderr else None,
245+
)
246+
247+
output = e.stdout
248+
returncode = e.returncode
249+
else:
238250
LOGGER.info('Execution succeeded: ')
239251
# Parse output
240252
with open(result_path, 'r') as f:
@@ -250,24 +262,15 @@ def run(self, test_name: str, script: str, generic_settings: GenericSettings) ->
250262

251263
artifacts.dump_yson(data_out, test_name, "data_out.yson")
252264
artifacts.dump_str(data_out_with_types, test_name, "data_out_with_types.yson")
253-
else:
254-
LOGGER.error(
255-
'Execution failed:\n\nSTDOUT: %s\n\nSTDERR: %s\n\n',
256-
out.stdout.decode('utf-8'),
257-
out.stderr.decode('utf-8'),
258-
)
259-
260-
with open(artifacts.make_path(test_name, "dqrun.err"), "w") as f:
261-
f.write(out.stderr.decode('utf-8'))
262265

263-
with open(artifacts.make_path(test_name, "dqrun.out"), "w") as f:
264-
f.write(out.stdout.decode('utf-8'))
266+
finally:
267+
with open(artifacts.make_path(test_name, "kqprun.out"), "w") as f:
268+
f.write(output.decode('utf-8'))
265269

266270
return Result(
267271
data_out=data_out,
268272
data_out_with_types=data_out_with_types,
269273
schema=schema,
270-
stdout=out.stdout.decode('utf-8'),
271-
stderr=out.stderr.decode('utf-8'),
272-
returncode=out.returncode,
274+
output=output.decode('utf-8') if output else None,
275+
returncode=returncode,
273276
)

ydb/library/yql/providers/generic/connector/tests/utils/run/kqprun.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -193,24 +193,22 @@ def run(self, test_name: str, script: str, generic_settings: GenericSettings) ->
193193
# For debug add option --trace-opt to args
194194
cmd = f'{self.kqprun_path} -s {scheme_path} -p {script_path} --app-config={app_conf_path} --result-file={result_path} --result-format=full'
195195

196-
stdout = None
197-
stderr = None
196+
output = None
198197
data_out = None
199198
data_out_with_types = None
200199
schema = None
201200
returncode = 0
202201

203202
try:
204-
stdout = subprocess.check_output(cmd, shell=True, timeout=60)
203+
output = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT, timeout=60)
205204
except subprocess.CalledProcessError as e:
206205
LOGGER.error(
207206
'Execution failed:\n\nSTDOUT: %s\n\nSTDERR: %s\n\n',
208207
e.stdout.decode('utf-8') if e.stdout else None,
209208
e.stderr.decode('utf-8') if e.stderr else None,
210209
)
211210

212-
stdout = e.stdout
213-
stderr = e.stderr
211+
output = e.stdout
214212
returncode = e.returncode
215213
else:
216214
# Parse output
@@ -240,18 +238,13 @@ def run(self, test_name: str, script: str, generic_settings: GenericSettings) ->
240238
artifacts.dump_str(data_out_with_types, test_name, "data_out_with_types.yson")
241239

242240
finally:
243-
if stderr:
244-
with open(artifacts.make_path(test_name, "kqprun.err"), "w") as f:
245-
f.write(stderr.decode('utf-8'))
246-
247241
with open(artifacts.make_path(test_name, "kqprun.out"), "w") as f:
248-
f.write(stdout.decode('utf-8'))
242+
f.write(output.decode('utf-8'))
249243

250244
return Result(
251245
data_out=data_out,
252246
data_out_with_types=data_out_with_types,
253247
schema=schema,
254-
stdout=stdout.decode('utf-8') if stdout else None,
255-
stderr=stderr.decode('utf-8') if stderr else None,
248+
output=output.decode('utf-8') if output else None,
256249
returncode=returncode,
257250
)

ydb/library/yql/providers/generic/connector/tests/utils/run/result.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,5 @@ class Result:
1010
data_out: Optional[yson.yson_types.YsonList]
1111
data_out_with_types: Optional[List]
1212
schema: Optional[Schema]
13-
stdout: str
14-
stderr: str
13+
output: str
1514
returncode: int

ydb/library/yql/providers/generic/connector/tests/utils/scenario/clickhouse.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def select_positive(
101101
generic_settings=test_case.generic_settings,
102102
)
103103

104-
assert result.returncode == 0, result.stderr
104+
assert result.returncode == 0, result.output
105105

106106
assert data_outs_equal(test_case.data_out, result.data_out_with_types), (
107107
test_case.data_out,
@@ -128,7 +128,7 @@ def select_missing_database(
128128
generic_settings=test_case.generic_settings,
129129
)
130130

131-
assert test_case.database.missing_database_msg() in result.stderr, result.stderr
131+
assert test_case.database.missing_database_msg() in result.output, result.output
132132

133133

134134
def select_missing_table(
@@ -153,4 +153,4 @@ def select_missing_table(
153153
generic_settings=test_case.generic_settings,
154154
)
155155

156-
assert test_case.database.missing_table_msg() in result.stderr, result.stderr
156+
assert test_case.database.missing_table_msg() in result.output, result.output

0 commit comments

Comments
 (0)