Skip to content

Commit 72fa58e

Browse files
committed
Fix leftover processes/hangs in tests
One of such cases is 02479_race_condition_between_insert_and_droppin_mv [1], yes it can be fixed (by using fixed number of iterations, or with some bash trickery), but it is better to fix them completelly, eventually such tests will be submitted and pass review anyway. By allocating process group for each test we can kill all the processes in this process group, and this what this patch does. This will also fix some test hangs (like in [1]) as well as some possible issues in stress tests. [1]: https://s3.amazonaws.com/clickhouse-test-reports/0/e2c1230b00386c4d0096a245396ab3be7ce60950/stateless_tests__release__analyzer_/run.log Signed-off-by: Azat Khuzhin <[email protected]>
1 parent a30980c commit 72fa58e

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

tests/clickhouse-test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,7 @@ class TestCase:
10311031
if proc:
10321032
if proc.returncode is None:
10331033
try:
1034-
proc.kill()
1034+
os.killpg(os.getpgid(proc.pid), signal.SIGKILL)
10351035
except OSError as e:
10361036
if e.errno != ESRCH:
10371037
raise
@@ -1307,7 +1307,7 @@ class TestCase:
13071307

13081308
command = pattern.format(**params)
13091309

1310-
proc = Popen(command, shell=True, env=os.environ)
1310+
proc = Popen(command, shell=True, env=os.environ, start_new_session=True)
13111311

13121312
while (
13131313
datetime.now() - start_time

tests/queries/shell_config.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,3 +185,11 @@ function query_with_retry
185185
done
186186
echo "Query '$query' failed with '$result'"
187187
}
188+
189+
# Add --foreground to avoid running setpgid() in timeout, otherwise
190+
# clickhouse-test will not kill those processes in case of timeout
191+
function timeout()
192+
{
193+
command timeout --foreground "$@"
194+
}
195+
export -f timeout

0 commit comments

Comments
 (0)