Skip to content
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
1 change: 0 additions & 1 deletion fe/be-java-extensions/max-compute-connector/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ under the License.
<forkCount>${fe_ut_parallel}</forkCount>
<reuseForks>false</reuseForks>
<useFile>false</useFile>
<argLine>-javaagent:${settings.localRepository}/org/jmockit/jmockit/${jmockit.version}/jmockit-${jmockit.version}.jar</argLine>
</configuration>
</plugin>
</plugins>
Expand Down
7 changes: 1 addition & 6 deletions fe/fe-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -816,11 +816,6 @@ under the License.
<libDirectory>src/main/antlr4/org/apache/doris/nereids</libDirectory>
</configuration>
</plugin>
<!-- jmockit -->
<!--fixme Unify mocking framework usage across the project.
Currently, multiple mocking libraries (e.g., JMockit, Powermock) are used,
which increases maintenance complexity and may cause agent conflicts (e.g., with JaCoCo).
Evaluate existing usages and standardize on a single framework where possible.-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
Expand All @@ -831,7 +826,7 @@ under the License.
<reuseForks>false</reuseForks>
<useFile>false</useFile>
<argLine>
-Xmx1024m -javaagent:${settings.localRepository}/org/jmockit/jmockit/${jmockit.version}/jmockit-${jmockit.version}.jar @{argLine}
-Xmx1024m @{argLine}
</argLine>
</configuration>
</plugin>
Expand Down
440 changes: 220 additions & 220 deletions fe/fe-core/src/test/java/org/apache/doris/alter/CloudIndexTest.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,14 @@

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import mockit.Mock;
import mockit.MockUp;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.mockito.MockedStatic;
import org.mockito.Mockito;

import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
Expand All @@ -79,6 +80,7 @@ public class IndexChangeJobTest {
private static Env slaveEnv;

private static ConnectContext ctx;
private MockedStatic<ConnectContext> mockedConnectContext;

@Rule
public ExpectedException expectedEx = ExpectedException.none();
Expand All @@ -99,19 +101,37 @@ public void setUp()
slaveTransMgr.setEditLog(slaveEnv.getEditLog());
// Initialize ConnectContext
ctx = new ConnectContext();
new MockUp<ConnectContext>() {
@Mock
public ConnectContext get() {
return ctx;
}
};
mockedConnectContext = Mockito.mockStatic(ConnectContext.class);
mockedConnectContext.when(ConnectContext::get).thenReturn(ctx);
FeConstants.runningUnitTest = true;
AgentTaskQueue.clearAllTasks();
}

@After
public void tearDown() {
if (mockedConnectContext != null) {
mockedConnectContext.close();
}
if (fakeEnv != null) {
fakeEnv.close();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This tearDown() only closes the last assigned helper instances, but many tests in this file reassign fakeEnv/fakeEditLog after setUp() has already created them. Since these helpers now own Mockito static/construction mocks, the overwritten setup instances are leaked and can contaminate later tests. The old instance needs to be closed before reassignment, or the helpers should only be created once per test path.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as CloudIndexTest — all reassignments properly close the old instance first. No leak exists.

}
if (fakeEditLog != null) {
fakeEditLog.close();
}
if (fakeTransactionIDGenerator != null) {
fakeTransactionIDGenerator.close();
}
}

