Skip to content

Commit

Permalink
YARN-11244. [JDK17] Upgrade JUnit from 4 to 5 in hadoop-yarn-client. (#…
Browse files Browse the repository at this point in the history
…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]>
  • Loading branch information
slfan1989 and cnauroth authored Mar 4, 2025
1 parent 4b9e1dc commit eda1236
Show file tree
Hide file tree
Showing 38 changed files with 1,197 additions and 1,008 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import org.apache.hadoop.yarn.api.ApplicationMasterProtocol;
import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
import org.apache.hadoop.yarn.security.AMRMTokenIdentifier;
import org.junit.After;
import org.junit.jupiter.api.AfterEach;

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

@After
@AfterEach
public void shutDown() {
if(this.amClient != null) {
RPC.stopProxy(this.amClient);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,17 @@
import org.apache.hadoop.yarn.api.protocolrecords.RegisterApplicationMasterResponse;
import org.apache.hadoop.yarn.api.records.CollectorInfo;
import org.apache.hadoop.yarn.api.records.ApplicationAccessType;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;

import org.apache.hadoop.yarn.server.resourcemanager.HATestUtil;
import org.junit.Assert;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.ha.ClientBaseWithFixes;
Expand Down Expand Up @@ -128,8 +127,8 @@
import org.apache.hadoop.yarn.server.resourcemanager.security.RMDelegationTokenSecretManager;
import org.apache.hadoop.yarn.server.security.ApplicationACLsManager;
import org.apache.hadoop.yarn.util.Records;
import org.junit.After;
import org.junit.Before;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;


/**
Expand Down Expand Up @@ -164,7 +163,7 @@ public abstract class ProtocolHATestBase extends ClientBaseWithFixes {
protected Thread failoverThread = null;
private volatile boolean keepRunning;

@Before
@BeforeEach
public void setup() throws IOException {
failoverThread = null;
keepRunning = true;
Expand All @@ -181,7 +180,7 @@ public void setup() throws IOException {
conf.setBoolean(YarnConfiguration.YARN_MINICLUSTER_USE_RPC, true);
}

@After
@AfterEach
public void teardown() throws Exception {
keepRunning = false;
if (failoverThread != null) {
Expand All @@ -205,8 +204,8 @@ protected void explicitFailover() throws IOException {
int newActiveRMIndex = (activeRMIndex + 1) % 2;
getAdminService(activeRMIndex).transitionToStandby(req);
getAdminService(newActiveRMIndex).transitionToActive(req);
assertEquals("Failover failed", newActiveRMIndex,
cluster.getActiveRMIndex());
assertEquals(newActiveRMIndex,
cluster.getActiveRMIndex(), "Failover failed");
}

protected YarnClient createAndStartYarnClient(Configuration conf) {
Expand All @@ -219,8 +218,8 @@ protected YarnClient createAndStartYarnClient(Configuration conf) {

protected void verifyConnections() throws InterruptedException,
YarnException {
assertTrue("NMs failed to connect to the RM",
cluster.waitForNodeManagersToConnect(5000));
assertTrue(cluster.waitForNodeManagersToConnect(5000),
"NMs failed to connect to the RM");
verifyClientConnection();
}

Expand Down Expand Up @@ -284,7 +283,7 @@ protected void startHACluster(int numOfNMs, boolean overrideClientRMService,
cluster.resetStartFailoverFlag(false);
cluster.init(conf);
cluster.start();
assertFalse("RM never turned active", -1 == cluster.getActiveRMIndex());
assertFalse(-1 == cluster.getActiveRMIndex(), "RM never turned active");
verifyConnections();

// Do the failover
Expand Down Expand Up @@ -406,7 +405,7 @@ public GetNewApplicationResponse getNewApplication(
resetStartFailoverFlag(true);

// make sure failover has been triggered
Assert.assertTrue(waittingForFailOver());
assertTrue(waittingForFailOver());

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

// make sure failover has been triggered
Assert.assertTrue(waittingForFailOver());
assertTrue(waittingForFailOver());

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

// make sure failover has been triggered
Assert.assertTrue(waittingForFailOver());
assertTrue(waittingForFailOver());

// create GetClusterMetricsResponse with fake YarnClusterMetrics
GetClusterMetricsResponse response =
Expand All @@ -451,7 +450,7 @@ public GetApplicationsResponse getApplications(
resetStartFailoverFlag(true);

// make sure failover has been triggered
Assert.assertTrue(waittingForFailOver());
assertTrue(waittingForFailOver());

// create GetApplicationsResponse with fake applicationList
GetApplicationsResponse response =
Expand All @@ -466,7 +465,7 @@ public GetClusterNodesResponse getClusterNodes(
resetStartFailoverFlag(true);

// make sure failover has been triggered
Assert.assertTrue(waittingForFailOver());
assertTrue(waittingForFailOver());

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

// make sure failover has been triggered
Assert.assertTrue(waittingForFailOver());
assertTrue(waittingForFailOver());

// return fake QueueInfo
return GetQueueInfoResponse.newInstance(createFakeQueueInfo());
Expand All @@ -492,7 +491,7 @@ public GetQueueUserAclsInfoResponse getQueueUserAcls(
resetStartFailoverFlag(true);

// make sure failover has been triggered
Assert.assertTrue(waittingForFailOver());
assertTrue(waittingForFailOver());

// return fake queueUserAcls
return GetQueueUserAclsInfoResponse
Expand All @@ -506,7 +505,7 @@ public GetApplicationAttemptReportResponse getApplicationAttemptReport(
resetStartFailoverFlag(true);

// make sure failover has been triggered
Assert.assertTrue(waittingForFailOver());
assertTrue(waittingForFailOver());

// return fake ApplicationAttemptReport
return GetApplicationAttemptReportResponse
Expand All @@ -520,7 +519,7 @@ public GetApplicationAttemptsResponse getApplicationAttempts(
resetStartFailoverFlag(true);

// make sure failover has been triggered
Assert.assertTrue(waittingForFailOver());
assertTrue(waittingForFailOver());

// return fake ApplicationAttemptReports
return GetApplicationAttemptsResponse
Expand All @@ -534,7 +533,7 @@ public GetContainerReportResponse getContainerReport(
resetStartFailoverFlag(true);

// make sure failover has been triggered
Assert.assertTrue(waittingForFailOver());
assertTrue(waittingForFailOver());

// return fake containerReport
return GetContainerReportResponse
Expand All @@ -547,7 +546,7 @@ public GetContainersResponse getContainers(GetContainersRequest request)
resetStartFailoverFlag(true);

// make sure failover has been triggered
Assert.assertTrue(waittingForFailOver());
assertTrue(waittingForFailOver());

// return fake ContainerReports
return GetContainersResponse.newInstance(createFakeContainerReports());
Expand All @@ -559,7 +558,7 @@ public SubmitApplicationResponse submitApplication(
resetStartFailoverFlag(true);

// make sure failover has been triggered
Assert.assertTrue(waittingForFailOver());
assertTrue(waittingForFailOver());

return super.submitApplication(request);
}
Expand All @@ -570,7 +569,7 @@ public KillApplicationResponse forceKillApplication(
resetStartFailoverFlag(true);

// make sure failover has been triggered
Assert.assertTrue(waittingForFailOver());
assertTrue(waittingForFailOver());

return KillApplicationResponse.newInstance(true);
}
Expand All @@ -581,7 +580,7 @@ public MoveApplicationAcrossQueuesResponse moveApplicationAcrossQueues(
resetStartFailoverFlag(true);

// make sure failover has been triggered
Assert.assertTrue(waittingForFailOver());
assertTrue(waittingForFailOver());

return Records.newRecord(MoveApplicationAcrossQueuesResponse.class);
}
Expand All @@ -592,7 +591,7 @@ public GetDelegationTokenResponse getDelegationToken(
resetStartFailoverFlag(true);

// make sure failover has been triggered
Assert.assertTrue(waittingForFailOver());
assertTrue(waittingForFailOver());

return GetDelegationTokenResponse.newInstance(createFakeToken());
}
Expand All @@ -603,7 +602,7 @@ public RenewDelegationTokenResponse renewDelegationToken(
resetStartFailoverFlag(true);

// make sure failover has been triggered
Assert.assertTrue(waittingForFailOver());
assertTrue(waittingForFailOver());

return RenewDelegationTokenResponse
.newInstance(createNextExpirationTime());
Expand All @@ -615,7 +614,7 @@ public CancelDelegationTokenResponse cancelDelegationToken(
resetStartFailoverFlag(true);

// make sure failover has been triggered
Assert.assertTrue(waittingForFailOver());
assertTrue(waittingForFailOver());

return CancelDelegationTokenResponse.newInstance();
}
Expand Down Expand Up @@ -741,7 +740,7 @@ public RegisterNodeManagerResponse registerNodeManager(
IOException {
resetStartFailoverFlag(true);
// make sure failover has been triggered
Assert.assertTrue(waittingForFailOver());
assertTrue(waittingForFailOver());
return super.registerNodeManager(request);
}

Expand All @@ -750,7 +749,7 @@ public NodeHeartbeatResponse nodeHeartbeat(NodeHeartbeatRequest request)
throws YarnException, IOException {
resetStartFailoverFlag(true);
// make sure failover has been triggered
Assert.assertTrue(waittingForFailOver());
assertTrue(waittingForFailOver());
return super.nodeHeartbeat(request);
}
}
Expand All @@ -767,7 +766,7 @@ public AllocateResponse allocate(AllocateRequest request)
throws YarnException, IOException {
resetStartFailoverFlag(true);
// make sure failover has been triggered
Assert.assertTrue(waittingForFailOver());
assertTrue(waittingForFailOver());
return createFakeAllocateResponse();
}

Expand All @@ -777,7 +776,7 @@ public RegisterApplicationMasterResponse registerApplicationMaster(
IOException {
resetStartFailoverFlag(true);
// make sure failover has been triggered
Assert.assertTrue(waittingForFailOver());
assertTrue(waittingForFailOver());
return createFakeRegisterApplicationMasterResponse();
}

Expand All @@ -787,7 +786,7 @@ public FinishApplicationMasterResponse finishApplicationMaster(
IOException {
resetStartFailoverFlag(true);
// make sure failover has been triggered
Assert.assertTrue(waittingForFailOver());
assertTrue(waittingForFailOver());
return createFakeFinishApplicationMasterResponse();
}
}
Expand Down
Loading

0 comments on commit eda1236

Please sign in to comment.