Merge pull request #68487 from azat/tests/capture-kill-output

Fix output of clickhouse-test in case of tests timeouts
This commit is contained in:
alesapin 2024-08-28 09:40:32 +00:00 committed by GitHub
commit d8bf6bfc07
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -30,6 +30,7 @@ import subprocess
import sys
import traceback
import urllib.parse
import io
# for crc32
import zlib
@ -39,8 +40,10 @@ from errno import ESRCH
from subprocess import PIPE, Popen
from time import sleep, time
from typing import Dict, List, Optional, Set, Tuple, Union
from contextlib import redirect_stdout
from ast import literal_eval as make_tuple
try:
import termcolor # type: ignore
except ImportError:
@ -1342,9 +1345,13 @@ class TestCase:
return None
def process_result_impl(self, proc, total_time: float):
kill_output = ""
if proc:
if proc.returncode is None:
kill_process_group(os.getpgid(proc.pid))
f = io.StringIO()
with redirect_stdout(f):
kill_process_group(os.getpgid(proc.pid))
kill_output = f.getvalue()
description = ""
@ -1360,7 +1367,7 @@ class TestCase:
with open(self.stdout_file, "rb") as stdfd:
stdout = str(stdfd.read(), errors="replace", encoding="utf-8")
stderr = ""
stderr = kill_output
if os.path.exists(self.stderr_file):
with open(self.stderr_file, "rb") as stdfd:
stderr += str(stdfd.read(), errors="replace", encoding="utf-8")