From 9e892fe9b908b6c531dcab425ee4d6cb8809be87 Mon Sep 17 00:00:00 2001 From: walter Date: Mon, 6 Nov 2023 11:10:37 +0800 Subject: [PATCH 1/2] [test](regression) Add more regression test for FE (#26384) --- .../schema_change_p0/test_rename_column.out | Bin 4097 -> 4171 bytes .../test_show_create_table_and_views.out | 46 +++++++ .../show_p0/test_show_table_and_views.out | 40 ++++++ .../suites/node_p0/test_backend.groovy | 8 +- .../test_rename_column.groovy | 5 + .../test_show_create_table_and_views.groovy | 124 ++++++++++++++++++ .../test_sql_block_rule.groovy | 16 +++ .../statistics/test_basic_statistics.groovy | 1 + 8 files changed, 239 insertions(+), 1 deletion(-) create mode 100644 regression-test/data/show_p0/test_show_create_table_and_views.out create mode 100644 regression-test/data/show_p0/test_show_table_and_views.out create mode 100644 regression-test/suites/show_p0/test_show_create_table_and_views.groovy diff --git a/regression-test/data/schema_change_p0/test_rename_column.out b/regression-test/data/schema_change_p0/test_rename_column.out index 3e8d56d043e4a06e0cde1ed0a679505fc2a9cc57..c55ccab9e0f0a322555edcc9c5933c84714d16cd 100644 GIT binary patch delta 64 zcmZovIIXZ@D(~c0&GHM!f7NzDT=B7I5=alB=g=MCe8*&+OViBDj&npQ4 D5$hKM delta 22 ecmX@D(5SFsD(~b2JOPs 1 && ret[0][1] == 'false') { + logger.info("enable_feature_binlog=false in frontend config, no need to run this case.") + return + } + + String suiteName = "show_create_table_and_views" + String dbName = "${suiteName}_db" + String tableName = "${suiteName}_table" + String viewName = "${suiteName}_view" + String rollupName = "${suiteName}_rollup" + String likeName = "${suiteName}_like" + + sql "CREATE DATABASE IF NOT EXISTS ${dbName}" + sql "DROP TABLE IF EXISTS ${dbName}.${tableName}" + sql """ + CREATE TABLE ${dbName}.${tableName} ( + `user_id` LARGEINT NOT NULL, + `good_id` LARGEINT NOT NULL, + `cost` BIGINT SUM DEFAULT "0", + ) + AGGREGATE KEY(`user_id`, `good_id`) + PARTITION BY RANGE(`good_id`) + ( + PARTITION p1 VALUES LESS THAN ("100"), + PARTITION p2 VALUES LESS THAN ("200"), + PARTITION p3 VALUES LESS THAN ("300"), + PARTITION p4 VALUES LESS THAN ("400"), + PARTITION p5 VALUES LESS THAN ("500"), + PARTITION p6 VALUES LESS THAN ("600"), + PARTITION p7 VALUES LESS THAN MAXVALUE + ) + DISTRIBUTED BY HASH(`user_id`) BUCKETS 2 + PROPERTIES ( + "replication_num" = "1" + ) + """ + + sql """INSERT INTO ${dbName}.${tableName} VALUES + (1, 1, 10), + (1, 1, 20), + (1, 2, 5), + (1, 3, 10), + (2, 1, 0), + (2, 1, 100), + (3, 1, 10), + (2, 2, 10), + (2, 3, 44), + (3, 2, 1), + (100, 100, 1), + (200, 20, 1), + (300, 20, 1), + (1, 300, 2), + (2, 200, 1111), + (23, 900, 1)""" + + qt_show "SHOW CREATE TABLE ${dbName}.${tableName}" + qt_select "SELECT * FROM ${dbName}.${tableName} ORDER BY user_id" + + // create view and show + sql """ + CREATE VIEW IF NOT EXISTS ${dbName}.${viewName} (user_id, cost) + AS + SELECT user_id, cost FROM ${dbName}.${tableName} + WHERE good_id = 2 + """ + qt_select "SELECT * FROM ${dbName}.${viewName} ORDER BY user_id" + qt_show "SHOW CREATE VIEW ${dbName}.${viewName}" + + // create rollup + sql """ALTER TABLE ${dbName}.${tableName} + ADD ROLLUP ${rollupName} (user_id, cost) + """ + + def isAlterTableFinish = { -> + def records = sql """SHOW ALTER TABLE ROLLUP FROM ${dbName}""" + for (def row in records) { + if (row[5] == "${rollupName}" && row[8] == "FINISHED") { + return true + } + } + false + } + while (!isAlterTableFinish()) { + Thread.sleep(100) + } + + qt_select "SELECT user_id, SUM(cost) FROM ${dbName}.${tableName} GROUP BY user_id ORDER BY user_id" + qt_show "SHOW CREATE TABLE ${dbName}.${tableName}" + + // create like + sql "CREATE TABLE ${dbName}.${likeName} LIKE ${dbName}.${tableName}" + qt_show "SHOW CREATE TABLE ${dbName}.${likeName}" + + // create like with rollup + sql "CREATE TABLE ${dbName}.${likeName}_with_rollup LIKE ${dbName}.${tableName} WITH ROLLUP" + qt_show "SHOW CREATE TABLE ${dbName}.${likeName}_with_rollup" + + sql "DROP TABLE IF EXISTS ${dbName}.${likeName}_with_rollup FORCE" + sql "DROP TABLE ${dbName}.${likeName} FORCE" + sql "DROP VIEW ${dbName}.${viewName}" + sql "DROP TABLE ${dbName}.${tableName} FORCE" + sql "DROP DATABASE ${dbName} FORCE" +} + diff --git a/regression-test/suites/sql_block_rule_p0/test_sql_block_rule.groovy b/regression-test/suites/sql_block_rule_p0/test_sql_block_rule.groovy index fed19fd7b69500..978486d8afdf7d 100644 --- a/regression-test/suites/sql_block_rule_p0/test_sql_block_rule.groovy +++ b/regression-test/suites/sql_block_rule_p0/test_sql_block_rule.groovy @@ -66,6 +66,22 @@ suite("test_sql_block_rule") { exception "sql match regex sql block rule: test_rule_sql" } + sql """ + ALTER SQL_BLOCK_RULE test_rule_sql PROPERTIES("enable"="false") + """ + + sql "SELECT * FROM table_2" + + sql """ + ALTER SQL_BLOCK_RULE test_rule_sql + PROPERTIES("sql"="SELECT abcd FROM table_2", "global"= "true", "enable"= "true") + """ + + test { + sql("SELECT abcd FROM table_2", false) + exception "sql match regex sql block rule: test_rule_sql" + } + sql """ DROP SQL_BLOCK_RULE if exists test_rule_sql """ diff --git a/regression-test/suites/statistics/test_basic_statistics.groovy b/regression-test/suites/statistics/test_basic_statistics.groovy index a885ac1c11cbcf..6ee54baa942e36 100644 --- a/regression-test/suites/statistics/test_basic_statistics.groovy +++ b/regression-test/suites/statistics/test_basic_statistics.groovy @@ -69,6 +69,7 @@ suite("test_basic_statistics") { assertTrue(result[0][6] == "\'name1\'") assertTrue(result[0][7] == "\'name9\'") + sql """drop stats ${tbl}""" sql """drop table ${tbl}""" sql """drop database ${db}""" From 499f0f9f3e8bf8c30011322f255adb41626ec4ed Mon Sep 17 00:00:00 2001 From: walter Date: Mon, 6 Nov 2023 18:34:14 +0800 Subject: [PATCH 2/2] [fix](regression) Fix unstable regression case introduced by #26384 (#26453) --- .../data/show_p0/test_show_create_table_and_views.out | 4 ++-- .../suites/show_p0/test_show_create_table_and_views.groovy | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/regression-test/data/show_p0/test_show_create_table_and_views.out b/regression-test/data/show_p0/test_show_create_table_and_views.out index fb541f2e2c7b3b..ccd97f308f5017 100644 --- a/regression-test/data/show_p0/test_show_create_table_and_views.out +++ b/regression-test/data/show_p0/test_show_create_table_and_views.out @@ -4,13 +4,13 @@ show_create_table_and_views_table CREATE TABLE `show_create_table_and_views_tabl -- !select -- 1 1 30 -1 300 2 1 2 5 1 3 10 -2 200 1111 +1 300 2 2 1 100 2 2 10 2 3 44 +2 200 1111 3 1 10 3 2 1 23 900 1 diff --git a/regression-test/suites/show_p0/test_show_create_table_and_views.groovy b/regression-test/suites/show_p0/test_show_create_table_and_views.groovy index d73bb9fdc9311c..89670aa434f680 100644 --- a/regression-test/suites/show_p0/test_show_create_table_and_views.groovy +++ b/regression-test/suites/show_p0/test_show_create_table_and_views.groovy @@ -74,7 +74,7 @@ suite("test_show_create_table_and_views", "show") { (23, 900, 1)""" qt_show "SHOW CREATE TABLE ${dbName}.${tableName}" - qt_select "SELECT * FROM ${dbName}.${tableName} ORDER BY user_id" + qt_select "SELECT * FROM ${dbName}.${tableName} ORDER BY user_id, good_id" // create view and show sql """