From 06ff6d2eda5f0dfc12c6fb13101aa062a0e15ede Mon Sep 17 00:00:00 2001 From: Alexander Tokmakov Date: Thu, 17 Sep 2020 18:54:41 +0300 Subject: [PATCH] better 01193_metadata_loading --- .../01193_metadata_loading.reference | 4 +- .../0_stateless/01193_metadata_loading.sh | 38 +++++++++---------- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/tests/queries/0_stateless/01193_metadata_loading.reference b/tests/queries/0_stateless/01193_metadata_loading.reference index 8ff246325ac..9789cbf33ba 100644 --- a/tests/queries/0_stateless/01193_metadata_loading.reference +++ b/tests/queries/0_stateless/01193_metadata_loading.reference @@ -1,5 +1,5 @@ -10000 0 2020-06-25 hello [1,2] [3,4] -10000 1 2020-06-26 word [10,20] [30,40] +1000 0 2020-06-25 hello [1,2] [3,4] +1000 1 2020-06-26 word [10,20] [30,40] ok 8000 0 2020-06-25 hello [1,2] [3,4] 8000 1 2020-06-26 word [10,20] [30,40] diff --git a/tests/queries/0_stateless/01193_metadata_loading.sh b/tests/queries/0_stateless/01193_metadata_loading.sh index c16726209a3..0ee583a7265 100755 --- a/tests/queries/0_stateless/01193_metadata_loading.sh +++ b/tests/queries/0_stateless/01193_metadata_loading.sh @@ -6,14 +6,6 @@ CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) # 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 @@ -24,11 +16,17 @@ debug_or_sanitizer_build=$($CLICKHOUSE_CLIENT -q "WITH ((SELECT value FROM syste 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 "WITH + 'CREATE TABLE $db.table_$1_' AS create1, + ' (i UInt64, d Date, s String, n Nested(i UInt8, f Float32)) ENGINE=' AS create2, + ['Memory', 'File(CSV)', 'Log', 'StripeLog', 'MergeTree ORDER BY i'] AS engines, + 'INSERT INTO $db.table_$1_' AS insert1, + ' VALUES (0, ''2020-06-25'', ''hello'', [1, 2], [3, 4]), (1, ''2020-06-26'', ''word'', [10, 20], [30, 40])' AS insert2 + SELECT arrayStringConcat( + groupArray( + create1 || toString(number) || create2 || engines[1 + number % length(engines)] || ';\n' || + insert1 || toString(number) || insert2 + ), ';\n') FROM numbers($tables) FORMAT TSVRaw;" | $CLICKHOUSE_CLIENT -nm } $CLICKHOUSE_CLIENT -q "CREATE DATABASE $db" @@ -39,15 +37,15 @@ 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_')" -$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" +$CLICKHOUSE_CLIENT -q "SELECT count() * $count_multiplier, i, d, s, n.i, n.f FROM merge('$db', '^table_9') GROUP BY i, d, s, n.i, n.f ORDER BY i" -$CLICKHOUSE_CLIENT -q "DETACH DATABASE $db" +for i in {1..5}; do + $CLICKHOUSE_CLIENT -q "DETACH DATABASE $db" + $CLICKHOUSE_CLIENT -q "ATTACH DATABASE $db" --query_id="$db-$i"; +done -# get real time, grep seconds, remove point, remove leading zeros -elapsed_ms=$({ time $CLICKHOUSE_CLIENT -q "ATTACH DATABASE $db"; } 2>&1 | grep real | grep -Po "0m\K[0-9\.]*" | tr -d '.' | sed "s/^0*//") -$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 +$CLICKHOUSE_CLIENT -q "SYSTEM FLUSH LOGS" +$CLICKHOUSE_CLIENT -q "SELECT if(quantile(0.5)(query_duration_ms) < $max_time_ms, 'ok', toString(groupArray(query_duration_ms))) FROM system.query_log WHERE query_id LIKE '$db-%' AND type=2" $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"