提交 039cf36a 编写于 作者: A Alexander Kuzmenkov

Minor fixes for query fuzzer

上级 97e8a88b
......@@ -37,6 +37,8 @@ function download
wget -nv -nd -c "https://clickhouse-builds.s3.yandex.net/$PR_TO_TEST/$SHA_TO_TEST/clickhouse_build_check/clang-10_debug_none_bundled_unsplitted_disable_False_binary/clickhouse"
chmod +x clickhouse
ln -s ./clickhouse ./clickhouse-server
ln -s ./clickhouse ./clickhouse-client
}
function configure
......@@ -54,30 +56,57 @@ function watchdog
sleep 3600
echo "Fuzzing run has timed out"
./clickhouse client --query "select elapsed, query from system.processes" ||:
killall -9 clickhouse clickhouse-server clickhouse-client ||:
killall clickhouse-client ||:
for x in {1..10}
do
if ! pgrep -f clickhouse-client
then
break
fi
sleep 1
done
./clickhouse-client --query "select elapsed, query from system.processes" ||:
killall clickhouse-server ||:
for x in {1..10}
do
if ! pgrep -f clickhouse-server
then
break
fi
sleep 1
done
killall -9 clickhouse-server clickhouse-client ||:
}
function fuzz
{
./clickhouse server --config-file db/config.xml -- --path db 2>&1 | tail -100000 > server.log &
./clickhouse-server --config-file db/config.xml -- --path db 2>&1 | tail -100000 > server.log &
server_pid=$!
kill -0 $server_pid
while ! ./clickhouse client --query "select 1" && kill -0 $server_pid ; do echo . ; sleep 1 ; done
./clickhouse client --query "select 1"
while ! ./clickhouse-client --query "select 1" && kill -0 $server_pid ; do echo . ; sleep 1 ; done
./clickhouse-client --query "select 1"
kill -0 $server_pid
echo Server started
fuzzer_exit_code=0
./clickhouse client --query-fuzzer-runs=1000 \
./clickhouse-client --query-fuzzer-runs=1000 \
< <(for f in $(ls ch/tests/queries/0_stateless/*.sql | sort -R); do cat "$f"; echo ';'; done) \
> >(tail -100000 > fuzzer.log) \
2>&1 \
|| fuzzer_exit_code=$?
echo "Fuzzer exit code is $fuzzer_exit_code"
./clickhouse client --query "select elapsed, query from system.processes" ||:
./clickhouse-client --query "select elapsed, query from system.processes" ||:
kill -9 $server_pid ||:
if [ "$fuzzer_exit_code" == "137" ]
then
# Killed by watchdog, meaning, no errors.
return 0
fi
return $fuzzer_exit_code
}
......@@ -106,11 +135,19 @@ case "$stage" in
time configure
;&
"fuzz")
# Start a watchdog that should kill the fuzzer on timeout.
# The shell won't kill the child sleep when we kill it, so we have to put it
# into a separate process group so that we can kill them all.
set -m
watchdog &
watchdog_pid=$!
set +m
# Check that the watchdog has started
kill -0 $watchdog_pid
fuzzer_exit_code=0
time fuzz || fuzzer_exit_code=$?
kill $watchdog_pid ||:
kill -- -$watchdog_pid ||:
# Debug
date
......@@ -118,6 +155,19 @@ case "$stage" in
jobs
pstree -aspgT
# Make files with status and description we'll show for this check on Github
if [ "$fuzzer_exit_code" == 0 ]
then
echo "OK" > description.txt
echo "success" > status.txt
else
echo "failure" > status.txt
if ! grep -m2 "received signal \|Logical error" server-log.txt > description.txt
then
echo "Fuzzer exit code $fuzzer_exit_code. See the logs" > description.txt
fi
fi
exit $fuzzer_exit_code
;&
esac
......
......@@ -216,7 +216,7 @@ private:
ConnectionParameters connection_parameters;
QueryFuzzer fuzzer;
int query_fuzzer_runs;
int query_fuzzer_runs = 0;
void initialize(Poco::Util::Application & self) override
{
......@@ -1041,10 +1041,12 @@ private:
begin - text.data());
ASTPtr fuzz_base = orig_ast;
for (int fuzz_step = 0; fuzz_step < query_fuzzer_runs; fuzz_step++)
// Don't repeat inserts, the tables grow too big.
const int this_query_runs = as_insert ? 1 : query_fuzzer_runs;
for (int fuzz_step = 0; fuzz_step < this_query_runs; fuzz_step++)
{
fprintf(stderr, "fuzzing step %d for query at pos %zd\n",
fuzz_step, this_query_begin - text.data());
fprintf(stderr, "fuzzing step %d out of %d for query at pos %zd\n",
fuzz_step, this_query_runs, this_query_begin - text.data());
ASTPtr ast_to_process;
try
......@@ -1058,7 +1060,11 @@ private:
std::stringstream dump_of_cloned_ast;
ast_to_process->dumpTree(dump_of_cloned_ast);
fuzzer.fuzzMain(ast_to_process);
// Run the original query as well.
if (fuzz_step > 0)
{
fuzzer.fuzzMain(ast_to_process);
}
auto base_after_fuzz = fuzz_base->formatForErrorMessage();
......
......@@ -222,7 +222,7 @@ struct ValueGetterBuilderImpl<>
static TernaryValueGetter build(const IColumn * x)
{
throw Exception(
std::string("Unknown numeric column of type: ") + demangle(typeid(x).name()),
std::string("Unknown numeric column of type: ") + demangle(typeid(*x).name()),
ErrorCodes::LOGICAL_ERROR);
}
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册