Skip to content

Commit 88b470c

Browse files
authored
[fix](fe) Adapt warm-up scheduler tests to JUnit 5 (apache#67655)
### What problem does this PR solve? Related PR: apache#67527, apache#67396 Problem Summary: apache#67527 added seven JUnit 4 `Assert` calls to `ConfigTest` after apache#67396 migrated the class to JUnit 5, causing `fe-common:testCompile` to fail with `cannot find symbol: Assert`. Use the existing JUnit 5 `Assertions` import. Also migrate the scheduler test introduced by the same PR to JUnit 5 assertions and lifecycle annotations, consistent with the FE test migration. ### Release note None ### Check List (For Author) - Test: `./run-fe-ut.sh --run org.apache.doris.common.ConfigTest,org.apache.doris.cloud.CacheHotspotManagerSchedulerTest` completed with BUILD SUCCESS: ConfigTest 10/10 and CacheHotspotManagerSchedulerTest 4/4 passed, with no failures, errors, or skipped tests. Checkstyle passed for fe-common and fe-core with zero violations; `git diff --check` passed. - Behavior changed: No - Does this need documentation: No
1 parent 9957987 commit 88b470c

2 files changed

Lines changed: 17 additions & 17 deletions

File tree

‎fe/fe-common/src/test/java/org/apache/doris/common/ConfigTest.java‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,17 +170,17 @@ public void testCloudWarmUpSchedulerIntervalMustBePositive() throws ConfigExcept
170170
int original = Config.cloud_warm_up_job_scheduler_interval_millisecond;
171171
try {
172172
ConfigBase.setMutableConfig("cloud_warm_up_job_scheduler_interval_millisecond", "2000");
173-
Assert.assertEquals(2000, Config.cloud_warm_up_job_scheduler_interval_millisecond);
173+
Assertions.assertEquals(2000, Config.cloud_warm_up_job_scheduler_interval_millisecond);
174174

175-
ConfigException zeroException = Assert.assertThrows(ConfigException.class,
175+
ConfigException zeroException = Assertions.assertThrows(ConfigException.class,
176176
() -> ConfigBase.setMutableConfig("cloud_warm_up_job_scheduler_interval_millisecond", "0"));
177-
Assert.assertTrue(zeroException.getMessage().contains("must be greater than 0"));
178-
Assert.assertEquals(2000, Config.cloud_warm_up_job_scheduler_interval_millisecond);
177+
Assertions.assertTrue(zeroException.getMessage().contains("must be greater than 0"));
178+
Assertions.assertEquals(2000, Config.cloud_warm_up_job_scheduler_interval_millisecond);
179179

180-
ConfigException negativeException = Assert.assertThrows(ConfigException.class,
180+
ConfigException negativeException = Assertions.assertThrows(ConfigException.class,
181181
() -> ConfigBase.setMutableConfig("cloud_warm_up_job_scheduler_interval_millisecond", "-1"));
182-
Assert.assertTrue(negativeException.getMessage().contains("must be greater than 0"));
183-
Assert.assertEquals(2000, Config.cloud_warm_up_job_scheduler_interval_millisecond);
182+
Assertions.assertTrue(negativeException.getMessage().contains("must be greater than 0"));
183+
Assertions.assertEquals(2000, Config.cloud_warm_up_job_scheduler_interval_millisecond);
184184
} finally {
185185
Config.cloud_warm_up_job_scheduler_interval_millisecond = original;
186186
}

‎fe/fe-core/src/test/java/org/apache/doris/cloud/CacheHotspotManagerSchedulerTest.java‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
import org.apache.doris.common.Config;
2222
import org.apache.doris.common.FeConstants;
2323

24-
import org.junit.After;
25-
import org.junit.Assert;
26-
import org.junit.Before;
27-
import org.junit.Test;
24+
import org.junit.jupiter.api.AfterEach;
25+
import org.junit.jupiter.api.Assertions;
26+
import org.junit.jupiter.api.BeforeEach;
27+
import org.junit.jupiter.api.Test;
2828
import org.mockito.Mockito;
2929

3030
import java.util.ArrayList;
@@ -40,7 +40,7 @@ public class CacheHotspotManagerSchedulerTest {
4040
private ThreadPoolExecutor executor;
4141
private CacheHotspotManager manager;
4242

43-
@Before
43+
@BeforeEach
4444
public void setUp() {
4545
originalRunningUnitTest = FeConstants.runningUnitTest;
4646
originalMaxActiveCloudWarmUpJob = Config.max_active_cloud_warm_up_job;
@@ -52,7 +52,7 @@ public void setUp() {
5252
manager = new CacheHotspotManager(Mockito.mock(CloudSystemInfoService.class), executor);
5353
}
5454

55-
@After
55+
@AfterEach
5656
public void tearDown() {
5757
FeConstants.runningUnitTest = originalRunningUnitTest;
5858
Config.max_active_cloud_warm_up_job = originalMaxActiveCloudWarmUpJob;
@@ -76,7 +76,7 @@ public void testNewOnceJobGetsFirstTurnAndJobsRotate() throws Exception {
7676
manager.runCloudWarmUpJob();
7777
manager.runCloudWarmUpJob();
7878

79-
Assert.assertEquals(Arrays.asList(4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L), runOrder);
79+
Assertions.assertEquals(Arrays.asList(4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L), runOrder);
8080
}
8181

8282
@Test
@@ -92,11 +92,11 @@ public void testActiveJobIsNotSubmittedAgain() throws Exception {
9292

9393
manager.runCloudWarmUpJob();
9494
manager.runCloudWarmUpJob();
95-
Assert.assertEquals(1, submittedTasks.size());
95+
Assertions.assertEquals(1, submittedTasks.size());
9696

9797
submittedTasks.get(0).run();
9898
manager.runCloudWarmUpJob();
99-
Assert.assertEquals(2, submittedTasks.size());
99+
Assertions.assertEquals(2, submittedTasks.size());
100100
submittedTasks.get(1).run();
101101
Mockito.verify(job, Mockito.times(2)).run();
102102
}
@@ -119,7 +119,7 @@ public void testRejectedJobIsRetried() throws Exception {
119119
Mockito.verify(job, Mockito.never()).run();
120120
manager.runCloudWarmUpJob();
121121

122-
Assert.assertEquals(2, submitCount.get());
122+
Assertions.assertEquals(2, submitCount.get());
123123
Mockito.verify(job, Mockito.times(1)).run();
124124
}
125125

0 commit comments

Comments
 (0)