Merge pull request #59851 from azat/tests/initial_query_start_time

Reintroduce 02590_interserver_mode_client_info_initial_query_start_time
This commit is contained in:
Raúl Marín 2024-02-12 11:52:38 +01:00 committed by GitHub
commit fc964d6ddd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 75 additions and 0 deletions

View File

@ -0,0 +1,8 @@
SELECT
3 1
3 1
INSERT
CHECK
1
2
6 2

View File

@ -0,0 +1,67 @@
#!/usr/bin/env bash
# Tags: no-fasttest
# Tag no-fasttest: interserver mode requires SSL
#
# Test that checks that some of ClientInfo correctly passed in inter-server mode.
# NOTE: we need .sh test (.sql is not enough) because queries on remote nodes does not have current_database = currentDatabase()
#
# Check-style suppression: select * from system.query_log where current_database = currentDatabase();
CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=../shell_config.sh
. "$CUR_DIR"/../shell_config.sh
function get_query_id() { random_str 10; }
$CLICKHOUSE_CLIENT -nm -q "
drop table if exists buf;
drop table if exists dist;
drop table if exists data;
create table data (key Int) engine=Memory();
create table dist as data engine=Distributed(test_cluster_interserver_secret, currentDatabase(), data, key);
create table dist_dist as data engine=Distributed(test_cluster_interserver_secret, currentDatabase(), dist, key);
system stop distributed sends dist;
"
echo "SELECT"
query_id="$(get_query_id)"
# initialize connection, but actually if there are other tables that uses this
# cluster then, it will be created long time ago, but this is OK for this
# test, since we care about the difference between NOW() and there should
# not be any significant difference.
$CLICKHOUSE_CLIENT --prefer_localhost_replica=0 --query_id "$query_id" -q "select * from dist"
$CLICKHOUSE_CLIENT -nm --param_query_id "$query_id" -q "
system flush logs;
select count(), count(distinct initial_query_start_time_microseconds) from system.query_log where type = 'QueryFinish' and initial_query_id = {query_id:String};
"
sleep 1
query_id="$(get_query_id)"
# this query (and all subsequent) should reuse the previous connection (at least most of the time)
$CLICKHOUSE_CLIENT --prefer_localhost_replica=0 --query_id "$query_id" -q "select * from dist"
$CLICKHOUSE_CLIENT -nm --param_query_id "$query_id" -q "
system flush logs;
select count(), count(distinct initial_query_start_time_microseconds) from system.query_log where type = 'QueryFinish' and initial_query_id = {query_id:String};
"
echo "INSERT"
query_id="$(get_query_id)"
$CLICKHOUSE_CLIENT --prefer_localhost_replica=0 --query_id "$query_id" -nm -q "
insert into dist_dist values (1),(2);
select * from data;
"
sleep 1
$CLICKHOUSE_CLIENT -nm --param_query_id "$query_id" -q "system flush distributed dist_dist"
sleep 1
$CLICKHOUSE_CLIENT -nm --param_query_id "$query_id" -q "system flush distributed dist"
echo "CHECK"
$CLICKHOUSE_CLIENT -nm --param_query_id "$query_id" -q "
select * from data order by key;
system flush logs;
select count(), count(distinct initial_query_start_time_microseconds) from system.query_log where type = 'QueryFinish' and initial_query_id = {query_id:String};
"