maheshrajus commented on code in PR #520:
URL: https://github.com/apache/tez/pull/520#discussion_r3664686827


##########
tez-api/src/test/java/org/apache/tez/dag/api/client/rpc/TestDAGClient.java:
##########
@@ -725,6 +726,55 @@ public void testGetDagStatusWithCachedStatusExpiration() 
throws Exception {
     }
   }
 
+  /**
+   * Covers the YARN-808 guard in DAGClientRPCImpl#createAMProxyIfNeeded
+   */
+  @Test
+  @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
+  public void testCreateAMProxyIfNeededReturnsFalseOnBadEndpoint() throws 
Exception {
+    TezConfiguration tezConf = new TezConfiguration();
+
+    // Case: rpcPort == 0 (protobuf default sentinel).
+    assertFalse(mockReportClient(tezConf, "somehost", 
0).createAMProxyIfNeeded(),
+        "rpcPort == 0 should return false");
+
+    // Case: rpcPort == -1 (YARN-808 gap — AM allocated but RPC not bound).
+    assertFalse(mockReportClient(tezConf, "somehost", 
-1).createAMProxyIfNeeded(),
+        "rpcPort == -1 should return false");
+
+    // Case: host == null.
+    assertFalse(mockReportClient(tezConf, null, 8080).createAMProxyIfNeeded(),
+        "host == null should return false");
+
+    // Case: host == "N/A".
+    assertFalse(mockReportClient(tezConf, "N/A", 8080).createAMProxyIfNeeded(),
+        "host == N/A should return false");
+  }
+
+  private DAGClientRPCImplWithFakeReport mockReportClient(TezConfiguration 
conf,
+      String host, int rpcPort) throws IOException {
+    ApplicationReport report = mock(ApplicationReport.class);
+    
when(report.getYarnApplicationState()).thenReturn(YarnApplicationState.RUNNING);
+    when(report.getHost()).thenReturn(host);
+    when(report.getRpcPort()).thenReturn(rpcPort);
+    return new DAGClientRPCImplWithFakeReport(mockAppId, dagIdStr, conf, 
report);
+  }

Review Comment:
   Fixed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to