Skip to content

Commit eda1236

Browse files
slfan1989cnauroth
andauthored
YARN-11244. [JDK17] Upgrade JUnit from 4 to 5 in hadoop-yarn-client. (#7438)
[JDK17] Upgrade JUnit from 4 to 5 in hadoop-yarn-client. Co-authored-by: Chris Nauroth <[email protected]> Reviewed-by: Chris Nauroth <[email protected]> Signed-off-by: Shilun Fan <[email protected]>
1 parent 4b9e1dc commit eda1236

38 files changed

+1197
-1008
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/ApplicationMasterServiceProtoTestBase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import org.apache.hadoop.yarn.api.ApplicationMasterProtocol;
2727
import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
2828
import org.apache.hadoop.yarn.security.AMRMTokenIdentifier;
29-
import org.junit.After;
29+
import org.junit.jupiter.api.AfterEach;
3030

3131
/**
3232
* Test Base for Application Master Service Protocol.
@@ -52,7 +52,7 @@ protected void startupHAAndSetupClient() throws Exception {
5252
.createRMProxy(this.conf, ApplicationMasterProtocol.class);
5353
}
5454

55-
@After
55+
@AfterEach
5656
public void shutDown() {
5757
if(this.amClient != null) {
5858
RPC.stopProxy(this.amClient);

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/ProtocolHATestBase.java

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,17 @@
2929
import org.apache.hadoop.yarn.api.protocolrecords.RegisterApplicationMasterResponse;
3030
import org.apache.hadoop.yarn.api.records.CollectorInfo;
3131
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;
3636

3737
import java.io.IOException;
3838
import java.util.ArrayList;
3939
import java.util.List;
4040
import java.util.concurrent.atomic.AtomicBoolean;
4141

4242
import org.apache.hadoop.yarn.server.resourcemanager.HATestUtil;
43-
import org.junit.Assert;
4443

4544
import org.apache.hadoop.conf.Configuration;
4645
import org.apache.hadoop.ha.ClientBaseWithFixes;
@@ -128,8 +127,8 @@
128127
import org.apache.hadoop.yarn.server.resourcemanager.security.RMDelegationTokenSecretManager;
129128
import org.apache.hadoop.yarn.server.security.ApplicationACLsManager;
130129
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;
133132

134133

135134
/**
@@ -164,7 +163,7 @@ public abstract class ProtocolHATestBase extends ClientBaseWithFixes {
164163
protected Thread failoverThread = null;
165164
private volatile boolean keepRunning;
166165

167-
@Before
166+
@BeforeEach
168167
public void setup() throws IOException {
169168
failoverThread = null;
170169
keepRunning = true;
@@ -181,7 +180,7 @@ public void setup() throws IOException {
181180
conf.setBoolean(YarnConfiguration.YARN_MINICLUSTER_USE_RPC, true);
182181
}
183182

184-
@After
183+
@AfterEach
185184
public void teardown() throws Exception {
186185
keepRunning = false;
187186
if (failoverThread != null) {
@@ -205,8 +204,8 @@ protected void explicitFailover() throws IOException {
205204
int newActiveRMIndex = (activeRMIndex + 1) % 2;
206205
getAdminService(activeRMIndex).transitionToStandby(req);
207206
getAdminService(newActiveRMIndex).transitionToActive(req);
208-
assertEquals("Failover failed", newActiveRMIndex,
209-
cluster.getActiveRMIndex());
207+
assertEquals(newActiveRMIndex,
208+
cluster.getActiveRMIndex(), "Failover failed");
210209
}
211210

212211
protected YarnClient createAndStartYarnClient(Configuration conf) {
@@ -219,8 +218,8 @@ protected YarnClient createAndStartYarnClient(Configuration conf) {
219218

220219
protected void verifyConnections() throws InterruptedException,
221220
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");
224223
verifyClientConnection();
225224
}
226225

@@ -284,7 +283,7 @@ protected void startHACluster(int numOfNMs, boolean overrideClientRMService,
284283
cluster.resetStartFailoverFlag(false);
285284
cluster.init(conf);
286285
cluster.start();
287-
assertFalse("RM never turned active", -1 == cluster.getActiveRMIndex());
286+
assertFalse(-1 == cluster.getActiveRMIndex(), "RM never turned active");
288287
verifyConnections();
289288

290289
// Do the failover
@@ -406,7 +405,7 @@ public GetNewApplicationResponse getNewApplication(
406405
resetStartFailoverFlag(true);
407406

408407
// make sure failover has been triggered
409-
Assert.assertTrue(waittingForFailOver());
408+
assertTrue(waittingForFailOver());
410409

411410
// create the GetNewApplicationResponse with fake applicationId
412411
GetNewApplicationResponse response =
@@ -421,7 +420,7 @@ public GetApplicationReportResponse getApplicationReport(
421420
resetStartFailoverFlag(true);
422421

423422
// make sure failover has been triggered
424-
Assert.assertTrue(waittingForFailOver());
423+
assertTrue(waittingForFailOver());
425424

426425
// create a fake application report
427426
ApplicationReport report = createFakeAppReport();
@@ -436,7 +435,7 @@ public GetClusterMetricsResponse getClusterMetrics(
436435
resetStartFailoverFlag(true);
437436

438437
// make sure failover has been triggered
439-
Assert.assertTrue(waittingForFailOver());
438+
assertTrue(waittingForFailOver());
440439

441440
// create GetClusterMetricsResponse with fake YarnClusterMetrics
442441
GetClusterMetricsResponse response =
@@ -451,7 +450,7 @@ public GetApplicationsResponse getApplications(
451450
resetStartFailoverFlag(true);
452451

453452
// make sure failover has been triggered
454-
Assert.assertTrue(waittingForFailOver());
453+
assertTrue(waittingForFailOver());
455454

456455
// create GetApplicationsResponse with fake applicationList
457456
GetApplicationsResponse response =
@@ -466,7 +465,7 @@ public GetClusterNodesResponse getClusterNodes(
466465
resetStartFailoverFlag(true);
467466

468467
// make sure failover has been triggered
469-
Assert.assertTrue(waittingForFailOver());
468+
assertTrue(waittingForFailOver());
470469

471470
// create GetClusterNodesResponse with fake ClusterNodeLists
472471
GetClusterNodesResponse response =
@@ -480,7 +479,7 @@ public GetQueueInfoResponse getQueueInfo(GetQueueInfoRequest request)
480479
resetStartFailoverFlag(true);
481480

482481
// make sure failover has been triggered
483-
Assert.assertTrue(waittingForFailOver());
482+
assertTrue(waittingForFailOver());
484483

485484
// return fake QueueInfo
486485
return GetQueueInfoResponse.newInstance(createFakeQueueInfo());
@@ -492,7 +491,7 @@ public GetQueueUserAclsInfoResponse getQueueUserAcls(
492491
resetStartFailoverFlag(true);
493492

494493
// make sure failover has been triggered
495-
Assert.assertTrue(waittingForFailOver());
494+
assertTrue(waittingForFailOver());
496495

497496
// return fake queueUserAcls
498497
return GetQueueUserAclsInfoResponse
@@ -506,7 +505,7 @@ public GetApplicationAttemptReportResponse getApplicationAttemptReport(
506505
resetStartFailoverFlag(true);
507506

508507
// make sure failover has been triggered
509-
Assert.assertTrue(waittingForFailOver());
508+
assertTrue(waittingForFailOver());
510509

511510
// return fake ApplicationAttemptReport
512511
return GetApplicationAttemptReportResponse
@@ -520,7 +519,7 @@ public GetApplicationAttemptsResponse getApplicationAttempts(
520519
resetStartFailoverFlag(true);
521520

522521
// make sure failover has been triggered
523-
Assert.assertTrue(waittingForFailOver());
522+
assertTrue(waittingForFailOver());
524523

525524
// return fake ApplicationAttemptReports
526525
return GetApplicationAttemptsResponse
@@ -534,7 +533,7 @@ public GetContainerReportResponse getContainerReport(
534533
resetStartFailoverFlag(true);
535534

536535
// make sure failover has been triggered
537-
Assert.assertTrue(waittingForFailOver());
536+
assertTrue(waittingForFailOver());
538537

539538
// return fake containerReport
540539
return GetContainerReportResponse
@@ -547,7 +546,7 @@ public GetContainersResponse getContainers(GetContainersRequest request)
547546
resetStartFailoverFlag(true);
548547

549548
// make sure failover has been triggered
550-
Assert.assertTrue(waittingForFailOver());
549+
assertTrue(waittingForFailOver());
551550

552551
// return fake ContainerReports
553552
return GetContainersResponse.newInstance(createFakeContainerReports());
@@ -559,7 +558,7 @@ public SubmitApplicationResponse submitApplication(
559558
resetStartFailoverFlag(true);
560559

561560
// make sure failover has been triggered
562-
Assert.assertTrue(waittingForFailOver());
561+
assertTrue(waittingForFailOver());
563562

564563
return super.submitApplication(request);
565564
}
@@ -570,7 +569,7 @@ public KillApplicationResponse forceKillApplication(
570569
resetStartFailoverFlag(true);
571570

572571
// make sure failover has been triggered
573-
Assert.assertTrue(waittingForFailOver());
572+
assertTrue(waittingForFailOver());
574573

575574
return KillApplicationResponse.newInstance(true);
576575
}
@@ -581,7 +580,7 @@ public MoveApplicationAcrossQueuesResponse moveApplicationAcrossQueues(
581580
resetStartFailoverFlag(true);
582581

583582
// make sure failover has been triggered
584-
Assert.assertTrue(waittingForFailOver());
583+
assertTrue(waittingForFailOver());
585584

586585
return Records.newRecord(MoveApplicationAcrossQueuesResponse.class);
587586
}
@@ -592,7 +591,7 @@ public GetDelegationTokenResponse getDelegationToken(
592591
resetStartFailoverFlag(true);
593592

594593
// make sure failover has been triggered
595-
Assert.assertTrue(waittingForFailOver());
594+
assertTrue(waittingForFailOver());
596595

597596
return GetDelegationTokenResponse.newInstance(createFakeToken());
598597
}
@@ -603,7 +602,7 @@ public RenewDelegationTokenResponse renewDelegationToken(
603602
resetStartFailoverFlag(true);
604603

605604
// make sure failover has been triggered
606-
Assert.assertTrue(waittingForFailOver());
605+
assertTrue(waittingForFailOver());
607606

608607
return RenewDelegationTokenResponse
609608
.newInstance(createNextExpirationTime());
@@ -615,7 +614,7 @@ public CancelDelegationTokenResponse cancelDelegationToken(
615614
resetStartFailoverFlag(true);
616615

617616
// make sure failover has been triggered
618-
Assert.assertTrue(waittingForFailOver());
617+
assertTrue(waittingForFailOver());
619618

620619
return CancelDelegationTokenResponse.newInstance();
621620
}
@@ -741,7 +740,7 @@ public RegisterNodeManagerResponse registerNodeManager(
741740
IOException {
742741
resetStartFailoverFlag(true);
743742
// make sure failover has been triggered
744-
Assert.assertTrue(waittingForFailOver());
743+
assertTrue(waittingForFailOver());
745744
return super.registerNodeManager(request);
746745
}
747746

@@ -750,7 +749,7 @@ public NodeHeartbeatResponse nodeHeartbeat(NodeHeartbeatRequest request)
750749
throws YarnException, IOException {
751750
resetStartFailoverFlag(true);
752751
// make sure failover has been triggered
753-
Assert.assertTrue(waittingForFailOver());
752+
assertTrue(waittingForFailOver());
754753
return super.nodeHeartbeat(request);
755754
}
756755
}
@@ -767,7 +766,7 @@ public AllocateResponse allocate(AllocateRequest request)
767766
throws YarnException, IOException {
768767
resetStartFailoverFlag(true);
769768
// make sure failover has been triggered
770-
Assert.assertTrue(waittingForFailOver());
769+
assertTrue(waittingForFailOver());
771770
return createFakeAllocateResponse();
772771
}
773772

@@ -777,7 +776,7 @@ public RegisterApplicationMasterResponse registerApplicationMaster(
777776
IOException {
778777
resetStartFailoverFlag(true);
779778
// make sure failover has been triggered
780-
Assert.assertTrue(waittingForFailOver());
779+
assertTrue(waittingForFailOver());
781780
return createFakeRegisterApplicationMasterResponse();
782781
}
783782

@@ -787,7 +786,7 @@ public FinishApplicationMasterResponse finishApplicationMaster(
787786
IOException {
788787
resetStartFailoverFlag(true);
789788
// make sure failover has been triggered
790-
Assert.assertTrue(waittingForFailOver());
789+
assertTrue(waittingForFailOver());
791790
return createFakeFinishApplicationMasterResponse();
792791
}
793792
}

0 commit comments

Comments
 (0)