Skip to content

Commit

Permalink
fix feut
Browse files Browse the repository at this point in the history
  • Loading branch information
zclllyybb committed Jul 11, 2024
1 parent 15a4fbe commit 48e3a3c
Show file tree
Hide file tree
Showing 39 changed files with 85 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public static TimeZone getUTCTimeZone() {

// return the time zone of current system
public static TimeZone getSystemTimeZone() {
return TimeZone.getTimeZone(ZoneId.of(ZoneId.systemDefault().getId(), timeZoneAliasMap));
return TimeZone.getTimeZone(ZoneId.of(TimeZone.getDefault().getID(), timeZoneAliasMap));
}

// get time zone of given zone name, or return system time zone if name is null.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ public class AdminCancelRebalanceDiskStmtTest {

@Before()
public void setUp() {
analyzer = AccessTestUtil.fetchAdminAnalyzer(true);
MockedAuth.mockedAccess(accessManager);
MockedAuth.mockedConnectContext(ctx, "root", "192.168.1.1");
analyzer = AccessTestUtil.fetchAdminAnalyzer(true);

List<Long> beIds = Lists.newArrayList(10001L, 10002L, 10003L, 10004L);
beIds.forEach(id -> Env.getCurrentSystemInfo().addBackend(RebalancerTestUtil.createBackend(id, 2048, 0)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ public class AdminRebalanceDiskStmtTest {

@Before
public void setUp() {
analyzer = AccessTestUtil.fetchAdminAnalyzer(true);
MockedAuth.mockedAccess(accessManager);
MockedAuth.mockedConnectContext(ctx, "root", "192.168.1.1");
analyzer = AccessTestUtil.fetchAdminAnalyzer(true);

List<Long> beIds = Lists.newArrayList(10001L, 10002L, 10003L, 10004L);
beIds.forEach(id -> Env.getCurrentSystemInfo().addBackend(RebalancerTestUtil.createBackend(id, 2048, 0)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ public class AlterCatalogNameStmtTest {

@Before
public void setUp() throws DdlException {
analyzer = AccessTestUtil.fetchAdminAnalyzer(false);
MockedAuth.mockedAccess(accessManager);
MockedAuth.mockedConnectContext(ctx, "root", "%");
analyzer = AccessTestUtil.fetchAdminAnalyzer(false);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ public class AlterCatalogPropsStmtTest {

@Before
public void setUp() throws DdlException {
analyzer = AccessTestUtil.fetchAdminAnalyzer(false);
MockedAuth.mockedAccess(accessManager);
MockedAuth.mockedConnectContext(ctx, "root", "%");
analyzer = AccessTestUtil.fetchAdminAnalyzer(false);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ public class AlterSqlBlockRuleStmtTest {

@Before
public void setUp() {
analyzer = AccessTestUtil.fetchAdminAnalyzer(true);
MockedAuth.mockedAccess(accessManager);
MockedAuth.mockedConnectContext(ctx, "root", "192.168.1.1");
analyzer = AccessTestUtil.fetchAdminAnalyzer(true);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.apache.doris.catalog.Env;
import org.apache.doris.datasource.InternalCatalog;
import org.apache.doris.mysql.privilege.MockedAuth;
import org.apache.doris.qe.ConnectContext;

import com.google.common.collect.Lists;
Expand All @@ -41,6 +42,8 @@ public class BackupTest {

@Before
public void setUp() {
MockedAuth.mockedConnectContext(ctx, "root", "192.188.3.1");

analyzer = AccessTestUtil.fetchAdminAnalyzer(true);
env = AccessTestUtil.fetchAdminCatalog();
new MockUp<Env>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ public class CreateCatalogStmtTest {

@Before()
public void setUp() throws DdlException {
analyzer = AccessTestUtil.fetchAdminAnalyzer(true);
MockedAuth.mockedAccess(accessManager);
MockedAuth.mockedConnectContext(ctx, "root", "%");
analyzer = AccessTestUtil.fetchAdminAnalyzer(true);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public class CreateDbStmtTest {

@Before()
public void setUp() {
analyzer = AccessTestUtil.fetchAdminAnalyzer(true);
MockedAuth.mockedAccess(accessManager);
MockedAuth.mockedConnectContext(ctx, "root", "192.168.1.1");
analyzer = AccessTestUtil.fetchAdminAnalyzer(true);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ public void analyze(Analyzer analyzer1) {
result = sessionVariable;
sessionVariable.getSendBatchParallelism();
result = 1;

sessionVariable.getTimeZone();
result = "Asia/Hong_Kong";
}
};

Expand Down Expand Up @@ -254,6 +257,9 @@ public void analyze(Analyzer analyzer1) {
result = sessionVariable;
sessionVariable.getSendBatchParallelism();
result = 1;

sessionVariable.getTimeZone();
result = "Asia/Hong_Kong";
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ public class CreateSqlBlockRuleStmtTest {

@Before
public void setUp() {
analyzer = AccessTestUtil.fetchAdminAnalyzer(true);
MockedAuth.mockedAccess(accessManager);
MockedAuth.mockedConnectContext(ctx, "root", "192.168.1.1");
analyzer = AccessTestUtil.fetchAdminAnalyzer(true);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ public class CreateTableStmtTest {
**/
@Before
public void setUp() {
MockedAuth.mockedAccess(accessManager);
MockedAuth.mockedConnectContext(ctx, "root", "192.168.1.1");
// analyzer
analyzer = AccessTestUtil.fetchAdminAnalyzer(false);
// table name
Expand All @@ -98,9 +100,6 @@ public void setUp() {
invalidColsName.add("col1");
invalidColsName.add("col2");
invalidColsName.add("col2");

MockedAuth.mockedAccess(accessManager);
MockedAuth.mockedConnectContext(ctx, "root", "192.168.1.1");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ public class DeleteStmtTest {

@Before
public void setUp() {
analyzer = AccessTestUtil.fetchAdminAnalyzer(false);
MockedAuth.mockedAccess(accessManager);
MockedAuth.mockedConnectContext(ctx, "root", "192.168.1.1");
analyzer = AccessTestUtil.fetchAdminAnalyzer(false);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ public class DropCatalogStmtTest {

@Before
public void setUp() throws DdlException {
analyzer = AccessTestUtil.fetchAdminAnalyzer(true);
MockedAuth.mockedAccess(accessManager);
MockedAuth.mockedConnectContext(ctx, "root", "%");
analyzer = AccessTestUtil.fetchAdminAnalyzer(true);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ public class DropDbStmtTest {

@Before
public void setUp() {
analyzer = AccessTestUtil.fetchAdminAnalyzer(true);
MockedAuth.mockedAccess(accessManager);
MockedAuth.mockedConnectContext(ctx, "root", "192.168.1.1");
analyzer = AccessTestUtil.fetchAdminAnalyzer(true);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public class DropTableStmtTest {

@Before
public void setUp() {
MockedAuth.mockedAccess(accessManager);
MockedAuth.mockedConnectContext(ctx, "root", "192.168.1.1");

tbl = new TableName(internalCtl, "db1", "table1");
noDbTbl = new TableName(internalCtl, "", "table1");
analyzer = AccessTestUtil.fetchAdminAnalyzer(true);
Expand All @@ -61,9 +64,6 @@ public void setUp() {
result = "";
}
};

MockedAuth.mockedAccess(accessManager);
MockedAuth.mockedConnectContext(ctx, "root", "192.168.1.1");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ public class DropUserStmtTest {

@Before
public void setUp() {
analyzer = AccessTestUtil.fetchAdminAnalyzer(true);
MockedAuth.mockedAccess(accessManager);
MockedAuth.mockedConnectContext(ctx, "root", "192.168.1.1");
analyzer = AccessTestUtil.fetchAdminAnalyzer(true);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.apache.doris.mysql.privilege.AccessControllerManager;
import org.apache.doris.mysql.privilege.PrivPredicate;
import org.apache.doris.qe.ConnectContext;
import org.apache.doris.qe.VariableMgr;
import org.apache.doris.task.LoadTaskInfo;

import com.google.common.collect.Lists;
Expand Down Expand Up @@ -57,9 +58,6 @@ public class LoadStmtTest {

@Before
public void setUp() {
analyzer = AccessTestUtil.fetchAdminAnalyzer(true);
dataDescriptions = Lists.newArrayList();
dataDescriptions.add(desc);
new Expectations() {
{
ConnectContext.get();
Expand All @@ -70,11 +68,19 @@ public void setUp() {
minTimes = 0;
result = "user";

ctx.getSessionVariable();
minTimes = 0;
result = VariableMgr.newSessionVariable();

desc.toSql();
minTimes = 0;
result = "XXX";
}
};

analyzer = AccessTestUtil.fetchAdminAnalyzer(true);
dataDescriptions = Lists.newArrayList();
dataDescriptions.add(desc);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ public class SetOperationStmtTest {

@Before
public void setUp() {
analyzer = AccessTestUtil.fetchAdminAnalyzer(true);
MockedAuth.mockedAccess(accessManager);
MockedAuth.mockedConnectContext(ctx, "root", "192.168.1.1");
analyzer = AccessTestUtil.fetchAdminAnalyzer(true);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ public class SetPassVarTest {

@Before
public void setUp() {
analyzer = AccessTestUtil.fetchAdminAnalyzer(true);
MockedAuth.mockedAccess(accessManager);
MockedAuth.mockedConnectContext(ctx, "root", "192.168.1.1");
analyzer = AccessTestUtil.fetchAdminAnalyzer(true);
UserIdentity currentUser = new UserIdentity("root", "192.168.1.1");
currentUser.setIsAnalyzed();
ctx.setCurrentUserIdentity(currentUser);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public class SetStmtTest {

@Before
public void setUp() {
analyzer = AccessTestUtil.fetchAdminAnalyzer(true);
MockedAuth.mockedAccess(accessManager);
MockedAuth.mockedConnectContext(ctx, "root", "192.168.1.1");
analyzer = AccessTestUtil.fetchAdminAnalyzer(true);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public class SetUserPropertyStmtTest {

@Before
public void setUp() {
analyzer = AccessTestUtil.fetchAdminAnalyzer(true);
MockedAuth.mockedAccess(accessManager);
MockedAuth.mockedConnectContext(ctx, "root", "192.168.1.1");
analyzer = AccessTestUtil.fetchAdminAnalyzer(true);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ public class SetVarTest {

@Before
public void setUp() {
analyzer = AccessTestUtil.fetchAdminAnalyzer(false);
MockedAuth.mockedAccess(accessManager);
MockedAuth.mockedConnectContext(ctx, "root", "192.168.1.1");
analyzer = AccessTestUtil.fetchAdminAnalyzer(false);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public class ShowDataTypesStmtTest {

@Before
public void setUp() {
analyzer = AccessTestUtil.fetchAdminAnalyzer(true);
MockedAuth.mockedConnectContext(ctx, "root", "192.168.1.1");
analyzer = AccessTestUtil.fetchAdminAnalyzer(true);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ public class ShowDbIdStmtTest {

@Before
public void setUp() {
analyzer = AccessTestUtil.fetchAdminAnalyzer(true);
MockedAuth.mockedAccess(accessManager);
MockedAuth.mockedConnectContext(ctx, "root", "192.168.1.1");
analyzer = AccessTestUtil.fetchAdminAnalyzer(true);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ public class ShowEncryptKeysStmtTest {

@Before
public void setUp() {
fakeEnv = new FakeEnv();
env = AccessTestUtil.fetchAdminCatalog();
MockedAuth.mockedAccess(accessManager);
MockedAuth.mockedConnectContext(ctx, "root", "192.188.3.1");
fakeEnv = new FakeEnv();
env = AccessTestUtil.fetchAdminCatalog();
FakeEnv.setEnv(env);

new Expectations() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ public class ShowFunctionsStmtTest {

@Before
public void setUp() {
fakeEnv = new FakeEnv();
env = AccessTestUtil.fetchAdminCatalog();
MockedAuth.mockedAccess(accessManager);
MockedAuth.mockedConnectContext(ctx, "root", "192.188.3.1");
fakeEnv = new FakeEnv();
env = AccessTestUtil.fetchAdminCatalog();
FakeEnv.setEnv(env);

new Expectations() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public class ShowIndexStmtTest {

@Before
public void setUp() {
analyzer = AccessTestUtil.fetchAdminAnalyzer(true);
MockedAuth.mockedAccess(accessManager);
MockedAuth.mockedConnectContext(ctx, "root", "%");
analyzer = AccessTestUtil.fetchAdminAnalyzer(true);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ public class ShowPartitionIdStmtTest {

@Before
public void setUp() {
analyzer = AccessTestUtil.fetchAdminAnalyzer(true);
MockedAuth.mockedAccess(accessManager);
MockedAuth.mockedConnectContext(ctx, "root", "192.168.1.1");
analyzer = AccessTestUtil.fetchAdminAnalyzer(true);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ public class ShowTableCreationStmtTest {

@Before
public void setUp() {
analyzer = AccessTestUtil.fetchAdminAnalyzer(true);
MockedAuth.mockedAccess(accessManager);
MockedAuth.mockedConnectContext(ctx, "root", "192.168.1.1");
analyzer = AccessTestUtil.fetchAdminAnalyzer(true);
}

@Test
Expand Down
Loading

0 comments on commit 48e3a3c

Please sign in to comment.