mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 16:12:01 +00:00
Merge pull request #63352 from CurtizJ/benchmark-query-id-prefix
Add option `query_id_prefix` to `clickhouse-benchmark`
This commit is contained in:
commit
0f834557e1
@ -7,6 +7,8 @@
|
||||
#include <random>
|
||||
#include <string_view>
|
||||
#include <pcg_random.hpp>
|
||||
#include <Poco/UUID.h>
|
||||
#include <Poco/UUIDGenerator.h>
|
||||
#include <Poco/Util/Application.h>
|
||||
#include <Common/Stopwatch.h>
|
||||
#include <Common/ThreadPool.h>
|
||||
@ -80,6 +82,7 @@ public:
|
||||
double max_time_,
|
||||
size_t confidence_,
|
||||
const String & query_id_,
|
||||
const String & query_id_prefix_,
|
||||
const String & query_to_execute_,
|
||||
size_t max_consecutive_errors_,
|
||||
bool continue_on_errors_,
|
||||
@ -98,6 +101,7 @@ public:
|
||||
max_time(max_time_),
|
||||
confidence(confidence_),
|
||||
query_id(query_id_),
|
||||
query_id_prefix(query_id_prefix_),
|
||||
query_to_execute(query_to_execute_),
|
||||
continue_on_errors(continue_on_errors_),
|
||||
max_consecutive_errors(max_consecutive_errors_),
|
||||
@ -205,6 +209,7 @@ private:
|
||||
double max_time;
|
||||
size_t confidence;
|
||||
String query_id;
|
||||
String query_id_prefix;
|
||||
String query_to_execute;
|
||||
bool continue_on_errors;
|
||||
size_t max_consecutive_errors;
|
||||
@ -463,8 +468,11 @@ private:
|
||||
|
||||
RemoteQueryExecutor executor(
|
||||
*entry, query, {}, global_context, nullptr, Scalars(), Tables(), query_processing_stage);
|
||||
|
||||
if (!query_id.empty())
|
||||
executor.setQueryId(query_id);
|
||||
else if (!query_id_prefix.empty())
|
||||
executor.setQueryId(query_id_prefix + "_" + Poco::UUIDGenerator().createRandom().toString());
|
||||
|
||||
Progress progress;
|
||||
executor.setProgressCallback([&progress](const Progress & value) { progress.incrementPiecewiseAtomically(value); });
|
||||
@ -617,6 +625,7 @@ int mainEntryClickHouseBenchmark(int argc, char ** argv)
|
||||
("stacktrace", "print stack traces of exceptions")
|
||||
("confidence", value<size_t>()->default_value(5), "set the level of confidence for T-test [0=80%, 1=90%, 2=95%, 3=98%, 4=99%, 5=99.5%(default)")
|
||||
("query_id", value<std::string>()->default_value(""), "")
|
||||
("query_id_prefix", value<std::string>()->default_value(""), "")
|
||||
("max-consecutive-errors", value<size_t>()->default_value(0), "set number of allowed consecutive errors")
|
||||
("ignore-error,continue_on_errors", "continue testing even if a query fails")
|
||||
("reconnect", "establish new connection for every query")
|
||||
@ -671,6 +680,7 @@ int mainEntryClickHouseBenchmark(int argc, char ** argv)
|
||||
options["timelimit"].as<double>(),
|
||||
options["confidence"].as<size_t>(),
|
||||
options["query_id"].as<std::string>(),
|
||||
options["query_id_prefix"].as<std::string>(),
|
||||
options["query"].as<std::string>(),
|
||||
options["max-consecutive-errors"].as<size_t>(),
|
||||
options.count("ignore-error"),
|
||||
|
@ -0,0 +1 @@
|
||||
0 100
|
11
tests/queries/0_stateless/03143_benchmark_query_id_prefix.sh
Executable file
11
tests/queries/0_stateless/03143_benchmark_query_id_prefix.sh
Executable file
@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
# shellcheck source=../shell_config.sh
|
||||
. "$CURDIR"/../shell_config.sh
|
||||
|
||||
query_id_prefix=${CLICKHOUSE_DATABASE}_test_benchmark
|
||||
$CLICKHOUSE_BENCHMARK -i 100 -c 8 <<< "SELECT 1" --query_id_prefix $query_id_prefix 2>/dev/null
|
||||
|
||||
$CLICKHOUSE_CLIENT --query "SYSTEM FLUSH LOGS"
|
||||
$CLICKHOUSE_CLIENT --query "SELECT countIf(query_id = '$query_id_prefix'), countIf(query_id LIKE '$query_id_prefix%') FROM system.query_log WHERE current_database = currentDatabase() AND type = 'QueryFinish'"
|
Loading…
Reference in New Issue
Block a user