From fe8a334056e1a1498d715f66aedcc646c75b161c Mon Sep 17 00:00:00 2001 From: "Mingyu Chen (Rayner)" Date: Sat, 4 Jan 2025 19:32:59 +0800 Subject: [PATCH] [fix](test) fix unstable lower case test (#46410) ### What problem does this PR solve? when "use_meta_cache" = "false", the meta sync between FEs maybe delay, and it may cause the case unstable, so I added a `wait()` method to wait the meta sync. --- ...est_lower_case_meta_show_and_select.groovy | 18 +++ ...th_lower_table_conf_show_and_select.groovy | 66 ++++++++- .../test_timing_refresh_catalog.groovy | 127 ++++++++++-------- .../lower_case/upgrade/load.groovy | 17 +++ 4 files changed, 173 insertions(+), 55 deletions(-) diff --git a/regression-test/suites/external_table_p0/lower_case/test_lower_case_meta_show_and_select.groovy b/regression-test/suites/external_table_p0/lower_case/test_lower_case_meta_show_and_select.groovy index 7b61216e949d8c..ac86623243d9dc 100644 --- a/regression-test/suites/external_table_p0/lower_case/test_lower_case_meta_show_and_select.groovy +++ b/regression-test/suites/external_table_p0/lower_case/test_lower_case_meta_show_and_select.groovy @@ -15,6 +15,10 @@ // specific language governing permissions and limitations // under the License. +import java.util.concurrent.Executors +import java.util.concurrent.TimeUnit +import org.awaitility.Awaitility + suite("test_lower_case_meta_show_and_select", "p0,external,doris,external_docker,external_docker_doris") { String jdbcUrl = context.config.jdbcUrl @@ -24,6 +28,18 @@ suite("test_lower_case_meta_show_and_select", "p0,external,doris,external_docker String bucket = getS3BucketName() String driver_url = "https://${bucket}.${s3_endpoint}/regression/jdbc_driver/mysql-connector-j-8.3.0.jar" + def wait_table_sync = { String db -> + Awaitility.await().atMost(10, TimeUnit.SECONDS).pollInterval(1, TimeUnit.SECONDS).until{ + try { + def res = sql "show tables from ${db}" + return res.size() > 0; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + } + try_sql """drop user ${jdbcUser}""" sql """create user ${jdbcUser} identified by '${jdbcPassword}'""" sql """grant all on *.*.* to ${jdbcUser}""" @@ -75,6 +91,7 @@ suite("test_lower_case_meta_show_and_select", "p0,external,doris,external_docker "include_database_list" = "external_test_lower,external_test_UPPER" )""" + wait_table_sync("test_cache_false_lower_false.external_test_lower") test { sql """show databases from test_cache_false_lower_false""" @@ -172,6 +189,7 @@ suite("test_lower_case_meta_show_and_select", "p0,external,doris,external_docker "include_database_list" = "external_test_lower,external_test_UPPER" )""" + wait_table_sync("test_cache_false_lower_true.external_test_lower") test { sql """show databases from test_cache_false_lower_true""" diff --git a/regression-test/suites/external_table_p0/lower_case/test_lower_case_meta_with_lower_table_conf_show_and_select.groovy b/regression-test/suites/external_table_p0/lower_case/test_lower_case_meta_with_lower_table_conf_show_and_select.groovy index d16648fc5e1e79..0c2712e4686602 100644 --- a/regression-test/suites/external_table_p0/lower_case/test_lower_case_meta_with_lower_table_conf_show_and_select.groovy +++ b/regression-test/suites/external_table_p0/lower_case/test_lower_case_meta_with_lower_table_conf_show_and_select.groovy @@ -15,6 +15,10 @@ // specific language governing permissions and limitations // under the License. +import java.util.concurrent.Executors +import java.util.concurrent.TimeUnit +import org.awaitility.Awaitility + suite("test_lower_case_meta_with_lower_table_conf_show_and_select", "p0,external,doris,external_docker,external_docker_doris") { String jdbcUrl = context.config.jdbcUrl @@ -24,6 +28,18 @@ suite("test_lower_case_meta_with_lower_table_conf_show_and_select", "p0,external String bucket = getS3BucketName() String driver_url = "https://${bucket}.${s3_endpoint}/regression/jdbc_driver/mysql-connector-j-8.3.0.jar" + def wait_table_sync = { String db -> + Awaitility.await().atMost(10, TimeUnit.SECONDS).pollInterval(1, TimeUnit.SECONDS).until{ + try { + def res = sql "show tables from ${db}" + return res.size() > 0; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + } + try_sql """drop user ${jdbcUser}""" sql """create user ${jdbcUser} identified by '${jdbcPassword}'""" sql """grant all on *.*.* to ${jdbcUser}""" @@ -68,21 +84,29 @@ suite("test_lower_case_meta_with_lower_table_conf_show_and_select", "p0,external "only_test_lower_case_table_names" = "1" )""" + wait_table_sync("test_cache_false_lower_false_with_conf1.external_test_lower_with_conf"); qt_sql_test_cache_false_lower_false_with_conf1_1 "select * from test_cache_false_lower_false_with_conf1.external_test_lower_with_conf.lower_with_conf" sql "refresh catalog test_cache_false_lower_false_with_conf1" + wait_table_sync("test_cache_false_lower_false_with_conf1.external_test_lower_with_conf"); qt_sql_test_cache_false_lower_false_with_conf1_2 "select * from test_cache_false_lower_false_with_conf1.external_test_lower_with_conf.LOWER_with_conf" sql "refresh catalog test_cache_false_lower_false_with_conf1" + wait_table_sync("test_cache_false_lower_false_with_conf1.external_test_lower_with_conf"); qt_sql_test_cache_false_lower_false_with_conf1_3 "select * from test_cache_false_lower_false_with_conf1.external_test_lower_with_conf.UPPER_with_conf" sql "refresh catalog test_cache_false_lower_false_with_conf1" + wait_table_sync("test_cache_false_lower_false_with_conf1.external_test_lower_with_conf"); qt_sql_test_cache_false_lower_false_with_conf1_4 "select * from test_cache_false_lower_false_with_conf1.external_test_lower_with_conf.upper_with_conf" sql "refresh catalog test_cache_false_lower_false_with_conf1" + wait_table_sync("test_cache_false_lower_false_with_conf1.external_test_lower_with_conf"); qt_sql_test_cache_false_lower_false_with_conf1_1_insert "insert into internal.external_test_lower_with_conf.with_conf_insert select * from test_cache_false_lower_false_with_conf1.external_test_lower_with_conf.lower_with_conf" sql "refresh catalog test_cache_false_lower_false_with_conf1" + wait_table_sync("test_cache_false_lower_false_with_conf1.external_test_lower_with_conf"); qt_sql_test_cache_false_lower_false_with_conf1_2_insert "insert into internal.external_test_lower_with_conf.with_conf_insert select * from test_cache_false_lower_false_with_conf1.external_test_lower_with_conf.LOWER_with_conf" sql "refresh catalog test_cache_false_lower_false_with_conf1" + wait_table_sync("test_cache_false_lower_false_with_conf1.external_test_lower_with_conf"); qt_sql_test_cache_false_lower_false_with_conf1_3_insert "insert into internal.external_test_lower_with_conf.with_conf_insert select * from test_cache_false_lower_false_with_conf1.external_test_lower_with_conf.UPPER_with_conf" sql "refresh catalog test_cache_false_lower_false_with_conf1" + wait_table_sync("test_cache_false_lower_false_with_conf1.external_test_lower_with_conf"); qt_sql_test_cache_false_lower_false_with_conf1_4_insert "insert into internal.external_test_lower_with_conf.with_conf_insert select * from test_cache_false_lower_false_with_conf1.external_test_lower_with_conf.upper_with_conf" @@ -117,21 +141,29 @@ suite("test_lower_case_meta_with_lower_table_conf_show_and_select", "p0,external "only_test_lower_case_table_names" = "2" )""" + wait_table_sync("test_cache_false_lower_false_with_conf2.external_test_lower_with_conf"); qt_sql_test_cache_false_lower_false_with_conf2_1 "select * from test_cache_false_lower_false_with_conf2.external_test_lower_with_conf.lower_with_conf" sql "refresh catalog test_cache_false_lower_false_with_conf2" + wait_table_sync("test_cache_false_lower_false_with_conf2.external_test_lower_with_conf"); qt_sql_test_cache_false_lower_false_with_conf2_2 "select * from test_cache_false_lower_false_with_conf2.external_test_lower_with_conf.LOWER_with_conf" sql "refresh catalog test_cache_false_lower_false_with_conf2" + wait_table_sync("test_cache_false_lower_false_with_conf2.external_test_lower_with_conf"); qt_sql_test_cache_false_lower_false_with_conf2_3 "select * from test_cache_false_lower_false_with_conf2.external_test_lower_with_conf.UPPER_with_conf" sql "refresh catalog test_cache_false_lower_false_with_conf2" + wait_table_sync("test_cache_false_lower_false_with_conf2.external_test_lower_with_conf"); qt_sql_test_cache_false_lower_false_with_conf2_4 "select * from test_cache_false_lower_false_with_conf2.external_test_lower_with_conf.upper_with_conf" sql "refresh catalog test_cache_false_lower_false_with_conf2" + wait_table_sync("test_cache_false_lower_false_with_conf2.external_test_lower_with_conf"); qt_sql_test_cache_false_lower_false_with_conf2_1_insert "insert into internal.external_test_lower_with_conf.with_conf_insert select * from test_cache_false_lower_false_with_conf2.external_test_lower_with_conf.lower_with_conf" sql "refresh catalog test_cache_false_lower_false_with_conf2" + wait_table_sync("test_cache_false_lower_false_with_conf2.external_test_lower_with_conf"); qt_sql_test_cache_false_lower_false_with_conf2_2_insert "insert into internal.external_test_lower_with_conf.with_conf_insert select * from test_cache_false_lower_false_with_conf2.external_test_lower_with_conf.LOWER_with_conf" sql "refresh catalog test_cache_false_lower_false_with_conf2" + wait_table_sync("test_cache_false_lower_false_with_conf2.external_test_lower_with_conf"); qt_sql_test_cache_false_lower_false_with_conf2_3_insert "insert into internal.external_test_lower_with_conf.with_conf_insert select * from test_cache_false_lower_false_with_conf2.external_test_lower_with_conf.UPPER_with_conf" sql "refresh catalog test_cache_false_lower_false_with_conf2" + wait_table_sync("test_cache_false_lower_false_with_conf2.external_test_lower_with_conf"); qt_sql_test_cache_false_lower_false_with_conf2_4_insert "insert into internal.external_test_lower_with_conf.with_conf_insert select * from test_cache_false_lower_false_with_conf2.external_test_lower_with_conf.upper_with_conf" test { @@ -263,21 +295,29 @@ suite("test_lower_case_meta_with_lower_table_conf_show_and_select", "p0,external "only_test_lower_case_table_names" = "1" )""" + wait_table_sync("test_cache_false_lower_true_with_conf1.external_test_lower_with_conf"); qt_sql_test_cache_false_lower_true_with_conf1_1 "select * from test_cache_false_lower_true_with_conf1.external_test_lower_with_conf.lower_with_conf" sql "refresh catalog test_cache_false_lower_true_with_conf1" + wait_table_sync("test_cache_false_lower_true_with_conf1.external_test_lower_with_conf"); qt_sql_test_cache_false_lower_true_with_conf1_2 "select * from test_cache_false_lower_true_with_conf1.external_test_lower_with_conf.LOWER_with_conf" sql "refresh catalog test_cache_false_lower_true_with_conf1" + wait_table_sync("test_cache_false_lower_true_with_conf1.external_test_lower_with_conf"); qt_sql_test_cache_false_lower_true_with_conf1_3 "select * from test_cache_false_lower_true_with_conf1.external_test_lower_with_conf.UPPER_with_conf" sql "refresh catalog test_cache_false_lower_true_with_conf1" + wait_table_sync("test_cache_false_lower_true_with_conf1.external_test_lower_with_conf"); qt_sql_test_cache_false_lower_true_with_conf1_4 "select * from test_cache_false_lower_true_with_conf1.external_test_lower_with_conf.upper_with_conf" sql "refresh catalog test_cache_false_lower_true_with_conf1" + wait_table_sync("test_cache_false_lower_true_with_conf1.external_test_lower_with_conf"); qt_sql_test_cache_false_lower_true_with_conf1_1_insert "insert into internal.external_test_lower_with_conf.with_conf_insert select * from test_cache_false_lower_true_with_conf1.external_test_lower_with_conf.lower_with_conf" sql "refresh catalog test_cache_false_lower_true_with_conf1" + wait_table_sync("test_cache_false_lower_true_with_conf1.external_test_lower_with_conf"); qt_sql_test_cache_false_lower_true_with_conf1_2_insert "insert into internal.external_test_lower_with_conf.with_conf_insert select * from test_cache_false_lower_true_with_conf1.external_test_lower_with_conf.LOWER_with_conf" sql "refresh catalog test_cache_false_lower_true_with_conf1" + wait_table_sync("test_cache_false_lower_true_with_conf1.external_test_lower_with_conf"); qt_sql_test_cache_false_lower_true_with_conf1_3_insert "insert into internal.external_test_lower_with_conf.with_conf_insert select * from test_cache_false_lower_true_with_conf1.external_test_lower_with_conf.UPPER_with_conf" sql "refresh catalog test_cache_false_lower_true_with_conf1" + wait_table_sync("test_cache_false_lower_true_with_conf1.external_test_lower_with_conf"); qt_sql_test_cache_false_lower_true_with_conf1_4_insert "insert into internal.external_test_lower_with_conf.with_conf_insert select * from test_cache_false_lower_true_with_conf1.external_test_lower_with_conf.upper_with_conf" test { @@ -311,21 +351,29 @@ suite("test_lower_case_meta_with_lower_table_conf_show_and_select", "p0,external "only_test_lower_case_table_names" = "2" )""" + wait_table_sync("test_cache_false_lower_true_with_conf2.external_test_lower_with_conf"); qt_sql_test_cache_false_lower_true_with_conf2_1 "select * from test_cache_false_lower_true_with_conf2.external_test_lower_with_conf.lower_with_conf" sql "refresh catalog test_cache_false_lower_true_with_conf2" + wait_table_sync("test_cache_false_lower_true_with_conf2.external_test_lower_with_conf"); qt_sql_test_cache_false_lower_true_with_conf2_2 "select * from test_cache_false_lower_true_with_conf2.external_test_lower_with_conf.LOWER_with_conf" sql "refresh catalog test_cache_false_lower_true_with_conf2" + wait_table_sync("test_cache_false_lower_true_with_conf2.external_test_lower_with_conf"); qt_sql_test_cache_false_lower_true_with_conf2_3 "select * from test_cache_false_lower_true_with_conf2.external_test_lower_with_conf.UPPER_with_conf" sql "refresh catalog test_cache_false_lower_true_with_conf2" + wait_table_sync("test_cache_false_lower_true_with_conf2.external_test_lower_with_conf"); qt_sql_test_cache_false_lower_true_with_conf2_4 "select * from test_cache_false_lower_true_with_conf2.external_test_lower_with_conf.upper_with_conf" sql "refresh catalog test_cache_false_lower_true_with_conf2" + wait_table_sync("test_cache_false_lower_true_with_conf2.external_test_lower_with_conf"); qt_sql_test_cache_false_lower_true_with_conf2_1_insert "insert into internal.external_test_lower_with_conf.with_conf_insert select * from test_cache_false_lower_true_with_conf2.external_test_lower_with_conf.lower_with_conf" sql "refresh catalog test_cache_false_lower_true_with_conf2" + wait_table_sync("test_cache_false_lower_true_with_conf2.external_test_lower_with_conf"); qt_sql_test_cache_false_lower_true_with_conf2_2_insert "insert into internal.external_test_lower_with_conf.with_conf_insert select * from test_cache_false_lower_true_with_conf2.external_test_lower_with_conf.LOWER_with_conf" sql "refresh catalog test_cache_false_lower_true_with_conf2" + wait_table_sync("test_cache_false_lower_true_with_conf2.external_test_lower_with_conf"); qt_sql_test_cache_false_lower_true_with_conf2_3_insert "insert into internal.external_test_lower_with_conf.with_conf_insert select * from test_cache_false_lower_true_with_conf2.external_test_lower_with_conf.UPPER_with_conf" sql "refresh catalog test_cache_false_lower_true_with_conf2" + wait_table_sync("test_cache_false_lower_true_with_conf2.external_test_lower_with_conf"); qt_sql_test_cache_false_lower_true_with_conf2_4_insert "insert into internal.external_test_lower_with_conf.with_conf_insert select * from test_cache_false_lower_true_with_conf2.external_test_lower_with_conf.upper_with_conf" test { @@ -401,7 +449,7 @@ suite("test_lower_case_meta_with_lower_table_conf_show_and_select", "p0,external "jdbc_url" = "${jdbcUrl}", "driver_url" = "${driver_url}", "driver_class" = "com.mysql.cj.jdbc.Driver", - "use_meta_cache" = "truee", + "use_meta_cache" = "true", "lower_case_meta_names" = "true", "only_specified_database" = "true", "include_database_list" = "external_test_lower_with_conf", @@ -457,34 +505,42 @@ suite("test_lower_case_meta_with_lower_table_conf_show_and_select", "p0,external "only_test_lower_case_table_names" = "0" )""" + wait_table_sync("test_cache_false_lower_false_with_conf0.external_test_lower_with_conf"); qt_sql_test_cache_false_lower_false_with_conf0_1 "select * from test_cache_false_lower_false_with_conf0.external_test_lower_with_conf.lower_with_conf" sql "refresh catalog test_cache_false_lower_false_with_conf0" + wait_table_sync("test_cache_false_lower_false_with_conf0.external_test_lower_with_conf"); qt_sql_test_cache_false_lower_false_with_conf0_2 "select * from test_cache_false_lower_false_with_conf0.external_test_lower_with_conf.UPPER_with_conf" sql "refresh catalog test_cache_false_lower_false_with_conf0" + wait_table_sync("test_cache_false_lower_false_with_conf0.external_test_lower_with_conf"); qt_sql_test_cache_false_lower_false_with_conf0_1_insert "insert into internal.external_test_lower_with_conf.with_conf_insert select * from test_cache_false_lower_false_with_conf0.external_test_lower_with_conf.lower_with_conf" sql "refresh catalog test_cache_false_lower_false_with_conf0" + wait_table_sync("test_cache_false_lower_false_with_conf0.external_test_lower_with_conf"); qt_sql_test_cache_false_lower_false_with_conf0_2_insert "insert into internal.external_test_lower_with_conf.with_conf_insert select * from test_cache_false_lower_false_with_conf0.external_test_lower_with_conf.UPPER_with_conf" sql "refresh catalog test_cache_false_lower_false_with_conf0" + wait_table_sync("test_cache_false_lower_false_with_conf0.external_test_lower_with_conf"); test { sql "select * from test_cache_false_lower_false_with_conf0.external_test_lower_with_conf.Lower_with_conf" exception "Table [Lower_with_conf] does not exist in database [external_test_lower_with_conf]." } sql "refresh catalog test_cache_false_lower_false_with_conf0" + wait_table_sync("test_cache_false_lower_false_with_conf0.external_test_lower_with_conf"); test { sql "select * from test_cache_false_lower_false_with_conf0.external_test_lower_with_conf.upper_with_conf" exception "Table [upper_with_conf] does not exist in database [external_test_lower_with_conf]." } sql "refresh catalog test_cache_false_lower_false_with_conf0" + wait_table_sync("test_cache_false_lower_false_with_conf0.external_test_lower_with_conf"); test { sql "insert into internal.external_test_lower_with_conf.with_conf_insert select * from test_cache_false_lower_false_with_conf0.external_test_lower_with_conf.Lower_with_conf" exception "Table [Lower_with_conf] does not exist in database [external_test_lower_with_conf]." } sql "refresh catalog test_cache_false_lower_false_with_conf0" + wait_table_sync("test_cache_false_lower_false_with_conf0.external_test_lower_with_conf"); test { sql "insert into internal.external_test_lower_with_conf.with_conf_insert select * from test_cache_false_lower_false_with_conf0.external_test_lower_with_conf.upper_with_conf" exception "Table [upper_with_conf] does not exist in database [external_test_lower_with_conf]." @@ -588,34 +644,42 @@ suite("test_lower_case_meta_with_lower_table_conf_show_and_select", "p0,external "only_test_lower_case_table_names" = "0" )""" + wait_table_sync("test_cache_false_lower_true_with_conf0.external_test_lower_with_conf"); qt_sql_test_cache_false_lower_true_with_conf0_1 "select * from test_cache_false_lower_true_with_conf0.external_test_lower_with_conf.lower_with_conf" sql "refresh catalog test_cache_false_lower_true_with_conf0" + wait_table_sync("test_cache_false_lower_true_with_conf0.external_test_lower_with_conf"); qt_sql_test_cache_false_lower_true_with_conf0_2 "select * from test_cache_false_lower_true_with_conf0.external_test_lower_with_conf.upper_with_conf" sql "refresh catalog test_cache_false_lower_true_with_conf0" + wait_table_sync("test_cache_false_lower_true_with_conf0.external_test_lower_with_conf"); qt_sql_test_cache_false_lower_true_with_conf0_1_insert "insert into internal.external_test_lower_with_conf.with_conf_insert select * from test_cache_false_lower_true_with_conf0.external_test_lower_with_conf.lower_with_conf" sql "refresh catalog test_cache_false_lower_true_with_conf0" + wait_table_sync("test_cache_false_lower_true_with_conf0.external_test_lower_with_conf"); qt_sql_test_cache_false_lower_true_with_conf0_2_insert "insert into internal.external_test_lower_with_conf.with_conf_insert select * from test_cache_false_lower_true_with_conf0.external_test_lower_with_conf.upper_with_conf" sql "refresh catalog test_cache_false_lower_true_with_conf0" + wait_table_sync("test_cache_false_lower_true_with_conf0.external_test_lower_with_conf"); test { sql "select * from test_cache_false_lower_true_with_conf0.external_test_lower_with_conf.Lower_with_conf" exception "Table [Lower_with_conf] does not exist in database [external_test_lower_with_conf]." } sql "refresh catalog test_cache_false_lower_true_with_conf0" + wait_table_sync("test_cache_false_lower_true_with_conf0.external_test_lower_with_conf"); test { sql "select * from test_cache_false_lower_true_with_conf0.external_test_lower_with_conf.UPPER_with_conf" exception "Table [UPPER_with_conf] does not exist in database [external_test_lower_with_conf]." } sql "refresh catalog test_cache_false_lower_true_with_conf0" + wait_table_sync("test_cache_false_lower_true_with_conf0.external_test_lower_with_conf"); test { sql "insert into internal.external_test_lower_with_conf.with_conf_insert select * from test_cache_false_lower_true_with_conf0.external_test_lower_with_conf.Lower_with_conf" exception "Table [Lower_with_conf] does not exist in database [external_test_lower_with_conf]." } sql "refresh catalog test_cache_false_lower_true_with_conf0" + wait_table_sync("test_cache_false_lower_true_with_conf0.external_test_lower_with_conf"); test { sql "insert into internal.external_test_lower_with_conf.with_conf_insert select * from test_cache_false_lower_true_with_conf0.external_test_lower_with_conf.UPPER_with_conf" exception "Table [UPPER_with_conf] does not exist in database [external_test_lower_with_conf]." diff --git a/regression-test/suites/external_table_p0/lower_case/test_timing_refresh_catalog.groovy b/regression-test/suites/external_table_p0/lower_case/test_timing_refresh_catalog.groovy index a95da3b5d67448..242ca1b8a53f34 100644 --- a/regression-test/suites/external_table_p0/lower_case/test_timing_refresh_catalog.groovy +++ b/regression-test/suites/external_table_p0/lower_case/test_timing_refresh_catalog.groovy @@ -15,6 +15,10 @@ // specific language governing permissions and limitations // under the License. +import java.util.concurrent.Executors +import java.util.concurrent.TimeUnit +import org.awaitility.Awaitility + suite("test_timing_refresh_catalog", "p0,external,doris,external_docker,external_docker_doris") { String jdbcUrl = context.config.jdbcUrl @@ -24,6 +28,23 @@ suite("test_timing_refresh_catalog", "p0,external,doris,external_docker,external String bucket = getS3BucketName() String driver_url = "https://${bucket}.${s3_endpoint}/regression/jdbc_driver/mysql-connector-j-8.3.0.jar" + def wait_table_sync = { String db -> + Awaitility.await().atMost(10, TimeUnit.SECONDS).pollInterval(1, TimeUnit.SECONDS).until{ + try { + def res = sql "show tables from ${db}" + return res.size() > 0; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + } + + def is_single_fe = { + def res = sql "show frontends"; + return res.size() == 1; + } + try_sql """drop user ${jdbcUser}""" sql """create user ${jdbcUser} identified by '${jdbcPassword}'""" sql """grant all on *.*.* to ${jdbcUser}""" @@ -53,7 +74,6 @@ suite("test_timing_refresh_catalog", "p0,external,doris,external_docker,external sql """insert into internal.external_timing_refresh_catalog.tbl values(1, 'lower')""" sql """drop catalog if exists test_timing_refresh_catalog1 """ - sql """ CREATE CATALOG `test_timing_refresh_catalog1` PROPERTIES ( "user" = "${jdbcUser}", "type" = "jdbc", @@ -68,22 +88,6 @@ suite("test_timing_refresh_catalog", "p0,external,doris,external_docker,external "include_database_list" = "external_timing_refresh_catalog" )""" - sql """drop catalog if exists test_timing_refresh_catalog2 """ - - sql """ CREATE CATALOG `test_timing_refresh_catalog2` PROPERTIES ( - "user" = "${jdbcUser}", - "type" = "jdbc", - "password" = "${jdbcPassword}", - "jdbc_url" = "${jdbcUrl}", - "driver_url" = "${driver_url}", - "driver_class" = "com.mysql.cj.jdbc.Driver", - "use_meta_cache" = "false", - "metadata_refresh_interval_seconds" = "1", - "lower_case_meta_names" = "true", - "only_specified_database" = "true", - "include_database_list" = "external_timing_refresh_catalog" - )""" - test { def catalogName = "test_timing_refresh_catalog1" for (int i = 0; i < 10; i++) { @@ -94,19 +98,37 @@ suite("test_timing_refresh_catalog", "p0,external,doris,external_docker,external } } - test { - def catalogName = "test_timing_refresh_catalog2" - for (int i = 0; i < 10; i++) { - sql """ - select * from ${catalogName}.external_timing_refresh_catalog.tbl - """ - Thread.sleep(1000) + // when "use_meta_cache" = "false", the meta sync between FEs maybe delay, + // and it may cause the case unstable, so only run when there is single FE + if (is_single_fe()) { + sql """drop catalog if exists test_timing_refresh_catalog2 """ + sql """ CREATE CATALOG `test_timing_refresh_catalog2` PROPERTIES ( + "user" = "${jdbcUser}", + "type" = "jdbc", + "password" = "${jdbcPassword}", + "jdbc_url" = "${jdbcUrl}", + "driver_url" = "${driver_url}", + "driver_class" = "com.mysql.cj.jdbc.Driver", + "use_meta_cache" = "false", + "metadata_refresh_interval_seconds" = "1", + "lower_case_meta_names" = "true", + "only_specified_database" = "true", + "include_database_list" = "external_timing_refresh_catalog" + )""" + + test { + def catalogName = "test_timing_refresh_catalog2" + for (int i = 0; i < 10; i++) { + sql """ + select * from ${catalogName}.external_timing_refresh_catalog.tbl + """ + Thread.sleep(1000) + } } } // with mapping sql """drop catalog if exists test_timing_refresh_catalog1 """ - sql """ CREATE CATALOG `test_timing_refresh_catalog1` PROPERTIES ( "user" = "${jdbcUser}", "type" = "jdbc", @@ -122,23 +144,6 @@ suite("test_timing_refresh_catalog", "p0,external,doris,external_docker,external 'meta_names_mapping' = '${mapping}' )""" - sql """drop catalog if exists test_timing_refresh_catalog2 """ - - sql """ CREATE CATALOG `test_timing_refresh_catalog2` PROPERTIES ( - "user" = "${jdbcUser}", - "type" = "jdbc", - "password" = "${jdbcPassword}", - "jdbc_url" = "${jdbcUrl}", - "driver_url" = "${driver_url}", - "driver_class" = "com.mysql.cj.jdbc.Driver", - "use_meta_cache" = "false", - "metadata_refresh_interval_seconds" = "1", - "lower_case_meta_names" = "true", - "only_specified_database" = "true", - "include_database_list" = "external_timing_refresh_catalog", - 'meta_names_mapping' = '${mapping}' - )""" - test { def catalogName = "test_timing_refresh_catalog1" for (int i = 0; i < 10; i++) { @@ -149,19 +154,33 @@ suite("test_timing_refresh_catalog", "p0,external,doris,external_docker,external } } - test { - def catalogName = "test_timing_refresh_catalog2" - for (int i = 0; i < 10; i++) { - sql """ - select id_c from ${catalogName}.db.table_t - """ - Thread.sleep(1000) + if (is_single_fe()) { + sql """drop catalog if exists test_timing_refresh_catalog2 """ + sql """ CREATE CATALOG `test_timing_refresh_catalog2` PROPERTIES ( + "user" = "${jdbcUser}", + "type" = "jdbc", + "password" = "${jdbcPassword}", + "jdbc_url" = "${jdbcUrl}", + "driver_url" = "${driver_url}", + "driver_class" = "com.mysql.cj.jdbc.Driver", + "use_meta_cache" = "false", + "metadata_refresh_interval_seconds" = "1", + "lower_case_meta_names" = "true", + "only_specified_database" = "true", + "include_database_list" = "external_timing_refresh_catalog", + 'meta_names_mapping' = '${mapping}' + )""" + + test { + def catalogName = "test_timing_refresh_catalog2" + for (int i = 0; i < 10; i++) { + sql """ + select id_c from ${catalogName}.db.table_t + """ + Thread.sleep(1000) + } } } - sql """drop catalog if exists test_timing_refresh_catalog1 """ - sql """drop catalog if exists test_timing_refresh_catalog2 """ - sql """drop database if exists internal.external_timing_refresh_catalog """ - try_sql """drop user ${jdbcUser}""" -} \ No newline at end of file +} diff --git a/regression-test/suites/external_table_p0/lower_case/upgrade/load.groovy b/regression-test/suites/external_table_p0/lower_case/upgrade/load.groovy index ef03f97d0e2188..782f7b3711904c 100644 --- a/regression-test/suites/external_table_p0/lower_case/upgrade/load.groovy +++ b/regression-test/suites/external_table_p0/lower_case/upgrade/load.groovy @@ -15,6 +15,10 @@ // specific language governing permissions and limitations // under the License. +import java.util.concurrent.Executors +import java.util.concurrent.TimeUnit +import org.awaitility.Awaitility + suite("test_upgrade_lower_case_catalog_prepare", "p0,external,doris,external_docker,external_docker_doris") { String jdbcUrl = context.config.jdbcUrl @@ -24,6 +28,18 @@ suite("test_upgrade_lower_case_catalog_prepare", "p0,external,doris,external_doc String bucket = getS3BucketName() String driver_url = "https://${bucket}.${s3_endpoint}/regression/jdbc_driver/mysql-connector-j-8.3.0.jar" + def wait_table_sync = { String db -> + Awaitility.await().atMost(10, TimeUnit.SECONDS).pollInterval(1, TimeUnit.SECONDS).until{ + try { + def res = sql "show tables from ${db}" + return res.size() > 0; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + } + try_sql """drop user ${jdbcUser}""" sql """create user ${jdbcUser} identified by '${jdbcPassword}'""" sql """grant all on *.*.* to ${jdbcUser}""" @@ -63,6 +79,7 @@ suite("test_upgrade_lower_case_catalog_prepare", "p0,external,doris,external_doc "include_database_list" = "upgrade_lower_case_catalog_lower,upgrade_lower_case_catalog_UPPER" )""" + wait_table_sync("test_upgrade_lower_case_catalog.upgrade_lower_case_catalog_lower") test { sql """show databases from test_upgrade_lower_case_catalog"""