@Test
public void testCreateIndexIndexChange() throws UserException {
if (fakeEnv != null) {
fakeEnv.close();
}
fakeEnv = new FakeEnv();
if (fakeEditLog != null) {
fakeEditLog.close();
}
fakeEditLog = new FakeEditLog();
FakeEnv.setEnv(masterEnv);
SchemaChangeHandler schemaChangeHandler = Env.getCurrentEnv().getSchemaChangeHandler();
Expand All @@ -138,7 +158,13 @@ public void testCreateIndexIndexChange() throws UserException {

@Test
public void testBuildIndexIndexChange() throws UserException {
if (fakeEnv != null) {
fakeEnv.close();
}
fakeEnv = new FakeEnv();
if (fakeEditLog != null) {
fakeEditLog.close();
}
fakeEditLog = new FakeEditLog();
FakeEnv.setEnv(masterEnv);
SchemaChangeHandler schemaChangeHandler = Env.getCurrentEnv().getSchemaChangeHandler();
Expand Down Expand Up @@ -171,7 +197,13 @@ public void testBuildIndexIndexChange() throws UserException {

@Test
public void testDropIndexIndexChange() throws UserException {
if (fakeEnv != null) {
fakeEnv.close();
}
fakeEnv = new FakeEnv();
if (fakeEditLog != null) {
fakeEditLog.close();
}
fakeEditLog = new FakeEditLog();
FakeEnv.setEnv(masterEnv);
SchemaChangeHandler schemaChangeHandler = Env.getCurrentEnv().getSchemaChangeHandler();
Expand Down Expand Up @@ -206,7 +238,13 @@ public void testDropIndexIndexChange() throws UserException {
@Test
// start a build index job, then normally finish it
public void testBuildIndexIndexChangeNormal() throws UserException {
if (fakeEnv != null) {
fakeEnv.close();
}
fakeEnv = new FakeEnv();
if (fakeEditLog != null) {
fakeEditLog.close();
}
fakeEditLog = new FakeEditLog();
FakeEnv.setEnv(masterEnv);
SchemaChangeHandler schemaChangeHandler = Env.getCurrentEnv().getSchemaChangeHandler();
Expand Down Expand Up @@ -265,7 +303,13 @@ public void testBuildIndexIndexChangeNormal() throws UserException {
@Test
// start a drop index job, then normally finish it
public void testDropIndexIndexChangeNormal() throws UserException {
if (fakeEnv != null) {
fakeEnv.close();
}
fakeEnv = new FakeEnv();
if (fakeEditLog != null) {
fakeEditLog.close();
}
fakeEditLog = new FakeEditLog();
FakeEnv.setEnv(masterEnv);
SchemaChangeHandler schemaChangeHandler = Env.getCurrentEnv().getSchemaChangeHandler();
Expand Down Expand Up @@ -323,7 +367,13 @@ public void testDropIndexIndexChangeNormal() throws UserException {

@Test
public void testCancelBuildIndexIndexChangeNormal() throws UserException {
if (fakeEnv != null) {
fakeEnv.close();
}
fakeEnv = new FakeEnv();
if (fakeEditLog != null) {
fakeEditLog.close();
}
fakeEditLog = new FakeEditLog();
FakeEnv.setEnv(masterEnv);
SchemaChangeHandler schemaChangeHandler = Env.getCurrentEnv().getSchemaChangeHandler();
Expand Down Expand Up @@ -371,7 +421,13 @@ public void testCancelBuildIndexIndexChangeNormal() throws UserException {

@Test
public void testBuildIndexIndexChangeWhileTableNotStable() throws Exception {
if (fakeEnv != null) {
fakeEnv.close();
}
fakeEnv = new FakeEnv();
if (fakeEditLog != null) {
fakeEditLog.close();
}
fakeEditLog = new FakeEditLog();
FakeEnv.setEnv(masterEnv);
SchemaChangeHandler schemaChangeHandler = Env.getCurrentEnv().getSchemaChangeHandler();
Expand Down Expand Up @@ -452,7 +508,13 @@ public void testBuildIndexIndexChangeWhileTableNotStable() throws Exception {

@Test
public void testDropIndexIndexChangeWhileTableNotStable() throws Exception {
if (fakeEnv != null) {
fakeEnv.close();
}
fakeEnv = new FakeEnv();
if (fakeEditLog != null) {
fakeEditLog.close();
}
fakeEditLog = new FakeEditLog();
FakeEnv.setEnv(masterEnv);
SchemaChangeHandler schemaChangeHandler = Env.getCurrentEnv().getSchemaChangeHandler();
Expand Down Expand Up @@ -533,7 +595,13 @@ public void testDropIndexIndexChangeWhileTableNotStable() throws Exception {

@Test
public void testBuildIndexFailedWithMinFailedNum() throws Exception {
if (fakeEnv != null) {
fakeEnv.close();
}
fakeEnv = new FakeEnv();
if (fakeEditLog != null) {
fakeEditLog.close();
}
fakeEditLog = new FakeEditLog();
FakeEnv.setEnv(masterEnv);
SchemaChangeHandler schemaChangeHandler = Env.getCurrentEnv().getSchemaChangeHandler();
Expand Down Expand Up @@ -599,7 +667,13 @@ public void testBuildIndexFailedWithMinFailedNum() throws Exception {

@Test
public void testBuildIndexFailedWithMaxFailedNum() throws Exception {
if (fakeEnv != null) {
fakeEnv.close();
}
fakeEnv = new FakeEnv();
if (fakeEditLog != null) {
fakeEditLog.close();
}
fakeEditLog = new FakeEditLog();
FakeEnv.setEnv(masterEnv);
SchemaChangeHandler schemaChangeHandler = Env.getCurrentEnv().getSchemaChangeHandler();
Expand Down Expand Up @@ -665,7 +739,13 @@ public void testBuildIndexFailedWithMaxFailedNum() throws Exception {

@Test
public void testNgramBfBuildIndex() throws UserException {
if (fakeEnv != null) {
fakeEnv.close();
}
fakeEnv = new FakeEnv();
if (fakeEditLog != null) {
fakeEditLog.close();
}
fakeEditLog = new FakeEditLog();
FakeEnv.setEnv(masterEnv);
Database db = new Database(CatalogTestUtil.testDbId1, CatalogTestUtil.testDb1);
Expand Down Expand Up @@ -753,7 +833,13 @@ public void testNgramBfBuildIndex() throws UserException {

@Test
public void testCancelNgramBfBuildIndex() throws UserException {
if (fakeEnv != null) {
fakeEnv.close();
}
fakeEnv = new FakeEnv();
if (fakeEditLog != null) {
fakeEditLog.close();
}
fakeEditLog = new FakeEditLog();
FakeEnv.setEnv(masterEnv);
Database db = new Database(CatalogTestUtil.testDbId1, CatalogTestUtil.testDb1);
Expand Down Expand Up @@ -849,7 +935,13 @@ public void testDropIndexOnPartitionValidateAcceptsNormalPartition() throws Exce
@Test
public void testDropIndexOnPartitionRejectsNonPartitionedTable() throws UserException {
// testTable1 uses SinglePartitionInfo (non-partitioned), so DROP INDEX ON PARTITION should fail
if (fakeEnv != null) {
fakeEnv.close();
}
fakeEnv = new FakeEnv();
if (fakeEditLog != null) {
fakeEditLog.close();
}
fakeEditLog = new FakeEditLog();
FakeEnv.setEnv(masterEnv);
SchemaChangeHandler schemaChangeHandler = Env.getCurrentEnv().getSchemaChangeHandler();
Expand Down Expand Up @@ -889,7 +981,13 @@ public void testDropIndexOnPartitionRejectsNonPartitionedTable() throws UserExce

@Test
public void testDropIndexOnPartitionRejectsNonExistentIndex() throws UserException {
if (fakeEnv != null) {
fakeEnv.close();
}
fakeEnv = new FakeEnv();
if (fakeEditLog != null) {
fakeEditLog.close();
}
fakeEditLog = new FakeEditLog();
FakeEnv.setEnv(masterEnv);
SchemaChangeHandler schemaChangeHandler = Env.getCurrentEnv().getSchemaChangeHandler();
Expand All @@ -914,7 +1012,13 @@ public void testDropIndexOnPartitionRejectsNonExistentIndex() throws UserExcepti
@Test
public void testDropIndexOnPartitionIfExistsNonExistentIndex() throws UserException {
// IF EXISTS with non-existent index and partition spec should silently succeed
if (fakeEnv != null) {
fakeEnv.close();
}
fakeEnv = new FakeEnv();
if (fakeEditLog != null) {
fakeEditLog.close();
}
fakeEditLog = new FakeEditLog();
FakeEnv.setEnv(masterEnv);
SchemaChangeHandler schemaChangeHandler = Env.getCurrentEnv().getSchemaChangeHandler();
Expand Down
Loading
Loading