mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-05 05:52:05 +00:00
5aedbac37d
- reduce min_time for Buffer's min test - rewrite the test to .sh to avoid extra sleeping time (with .sql we have to wait the max time) - change the assertion for min test, the time there should not exceed max time (100 seconds), this should fix with test flakiness [1] even after [2]. [1]: https://s3.amazonaws.com/clickhouse-test-reports/0/76119a4567ce2ac9c0aff715c1a9ba2607e806e0/stateless_tests__tsan__[3_5].html [2]: https://github.com/ClickHouse/ClickHouse/pull/65310 Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
77 lines
2.4 KiB
Bash
Executable File
77 lines
2.4 KiB
Bash
Executable File
#!/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"
|