2017-11-01 11:46:58 +00:00
|
|
|
#!/usr/bin/env bash
|
2021-11-21 10:58:26 +00:00
|
|
|
# Tags: long, no-parallel
|
2017-12-15 19:34:19 +00:00
|
|
|
|
2017-03-02 09:35:17 +00:00
|
|
|
set -e
|
|
|
|
|
2017-12-15 19:34:19 +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
|
2017-12-15 19:34:19 +00:00
|
|
|
|
2023-06-30 17:07:32 +00:00
|
|
|
format="RowBinary"
|
|
|
|
|
2017-03-02 09:35:17 +00:00
|
|
|
function query {
|
2017-10-30 13:10:22 +00:00
|
|
|
# bash isn't able to store \0 bytes, so use [1; 255] random range
|
2023-06-30 17:07:32 +00:00
|
|
|
echo "SELECT greatest(toUInt8(1), toUInt8(intHash64(number))) FROM system.numbers LIMIT $1 FORMAT $format"
|
2017-03-02 09:35:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function ch_url() {
|
2023-07-04 18:19:20 +00:00
|
|
|
${CLICKHOUSE_CURL_COMMAND} -q -sS \
|
|
|
|
"${CLICKHOUSE_URL}${max_block_size:+"&max_block_size=$max_block_size"}&$1" \
|
|
|
|
-d "$(query "$2")"
|
2017-03-02 09:35:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Check correct exceptions handling
|
|
|
|
|
2021-07-12 00:18:22 +00:00
|
|
|
exception_pattern="DB::Exception:[[:print:]]*"
|
2017-03-02 09:35:17 +00:00
|
|
|
|
|
|
|
function check_only_exception() {
|
2020-08-01 00:40:56 +00:00
|
|
|
local res
|
2020-08-01 01:20:22 +00:00
|
|
|
res=$(ch_url "$1" "$2")
|
2023-07-04 18:19:20 +00:00
|
|
|
# echo "$res"
|
|
|
|
# echo "$res" | wc -l
|
|
|
|
# echo "$res" | grep -c "$exception_pattern"
|
2020-08-01 01:20:22 +00:00
|
|
|
[[ $(echo "$res" | wc -l) -eq 1 ]] || echo FAIL 1 "$@"
|
2020-07-31 23:55:20 +00:00
|
|
|
[[ $(echo "$res" | grep -c "$exception_pattern") -eq 1 ]] || echo FAIL 2 "$@"
|
2017-03-02 09:35:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function check_last_line_exception() {
|
2020-08-01 00:40:56 +00:00
|
|
|
local res
|
2020-08-01 01:20:22 +00:00
|
|
|
res=$(ch_url "$1" "$2")
|
2023-07-04 18:19:20 +00:00
|
|
|
# echo "$res" > res
|
|
|
|
# echo "$res" | wc -c
|
|
|
|
# echo "$res" | tail -n -2
|
2020-07-31 23:55:20 +00:00
|
|
|
[[ $(echo "$res" | tail -n -1 | grep -c "$exception_pattern") -eq 1 ]] || echo FAIL 3 "$@"
|
|
|
|
[[ $(echo "$res" | head -n -1 | grep -c "$exception_pattern") -eq 0 ]] || echo FAIL 4 "$@"
|
2017-03-02 09:35:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function check_exception_handling() {
|
2023-06-30 17:07:32 +00:00
|
|
|
format=TSV \
|
|
|
|
check_last_line_exception \
|
2023-07-04 18:19:20 +00:00
|
|
|
"max_block_size=30000&max_result_rows=400000&buffer_size=1048577&wait_end_of_query=0" 111222333444
|
2023-06-30 17:07:32 +00:00
|
|
|
|
2018-01-10 01:45:28 +00:00
|
|
|
check_only_exception "max_result_bytes=1000" 1001
|
2017-04-05 11:52:23 +00:00
|
|
|
check_only_exception "max_result_bytes=1000&wait_end_of_query=1" 1001
|
2017-03-20 16:39:28 +00:00
|
|
|
|
2023-07-04 18:19:20 +00:00
|
|
|
check_last_line_exception "max_result_bytes=1048576&buffer_size=1048576&wait_end_of_query=0" 1048577
|
|
|
|
check_only_exception "max_result_bytes=1048576&buffer_size=1048576&wait_end_of_query=1" 1048577
|
2017-03-20 16:39:28 +00:00
|
|
|
|
2017-04-05 11:52:23 +00:00
|
|
|
check_only_exception "max_result_bytes=1500000&buffer_size=2500000&wait_end_of_query=0" 1500001
|
|
|
|
check_only_exception "max_result_bytes=1500000&buffer_size=1500000&wait_end_of_query=1" 1500001
|
2017-03-20 16:39:28 +00:00
|
|
|
|
2017-04-05 11:52:23 +00:00
|
|
|
check_only_exception "max_result_bytes=4000000&buffer_size=2000000&wait_end_of_query=1" 5000000
|
|
|
|
check_only_exception "max_result_bytes=4000000&wait_end_of_query=1" 5000000
|
2017-10-26 18:36:23 +00:00
|
|
|
check_last_line_exception "max_result_bytes=4000000&buffer_size=2000000&wait_end_of_query=0" 5000000
|
2017-03-02 09:35:17 +00:00
|
|
|
}
|
|
|
|
|
2017-03-20 16:39:28 +00:00
|
|
|
check_exception_handling
|
2017-03-02 09:35:17 +00:00
|
|
|
|
|
|
|
|
2017-03-20 16:39:28 +00:00
|
|
|
# Tune setting to speed up combinatorial test
|
2017-03-02 09:35:17 +00:00
|
|
|
max_block_size=500000
|
2020-08-01 01:20:22 +00:00
|
|
|
corner_sizes="1048576 $(seq 500000 1000000 3500000)"
|
2017-03-20 16:39:28 +00:00
|
|
|
|
|
|
|
|
2017-12-15 19:34:19 +00:00
|
|
|
# Check HTTP results with $CLICKHOUSE_CLIENT in normal case
|
2017-03-02 09:35:17 +00:00
|
|
|
|
|
|
|
function cmp_cli_and_http() {
|
2020-08-01 01:20:22 +00:00
|
|
|
$CLICKHOUSE_CLIENT -q "$(query "$1")" > "${CLICKHOUSE_TMP}"/res1
|
2020-08-01 00:56:32 +00:00
|
|
|
ch_url "buffer_size=$2&wait_end_of_query=0" "$1" > "${CLICKHOUSE_TMP}"/res2
|
|
|
|
ch_url "buffer_size=$2&wait_end_of_query=1" "$1" > "${CLICKHOUSE_TMP}"/res3
|
|
|
|
cmp "${CLICKHOUSE_TMP}"/res1 "${CLICKHOUSE_TMP}"/res2 && cmp "${CLICKHOUSE_TMP}"/res1 "${CLICKHOUSE_TMP}"/res3 || echo FAIL 5 "$@"
|
|
|
|
rm -rf "${CLICKHOUSE_TMP}"/res1 "${CLICKHOUSE_TMP}"/res2 "${CLICKHOUSE_TMP}"/res3
|
2017-03-02 09:35:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function check_cli_and_http() {
|
2017-04-05 11:52:23 +00:00
|
|
|
for input_size in $corner_sizes; do
|
|
|
|
for buffer_size in $corner_sizes; do
|
|
|
|
#echo "$input_size" "$buffer_size"
|
|
|
|
cmp_cli_and_http "$input_size" "$buffer_size"
|
|
|
|
done
|
|
|
|
done
|
2017-03-02 09:35:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
check_cli_and_http
|
|
|
|
|
2017-03-20 16:39:28 +00:00
|
|
|
|
|
|
|
# Check HTTP internal compression in normal case
|
2017-03-02 09:35:17 +00:00
|
|
|
|
|
|
|
function cmp_http_compression() {
|
2020-08-01 01:20:22 +00:00
|
|
|
$CLICKHOUSE_CLIENT -q "$(query "$1")" > "${CLICKHOUSE_TMP}"/res0
|
2020-08-01 00:56:32 +00:00
|
|
|
ch_url 'compress=1' "$1" | "${CLICKHOUSE_BINARY}"-compressor --decompress > "${CLICKHOUSE_TMP}"/res1
|
|
|
|
ch_url "compress=1&buffer_size=$2&wait_end_of_query=0" "$1" | "${CLICKHOUSE_BINARY}"-compressor --decompress > "${CLICKHOUSE_TMP}"/res2
|
|
|
|
ch_url "compress=1&buffer_size=$2&wait_end_of_query=1" "$1" | "${CLICKHOUSE_BINARY}"-compressor --decompress > "${CLICKHOUSE_TMP}"/res3
|
|
|
|
cmp "${CLICKHOUSE_TMP}"/res0 "${CLICKHOUSE_TMP}"/res1
|
|
|
|
cmp "${CLICKHOUSE_TMP}"/res1 "${CLICKHOUSE_TMP}"/res2
|
|
|
|
cmp "${CLICKHOUSE_TMP}"/res1 "${CLICKHOUSE_TMP}"/res3
|
|
|
|
rm -rf "${CLICKHOUSE_TMP}"/res0 "${CLICKHOUSE_TMP}"/res1 "${CLICKHOUSE_TMP}"/res2 "${CLICKHOUSE_TMP}"/res3
|
2017-03-02 09:35:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function check_http_compression() {
|
2017-04-05 11:52:23 +00:00
|
|
|
for input_size in $corner_sizes; do
|
|
|
|
for buffer_size in $corner_sizes; do
|
|
|
|
#echo "$input_size" "$buffer_size"
|
|
|
|
cmp_http_compression "$input_size" "$buffer_size"
|
|
|
|
done
|
|
|
|
done
|
2017-03-02 09:35:17 +00:00
|
|
|
}
|
|
|
|
|
2017-10-30 13:10:22 +00:00
|
|
|
check_http_compression
|