2626import org .apache .hadoop .test .GenericTestUtils ;
2727import org .apache .hadoop .util .ReflectionUtils ;
2828import org .apache .hadoop .util .Time ;
29- import org .junit .BeforeClass ;
30- import org .junit .AfterClass ;
31- import org .junit .Test ;
29+ import org .junit .jupiter .api .BeforeAll ;
30+ import org .junit .jupiter .api .AfterAll ;
31+ import org .junit .jupiter .api .Test ;
32+ import org .junit .jupiter .api .Timeout ;
3233import org .mockito .Mockito ;
3334
3435import java .io .IOException ;
4647import static org .apache .hadoop .tools .fedbalance .FedBalanceConfigs .SCHEDULER_JOURNAL_URI ;
4748import static org .apache .hadoop .tools .fedbalance .FedBalanceConfigs .WORK_THREAD_NUM ;
4849import static org .apache .hadoop .hdfs .DFSConfigKeys .DFS_NAMENODE_ACLS_ENABLED_KEY ;
49- import static org .junit .Assert .assertNull ;
50- import static org .junit .Assert .assertEquals ;
51- import static org .junit .Assert .assertTrue ;
52- import static org .junit .Assert .assertFalse ;
53- import static org .junit .Assert .assertNotSame ;
50+ import static org .junit .jupiter . api . Assertions .assertNull ;
51+ import static org .junit .jupiter . api . Assertions .assertEquals ;
52+ import static org .junit .jupiter . api . Assertions .assertTrue ;
53+ import static org .junit .jupiter . api . Assertions .assertFalse ;
54+ import static org .junit .jupiter . api . Assertions .assertNotSame ;
5455import static org .mockito .ArgumentMatchers .any ;
5556
5657/**
@@ -63,7 +64,7 @@ public class TestBalanceProcedureScheduler {
6364 private static DistributedFileSystem fs ;
6465 private static final int DEFAULT_BLOCK_SIZE = 512 ;
6566
66- @ BeforeClass
67+ @ BeforeAll
6768 public static void setup () throws IOException {
6869 CONF .setBoolean (DFSConfigKeys .DFS_NAMENODE_DELEGATION_TOKEN_ALWAYS_USE_KEY ,
6970 true );
@@ -84,7 +85,7 @@ public static void setup() throws IOException {
8485 fs .mkdirs (new Path (workPath ));
8586 }
8687
87- @ AfterClass
88+ @ AfterAll
8889 public static void close () {
8990 if (cluster != null ) {
9091 cluster .shutdown ();
@@ -94,7 +95,8 @@ public static void close() {
9495 /**
9596 * Test the scheduler could be shutdown correctly.
9697 */
97- @ Test (timeout = 60000 )
98+ @ Test
99+ @ Timeout (value = 60 )
98100 public void testShutdownScheduler () throws Exception {
99101 BalanceProcedureScheduler scheduler = new BalanceProcedureScheduler (CONF );
100102 scheduler .init (true );
@@ -115,7 +117,8 @@ public void testShutdownScheduler() throws Exception {
115117 /**
116118 * Test a successful job.
117119 */
118- @ Test (timeout = 60000 )
120+ @ Test
121+ @ Timeout (value = 60 )
119122 public void testSuccessfulJob () throws Exception {
120123 BalanceProcedureScheduler scheduler = new BalanceProcedureScheduler (CONF );
121124 scheduler .init (true );
@@ -146,7 +149,8 @@ public void testSuccessfulJob() throws Exception {
146149 /**
147150 * Test a job fails and the error can be got.
148151 */
149- @ Test (timeout = 60000 )
152+ @ Test
153+ @ Timeout (value = 60 )
150154 public void testFailedJob () throws Exception {
151155 BalanceProcedureScheduler scheduler = new BalanceProcedureScheduler (CONF );
152156 scheduler .init (true );
@@ -174,7 +178,8 @@ public void testFailedJob() throws Exception {
174178 * the last unfinished procedure, which is the first procedure without
175179 * journal.
176180 */
177- @ Test (timeout = 60000 )
181+ @ Test
182+ @ Timeout (value = 60 )
178183 public void testGetJobAfterRecover () throws Exception {
179184 BalanceProcedureScheduler scheduler = new BalanceProcedureScheduler (CONF );
180185 scheduler .init (true );
@@ -238,7 +243,8 @@ public void testGetJobAfterRecover() throws Exception {
238243 /**
239244 * Test RetryException is handled correctly.
240245 */
241- @ Test (timeout = 60000 )
246+ @ Test
247+ @ Timeout (value = 60 )
242248 public void testRetry () throws Exception {
243249 BalanceProcedureScheduler scheduler = new BalanceProcedureScheduler (CONF );
244250 scheduler .init (true );
@@ -265,7 +271,8 @@ public void testRetry() throws Exception {
265271 /**
266272 * Test schedule an empty job.
267273 */
268- @ Test (timeout = 60000 )
274+ @ Test
275+ @ Timeout (value = 60 )
269276 public void testEmptyJob () throws Exception {
270277 BalanceProcedureScheduler scheduler = new BalanceProcedureScheduler (CONF );
271278 scheduler .init (true );
@@ -281,7 +288,8 @@ public void testEmptyJob() throws Exception {
281288 /**
282289 * Test serialization and deserialization of Job.
283290 */
284- @ Test (timeout = 60000 )
291+ @ Test
292+ @ Timeout (value = 60 )
285293 public void testJobSerializeAndDeserialize () throws Exception {
286294 BalanceJob .Builder builder = new BalanceJob .Builder <RecordProcedure >();
287295 for (int i = 0 ; i < 5 ; i ++) {
@@ -305,7 +313,8 @@ public void testJobSerializeAndDeserialize() throws Exception {
305313 /**
306314 * Test scheduler crashes and recovers.
307315 */
308- @ Test (timeout = 180000 )
316+ @ Test
317+ @ Timeout (value = 180 )
309318 public void testSchedulerDownAndRecoverJob () throws Exception {
310319 BalanceProcedureScheduler scheduler = new BalanceProcedureScheduler (CONF );
311320 scheduler .init (true );
@@ -347,7 +356,8 @@ public void testSchedulerDownAndRecoverJob() throws Exception {
347356 }
348357 }
349358
350- @ Test (timeout = 60000 )
359+ @ Test
360+ @ Timeout (value = 60 )
351361 public void testRecoverJobFromJournal () throws Exception {
352362 BalanceJournal journal =
353363 ReflectionUtils .newInstance (BalanceJournalInfoHDFS .class , CONF );
@@ -374,7 +384,8 @@ public void testRecoverJobFromJournal() throws Exception {
374384 }
375385 }
376386
377- @ Test (timeout = 60000 )
387+ @ Test
388+ @ Timeout (value = 60 )
378389 public void testClearJournalFail () throws Exception {
379390 BalanceProcedureScheduler scheduler = new BalanceProcedureScheduler (CONF );
380391 scheduler .init (true );
@@ -404,7 +415,8 @@ public void testClearJournalFail() throws Exception {
404415 /**
405416 * Test the job will be recovered if writing journal fails.
406417 */
407- @ Test (timeout = 60000 )
418+ @ Test
419+ @ Timeout (value = 60 )
408420 public void testJobRecoveryWhenWriteJournalFail () throws Exception {
409421 BalanceProcedureScheduler scheduler = new BalanceProcedureScheduler (CONF );
410422 scheduler .init (true );
0 commit comments