Skip to content

Commit

Permalink
add regression test and delete unuseless code
Browse files Browse the repository at this point in the history
  • Loading branch information
vinlee19 committed Nov 19, 2024
1 parent 007ae95 commit ff1aa84
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,13 @@
import org.apache.doris.qe.StmtExecutor;

import com.google.common.base.Strings;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.Map;

/**
* Refresh database.
*/
public class RefreshDatabaseCommand extends Command implements ForwardWithSync {
private static final Logger LOG = LogManager.getLogger(RefreshDatabaseCommand.class);
private static final String INVALID_CACHE = "invalid_cache";

private String catalogName;
Expand Down
12 changes: 6 additions & 6 deletions regression-test/conf/regression-conf.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ defaultDb = "regression_test"
// init cmd like: select @@session.tx_read_only
// at each time we connect.
// add allowLoadLocalInfile so that the jdbc can execute mysql load data from client.
jdbcUrl = "jdbc:mysql://127.0.0.1:9030/?useLocalSessionState=true&allowLoadLocalInfile=true"
targetJdbcUrl = "jdbc:mysql://127.0.0.1:9030/?useLocalSessionState=true&allowLoadLocalInfile=true"
jdbcUrl = "jdbc:mysql://172.21.16.12:49035/?useLocalSessionState=true&allowLoadLocalInfile=true"
targetJdbcUrl = "jdbc:mysql://172.21.16.12:49035/?useLocalSessionState=true&allowLoadLocalInfile=true"
jdbcUser = "root"
jdbcPassword = ""

Expand All @@ -35,7 +35,7 @@ syncerAddress = "127.0.0.1:9190"
feSyncerUser = "root"
feSyncerPassword = ""

feHttpAddress = "127.0.0.1:8030"
feHttpAddress = "172.21.16.12:48035"
feHttpUser = "root"
feHttpPassword = ""

Expand Down Expand Up @@ -118,8 +118,8 @@ sk="***********"
// jdbc connector test config
// To enable jdbc test, you need first start mysql/pg container.
// See `docker/thirdparties/run-thirdparties-docker.sh`
enableJdbcTest=false
mysql_57_port=3316
enableJdbcTest=true
mysql_57_port=23316
pg_14_port=5442
oracle_11_port=1521
sqlserver_2022_port=1433
Expand Down Expand Up @@ -233,7 +233,7 @@ max_failure_num=0
// used for exporting test
s3ExportBucketName = ""

externalEnvIp="127.0.0.1"
externalEnvIp="172.21.16.12"

// trino-connector catalog test config
enableTrinoConnectorTest = false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !sql --
-- !database --
DORIS
Doris
doris
Expand All @@ -19,7 +19,7 @@ show_test_do_not_modify
114 abf
115 abg

-- !sql --
-- !preceding_create_external_database --
DORIS
Doris
doris
Expand All @@ -29,7 +29,7 @@ init_db
mysql
show_test_do_not_modify

-- !sql --
-- !subsequent_create_external_database --
DORIS
Doris
doris
Expand All @@ -40,7 +40,21 @@ mysql
new_mysql_db
show_test_do_not_modify

-- !sql --
-- !sql_show_tables --

-- !preceding_refresh_database --

-- !subsequent_refresh_database --
new_mysql_table1

-- !preceding_refresh_database --
new_mysql_table1

-- !subsequent_refresh_database --
new_mysql_table1
new_mysql_table2

-- !preceding_drop_external_database --
DORIS
Doris
doris
Expand All @@ -51,7 +65,7 @@ mysql
new_mysql_db
show_test_do_not_modify

-- !sql --
-- !subsequent_drop_external_database --
DORIS
Doris
doris
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ suite("test_nereids_refresh_catalog", "p0,external,mysql,external_docker,externa
String mysql_port = context.config.otherConfigs.get("mysql_57_port");
String ex_tb0 = "ex_tb0";
String new_mysql_db = "new_mysql_db";
String new_mysql_table1 = "new_mysql_table1";
String new_mysql_table2 = "new_mysql_table2";

sql """drop catalog if exists ${catalog_name} """

Expand All @@ -43,27 +45,41 @@ suite("test_nereids_refresh_catalog", "p0,external,mysql,external_docker,externa
"driver_class" = "com.mysql.cj.jdbc.Driver"
);"""

sql """switch ${catalog_name}"""
sql """CALL EXECUTE_STMT("${catalog_name}", "drop database if exists ${new_mysql_db}");"""
sql """switch ${catalog_name}"""

qt_sql """show databases;"""
qt_database """show databases;"""
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_sql """show databases;"""
qt_preceding_create_external_database """show databases;"""
checkNereidsExecute("refresh catalog ${catalog_name} ;")
qt_sql """show databases;"""
qt_subsequent_create_external_database """show databases;"""

checkNereidsExecute("refresh catalog ${catalog_name} properties ('invalid_cache'='true');")
sql """use ${new_mysql_db}"""
qt_sql_show_tables """show tables;"""

// create table in mysql external database
sql """CALL EXECUTE_STMT("${catalog_name}", "create table ${new_mysql_db}.${new_mysql_table1} (id int, name varchar(20));");"""

qt_preceding_refresh_database """show tables;"""
checkNereidsExecute("refresh database ${new_mysql_db} ;")
qt_subsequent_refresh_database """show tables;"""

sql """CALL EXECUTE_STMT("${catalog_name}", "create table ${new_mysql_db}.${new_mysql_table2} (id int, name varchar(20));");"""
qt_preceding_refresh_database """show tables;"""
checkNereidsExecute("refresh database ${catalog_name}.${new_mysql_db} ;")
qt_subsequent_refresh_database """show tables;"""

sql """CALL EXECUTE_STMT("${catalog_name}", "drop database if exists ${new_mysql_db} ;");"""
qt_sql """show databases;"""
qt_preceding_drop_external_database """show databases;"""

checkNereidsExecute("refresh catalog ${catalog_name} properties ('invalid_cache'='true');")
qt_sql """show databases;"""
qt_subsequent_drop_external_database """show databases;"""

sql """ drop catalog if exists ${catalog_name} ;"""
}
Expand Down

0 comments on commit ff1aa84

Please sign in to comment.