mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-12 09:22:05 +00:00
Merge pull request #72793 from ClickHouse/integration-tests-output
Output logs for integration tests, add TeePopen.terminate
This commit is contained in:
commit
2f3f5dbe0f
@ -655,13 +655,12 @@ class ClickhouseIntegrationTestsRunner:
|
||||
|
||||
log_basename = test_group_str + "_" + str(i) + ".log"
|
||||
log_path = os.path.join(self.repo_path, "tests/integration", log_basename)
|
||||
with open(log_path, "w", encoding="utf-8") as log:
|
||||
logging.info("Executing cmd: %s", cmd)
|
||||
# ignore retcode, since it meaningful due to pipe to tee
|
||||
with subprocess.Popen(cmd, shell=True, stderr=log, stdout=log) as proc:
|
||||
global runner_subprocess # pylint:disable=global-statement
|
||||
runner_subprocess = proc
|
||||
proc.wait()
|
||||
logging.info("Executing cmd: %s", cmd)
|
||||
# ignore retcode, since it meaningful due to pipe to tee
|
||||
with TeePopen(cmd, log_path) as proc:
|
||||
global runner_subprocess # pylint:disable=global-statement
|
||||
runner_subprocess = proc
|
||||
proc.wait()
|
||||
|
||||
extra_logs_names = [log_basename]
|
||||
log_result_path = os.path.join(
|
||||
@ -1089,7 +1088,7 @@ def run():
|
||||
|
||||
|
||||
timeout_expired = False
|
||||
runner_subprocess = None # type:Optional[subprocess.Popen]
|
||||
runner_subprocess = None # type:Optional[TeePopen]
|
||||
|
||||
|
||||
def handle_sigterm(signum, _frame):
|
||||
@ -1098,7 +1097,7 @@ def handle_sigterm(signum, _frame):
|
||||
global timeout_expired # pylint:disable=global-statement
|
||||
timeout_expired = True
|
||||
if runner_subprocess:
|
||||
runner_subprocess.send_signal(signal.SIGTERM)
|
||||
runner_subprocess.terminate()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -43,22 +43,24 @@ class TeePopen:
|
||||
self.process.pid,
|
||||
self.timeout,
|
||||
)
|
||||
self.send_signal(signal.SIGTERM)
|
||||
time_wait = 0
|
||||
self.terminated_by_sigterm = True
|
||||
self.timeout_exceeded = True
|
||||
while self.process.poll() is None and time_wait < 100:
|
||||
print("wait...")
|
||||
wait = 5
|
||||
sleep(wait)
|
||||
time_wait += wait
|
||||
self.terminate()
|
||||
|
||||
def terminate(self, wait_before_kill: int = 100) -> None:
|
||||
time_wait = 0
|
||||
time_sleep = 5
|
||||
self.terminated_by_sigterm = True
|
||||
self.send_signal(signal.SIGTERM)
|
||||
while self.process.poll() is None and time_wait < wait_before_kill:
|
||||
logging.warning("Wait the process %s to terminate", self.process.pid)
|
||||
sleep(time_sleep)
|
||||
time_wait += time_sleep
|
||||
|
||||
self.terminated_by_sigkill = True
|
||||
while self.process.poll() is None:
|
||||
logging.error(
|
||||
"Process is still running. Send SIGKILL",
|
||||
)
|
||||
logging.error("Process is still running. Send SIGKILL")
|
||||
self.send_signal(signal.SIGKILL)
|
||||
self.terminated_by_sigkill = True
|
||||
sleep(5)
|
||||
sleep(time_sleep)
|
||||
|
||||
def __enter__(self) -> "TeePopen":
|
||||
self.process = Popen(
|
||||
|
Loading…
Reference in New Issue
Block a user