29
29
import org .apache .hadoop .yarn .api .protocolrecords .RegisterApplicationMasterResponse ;
30
30
import org .apache .hadoop .yarn .api .records .CollectorInfo ;
31
31
import org .apache .hadoop .yarn .api .records .ApplicationAccessType ;
32
- import static org .junit .Assert .assertEquals ;
33
- import static org .junit .Assert .assertFalse ;
34
- import static org .junit .Assert .assertTrue ;
35
- import static org .junit .Assert .fail ;
32
+ import static org .junit .jupiter . api . Assertions .assertEquals ;
33
+ import static org .junit .jupiter . api . Assertions .assertFalse ;
34
+ import static org .junit .jupiter . api . Assertions .assertTrue ;
35
+ import static org .junit .jupiter . api . Assertions .fail ;
36
36
37
37
import java .io .IOException ;
38
38
import java .util .ArrayList ;
39
39
import java .util .List ;
40
40
import java .util .concurrent .atomic .AtomicBoolean ;
41
41
42
42
import org .apache .hadoop .yarn .server .resourcemanager .HATestUtil ;
43
- import org .junit .Assert ;
44
43
45
44
import org .apache .hadoop .conf .Configuration ;
46
45
import org .apache .hadoop .ha .ClientBaseWithFixes ;
128
127
import org .apache .hadoop .yarn .server .resourcemanager .security .RMDelegationTokenSecretManager ;
129
128
import org .apache .hadoop .yarn .server .security .ApplicationACLsManager ;
130
129
import org .apache .hadoop .yarn .util .Records ;
131
- import org .junit .After ;
132
- import org .junit .Before ;
130
+ import org .junit .jupiter . api . AfterEach ;
131
+ import org .junit .jupiter . api . BeforeEach ;
133
132
134
133
135
134
/**
@@ -164,7 +163,7 @@ public abstract class ProtocolHATestBase extends ClientBaseWithFixes {
164
163
protected Thread failoverThread = null ;
165
164
private volatile boolean keepRunning ;
166
165
167
- @ Before
166
+ @ BeforeEach
168
167
public void setup () throws IOException {
169
168
failoverThread = null ;
170
169
keepRunning = true ;
@@ -181,7 +180,7 @@ public void setup() throws IOException {
181
180
conf .setBoolean (YarnConfiguration .YARN_MINICLUSTER_USE_RPC , true );
182
181
}
183
182
184
- @ After
183
+ @ AfterEach
185
184
public void teardown () throws Exception {
186
185
keepRunning = false ;
187
186
if (failoverThread != null ) {
@@ -205,8 +204,8 @@ protected void explicitFailover() throws IOException {
205
204
int newActiveRMIndex = (activeRMIndex + 1 ) % 2 ;
206
205
getAdminService (activeRMIndex ).transitionToStandby (req );
207
206
getAdminService (newActiveRMIndex ).transitionToActive (req );
208
- assertEquals ("Failover failed" , newActiveRMIndex ,
209
- cluster .getActiveRMIndex ());
207
+ assertEquals (newActiveRMIndex ,
208
+ cluster .getActiveRMIndex (), "Failover failed" );
210
209
}
211
210
212
211
protected YarnClient createAndStartYarnClient (Configuration conf ) {
@@ -219,8 +218,8 @@ protected YarnClient createAndStartYarnClient(Configuration conf) {
219
218
220
219
protected void verifyConnections () throws InterruptedException ,
221
220
YarnException {
222
- assertTrue ("NMs failed to connect to the RM" ,
223
- cluster . waitForNodeManagersToConnect ( 5000 ) );
221
+ assertTrue (cluster . waitForNodeManagersToConnect ( 5000 ) ,
222
+ "NMs failed to connect to the RM" );
224
223
verifyClientConnection ();
225
224
}
226
225
@@ -284,7 +283,7 @@ protected void startHACluster(int numOfNMs, boolean overrideClientRMService,
284
283
cluster .resetStartFailoverFlag (false );
285
284
cluster .init (conf );
286
285
cluster .start ();
287
- assertFalse ("RM never turned active" , -1 == cluster .getActiveRMIndex ());
286
+ assertFalse (-1 == cluster .getActiveRMIndex (), "RM never turned active" );
288
287
verifyConnections ();
289
288
290
289
// Do the failover
@@ -406,7 +405,7 @@ public GetNewApplicationResponse getNewApplication(
406
405
resetStartFailoverFlag (true );
407
406
408
407
// make sure failover has been triggered
409
- Assert . assertTrue (waittingForFailOver ());
408
+ assertTrue (waittingForFailOver ());
410
409
411
410
// create the GetNewApplicationResponse with fake applicationId
412
411
GetNewApplicationResponse response =
@@ -421,7 +420,7 @@ public GetApplicationReportResponse getApplicationReport(
421
420
resetStartFailoverFlag (true );
422
421
423
422
// make sure failover has been triggered
424
- Assert . assertTrue (waittingForFailOver ());
423
+ assertTrue (waittingForFailOver ());
425
424
426
425
// create a fake application report
427
426
ApplicationReport report = createFakeAppReport ();
@@ -436,7 +435,7 @@ public GetClusterMetricsResponse getClusterMetrics(
436
435
resetStartFailoverFlag (true );
437
436
438
437
// make sure failover has been triggered
439
- Assert . assertTrue (waittingForFailOver ());
438
+ assertTrue (waittingForFailOver ());
440
439
441
440
// create GetClusterMetricsResponse with fake YarnClusterMetrics
442
441
GetClusterMetricsResponse response =
@@ -451,7 +450,7 @@ public GetApplicationsResponse getApplications(
451
450
resetStartFailoverFlag (true );
452
451
453
452
// make sure failover has been triggered
454
- Assert . assertTrue (waittingForFailOver ());
453
+ assertTrue (waittingForFailOver ());
455
454
456
455
// create GetApplicationsResponse with fake applicationList
457
456
GetApplicationsResponse response =
@@ -466,7 +465,7 @@ public GetClusterNodesResponse getClusterNodes(
466
465
resetStartFailoverFlag (true );
467
466
468
467
// make sure failover has been triggered
469
- Assert . assertTrue (waittingForFailOver ());
468
+ assertTrue (waittingForFailOver ());
470
469
471
470
// create GetClusterNodesResponse with fake ClusterNodeLists
472
471
GetClusterNodesResponse response =
@@ -480,7 +479,7 @@ public GetQueueInfoResponse getQueueInfo(GetQueueInfoRequest request)
480
479
resetStartFailoverFlag (true );
481
480
482
481
// make sure failover has been triggered
483
- Assert . assertTrue (waittingForFailOver ());
482
+ assertTrue (waittingForFailOver ());
484
483
485
484
// return fake QueueInfo
486
485
return GetQueueInfoResponse .newInstance (createFakeQueueInfo ());
@@ -492,7 +491,7 @@ public GetQueueUserAclsInfoResponse getQueueUserAcls(
492
491
resetStartFailoverFlag (true );
493
492
494
493
// make sure failover has been triggered
495
- Assert . assertTrue (waittingForFailOver ());
494
+ assertTrue (waittingForFailOver ());
496
495
497
496
// return fake queueUserAcls
498
497
return GetQueueUserAclsInfoResponse
@@ -506,7 +505,7 @@ public GetApplicationAttemptReportResponse getApplicationAttemptReport(
506
505
resetStartFailoverFlag (true );
507
506
508
507
// make sure failover has been triggered
509
- Assert . assertTrue (waittingForFailOver ());
508
+ assertTrue (waittingForFailOver ());
510
509
511
510
// return fake ApplicationAttemptReport
512
511
return GetApplicationAttemptReportResponse
@@ -520,7 +519,7 @@ public GetApplicationAttemptsResponse getApplicationAttempts(
520
519
resetStartFailoverFlag (true );
521
520
522
521
// make sure failover has been triggered
523
- Assert . assertTrue (waittingForFailOver ());
522
+ assertTrue (waittingForFailOver ());
524
523
525
524
// return fake ApplicationAttemptReports
526
525
return GetApplicationAttemptsResponse
@@ -534,7 +533,7 @@ public GetContainerReportResponse getContainerReport(
534
533
resetStartFailoverFlag (true );
535
534
536
535
// make sure failover has been triggered
537
- Assert . assertTrue (waittingForFailOver ());
536
+ assertTrue (waittingForFailOver ());
538
537
539
538
// return fake containerReport
540
539
return GetContainerReportResponse
@@ -547,7 +546,7 @@ public GetContainersResponse getContainers(GetContainersRequest request)
547
546
resetStartFailoverFlag (true );
548
547
549
548
// make sure failover has been triggered
550
- Assert . assertTrue (waittingForFailOver ());
549
+ assertTrue (waittingForFailOver ());
551
550
552
551
// return fake ContainerReports
553
552
return GetContainersResponse .newInstance (createFakeContainerReports ());
@@ -559,7 +558,7 @@ public SubmitApplicationResponse submitApplication(
559
558
resetStartFailoverFlag (true );
560
559
561
560
// make sure failover has been triggered
562
- Assert . assertTrue (waittingForFailOver ());
561
+ assertTrue (waittingForFailOver ());
563
562
564
563
return super .submitApplication (request );
565
564
}
@@ -570,7 +569,7 @@ public KillApplicationResponse forceKillApplication(
570
569
resetStartFailoverFlag (true );
571
570
572
571
// make sure failover has been triggered
573
- Assert . assertTrue (waittingForFailOver ());
572
+ assertTrue (waittingForFailOver ());
574
573
575
574
return KillApplicationResponse .newInstance (true );
576
575
}
@@ -581,7 +580,7 @@ public MoveApplicationAcrossQueuesResponse moveApplicationAcrossQueues(
581
580
resetStartFailoverFlag (true );
582
581
583
582
// make sure failover has been triggered
584
- Assert . assertTrue (waittingForFailOver ());
583
+ assertTrue (waittingForFailOver ());
585
584
586
585
return Records .newRecord (MoveApplicationAcrossQueuesResponse .class );
587
586
}
@@ -592,7 +591,7 @@ public GetDelegationTokenResponse getDelegationToken(
592
591
resetStartFailoverFlag (true );
593
592
594
593
// make sure failover has been triggered
595
- Assert . assertTrue (waittingForFailOver ());
594
+ assertTrue (waittingForFailOver ());
596
595
597
596
return GetDelegationTokenResponse .newInstance (createFakeToken ());
598
597
}
@@ -603,7 +602,7 @@ public RenewDelegationTokenResponse renewDelegationToken(
603
602
resetStartFailoverFlag (true );
604
603
605
604
// make sure failover has been triggered
606
- Assert . assertTrue (waittingForFailOver ());
605
+ assertTrue (waittingForFailOver ());
607
606
608
607
return RenewDelegationTokenResponse
609
608
.newInstance (createNextExpirationTime ());
@@ -615,7 +614,7 @@ public CancelDelegationTokenResponse cancelDelegationToken(
615
614
resetStartFailoverFlag (true );
616
615
617
616
// make sure failover has been triggered
618
- Assert . assertTrue (waittingForFailOver ());
617
+ assertTrue (waittingForFailOver ());
619
618
620
619
return CancelDelegationTokenResponse .newInstance ();
621
620
}
@@ -741,7 +740,7 @@ public RegisterNodeManagerResponse registerNodeManager(
741
740
IOException {
742
741
resetStartFailoverFlag (true );
743
742
// make sure failover has been triggered
744
- Assert . assertTrue (waittingForFailOver ());
743
+ assertTrue (waittingForFailOver ());
745
744
return super .registerNodeManager (request );
746
745
}
747
746
@@ -750,7 +749,7 @@ public NodeHeartbeatResponse nodeHeartbeat(NodeHeartbeatRequest request)
750
749
throws YarnException , IOException {
751
750
resetStartFailoverFlag (true );
752
751
// make sure failover has been triggered
753
- Assert . assertTrue (waittingForFailOver ());
752
+ assertTrue (waittingForFailOver ());
754
753
return super .nodeHeartbeat (request );
755
754
}
756
755
}
@@ -767,7 +766,7 @@ public AllocateResponse allocate(AllocateRequest request)
767
766
throws YarnException , IOException {
768
767
resetStartFailoverFlag (true );
769
768
// make sure failover has been triggered
770
- Assert . assertTrue (waittingForFailOver ());
769
+ assertTrue (waittingForFailOver ());
771
770
return createFakeAllocateResponse ();
772
771
}
773
772
@@ -777,7 +776,7 @@ public RegisterApplicationMasterResponse registerApplicationMaster(
777
776
IOException {
778
777
resetStartFailoverFlag (true );
779
778
// make sure failover has been triggered
780
- Assert . assertTrue (waittingForFailOver ());
779
+ assertTrue (waittingForFailOver ());
781
780
return createFakeRegisterApplicationMasterResponse ();
782
781
}
783
782
@@ -787,7 +786,7 @@ public FinishApplicationMasterResponse finishApplicationMaster(
787
786
IOException {
788
787
resetStartFailoverFlag (true );
789
788
// make sure failover has been triggered
790
- Assert . assertTrue (waittingForFailOver ());
789
+ assertTrue (waittingForFailOver ());
791
790
return createFakeFinishApplicationMasterResponse ();
792
791
}
793
792
}
0 commit comments