[fix][regression]update ccr test project (#32445)
This commit is contained in:
@ -29,11 +29,6 @@ targetJdbcUrl = "jdbc:mysql://127.0.0.1:9030/?useLocalSessionState=true&allowLoa
|
||||
jdbcUser = "root"
|
||||
jdbcPassword = ""
|
||||
|
||||
ccrDownstreamUrl = "jdbc:mysql://127.0.0.1:9030/?useLocalSessionState=true&allowLoadLocalInfile=true"
|
||||
ccrDownstreamUser = "root"
|
||||
ccrDownstreamPassword = ""
|
||||
ccrDownstreamFeThriftAddress = "127.0.0.1:9020"
|
||||
|
||||
feSourceThriftAddress = "127.0.0.1:9020"
|
||||
feTargetThriftAddress = "127.0.0.1:9020"
|
||||
syncerAddress = "127.0.0.1:9190"
|
||||
|
||||
@ -41,6 +41,10 @@ class Config {
|
||||
public String jdbcPassword
|
||||
public String defaultDb
|
||||
|
||||
public String ccrDownstreamUrl
|
||||
public String ccrDownstreamUser
|
||||
public String ccrDownstreamPassword
|
||||
|
||||
public String feSourceThriftAddress
|
||||
public String feTargetThriftAddress
|
||||
public String feSyncerUser
|
||||
@ -315,6 +319,9 @@ class Config {
|
||||
configToString(obj.sslCertificatePath)
|
||||
)
|
||||
|
||||
config.ccrDownstreamUrl = configToString(obj.ccrDownstreamUrl)
|
||||
config.ccrDownstreamUser = configToString(obj.ccrDownstreamUser)
|
||||
config.ccrDownstreamPassword = configToString(obj.ccrDownstreamPassword)
|
||||
config.image = configToString(obj.image)
|
||||
config.dockerCoverageOutputDir = configToString(obj.dockerCoverageOutputDir)
|
||||
config.dockerEndDeleteFiles = configToBoolean(obj.dockerEndDeleteFiles)
|
||||
@ -560,6 +567,13 @@ class Config {
|
||||
return DriverManager.getConnection(dbUrl, arrowFlightSqlJdbcUser, arrowFlightSqlJdbcPassword)
|
||||
}
|
||||
|
||||
Connection getDownstreamConnectionByDbName(String dbName) {
|
||||
String dbUrl = buildUrlWithDb(ccrDownstreamUrl, dbName)
|
||||
tryCreateDbIfNotExist(dbName)
|
||||
log.info("connect to ${dbUrl}".toString())
|
||||
return DriverManager.getConnection(dbUrl, ccrDownstreamUser, ccrDownstreamPassword)
|
||||
}
|
||||
|
||||
String getDbNameByFile(File suiteFile) {
|
||||
String dir = new File(suitePath).relativePath(suiteFile.parentFile)
|
||||
// We put sql files under sql dir, so dbs and tables used by cases
|
||||
|
||||
@ -336,8 +336,11 @@ class Suite implements GroovyInterceptable {
|
||||
}
|
||||
}
|
||||
|
||||
def sql_return_maparray_impl(Connection conn, String sqlStr) {
|
||||
def sql_return_maparray_impl(String sqlStr, Connection conn = null) {
|
||||
logger.info("Execute sql: ${sqlStr}".toString())
|
||||
if (conn == null) {
|
||||
conn = context.getConnection()
|
||||
}
|
||||
def (result, meta) = JdbcUtils.executeToList(conn, sqlStr)
|
||||
|
||||
// get all column names as list
|
||||
@ -359,11 +362,11 @@ class Suite implements GroovyInterceptable {
|
||||
}
|
||||
|
||||
def jdbc_sql_return_maparray(String sqlStr) {
|
||||
return sql_return_maparray_impl(context.getConnection(), sqlStr)
|
||||
return sql_return_maparray_impl(sqlStr, context.getConnection())
|
||||
}
|
||||
|
||||
def arrow_flight_sql_return_maparray(String sqlStr) {
|
||||
return sql_return_maparray_impl(context.getArrowFlightSqlConnection(), (String) ("USE ${context.dbName};" + sqlStr))
|
||||
return sql_return_maparray_impl((String) ("USE ${context.dbName};" + sqlStr), context.getArrowFlightSqlConnection())
|
||||
}
|
||||
|
||||
def sql_return_maparray(String sqlStr) {
|
||||
@ -706,6 +709,11 @@ class Suite implements GroovyInterceptable {
|
||||
return lines;
|
||||
}
|
||||
|
||||
|
||||
Connection getTargetConnection() {
|
||||
return context.getTargetConnection(this)
|
||||
}
|
||||
|
||||
boolean deleteFile(String filePath) {
|
||||
def file = new File(filePath)
|
||||
file.delete()
|
||||
|
||||
@ -195,9 +195,14 @@ class SuiteContext implements Closeable {
|
||||
return subJdbc.substring(0, subJdbc.indexOf("/"))
|
||||
}
|
||||
|
||||
private Map<String, String> getSpec() {
|
||||
private String getDownstreamJdbcNetInfo() {
|
||||
String subJdbc = config.ccrDownstreamUrl.substring(config.ccrDownstreamUrl.indexOf("://") + 3)
|
||||
return subJdbc.substring(0, subJdbc.indexOf("/"))
|
||||
}
|
||||
|
||||
private Map<String, String> getSpec(String[] jdbc) {
|
||||
Map<String, String> spec = Maps.newHashMap()
|
||||
String[] jdbc = getJdbcNetInfo().split(":")
|
||||
|
||||
spec.put("host", jdbc[0])
|
||||
spec.put("port", jdbc[1])
|
||||
spec.put("user", config.feSyncerUser)
|
||||
@ -208,7 +213,8 @@ class SuiteContext implements Closeable {
|
||||
}
|
||||
|
||||
Map<String, String> getSrcSpec() {
|
||||
Map<String, String> spec = getSpec()
|
||||
String[] jdbc = getJdbcNetInfo().split(":")
|
||||
Map<String, String> spec = getSpec(jdbc)
|
||||
spec.put("thrift_port", config.feSourceThriftNetworkAddress.port.toString())
|
||||
spec.put("database", dbName)
|
||||
|
||||
@ -216,7 +222,8 @@ class SuiteContext implements Closeable {
|
||||
}
|
||||
|
||||
Map<String, String> getDestSpec() {
|
||||
Map<String, String> spec = getSpec()
|
||||
String[] jdbc = getDownstreamJdbcNetInfo().split(":")
|
||||
Map<String, String> spec = getSpec(jdbc)
|
||||
spec.put("thrift_port", config.feTargetThriftNetworkAddress.port.toString())
|
||||
spec.put("database", "TEST_" + dbName)
|
||||
|
||||
@ -256,7 +263,7 @@ class SuiteContext implements Closeable {
|
||||
Connection getTargetConnection(Suite suite) {
|
||||
def context = getSyncer(suite).context
|
||||
if (context.targetConnection == null) {
|
||||
context.targetConnection = config.getConnectionByDbName("TEST_" + dbName)
|
||||
context.targetConnection = config.getDownstreamConnectionByDbName("TEST_" + dbName)
|
||||
}
|
||||
return context.targetConnection
|
||||
}
|
||||
|
||||
@ -147,8 +147,8 @@ class SyncerContext {
|
||||
return info
|
||||
}
|
||||
|
||||
FrontendClientImpl getMasterFrontClient() {
|
||||
def result = suite.sql_return_maparray "select Host, RpcPort, IsMaster from frontends();"
|
||||
FrontendClientImpl getMasterFrontClient(Connection conn) {
|
||||
def result = suite.sql_return_maparray_impl("select Host, RpcPort, IsMaster from frontends();", conn)
|
||||
logger.info("get master fe: ${result}")
|
||||
|
||||
def masterHost = ""
|
||||
@ -179,7 +179,7 @@ class SyncerContext {
|
||||
|
||||
FrontendClientImpl getTargetFrontClient() {
|
||||
if (targetFrontendClient == null) {
|
||||
targetFrontendClient = getMasterFrontClient()
|
||||
targetFrontendClient = getMasterFrontClient(suite.getTargetConnection())
|
||||
}
|
||||
return targetFrontendClient
|
||||
}
|
||||
|
||||
@ -25,6 +25,11 @@ targetJdbcUrl = "jdbc:mysql://172.19.0.2:9131/?useLocalSessionState=true&allowLo
|
||||
jdbcUser = "root"
|
||||
jdbcPassword = ""
|
||||
|
||||
ccrDownstreamUrl = "jdbc:mysql://172.19.0.2:9131/?useLocalSessionState=true&allowLoadLocalInfile=true"
|
||||
ccrDownstreamUser = "root"
|
||||
ccrDownstreamPassword = ""
|
||||
ccrDownstreamFeThriftAddress = "127.0.0.1:9020"
|
||||
|
||||
feSourceThriftAddress = "127.0.0.1:9020"
|
||||
feTargetThriftAddress = "127.0.0.1:9020"
|
||||
feSyncerUser = "root"
|
||||
|
||||
@ -25,6 +25,11 @@ targetJdbcUrl = "jdbc:mysql://172.19.0.2:9132/?useLocalSessionState=true&allowLo
|
||||
jdbcUser = "root"
|
||||
jdbcPassword = ""
|
||||
|
||||
ccrDownstreamUrl = "jdbc:mysql://172.19.0.2:9132/?useLocalSessionState=true&allowLoadLocalInfile=true"
|
||||
ccrDownstreamUser = "root"
|
||||
ccrDownstreamPassword = ""
|
||||
ccrDownstreamFeThriftAddress = "127.0.0.1:9020"
|
||||
|
||||
feSourceThriftAddress = "127.0.0.1:9020"
|
||||
feTargetThriftAddress = "127.0.0.1:9020"
|
||||
feSyncerUser = "root"
|
||||
|
||||
Reference in New Issue
Block a user