2020-04-19 19:22:03 +00:00
|
|
|
#!/usr/bin/env bash
|
2022-09-07 15:57:29 +00:00
|
|
|
# Tags: no-fasttest
|
2020-04-19 19:22:03 +00:00
|
|
|
|
|
|
|
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
2020-12-28 11:46:53 +00:00
|
|
|
# shellcheck source=../shell_config.sh
|
2020-08-01 00:51:12 +00:00
|
|
|
. "$CURDIR"/../shell_config.sh
|
2020-04-19 19:22:03 +00:00
|
|
|
|
|
|
|
# A question for curious reader:
|
|
|
|
# How to break shell pipeline as soon as 5 lines are found in the following command:
|
|
|
|
# ./my-program | head -n5
|
|
|
|
# When I tried to do it, pipeline was not actively terminated,
|
|
|
|
# unless the my-program will try to output a thousand more lines overflowing pipe buffer and terminating with Broken Pipe.
|
|
|
|
# But if my program just output 5 (or slightly more) lines and hang up, the pipeline is not terminated.
|
|
|
|
|
2021-06-21 18:51:12 +00:00
|
|
|
function test()
|
|
|
|
{
|
|
|
|
timeout 5 ${CLICKHOUSE_LOCAL} --max_execution_time 10 --query "
|
|
|
|
SELECT DISTINCT number % 5 FROM system.numbers" ||:
|
2023-01-03 19:00:18 +00:00
|
|
|
echo -e '---'
|
2021-06-21 18:51:12 +00:00
|
|
|
timeout 5 ${CLICKHOUSE_CURL} -sS --no-buffer "${CLICKHOUSE_URL}&max_execution_time=10" --data-binary "
|
|
|
|
SELECT DISTINCT number % 5 FROM system.numbers" ||:
|
2023-01-03 19:00:18 +00:00
|
|
|
echo -e '---'
|
2021-06-21 18:51:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# The test depends on timeouts. And there is a chance that under high system load the query
|
|
|
|
# will not be able to finish in 5 seconds (this will lead to test flakiness).
|
|
|
|
# Let's check that is will be able to show the expected result at least once.
|
|
|
|
while true; do
|
|
|
|
[[ $(test) == $(echo -ne "0\n1\n2\n3\n4\n---\n0\n1\n2\n3\n4\n---\n") ]] && break
|
|
|
|
sleep 1
|
|
|
|
done
|