mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 17:41:59 +00:00
Merge pull request #66188 from azat/tests/01246_buffer_flush-v10
Fix 01246_buffer_flush flakiness
This commit is contained in:
commit
0669270f98
76
tests/queries/0_stateless/01246_buffer_flush.sh
Executable file
76
tests/queries/0_stateless/01246_buffer_flush.sh
Executable file
@ -0,0 +1,76 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Tags: no-fasttest
|
||||||
|
|
||||||
|
CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||||
|
# shellcheck source=../shell_config.sh
|
||||||
|
. "$CUR_DIR"/../shell_config.sh
|
||||||
|
|
||||||
|
function elapsed_sec()
|
||||||
|
{
|
||||||
|
local expr=$1 && shift
|
||||||
|
local start end
|
||||||
|
start=$(date +%s.%N)
|
||||||
|
while ! eval "$expr"; do
|
||||||
|
sleep 0.5
|
||||||
|
done
|
||||||
|
end=$(date +%s.%N)
|
||||||
|
$CLICKHOUSE_LOCAL -q "select floor($end-$start)"
|
||||||
|
}
|
||||||
|
|
||||||
|
$CLICKHOUSE_CLIENT -nm -q "
|
||||||
|
drop table if exists data_01256;
|
||||||
|
drop table if exists buffer_01256;
|
||||||
|
|
||||||
|
create table data_01256 as system.numbers Engine=Memory();
|
||||||
|
"
|
||||||
|
|
||||||
|
echo "min"
|
||||||
|
$CLICKHOUSE_CLIENT -nm -q "
|
||||||
|
create table buffer_01256 as system.numbers Engine=Buffer(currentDatabase(), data_01256, 1,
|
||||||
|
2, 100, /* time */
|
||||||
|
4, 100, /* rows */
|
||||||
|
1, 1e6 /* bytes */
|
||||||
|
);
|
||||||
|
insert into buffer_01256 select * from system.numbers limit 5;
|
||||||
|
select count() from data_01256;
|
||||||
|
"
|
||||||
|
sec=$(elapsed_sec '[[ $($CLICKHOUSE_CLIENT -q "select count() from data_01256") -eq 5 ]]')
|
||||||
|
[[ $sec -ge 2 ]] || echo "Buffer flushed too early, min_time=2, flushed after $sec sec"
|
||||||
|
[[ $sec -lt 100 ]] || echo "Buffer flushed too late, max_time=100, flushed after $sec sec"
|
||||||
|
$CLICKHOUSE_CLIENT -q "select count() from data_01256"
|
||||||
|
$CLICKHOUSE_CLIENT -q "drop table buffer_01256"
|
||||||
|
|
||||||
|
echo "max"
|
||||||
|
$CLICKHOUSE_CLIENT -nm -q "
|
||||||
|
create table buffer_01256 as system.numbers Engine=Buffer(currentDatabase(), data_01256, 1,
|
||||||
|
100, 2, /* time */
|
||||||
|
0, 100, /* rows */
|
||||||
|
0, 1e6 /* bytes */
|
||||||
|
);
|
||||||
|
insert into buffer_01256 select * from system.numbers limit 5;
|
||||||
|
select count() from data_01256;
|
||||||
|
"
|
||||||
|
sec=$(elapsed_sec '[[ $($CLICKHOUSE_CLIENT -q "select count() from data_01256") -eq 10 ]]')
|
||||||
|
[[ $sec -ge 2 ]] || echo "Buffer flushed too early, max_time=2, flushed after $sec sec"
|
||||||
|
$CLICKHOUSE_CLIENT -q "select count() from data_01256"
|
||||||
|
$CLICKHOUSE_CLIENT -q "drop table buffer_01256"
|
||||||
|
|
||||||
|
echo "direct"
|
||||||
|
$CLICKHOUSE_CLIENT -nm -q "
|
||||||
|
create table buffer_01256 as system.numbers Engine=Buffer(currentDatabase(), data_01256, 1,
|
||||||
|
100, 100, /* time */
|
||||||
|
0, 9, /* rows */
|
||||||
|
0, 1e6 /* bytes */
|
||||||
|
);
|
||||||
|
insert into buffer_01256 select * from system.numbers limit 10;
|
||||||
|
select count() from data_01256;
|
||||||
|
"
|
||||||
|
|
||||||
|
echo "drop"
|
||||||
|
$CLICKHOUSE_CLIENT -nm -q "
|
||||||
|
insert into buffer_01256 select * from system.numbers limit 10;
|
||||||
|
drop table if exists buffer_01256;
|
||||||
|
select count() from data_01256;
|
||||||
|
"
|
||||||
|
|
||||||
|
$CLICKHOUSE_CLIENT -q "drop table data_01256"
|
@ -1,50 +0,0 @@
|
|||||||
-- Tags: no-fasttest
|
|
||||||
|
|
||||||
SET function_sleep_max_microseconds_per_block = 4000000;
|
|
||||||
|
|
||||||
drop table if exists data_01256;
|
|
||||||
drop table if exists buffer_01256;
|
|
||||||
|
|
||||||
create table data_01256 as system.numbers Engine=Memory();
|
|
||||||
|
|
||||||
select 'min';
|
|
||||||
create table buffer_01256 as system.numbers Engine=Buffer(currentDatabase(), data_01256, 1,
|
|
||||||
5, 100, /* time */
|
|
||||||
4, 100, /* rows */
|
|
||||||
1, 1e6 /* bytes */
|
|
||||||
);
|
|
||||||
insert into buffer_01256 select * from system.numbers limit 5;
|
|
||||||
select count() from data_01256;
|
|
||||||
-- It is enough to ensure that the buffer will be flushed earlier then 2*min_time (10 sec)
|
|
||||||
select sleepEachRow(9) FORMAT Null SETTINGS function_sleep_max_microseconds_per_block=10e6;
|
|
||||||
select count() from data_01256;
|
|
||||||
drop table buffer_01256;
|
|
||||||
|
|
||||||
select 'max';
|
|
||||||
create table buffer_01256 as system.numbers Engine=Buffer(currentDatabase(), data_01256, 1,
|
|
||||||
100, 2, /* time */
|
|
||||||
0, 100, /* rows */
|
|
||||||
0, 1e6 /* bytes */
|
|
||||||
);
|
|
||||||
insert into buffer_01256 select * from system.numbers limit 5;
|
|
||||||
select count() from data_01256;
|
|
||||||
-- sleep 2 (min time) + 1 (round up) + bias (1) = 4
|
|
||||||
select sleepEachRow(2) from numbers(2) FORMAT Null;
|
|
||||||
select count() from data_01256;
|
|
||||||
drop table buffer_01256;
|
|
||||||
|
|
||||||
select 'direct';
|
|
||||||
create table buffer_01256 as system.numbers Engine=Buffer(currentDatabase(), data_01256, 1,
|
|
||||||
100, 100, /* time */
|
|
||||||
0, 9, /* rows */
|
|
||||||
0, 1e6 /* bytes */
|
|
||||||
);
|
|
||||||
insert into buffer_01256 select * from system.numbers limit 10;
|
|
||||||
select count() from data_01256;
|
|
||||||
|
|
||||||
select 'drop';
|
|
||||||
insert into buffer_01256 select * from system.numbers limit 10;
|
|
||||||
drop table if exists buffer_01256;
|
|
||||||
select count() from data_01256;
|
|
||||||
|
|
||||||
drop table data_01256;
|
|
Loading…
Reference in New Issue
Block a user