Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix](regression-test) Fix regiressin test syncer suit use master fe directly #26583

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,28 @@ class Suite implements GroovyInterceptable {
return result
}

def sql_return_maparray(String sqlStr) {
logger.info("Execute sql: ${sqlStr}".toString())
def (result, meta) = JdbcUtils.executeToList(context.getConnection(), sqlStr)

// get all column names as list
List<String> columnNames = new ArrayList<>()
for (int i = 0; i < meta.getColumnCount(); i++) {
columnNames.add(meta.getColumnName(i + 1))
}

// add result to res map list, each row is a map with key is column name
List<Map<String, Object>> res = new ArrayList<>()
for (int i = 0; i < result.size(); i++) {
Map<String, Object> row = new HashMap<>()
for (int j = 0; j < columnNames.size(); j++) {
row.put(columnNames.get(j), result.get(i).get(j))
}
res.add(row)
}
return res;
}

List<List<Object>> target_sql(String sqlStr, boolean isOrder = false) {
logger.info("Execute ${isOrder ? "order_" : ""}target_sql: ${sqlStr}".toString())
def (result, meta) = JdbcUtils.executeToList(context.getTargetConnection(this), sqlStr)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class Syncer {

Syncer(Suite suite, Config config) {
this.suite = suite
context = new SyncerContext(suite.context.dbName, config)
context = new SyncerContext(suite, suite.context.dbName, config)
}

enum ccrCluster {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ import org.apache.doris.regression.suite.client.BackendClientImpl
import org.apache.doris.regression.suite.client.FrontendClientImpl
import org.apache.doris.thrift.TTabletCommitInfo
import org.apache.doris.thrift.TGetSnapshotResult
import org.apache.doris.thrift.TNetworkAddress;
import com.google.gson.annotations.SerializedName
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import groovy.util.logging.Slf4j

import java.sql.Connection

Expand Down Expand Up @@ -93,6 +97,9 @@ class ExtraInfo {
}

class SyncerContext {
final Logger logger = LoggerFactory.getLogger(this.class)

final Suite suite
protected Connection targetConnection
protected FrontendClientImpl sourceFrontendClient
protected FrontendClientImpl targetFrontendClient
Expand Down Expand Up @@ -121,7 +128,8 @@ class SyncerContext {
public long txnId
public long seq

SyncerContext(String dbName, Config config) {
SyncerContext(Suite suite, String dbName, Config config) {
this.suite = suite
this.sourceDbId = -1
this.targetDbId = -1
this.db = dbName
Expand All @@ -139,16 +147,39 @@ class SyncerContext {
return info
}

FrontendClientImpl getMasterFrontClient() {
def result = suite.sql_return_maparray "select Host, RpcPort, IsMaster from frontends();"
logger.info("get master fe: ${result}")

def masterHost = ""
def masterPort = 0
for (def row : result) {
if (row.IsMaster == "true") {
masterHost = row.Host
masterPort = row.RpcPort.toInteger()
break
}
}

if (masterHost == "" || masterPort == 0) {
throw new Exception("can not find master fe")
}

def masterNetworkAddr = new TNetworkAddress(masterHost, masterPort)
logger.info("master fe network addr: ${masterNetworkAddr}")
return new FrontendClientImpl(masterNetworkAddr)
}

FrontendClientImpl getSourceFrontClient() {
if (sourceFrontendClient == null) {
sourceFrontendClient = new FrontendClientImpl(config.feSourceThriftNetworkAddress)
sourceFrontendClient = getMasterFrontClient()
}
return sourceFrontendClient
}

FrontendClientImpl getTargetFrontClient() {
if (targetFrontendClient == null) {
targetFrontendClient = new FrontendClientImpl(config.feTargetThriftNetworkAddress)
targetFrontendClient = getMasterFrontClient()
}
return targetFrontendClient
}
Expand Down
Loading