2020-06-29 23:28:25 +00:00
#!/usr/bin/env bash
CURDIR = $( cd " $( dirname " ${ BASH_SOURCE [0] } " ) " && pwd )
2020-08-01 00:51:12 +00:00
. " $CURDIR " /../shell_config.sh
2020-06-29 23:28:25 +00:00
# it is the worst way of making performance test, nevertheless it can detect significant slowdown and some other issues, that usually found by stress test
db = " test_01193_ $RANDOM "
declare -A engines
engines[ 0] = "Memory"
engines[ 1] = "File(CSV)"
engines[ 2] = "Log"
engines[ 3] = "StripeLog"
engines[ 4] = "MergeTree ORDER BY i"
tables = 1000
threads = 10
count_multiplier = 1
max_time_ms = 1000
2020-08-01 01:20:22 +00:00
debug_or_sanitizer_build = $( $CLICKHOUSE_CLIENT -q "WITH ((SELECT value FROM system.build_options WHERE name='BUILD_TYPE') AS build, (SELECT value FROM system.build_options WHERE name='CXX_FLAGS') as flags) SELECT build='Debug' OR flags LIKE '%fsanitize%' OR hasThreadFuzzer()" )
2020-06-29 23:28:25 +00:00
if [ [ debug_or_sanitizer_build -eq 1 ] ] ; then tables = 100; count_multiplier = 10; max_time_ms = 1500; fi
create_tables( ) {
for i in $( seq 1 $tables ) ; do
engine = ${ engines [ $(( i % ${# engines [@] } )) ] }
$CLICKHOUSE_CLIENT -q " CREATE TABLE $db .table_ $1 _ $i (i UInt64, d Date, s String, n Nested(i UInt8, f Float32)) ENGINE= $engine "
$CLICKHOUSE_CLIENT -q " INSERT INTO $db .table_ $1 _ $i VALUES (0, '2020-06-25', 'hello', [1, 2], [3, 4]), (1, '2020-06-26', 'word', [10, 20], [30, 40]) "
done
}
$CLICKHOUSE_CLIENT -q " CREATE DATABASE $db "
for i in $( seq 1 $threads ) ; do
2020-08-01 00:56:32 +00:00
create_tables " $i " &
2020-06-29 23:28:25 +00:00
done
wait
$CLICKHOUSE_CLIENT -q " CREATE TABLE $db .table_merge (i UInt64, d Date, s String, n Nested(i UInt8, f Float32)) ENGINE=Merge(' $db ', '^table_') "
2020-07-10 14:00:44 +00:00
$CLICKHOUSE_CLIENT -q " SELECT count() * $count_multiplier , i, d, s, n.i, n.f FROM $db .table_merge GROUP BY i, d, s, n.i, n.f ORDER BY i "
2020-06-29 23:28:25 +00:00
$CLICKHOUSE_CLIENT -q " DETACH DATABASE $db "
# get real time, grep seconds, remove point, remove leading zeros
2020-08-03 11:35:40 +00:00
elapsed_ms = $( { time $CLICKHOUSE_CLIENT -q " ATTACH DATABASE $db " ; } 2>& 1 | grep real | grep -Po "0m\K[0-9\.]*" | tr -d '.' | sed "s/^0*//" )
2020-06-29 23:28:25 +00:00
$CLICKHOUSE_CLIENT -q " SELECT '01193_metadata_loading', $elapsed_ms FORMAT Null " # it will be printed to server log
if [ [ $elapsed_ms -le $max_time_ms ] ] ; then echo ok; fi
2020-07-10 14:00:44 +00:00
$CLICKHOUSE_CLIENT -q " SELECT count() * $count_multiplier , i, d, s, n.i, n.f FROM $db .table_merge GROUP BY i, d, s, n.i, n.f ORDER BY i "
2020-06-29 23:28:25 +00:00
$CLICKHOUSE_CLIENT -q " DROP DATABASE $db "