Skip to content

Commit ecdd0eb

Browse files
committed
YARN-11267. Fix Junit Test Error.
1 parent 77c8edf commit ecdd0eb

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/webapp/FederationInterceptorREST.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1002,7 +1002,7 @@ private SubClusterInfo getNodeSubcluster(String nodeId) throws NotFoundException
10021002
NodeInfo nodeInfo = null;
10031003
for (Entry<SubClusterInfo, NodeInfo> entry : results.entrySet()) {
10041004
NodeInfo nodeResponse = entry.getValue();
1005-
if (nodeInfo == null || (nodeInfo != null && nodeResponse != null &&
1005+
if (nodeInfo == null || (nodeResponse != null &&
10061006
nodeInfo.getLastHealthUpdate() < nodeResponse.getLastHealthUpdate())) {
10071007
subcluster = entry.getKey();
10081008
nodeInfo = nodeResponse;
@@ -3405,6 +3405,10 @@ private <R> Map<SubClusterInfo, R> invokeConcurrent(Collection<SubClusterInfo> c
34053405
}
34063406

34073407
if (results.isEmpty() && lastException != null) {
3408+
Throwable cause = lastException.getCause();
3409+
if (cause != null) {
3410+
throw new YarnRuntimeException(cause.getMessage());
3411+
}
34083412
throw new YarnRuntimeException(lastException.getMessage());
34093413
}
34103414
return results;

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/webapp/TestFederationInterceptorRESTRetry.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -556,8 +556,10 @@ public void testGetNodesOneBadSCAllowPartial() throws Exception {
556556
interceptor.setAllowPartialResult(true);
557557
setupCluster(Arrays.asList(bad2));
558558

559-
NodesInfo nodesInfo = interceptor.getNodes(null);
560-
assertNotNull(nodesInfo);
559+
YarnRuntimeException exception = assertThrows(YarnRuntimeException.class, () -> {
560+
interceptor.getNodes(null);
561+
});
562+
assertTrue(exception.getMessage().contains("RM is stopped"));
561563

562564
// We need to set allowPartialResult=false
563565
interceptor.setAllowPartialResult(false);
@@ -572,8 +574,10 @@ public void testGetNodesTwoBadSCsAllowPartial() throws Exception {
572574
interceptor.setAllowPartialResult(true);
573575
setupCluster(Arrays.asList(bad1, bad2));
574576

575-
NodesInfo nodesInfo = interceptor.getNodes(null);
576-
assertNotNull(nodesInfo);
577+
YarnRuntimeException exception = assertThrows(YarnRuntimeException.class, () -> {
578+
interceptor.getNodes(null);
579+
});
580+
assertTrue(exception.getMessage().contains("RM is stopped"));
577581

578582
// We need to set allowPartialResult=false
579583
interceptor.setAllowPartialResult(false);

0 commit comments

Comments
 (0)