Skip to content

Commit

Permalink
fix feut & reg test
Browse files Browse the repository at this point in the history
  • Loading branch information
Yulei-Yang committed Dec 27, 2024
1 parent 78a9321 commit 1161002
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ private void addBinlog(long dbId, List<Long> tableIds, long commitSeq, long time
if (tableIds.size() > 1) {
anyEnable = anyEnable || tableBinlogEnable;
} else {
anyEnable = anyEnable && tableBinlogEnable;
anyEnable = tableBinlogEnable;
}
if (anyEnable) {
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.apache.doris.common.Config;
import org.apache.doris.common.DdlException;
import org.apache.doris.common.ErrorCode;
import org.apache.doris.common.FeConstants;
import org.apache.doris.common.Status;
import org.apache.doris.common.UserException;
import org.apache.doris.common.util.DebugUtil;
Expand Down Expand Up @@ -379,7 +380,9 @@ public void init() {
}

sessionId = UUID.randomUUID().toString();
Env.getCurrentEnv().registerSessionInfo(sessionId);
if (!FeConstants.runningUnitTest) {
Env.getCurrentEnv().registerSessionInfo(sessionId);
}
}

public ConnectContext() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@
package org.apache.doris.analysis;

import org.apache.doris.common.AnalysisException;
import org.apache.doris.common.FeConstants;
import org.apache.doris.datasource.InternalCatalog;

import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import java.lang.reflect.Field;
Expand All @@ -41,6 +43,8 @@ public class GroupByClauseTest {

@Before
public void setUp() throws AnalysisException {
FeConstants.runningUnitTest = true;

Analyzer analyzerBase = AccessTestUtil.fetchTableAnalyzer();
analyzer = new Analyzer(analyzerBase.getEnv(), analyzerBase.getContext());
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.apache.doris.catalog.Type;
import org.apache.doris.common.AnalysisException;
import org.apache.doris.common.FeConstants;
import org.apache.doris.common.FeMetaVersion;
import org.apache.doris.datasource.InternalCatalog;
import org.apache.doris.meta.MetaContext;
Expand All @@ -27,6 +28,7 @@
import com.google.common.collect.Multimap;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import java.io.IOException;
Expand All @@ -40,8 +42,15 @@ public class VirtualSlotRefTest {
private TupleDescriptor virtualTuple;
private VirtualSlotRef virtualSlot;

@BeforeClass
public static void beforeClass() throws Exception {

}

@Before
public void setUp() throws IOException, AnalysisException {
FeConstants.runningUnitTest = true;

Analyzer analyzerBase = AccessTestUtil.fetchTableAnalyzer();
// read objects from file
MetaContext metaContext = new MetaContext();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.apache.doris.common.AuthenticationException;
import org.apache.doris.common.Config;
import org.apache.doris.common.DdlException;
import org.apache.doris.common.FeConstants;
import org.apache.doris.datasource.InternalCatalog;
import org.apache.doris.mysql.authenticate.AuthenticateRequest;
import org.apache.doris.mysql.authenticate.AuthenticatorManager;
Expand Down Expand Up @@ -76,6 +77,7 @@ public class MysqlProtoTest {

@Before
public void setUp() throws DdlException, AuthenticationException, IOException {
FeConstants.runningUnitTest = true;

// mock auth
new Expectations() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.apache.doris.catalog.ColocateTableIndex;
import org.apache.doris.catalog.Env;
import org.apache.doris.common.FeConstants;
import org.apache.doris.common.IdGenerator;
import org.apache.doris.common.Pair;
import org.apache.doris.nereids.hint.DistributeHint;
Expand Down Expand Up @@ -88,6 +89,8 @@ class ChildOutputPropertyDeriverTest {

@BeforeEach
public void setUp() {
FeConstants.runningUnitTest = true;

new MockUp<Env>() {
@Mock
ColocateTableIndex getCurrentColocateIndex() {
Expand Down
19 changes: 10 additions & 9 deletions regression-test/suites/backup_restore/test_backup_restore.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,16 @@ suite("test_backup_restore", "backup_restore") {
as select * from ${dbName}.${tableName};
"""

sql """
BACKUP SNAPSHOT ${dbName}.${snapshotName}_1
TO `${repoName}`
ON (test_temp_table_backup)
"""
syncer.waitSnapshotFinish(dbName)
def show_data = sql "show backup from ${dbName} where SnapshotName = '${snapshotName}_1'"
assertTrue(show_data.size() >= 1)
assertTrue(show_data[0][12].contains("test_temp_table_backup does not exist"))
try {
sql """
BACKUP SNAPSHOT ${dbName}.${snapshotName}_1
TO `${repoName}`
ON (test_temp_table_backup)
"""
throw new IllegalStateException("Should throw error")
} catch (Exception ex) {
assertTrue(ex.getMessage().contains("is a temporary table, do not support backup"), ex.getMessage())
}

sql "DROP TABLE ${dbName}.test_temp_table_backup FORCE"
sql "DROP TABLE ${dbName}.${tableName} FORCE"
Expand Down

0 comments on commit 1161002

Please sign in to comment.