Great simplification of test 01622_defaults_for_url_engine

This commit is contained in:
Alexey Milovidov 2021-12-25 16:01:35 +03:00
parent 795564ee1b
commit f78678dc3f
2 changed files with 7 additions and 31 deletions

View File

@ -1,37 +1,13 @@
#!/usr/bin/env bash
# Tags: no-fasttest
# Tag no-fasttest: nc - command not found
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=../shell_config.sh
. "$CURDIR"/../shell_config.sh
PORT="$(($RANDOM%63000+2001))"
function thread1
{
while true; do
echo -e "HTTP/1.1 200 OK\n\n{\"a\": 1}" | nc -l -p $1 -q 1;
done
}
function thread2
{
while true; do
$CLICKHOUSE_CLIENT --input_format_defaults_for_omitted_fields=1 -q "SELECT * FROM url('http://127.0.0.1:$1/', JSONEachRow, 'a int, b int default 7, c default a + b') format Values" | grep -F '(1,7,8)' && break
done
}
# https://stackoverflow.com/questions/9954794/execute-a-shell-function-with-timeout
export -f thread1;
export -f thread2;
TIMEOUT=60
timeout $TIMEOUT bash -c "thread1 $PORT" > /dev/null 2>&1 &
PID=$!
bash -c "thread2 $PORT" 2> /dev/null | grep -q -F '(1,7,8)' && echo "Ok" && kill -9 $PID
wait >/dev/null 2>&1
${CLICKHOUSE_CLIENT} --query "
SELECT * FROM url(
\$\$http://127.0.0.1:${CLICKHOUSE_PORT_HTTP}/?query=SELECT+'{\"a\":1}'\$\$,
JSONEachRow,
'a int, b int default 7, c default a + b')
FORMAT Values"