diff --git a/regression-test/data/external_table_p0/nereids_commands/test_nereids_refresh_catalog.out b/regression-test/data/external_table_p0/nereids_commands/test_nereids_refresh_catalog.out index 66ca9363d711dc..a71ca04ae66778 100644 --- a/regression-test/data/external_table_p0/nereids_commands/test_nereids_refresh_catalog.out +++ b/regression-test/data/external_table_p0/nereids_commands/test_nereids_refresh_catalog.out @@ -1,13 +1,6 @@ -- This file is automatically generated. You should know what you did if you want to edit this -- !database -- -DORIS -Doris -doris doris_test -information_schema -init_db -mysql -show_test_do_not_modify -- !ex_tb0_where -- 111 @@ -20,25 +13,9 @@ show_test_do_not_modify 115 abg -- !preceding_create_external_database -- -DORIS -Doris -doris -doris_test -information_schema -init_db -mysql -show_test_do_not_modify -- !subsequent_create_external_database -- -DORIS -Doris -doris -doris_test -information_schema -init_db -mysql new_mysql_db -show_test_do_not_modify -- !sql_show_tables -- @@ -76,23 +53,7 @@ new_mysql_table2 CREATE TABLE `new_mysql_table2` (\n `id` int NULL,\n `name` v new_mysql_table2 CREATE TABLE `new_mysql_table2` (\n `id` int NULL,\n `name` varchar(20) NULL,\n `new_column` int NULL,\n `new_column_1` int NULL,\n `new_column_2` int NULL\n) ENGINE=JDBC_EXTERNAL_TABLE; -- !preceding_drop_external_database -- -DORIS -Doris -doris -doris_test -information_schema -init_db -mysql new_mysql_db -show_test_do_not_modify -- !subsequent_drop_external_database -- -DORIS -Doris -doris -doris_test -information_schema -init_db -mysql -show_test_do_not_modify diff --git a/regression-test/suites/external_table_p0/jdbc/test_jdbc_catalog_ddl.groovy b/regression-test/suites/external_table_p0/jdbc/test_jdbc_catalog_ddl.groovy index 3735fe5305396b..1750f732baf745 100644 --- a/regression-test/suites/external_table_p0/jdbc/test_jdbc_catalog_ddl.groovy +++ b/regression-test/suites/external_table_p0/jdbc/test_jdbc_catalog_ddl.groovy @@ -15,6 +15,9 @@ // specific language governing permissions and limitations // under the License. +import java.util.concurrent.TimeUnit; +import org.awaitility.Awaitility; + suite("test_jdbc_catalog_ddl", "p0,external,mysql,external_docker,external_docker_mysql") { String enabled = context.config.otherConfigs.get("enableJdbcTest") @@ -23,6 +26,18 @@ suite("test_jdbc_catalog_ddl", "p0,external,mysql,external_docker,external_docke String bucket = getS3BucketName() String driver_url = "https://${bucket}.${s3_endpoint}/regression/jdbc_driver/mysql-connector-java-5.1.49.jar" String mysql_port = context.config.otherConfigs.get("mysql_57_port"); + + def wait_db_sync = { String ctl -> + Awaitility.await().atMost(10, TimeUnit.SECONDS).pollInterval(1, TimeUnit.SECONDS).until{ + try { + def res = sql "show databases from ${ctl}" + return res.size() > 0; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + } // String driver_url = "mysql-connector-java-5.1.49.jar" if (enabled != null && enabled.equalsIgnoreCase("true")) { String catalog_name = "test_jdbc_catalog_ddl"; @@ -38,6 +53,11 @@ suite("test_jdbc_catalog_ddl", "p0,external,mysql,external_docker,external_docke "driver_class" = "com.mysql.jdbc.Driver", "use_meta_cache" = "${useMetaCache}" );""" + + if (useMetaCache.equals("false")) { + wait_db_sync("${catalog_name}") + } + def res = sql(""" show databases from ${catalog_name}; """).collect {x -> x[0] as String} println("show databases result " + res); def containedDb = ['mysql', 'doris_test', 'information_schema'] @@ -68,6 +88,7 @@ suite("test_jdbc_catalog_ddl", "p0,external,mysql,external_docker,external_docke if (useMetaCache.equals("false")) { sql """refresh catalog ${catalog_name}""" + wait_db_sync("${catalog_name}") } sql "use ${catalog_name}.temp_database" qt_sql01 """select * from temp_table""" diff --git a/regression-test/suites/external_table_p0/nereids_commands/test_nereids_refresh_catalog.groovy b/regression-test/suites/external_table_p0/nereids_commands/test_nereids_refresh_catalog.groovy index 8fbaa486610109..e5ffbed9c219da 100644 --- a/regression-test/suites/external_table_p0/nereids_commands/test_nereids_refresh_catalog.groovy +++ b/regression-test/suites/external_table_p0/nereids_commands/test_nereids_refresh_catalog.groovy @@ -48,16 +48,16 @@ suite("test_nereids_refresh_catalog", "p0,external,mysql,external_docker,externa sql """CALL EXECUTE_STMT("${catalog_name}", "drop database if exists ${new_mysql_db}");""" sql """switch ${catalog_name}""" - qt_database """show databases;""" + qt_database """show databases like "%doris_test%";""" sql """ use ${ex_db_name}""" qt_ex_tb0_where """select id from ${ex_tb0} where id = 111;""" order_qt_ex_tb0 """ select id, name from ${ex_tb0} order by id; """ // create database in mysql sql """CALL EXECUTE_STMT("${catalog_name}", "create database ${new_mysql_db} ;");""" - qt_preceding_create_external_database """show databases;""" + qt_preceding_create_external_database """show databases like "%${new_mysql_db}%";""" checkNereidsExecute("refresh catalog ${catalog_name} ;") - qt_subsequent_create_external_database """show databases;""" + qt_subsequent_create_external_database """show databases like "%${new_mysql_db}%";""" checkNereidsExecute("refresh catalog ${catalog_name} properties ('invalid_cache'='true');") sql """use ${new_mysql_db}""" @@ -94,10 +94,10 @@ suite("test_nereids_refresh_catalog", "p0,external,mysql,external_docker,externa qt_subsequent_refresh_table """show create table ${new_mysql_db}.${new_mysql_table2};""" sql """CALL EXECUTE_STMT("${catalog_name}", "drop database if exists ${new_mysql_db} ;");""" - qt_preceding_drop_external_database """show databases;""" + qt_preceding_drop_external_database """show databases like "%${new_mysql_db}%";""" checkNereidsExecute("refresh catalog ${catalog_name} properties ('invalid_cache'='true');") - qt_subsequent_drop_external_database """show databases;""" + qt_subsequent_drop_external_database """show databases like "%${new_mysql_db}%";""" sql """ drop catalog if exists ${catalog_name} ;""" }