mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 00:52:02 +00:00
Fix server pid in fuzzer tests
Previously it was the pid of the subshell 40 while it should be the pid of the clickhouse-server 39: Here we see that the server pid is 39: 2021-09-28 11:02:34 + pgrep -f clickhouse-server 2021-09-28 11:02:34 39 Here we see that the 40 is the pid of subshell: 2021-09-28 11:02:45 ch/docker/test/fuzzer/run-fuzzer.sh: line 90: 39 Killed clickhouse-server --config-file db/config.xml -- --path db 2>&1 2021-09-28 11:02:45 40 Done | tail -100000 > server.log And here we see that server_pid variable is 40: 2021-09-28 11:02:45 + server_exit_code=0 2021-09-28 11:02:45 + wait 40 v2: wait in background to call wait in foreground and ensure that the process is alive, since w/o job control this is the only way to obtain the exit code
This commit is contained in:
parent
27f6d5864d
commit
769bfbe71f
@ -86,6 +86,27 @@ function filter_exists_and_template
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function stop_server
|
||||||
|
{
|
||||||
|
clickhouse-client --query "select elapsed, query from system.processes" ||:
|
||||||
|
killall clickhouse-server ||:
|
||||||
|
for _ in {1..10}
|
||||||
|
do
|
||||||
|
if ! pgrep -f clickhouse-server
|
||||||
|
then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
killall -9 clickhouse-server ||:
|
||||||
|
|
||||||
|
# Debug.
|
||||||
|
date
|
||||||
|
sleep 10
|
||||||
|
jobs
|
||||||
|
pstree -aspgT
|
||||||
|
}
|
||||||
|
|
||||||
function fuzz
|
function fuzz
|
||||||
{
|
{
|
||||||
/generate-test-j2.py --path ch/tests/queries/0_stateless
|
/generate-test-j2.py --path ch/tests/queries/0_stateless
|
||||||
@ -102,9 +123,28 @@ function fuzz
|
|||||||
NEW_TESTS_OPT="${NEW_TESTS_OPT:-}"
|
NEW_TESTS_OPT="${NEW_TESTS_OPT:-}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export CLICKHOUSE_WATCHDOG_ENABLE=0 # interferes with gdb
|
# interferes with gdb
|
||||||
clickhouse-server --config-file db/config.xml -- --path db 2>&1 | tail -100000 > server.log &
|
export CLICKHOUSE_WATCHDOG_ENABLE=0
|
||||||
server_pid=$!
|
# NOTE: that $! cannot be used to obtain the server pid, since it will be
|
||||||
|
# the pid of the bash, due to piping the output of clickhouse-server to
|
||||||
|
# tail
|
||||||
|
PID_FILE=clickhouse-server.pid
|
||||||
|
clickhouse-server --pidfile=$PID_FILE --config-file db/config.xml -- --path db 2>&1 | tail -100000 > server.log &
|
||||||
|
|
||||||
|
server_pid=-1
|
||||||
|
for _ in {1..60}; do
|
||||||
|
if [ -s $PID_FILE ]; then
|
||||||
|
server_pid=$(cat $PID_FILE)
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ $server_pid = -1 ]; then
|
||||||
|
echo "Server did not started" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
kill -0 $server_pid
|
kill -0 $server_pid
|
||||||
|
|
||||||
echo "
|
echo "
|
||||||
@ -180,25 +220,10 @@ continue
|
|||||||
server_died=1
|
server_died=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Stop the server.
|
# wait in background to call wait in foreground and ensure that the
|
||||||
clickhouse-client --query "select elapsed, query from system.processes" ||:
|
# process is alive, since w/o job control this is the only way to obtain
|
||||||
killall clickhouse-server ||:
|
# the exit code
|
||||||
for _ in {1..10}
|
stop_server &
|
||||||
do
|
|
||||||
if ! pgrep -f clickhouse-server
|
|
||||||
then
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
killall -9 clickhouse-server ||:
|
|
||||||
|
|
||||||
# Debug.
|
|
||||||
date
|
|
||||||
sleep 10
|
|
||||||
jobs
|
|
||||||
pstree -aspgT
|
|
||||||
|
|
||||||
server_exit_code=0
|
server_exit_code=0
|
||||||
wait $server_pid || server_exit_code=$?
|
wait $server_pid || server_exit_code=$?
|
||||||
echo "Server exit code is $server_exit_code"
|
echo "Server exit code is $server_exit_code"
|
||||||
|
Loading…
Reference in New Issue
Block a user