From 38ce4f33fbc15cf6f19105de7d2fee88fbd2af0f Mon Sep 17 00:00:00 2001 From: Anton Popov Date: Tue, 2 Jun 2020 05:39:19 +0300 Subject: [PATCH] fix flacky test with ttl --- ...oup_by.sql => 01280_ttl_where_group_by.sh} | 92 +++++++++++-------- ...1280_ttl_where_group_by_negative.reference | 0 .../01280_ttl_where_group_by_negative.sql | 7 ++ 3 files changed, 61 insertions(+), 38 deletions(-) rename tests/queries/0_stateless/{01280_ttl_where_group_by.sql => 01280_ttl_where_group_by.sh} (51%) mode change 100644 => 100755 create mode 100644 tests/queries/0_stateless/01280_ttl_where_group_by_negative.reference create mode 100644 tests/queries/0_stateless/01280_ttl_where_group_by_negative.sql diff --git a/tests/queries/0_stateless/01280_ttl_where_group_by.sql b/tests/queries/0_stateless/01280_ttl_where_group_by.sh old mode 100644 new mode 100755 similarity index 51% rename from tests/queries/0_stateless/01280_ttl_where_group_by.sql rename to tests/queries/0_stateless/01280_ttl_where_group_by.sh index e61716cfe81..d0e4c5b3099 --- a/tests/queries/0_stateless/01280_ttl_where_group_by.sql +++ b/tests/queries/0_stateless/01280_ttl_where_group_by.sh @@ -1,5 +1,19 @@ -drop table if exists ttl_01280_1; +#!/usr/bin/env bash +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +. $CURDIR/../shell_config.sh + +$CLICKHOUSE_CLIENT --query "drop table if exists ttl_01280_1" + +function optimize() +{ + for i in {0..20}; do + $CLICKHOUSE_CLIENT --query "OPTIMIZE TABLE $1 FINAL SETTINGS optimize_throw_if_noop=1" 2>/dev/null && break + sleep 0.3 + done +} + +$CLICKHOUSE_CLIENT -n --query " create table ttl_01280_1 (a Int, b Int, x Int, y Int, d DateTime) engine = MergeTree order by (a, b) ttl d + interval 1 second delete where x % 10 == 0 and y > 5; insert into ttl_01280_1 values (1, 1, 0, 4, now() + 10); insert into ttl_01280_1 values (1, 1, 10, 6, now()); @@ -7,13 +21,15 @@ insert into ttl_01280_1 values (1, 2, 3, 7, now()); insert into ttl_01280_1 values (1, 3, 0, 5, now()); insert into ttl_01280_1 values (2, 1, 20, 1, now()); insert into ttl_01280_1 values (2, 1, 0, 1, now()); -insert into ttl_01280_1 values (3, 1, 0, 8, now()); -select sleep(1.1) format Null; -optimize table ttl_01280_1 final; -select a, b, x, y from ttl_01280_1; +insert into ttl_01280_1 values (3, 1, 0, 8, now());" -drop table if exists ttl_01280_2; +sleep 2 +optimize "ttl_01280_1" +$CLICKHOUSE_CLIENT --query "select a, b, x, y from ttl_01280_1" +$CLICKHOUSE_CLIENT --query "drop table if exists ttl_01280_2" + +$CLICKHOUSE_CLIENT -n --query " create table ttl_01280_2 (a Int, b Int, x Array(Int32), y Double, d DateTime) engine = MergeTree order by (a, b) ttl d + interval 1 second group by a, b set x = minForEach(x), y = sum(y), d = max(d); insert into ttl_01280_2 values (1, 1, array(0, 2, 3), 4, now() + 10); insert into ttl_01280_2 values (1, 1, array(5, 4, 3), 6, now()); @@ -23,13 +39,15 @@ insert into ttl_01280_2 values (1, 3, array(1, 1, 2, 1), 9, now()); insert into ttl_01280_2 values (1, 3, array(3, 2, 1, 0), 3, now()); insert into ttl_01280_2 values (2, 1, array(3, 3, 3), 7, now()); insert into ttl_01280_2 values (2, 1, array(11, 1, 0, 3), 1, now()); -insert into ttl_01280_2 values (3, 1, array(2, 4, 5), 8, now()); -select sleep(1.1) format Null; -optimize table ttl_01280_2 final; -select a, b, x, y from ttl_01280_2; +insert into ttl_01280_2 values (3, 1, array(2, 4, 5), 8, now());" -drop table if exists ttl_01280_3; +sleep 2 +optimize "ttl_01280_2" +$CLICKHOUSE_CLIENT --query "select a, b, x, y from ttl_01280_2" +$CLICKHOUSE_CLIENT --query "drop table if exists ttl_01280_3" + +$CLICKHOUSE_CLIENT -n --query " create table ttl_01280_3 (a Int, b Int, x Int64, y Int, d DateTime) engine = MergeTree order by (a, b) ttl d + interval 1 second group by a set x = argMax(x, d), y = argMax(y, d), d = max(d); insert into ttl_01280_3 values (1, 1, 0, 4, now() + 10); insert into ttl_01280_3 values (1, 1, 10, 6, now() + 1); @@ -39,49 +57,47 @@ insert into ttl_01280_3 values (2, 1, 20, 1, now()); insert into ttl_01280_3 values (2, 1, 0, 3, now() + 1); insert into ttl_01280_3 values (3, 1, 0, 3, now()); insert into ttl_01280_3 values (3, 2, 8, 2, now() + 1); -insert into ttl_01280_3 values (3, 5, 5, 8, now()); -select sleep(2.1) format Null; -optimize table ttl_01280_3 final; -select a, b, x, y from ttl_01280_3; +insert into ttl_01280_3 values (3, 5, 5, 8, now());" -drop table if exists ttl_01280_4; +sleep 2 +optimize "ttl_01280_3" +$CLICKHOUSE_CLIENT --query "select a, b, x, y from ttl_01280_3" +$CLICKHOUSE_CLIENT --query "drop table if exists ttl_01280_4" + +$CLICKHOUSE_CLIENT -n --query " create table ttl_01280_4 (a Int, b Int, x Int64, y Int64, d DateTime) engine = MergeTree order by (toDate(d), -(a + b)) ttl d + interval 1 second group by toDate(d) set x = sum(x), y = max(y); insert into ttl_01280_4 values (1, 1, 0, 4, now() + 10); insert into ttl_01280_4 values (10, 2, 3, 3, now()); insert into ttl_01280_4 values (2, 10, 1, 7, now()); insert into ttl_01280_4 values (3, 3, 5, 2, now()); -insert into ttl_01280_4 values (1, 5, 4, 9, now()); -select sleep(1.1) format Null; -optimize table ttl_01280_4 final; -select a, b, x, y from ttl_01280_4; +insert into ttl_01280_4 values (1, 5, 4, 9, now())" -drop table if exists ttl_01280_5; +sleep 2 +optimize "ttl_01280_4" +$CLICKHOUSE_CLIENT --query "select a, b, x, y from ttl_01280_4" -create table ttl_01280_5 (a Int, b Int, x Int64, y Int64, d DateTime) engine = MergeTree order by (toDate(d), a, -b) ttl d + interval 1 second group by toDate(d), a set x = sum(x); +$CLICKHOUSE_CLIENT --query "drop table if exists ttl_01280_5" + +$CLICKHOUSE_CLIENT -n --query "create table ttl_01280_5 (a Int, b Int, x Int64, y Int64, d DateTime) engine = MergeTree order by (toDate(d), a, -b) ttl d + interval 1 second group by toDate(d), a set x = sum(x); insert into ttl_01280_5 values (1, 2, 3, 5, now()); insert into ttl_01280_5 values (2, 10, 1, 5, now()); insert into ttl_01280_5 values (2, 3, 5, 5, now()); -insert into ttl_01280_5 values (1, 5, 4, 5, now()); -select sleep(1.1) format Null; -optimize table ttl_01280_5 final; -select a, b, x, y from ttl_01280_5; +insert into ttl_01280_5 values (1, 5, 4, 5, now());" -drop table if exists ttl_01280_6; +sleep 2 +optimize "ttl_01280_5" +$CLICKHOUSE_CLIENT --query "select a, b, x, y from ttl_01280_5" +$CLICKHOUSE_CLIENT --query "drop table if exists ttl_01280_6" + +$CLICKHOUSE_CLIENT -n --query " create table ttl_01280_6 (a Int, b Int, x Int64, y Int64, d DateTime) engine = MergeTree order by (toDate(d), a, -b) ttl d + interval 1 second group by toDate(d), a; insert into ttl_01280_6 values (1, 2, 3, 5, now()); insert into ttl_01280_6 values (2, 10, 3, 5, now()); insert into ttl_01280_6 values (2, 3, 3, 5, now()); -insert into ttl_01280_6 values (1, 5, 3, 5, now()); -select sleep(1.1) format Null; -optimize table ttl_01280_6 final; -select a, b, x, y from ttl_01280_6; +insert into ttl_01280_6 values (1, 5, 3, 5, now())" -create table ttl_01280_error (a Int, b Int, x Int64, y Int64, d DateTime) engine = MergeTree order by (a, b) ttl d + interval 1 second group by x set y = max(y); -- { serverError 450} -create table ttl_01280_error (a Int, b Int, x Int64, y Int64, d DateTime) engine = MergeTree order by (a, b) ttl d + interval 1 second group by b set y = max(y); -- { serverError 450} -create table ttl_01280_error (a Int, b Int, x Int64, y Int64, d DateTime) engine = MergeTree order by (a, b) ttl d + interval 1 second group by a, b, x set y = max(y); -- { serverError 450} -create table ttl_01280_error (a Int, b Int, x Int64, y Int64, d DateTime) engine = MergeTree order by (a, b) ttl d + interval 1 second group by a set b = min(b), y = max(y); -- { serverError 450} -create table ttl_01280_error (a Int, b Int, x Int64, y Int64, d DateTime) engine = MergeTree order by (a, b) ttl d + interval 1 second group by a, b set y = max(y), y = max(y); -- { serverError 450} -create table ttl_01280_error (a Int, b Int, x Int64, y Int64, d DateTime) engine = MergeTree order by (toDate(d), a) ttl d + interval 1 second group by toDate(d), a set d = min(d), b = max(b); -- { serverError 450} -create table ttl_01280_error (a Int, b Int, x Int64, y Int64, d DateTime) engine = MergeTree order by (d, -(a + b)) ttl d + interval 1 second group by d, -(a + b) set a = sum(a), b = min(b); -- { serverError 450} +sleep 2 +optimize "ttl_01280_6" +$CLICKHOUSE_CLIENT --query "select a, b, x, y from ttl_01280_6" diff --git a/tests/queries/0_stateless/01280_ttl_where_group_by_negative.reference b/tests/queries/0_stateless/01280_ttl_where_group_by_negative.reference new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/queries/0_stateless/01280_ttl_where_group_by_negative.sql b/tests/queries/0_stateless/01280_ttl_where_group_by_negative.sql new file mode 100644 index 00000000000..f2c26a3d495 --- /dev/null +++ b/tests/queries/0_stateless/01280_ttl_where_group_by_negative.sql @@ -0,0 +1,7 @@ +create table ttl_01280_error (a Int, b Int, x Int64, y Int64, d DateTime) engine = MergeTree order by (a, b) ttl d + interval 1 second group by x set y = max(y); -- { serverError 450} +create table ttl_01280_error (a Int, b Int, x Int64, y Int64, d DateTime) engine = MergeTree order by (a, b) ttl d + interval 1 second group by b set y = max(y); -- { serverError 450} +create table ttl_01280_error (a Int, b Int, x Int64, y Int64, d DateTime) engine = MergeTree order by (a, b) ttl d + interval 1 second group by a, b, x set y = max(y); -- { serverError 450} +create table ttl_01280_error (a Int, b Int, x Int64, y Int64, d DateTime) engine = MergeTree order by (a, b) ttl d + interval 1 second group by a set b = min(b), y = max(y); -- { serverError 450} +create table ttl_01280_error (a Int, b Int, x Int64, y Int64, d DateTime) engine = MergeTree order by (a, b) ttl d + interval 1 second group by a, b set y = max(y), y = max(y); -- { serverError 450} +create table ttl_01280_error (a Int, b Int, x Int64, y Int64, d DateTime) engine = MergeTree order by (toDate(d), a) ttl d + interval 1 second group by toDate(d), a set d = min(d), b = max(b); -- { serverError 450} +create table ttl_01280_error (a Int, b Int, x Int64, y Int64, d DateTime) engine = MergeTree order by (d, -(a + b)) ttl d + interval 1 second group by d, -(a + b) set a = sum(a), b = min(b); -- { serverError 450}