smengcl commented on code in PR #8877:
URL: https://github.com/apache/hadoop/pull/8877#discussion_r4461631649
##########
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeRpcServer.java:
##########
@@ -84,6 +90,39 @@ public void testNamenodeRpcBindAny() throws IOException {
}
}
+ @Test
+ public void testAdvertisedAddress() throws IOException {
+ for (boolean useIp : new boolean[] {true, false}) {
+ SecurityUtil.setTokenServiceUseIp(useIp);
+ try {
+ // The reverse name of a literal is advertised only if it resolves
back to it.
+ for (String literal : new String[] {"127.0.0.1", "[::1]"}) {
+ InetSocketAddress configured = NetUtils.createSocketAddr(literal +
":0");
+ InetSocketAddress advertised =
+ NameNodeRpcServer.getAdvertisedAddress(configured, 8020);
+ assertEquals(8020, advertised.getPort());
+ assertEquals(configured.getAddress(), advertised.getAddress());
+ assertEquals(configured.getAddress(),
+ InetAddress.getByName(advertised.getHostName()));
+ }
+ assertEquals("localhost", NameNodeRpcServer.getAdvertisedAddress(
Review Comment:
Done in 99baf247033. The test now works out the expected name from the
platform's own reverse lookup, the same way the helper does: it expects the
reverse name only when that name resolves back to 127.0.0.1, and the literal
otherwise. It passes with preferIPv6Addresses=true, with a hosts file whose
first loopback name is localhost.localdomain, with both together, and under the
default CI settings.
_🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]