Skip to content

Commit

Permalink
add ut
Browse files Browse the repository at this point in the history
  • Loading branch information
qidaye committed Nov 7, 2024
1 parent d183145 commit 1aea2d8
Show file tree
Hide file tree
Showing 6 changed files with 579 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@

public class IndexChangeJob implements Writable {
private static final Logger LOG = LogManager.getLogger(IndexChangeJob.class);
private static final int MAX_FAILED_NUM = 10;
private static final int MIN_FAILED_NUM = 3;
static final int MAX_FAILED_NUM = 10;
static final int MIN_FAILED_NUM = 3;

public enum JobState {
// CHECKSTYLE OFF
Expand Down Expand Up @@ -387,7 +387,9 @@ protected void runRunningJob() throws AlterCancelException {
this.jobState = JobState.FINISHED;
this.finishedTimeMs = System.currentTimeMillis();

Env.getCurrentEnv().getEditLog().logIndexChangeJob(this);
if (!FeConstants.runningUnitTest) {
Env.getCurrentEnv().getEditLog().logIndexChangeJob(this);
}
LOG.info("inverted index job finished: {}", jobId);
}

Expand All @@ -405,7 +407,9 @@ protected boolean cancelImpl(String errMsg) {
jobState = JobState.CANCELLED;
this.errMsg = errMsg;
this.finishedTimeMs = System.currentTimeMillis();
Env.getCurrentEnv().getEditLog().logIndexChangeJob(this);
if (!FeConstants.runningUnitTest) {
Env.getCurrentEnv().getEditLog().logIndexChangeJob(this);
}
LOG.info("cancel index job {}, err: {}", jobId, errMsg);
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2912,7 +2912,9 @@ public void modifyTableLightSchemaChange(String rawSql, Database db, OlapTable o
if (LOG.isDebugEnabled()) {
LOG.debug("logModifyTableAddOrDropInvertedIndices info:{}", info);
}
Env.getCurrentEnv().getEditLog().logModifyTableAddOrDropInvertedIndices(info);
if (!FeConstants.runningUnitTest) {
Env.getCurrentEnv().getEditLog().logModifyTableAddOrDropInvertedIndices(info);
}
// Drop table column stats after light schema change finished.
Env.getCurrentEnv().getAnalysisManager().dropStats(olapTable, null);

Expand Down Expand Up @@ -3182,7 +3184,9 @@ public void buildOrDeleteTableInvertedIndices(Database db, OlapTable olapTable,
addIndexChangeJob(indexChangeJob);

// write edit log
Env.getCurrentEnv().getEditLog().logIndexChangeJob(indexChangeJob);
if (!FeConstants.runningUnitTest) {
Env.getCurrentEnv().getEditLog().logIndexChangeJob(indexChangeJob);
}
LOG.info("finish create table's inverted index job. table: {}, partition: {}, job: {}",
olapTable.getName(), partitionName, jobId);
} // end for partition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.apache.doris.common.AnalysisException;
import org.apache.doris.common.ErrorCode;
import org.apache.doris.common.ErrorReport;
import org.apache.doris.common.FeConstants;
import org.apache.doris.common.util.Util;
import org.apache.doris.mysql.privilege.PrivPredicate;
import org.apache.doris.qe.ConnectContext;
Expand Down Expand Up @@ -74,6 +75,9 @@ public void analyze(Analyzer analyzer) throws AnalysisException {
// disallow external catalog
Util.prohibitExternalCatalog(dbTableName.getCtl(), this.getClass().getSimpleName());

if (FeConstants.runningUnitTest) {
return;
}
// check access
if (!Env.getCurrentEnv().getAccessManager()
.checkTblPriv(ConnectContext.get(), dbTableName.getCtl(), dbTableName.getDb(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public static synchronized void updateTask(long backendId, TTaskType type, long
// this is just for unit test
public static synchronized List<AgentTask> getTask(TTaskType type) {
List<AgentTask> res = Lists.newArrayList();
for (Map<Long, AgentTask> agentTasks : tasks.column(TTaskType.ALTER).values()) {
for (Map<Long, AgentTask> agentTasks : tasks.column(type).values()) {
res.addAll(agentTasks.values());
}
return res;
Expand Down
Loading

0 comments on commit 1aea2d8

Please sign in to comment.