This is an automated email from the ASF dual-hosted git repository. zhangchen pushed a commit to branch branch-2.0 in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push: new f3317c555f [fix](regression) Add get master token into regression framework (#21198) (#22864) f3317c555f is described below commit f3317c555f74e73512af3ed0a936af4bfdb64b04 Author: abmdocrt <yukang.lian2...@gmail.com> AuthorDate: Fri Aug 11 11:11:14 2023 +0800 [fix](regression) Add get master token into regression framework (#21198) (#22864) Co-authored-by: DeadlineFen <117912096+deadline...@users.noreply.github.com> --- .../apache/doris/regression/suite/Syncer.groovy | 46 ++++++++++++++++++++++ .../doris/regression/suite/SyncerContext.groovy | 3 +- .../doris/regression/util/SyncerUtils.groovy | 9 +++++ 3 files changed, 57 insertions(+), 1 deletion(-) diff --git a/regression-test/framework/src/main/groovy/org/apache/doris/regression/suite/Syncer.groovy b/regression-test/framework/src/main/groovy/org/apache/doris/regression/suite/Syncer.groovy index 28db08c589..9504f2a874 100644 --- a/regression-test/framework/src/main/groovy/org/apache/doris/regression/suite/Syncer.groovy +++ b/regression-test/framework/src/main/groovy/org/apache/doris/regression/suite/Syncer.groovy @@ -30,6 +30,7 @@ import org.apache.doris.regression.json.BinlogData import org.apache.doris.thrift.TBinlogType import org.apache.doris.thrift.TCommitTxnResult import org.apache.doris.thrift.TGetBinlogResult +import org.apache.doris.thrift.TGetMasterTokenResult import org.apache.doris.thrift.TGetSnapshotResult import org.apache.doris.thrift.TIngestBinlogRequest import org.apache.doris.thrift.TIngestBinlogResult @@ -310,6 +311,37 @@ class Syncer { return isCheckedOK } + Boolean checkGetMasterToken(TGetMasterTokenResult result) { + Boolean isCheckedOK = false + + // step 1: check status + if (result != null && result.isSetStatus()) { + TStatus status = result.getStatus() + if (status.isSetStatusCode()) { + TStatusCode code = status.getStatusCode() + switch (code) { + case TStatusCode.OK: + isCheckedOK = result.isSetToken() + break + default: + logger.error("Get Master token result code is: ${code}") + break + } + } else { + logger.error("Invalid TStatus! StatusCode is unset.") + } + } else { + logger.error("Invalid TGetMasterTokenResult! result: ${result}") + } + + if (isCheckedOK) { + context.token = result.getToken() + logger.info("Token is ${context.token}.") + } + + return isCheckedOK + } + Boolean checkSnapshotFinish() { String checkSQL = "SHOW BACKUP FROM " + context.db List<Object> row = suite.sql(checkSQL)[0] @@ -415,10 +447,24 @@ class Syncer { context.closeBackendClients() } + Boolean getMasterToken() { + logger.info("Get master token.") + FrontendClientImpl clientImpl = context.getSourceFrontClient() + TGetMasterTokenResult result = SyncerUtils.getMasterToken(clientImpl, context) + + return checkGetMasterToken(result) + } + Boolean restoreSnapshot() { logger.info("Restore snapshot ${context.labelName}") FrontendClientImpl clientImpl = context.getSourceFrontClient() + // step 1: get master token + if (!getMasterToken()) { + logger.error("Get Master error!") + return false + } + // step 1: recode job info Gson gson = new Gson() Map jsonMap = gson.fromJson(new String(context.getSnapshotResult.getJobInfo()), Map.class) diff --git a/regression-test/framework/src/main/groovy/org/apache/doris/regression/suite/SyncerContext.groovy b/regression-test/framework/src/main/groovy/org/apache/doris/regression/suite/SyncerContext.groovy index fcc4d3116b..42659c892f 100644 --- a/regression-test/framework/src/main/groovy/org/apache/doris/regression/suite/SyncerContext.groovy +++ b/regression-test/framework/src/main/groovy/org/apache/doris/regression/suite/SyncerContext.groovy @@ -112,6 +112,7 @@ class SyncerContext { public String labelName public String tableName public TGetSnapshotResult getSnapshotResult + public String token public Config config public String user @@ -131,7 +132,7 @@ class SyncerContext { } ExtraInfo genExtraInfo() { - ExtraInfo info = new ExtraInfo("5ff161c3-2c08-4079-b108-26c8850b6598") + ExtraInfo info = new ExtraInfo(token) sourceBackendClients.forEach((id, client) -> { info.addBackendNetaddr(id, client.address.hostname, client.httpPort) }) diff --git a/regression-test/framework/src/main/groovy/org/apache/doris/regression/util/SyncerUtils.groovy b/regression-test/framework/src/main/groovy/org/apache/doris/regression/util/SyncerUtils.groovy index 3ff539966b..dbcd1dba5d 100644 --- a/regression-test/framework/src/main/groovy/org/apache/doris/regression/util/SyncerUtils.groovy +++ b/regression-test/framework/src/main/groovy/org/apache/doris/regression/util/SyncerUtils.groovy @@ -25,6 +25,8 @@ import org.apache.doris.thrift.TBeginTxnRequest import org.apache.doris.thrift.TBeginTxnResult import org.apache.doris.thrift.TCommitTxnRequest import org.apache.doris.thrift.TCommitTxnResult +import org.apache.doris.thrift.TGetMasterTokenRequest +import org.apache.doris.thrift.TGetMasterTokenResult import org.apache.doris.thrift.TGetSnapshotRequest import org.apache.doris.thrift.TGetSnapshotResult import org.apache.doris.thrift.TIngestBinlogRequest @@ -114,4 +116,11 @@ class SyncerUtils { request.setJobInfo(context.getSnapshotResult.getJobInfo()) return clientImpl.client.restoreSnapshot(request) } + + static TGetMasterTokenResult getMasterToken(FrontendClientImpl clientImpl, SyncerContext context) throws TException { + TGetMasterTokenRequest request = new TGetMasterTokenRequest() + request.setUser(context.user) + request.setPassword(context.passwd) + return clientImpl.client.getMasterToken(request) + } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org