mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
dbms: added test script [#METR-2944].
This commit is contained in:
parent
428618cd8e
commit
40b02cae63
66
dbms/tests/clickhouse-test
Executable file
66
dbms/tests/clickhouse-test
Executable file
@ -0,0 +1,66 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Скрипт для тестирования запросов к ClickHouse.
|
||||
# Из файлов *.sql в заданной директории, в алфавитном порядке, отправляются все запросы.
|
||||
# Результат сравнивается с эталоном.
|
||||
|
||||
QUERIES_DIR="./queries"
|
||||
CLIENT_PROGRAM="clickhouse-client"
|
||||
|
||||
|
||||
COLOR_RESET="\033[0m"
|
||||
COLOR_WHITE="\033[1;37m"
|
||||
COLOR_FAIL="\033[1;31m"
|
||||
COLOR_UNKNOWN="\033[1;30m"
|
||||
COLOR_OK="\033[1;32m"
|
||||
|
||||
MSG_FAIL="${COLOR_WHITE}[ ${COLOR_FAIL}FAIL${COLOR_WHITE} ]${COLOR_RESET}"
|
||||
MSG_UNKNOWN="${COLOR_WHITE}[ ${COLOR_UNKNOWN}UNKNOWN${COLOR_WHITE} ]${COLOR_RESET}"
|
||||
MSG_OK="${COLOR_WHITE}[ ${COLOR_OK}OK${COLOR_WHITE} ]${COLOR_RESET}"
|
||||
MSG_GENERATED="${COLOR_WHITE}[ ${COLOR_UNKNOWN}GENERATED${COLOR_WHITE} ]${COLOR_RESET}"
|
||||
|
||||
|
||||
for query_file in $(ls $QUERIES_DIR/*.sql)
|
||||
do
|
||||
test_name=$(basename -s .sql $query_file)
|
||||
|
||||
result_file=$QUERIES_DIR/$test_name.result
|
||||
error_file=$QUERIES_DIR/$test_name.error
|
||||
reference_file=$QUERIES_DIR/$test_name.reference
|
||||
diff_file=$QUERIES_DIR/$test_name.diff
|
||||
|
||||
printf "%-30s" "$test_name: "
|
||||
|
||||
$CLIENT_PROGRAM < $query_file > $result_file 2> $error_file
|
||||
ret_code=$?
|
||||
|
||||
if [ $ret_code -ne 0 ]; then
|
||||
echo -e "$MSG_FAIL - return code $ret_code"
|
||||
if [ -s "$error_file" ]; then
|
||||
cat $error_file
|
||||
fi
|
||||
# разорвано соединение с сервером
|
||||
if grep -q -E "Connection refused|Attempt to read after eof" $error_file; then
|
||||
exit 1;
|
||||
fi
|
||||
elif [ -s "$error_file" ]; then
|
||||
echo -e "$MSG_FAIL - having stderror:"
|
||||
cat $error_file
|
||||
elif [ ! -e "$reference_file" ]; then
|
||||
# надо сгенерировать эталонный результат
|
||||
if [ "$1" == "--generate" ]; then
|
||||
cp $result_file $reference_file
|
||||
echo -e "$MSG_GENERATED - no reference file"
|
||||
else
|
||||
echo -e "$MSG_UNKNOWN - no reference file (use --generate to create)"
|
||||
fi
|
||||
else
|
||||
diff $reference_file $result_file > $diff_file
|
||||
if [ -s "$diff_file" ]; then
|
||||
echo -e "$MSG_FAIL - result differs with reference:"
|
||||
cat $diff_file
|
||||
else
|
||||
echo -e "$MSG_OK"
|
||||
fi
|
||||
fi
|
||||
done
|
1
dbms/tests/queries/format_ast_and_remote_table.sql
Normal file
1
dbms/tests/queries/format_ast_and_remote_table.sql
Normal file
@ -0,0 +1 @@
|
||||
SELECT (dummy AS x) - 1 FROM remote('127.0.0.{1,2}', system, one)
|
1
dbms/tests/queries/select_1.reference
Normal file
1
dbms/tests/queries/select_1.reference
Normal file
@ -0,0 +1 @@
|
||||
1
|
1
dbms/tests/queries/select_1.sql
Normal file
1
dbms/tests/queries/select_1.sql
Normal file
@ -0,0 +1 @@
|
||||
SELECT 1
|
10
dbms/tests/queries/system_numbers.reference
Normal file
10
dbms/tests/queries/system_numbers.reference
Normal file
@ -0,0 +1,10 @@
|
||||
0
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
9
|
1
dbms/tests/queries/system_numbers.sql
Normal file
1
dbms/tests/queries/system_numbers.sql
Normal file
@ -0,0 +1 @@
|
||||
SELECT * FROM system.numbers LIMIT 10
|
Loading…
Reference in New Issue
Block a user