Skip to content

Commit

Permalink
Merge pull request #58200 from azat/tests/processes-cleanup
Browse files Browse the repository at this point in the history
Fix leftover processes/hangs in tests
  • Loading branch information
alexey-milovidov committed Dec 24, 2023
2 parents 2544e46 + 72fa58e commit 069f8bb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tests/clickhouse-test
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,7 @@ class TestCase:
if proc:
if proc.returncode is None:
try:
proc.kill()
os.killpg(os.getpgid(proc.pid), signal.SIGKILL)
except OSError as e:
if e.errno != ESRCH:
raise
Expand Down Expand Up @@ -1307,7 +1307,7 @@ class TestCase:

command = pattern.format(**params)

proc = Popen(command, shell=True, env=os.environ)
proc = Popen(command, shell=True, env=os.environ, start_new_session=True)

while (
datetime.now() - start_time
Expand Down
8 changes: 8 additions & 0 deletions tests/queries/shell_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,11 @@ function query_with_retry
done
echo "Query '$query' failed with '$result'"
}

# Add --foreground to avoid running setpgid() in timeout, otherwise
# clickhouse-test will not kill those processes in case of timeout
function timeout()
{
command timeout --foreground "$@"
}
export -f timeout

0 comments on commit 069f8bb

Please sign in to comment.