mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 23:52:03 +00:00
Merge pull request #3321 from yandex/test_for_fileopen
CLICKHOUSE-3943: Add test for FileOpen metric
This commit is contained in:
commit
20fcc11497
@ -204,7 +204,7 @@ BlockIO InterpreterSystemQuery::execute()
|
||||
throw Exception("There is no " + query.target_database + "." + query.target_table + " replicated table",
|
||||
ErrorCodes::BAD_ARGUMENTS);
|
||||
break;
|
||||
case Type::FLUSH_SYSTEM_TABLES:
|
||||
case Type::FLUSH_LOGS:
|
||||
executeCommandsAndThrowIfError(
|
||||
[&] () { if (auto query_log = context.getQueryLog(false)) query_log->flush(); },
|
||||
[&] () { if (auto part_log = context.getPartLog("", false)) part_log->flush(); },
|
||||
|
@ -65,8 +65,8 @@ const char * ASTSystemQuery::typeToString(Type type)
|
||||
return "STOP REPLICATION QUEUES";
|
||||
case Type::START_REPLICATION_QUEUES:
|
||||
return "START REPLICATION QUEUES";
|
||||
case Type::FLUSH_SYSTEM_TABLES:
|
||||
return "FLUSH SYSTEM TABLES";
|
||||
case Type::FLUSH_LOGS:
|
||||
return "FLUSH LOGS";
|
||||
default:
|
||||
throw Exception("Unknown SYSTEM query command", ErrorCodes::BAD_TYPE_OF_FIELD);
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public:
|
||||
START_REPLICATEDS_SENDS,
|
||||
STOP_REPLICATION_QUEUES,
|
||||
START_REPLICATION_QUEUES,
|
||||
FLUSH_SYSTEM_TABLES,
|
||||
FLUSH_LOGS,
|
||||
END
|
||||
};
|
||||
|
||||
|
@ -34,7 +34,7 @@ DROP TABLE test.null;"
|
||||
|
||||
heavy_cpu_query="SELECT ignore(sum(sipHash64(hex(sipHash64(hex(sipHash64(hex(number)))))))) FROM (SELECT * FROM system.numbers_mt LIMIT 1000000)"
|
||||
$CLICKHOUSE_CLIENT $settings --max_threads=1 -q "$heavy_cpu_query"
|
||||
$CLICKHOUSE_CLIENT $settings -q "SYSTEM FLUSH SYSTEM TABLES"
|
||||
$CLICKHOUSE_CLIENT $settings -q "SYSTEM FLUSH LOGS"
|
||||
$CLICKHOUSE_CLIENT $settings -q "
|
||||
WITH
|
||||
any(query_duration_ms*1000) AS duration,
|
||||
@ -53,7 +53,7 @@ SELECT
|
||||
# Check ProfileEvents in query_thread_log
|
||||
|
||||
$CLICKHOUSE_CLIENT $settings --max_threads=3 -q "$heavy_cpu_query"
|
||||
$CLICKHOUSE_CLIENT $settings -q "SYSTEM FLUSH SYSTEM TABLES"
|
||||
$CLICKHOUSE_CLIENT $settings -q "SYSTEM FLUSH LOGS"
|
||||
query_id=`$CLICKHOUSE_CLIENT $settings -q "SELECT query_id FROM system.query_log WHERE event_date >= today()-1 AND type=2 AND query='$heavy_cpu_query' ORDER BY event_time DESC LIMIT 1"`
|
||||
query_elapsed=`$CLICKHOUSE_CLIENT $settings -q "SELECT query_duration_ms*1000 FROM system.query_log WHERE event_date >= today()-1 AND type=2 AND query_id='$query_id' ORDER BY event_time DESC LIMIT 1"`
|
||||
threads=`$CLICKHOUSE_CLIENT $settings -q "SELECT length(thread_numbers) FROM system.query_log WHERE event_date >= today()-1 AND type=2 AND query_id='$query_id' ORDER BY event_time DESC LIMIT 1"`
|
||||
|
@ -0,0 +1 @@
|
||||
4
|
28
dbms/tests/queries/0_stateless/00731_merge_tree_select_opened_files.sh
Executable file
28
dbms/tests/queries/0_stateless/00731_merge_tree_select_opened_files.sh
Executable file
@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
. $CURDIR/../shell_config.sh
|
||||
|
||||
cur_name=${BASH_SOURCE[0]}
|
||||
|
||||
settings="$server_logs --log_queries=1 --log_query_threads=1 --log_profile_events=1 --log_query_settings=1"
|
||||
|
||||
# Test insert logging on each block and checkPacket() method
|
||||
|
||||
$CLICKHOUSE_CLIENT $settings -n -q "
|
||||
DROP TABLE IF EXISTS test.merge_tree_table;
|
||||
CREATE TABLE test.merge_tree_table (id UInt64, date Date, uid UInt32) ENGINE = MergeTree(date, id, 8192);"
|
||||
|
||||
$CLICKHOUSE_CLIENT $settings -q "INSERT INTO test.merge_tree_table SELECT (intHash64(number)) % 10000, toDate('2018-08-01'), rand() FROM system.numbers LIMIT 10000000;"
|
||||
|
||||
$CLICKHOUSE_CLIENT $settings -q "OPTIMIZE TABLE test.merge_tree_table FINAL;"
|
||||
|
||||
toching_many_parts_query="SELECT count() from (SELECT toDayOfWeek(date) as m, id, count() FROM test.merge_tree_table GROUP BY id, m ORDER BY count() DESC LIMIT 10 SETTINGS max_threads = 1)"
|
||||
$CLICKHOUSE_CLIENT $settings -q "$toching_many_parts_query" &> /dev/null
|
||||
|
||||
$CLICKHOUSE_CLIENT $settings -q "SYSTEM FLUSH LOGS"
|
||||
|
||||
$CLICKHOUSE_CLIENT $settings -q "SELECT pi.Values FROM system.query_log ARRAY JOIN ProfileEvents as pi WHERE query='$toching_many_parts_query' and pi.Names = 'FileOpen' ORDER BY event_time DESC LIMIT 1;"
|
||||
|
||||
$CLICKHOUSE_CLIENT $settings -q "DROP TABLE IF EXISTS test.merge_tree_table;"
|
Loading…
Reference in New Issue
Block a user