Bläddra i källkod

HADOOP-19499. Handle JDK-8225499 IpAddr.toString() format changes in tests

Closes #7502

Signed-off-by: Chris Nauroth <cnauroth@apache.org>
Istvan Toth 1 månad sedan
förälder
incheckning
af6a64f763

+ 29 - 12
hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterNamenodeHeartbeat.java

@@ -48,6 +48,7 @@ import org.apache.hadoop.hdfs.server.federation.resolver.FederationNamenodeConte
 import org.apache.hadoop.net.MockDomainNameResolver;
 import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.hadoop.service.Service.STATE;
+import org.apache.hadoop.util.Shell;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Rule;
@@ -216,18 +217,34 @@ public class TestRouterNamenodeHeartbeat {
 
   @Test
   public void testNamenodeHeartbeatServiceHAServiceProtocolProxy(){
-    testNamenodeHeartbeatServiceHAServiceProtocol(
-        "test-ns", "nn", 1000, -1, -1, 1003,
-        "host01.test:1000", "host02.test:1000");
-    testNamenodeHeartbeatServiceHAServiceProtocol(
-        "test-ns", "nn", 1000, 1001, -1, 1003,
-        "host01.test:1001", "host02.test:1001");
-    testNamenodeHeartbeatServiceHAServiceProtocol(
-        "test-ns", "nn", 1000, -1, 1002, 1003,
-        "host01.test:1002", "host02.test:1002");
-    testNamenodeHeartbeatServiceHAServiceProtocol(
-        "test-ns", "nn", 1000, 1001, 1002, 1003,
-        "host01.test:1002", "host02.test:1002");
+    // JDK-8225499. The string format of unresolved address has been changed.
+    if (Shell.isJavaVersionAtLeast(14)) {
+      testNamenodeHeartbeatServiceHAServiceProtocol(
+          "test-ns", "nn", 1000, -1, -1, 1003,
+          "host01.test/<unresolved>:1000", "host02.test/<unresolved>:1000");
+      testNamenodeHeartbeatServiceHAServiceProtocol(
+          "test-ns", "nn", 1000, 1001, -1, 1003,
+          "host01.test/<unresolved>:1001", "host02.test/<unresolved>:1001");
+      testNamenodeHeartbeatServiceHAServiceProtocol(
+          "test-ns", "nn", 1000, -1, 1002, 1003,
+          "host01.test/<unresolved>:1002", "host02.test/<unresolved>:1002");
+      testNamenodeHeartbeatServiceHAServiceProtocol(
+          "test-ns", "nn", 1000, 1001, 1002, 1003,
+          "host01.test/<unresolved>:1002", "host02.test/<unresolved>:1002");
+    } else {
+      testNamenodeHeartbeatServiceHAServiceProtocol(
+          "test-ns", "nn", 1000, -1, -1, 1003,
+          "host01.test:1000", "host02.test:1000");
+      testNamenodeHeartbeatServiceHAServiceProtocol(
+          "test-ns", "nn", 1000, 1001, -1, 1003,
+          "host01.test:1001", "host02.test:1001");
+      testNamenodeHeartbeatServiceHAServiceProtocol(
+          "test-ns", "nn", 1000, -1, 1002, 1003,
+          "host01.test:1002", "host02.test:1002");
+      testNamenodeHeartbeatServiceHAServiceProtocol(
+          "test-ns", "nn", 1000, 1001, 1002, 1003,
+          "host01.test:1002", "host02.test:1002");
+    }
   }
 
   private void testNamenodeHeartbeatServiceHAServiceProtocol(

+ 33 - 14
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/TestJobEndNotifier.java

@@ -61,6 +61,7 @@ import org.apache.hadoop.mapreduce.v2.app.rm.ContainerAllocator;
 import org.apache.hadoop.mapreduce.v2.app.rm.ContainerAllocatorEvent;
 import org.apache.hadoop.mapreduce.v2.app.rm.RMCommunicator;
 import org.apache.hadoop.mapreduce.v2.app.rm.RMHeartbeatHandler;
+import org.apache.hadoop.util.Shell;
 import org.apache.hadoop.yarn.exceptions.YarnException;
 import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
 import org.junit.jupiter.api.Test;
@@ -124,20 +125,38 @@ public class TestJobEndNotifier extends JobEndNotifier {
         "Proxy shouldn't be set because port wasn't numeric");
     conf.set(MRJobConfig.MR_JOB_END_NOTIFICATION_PROXY, "somehost:1000");
     setConf(conf);
-    assertEquals("HTTP @ somehost:1000", proxyToUse.toString(),
-        "Proxy should have been set but wasn't ");
-    conf.set(MRJobConfig.MR_JOB_END_NOTIFICATION_PROXY, "socks@somehost:1000");
-    setConf(conf);
-    assertEquals("SOCKS @ somehost:1000", proxyToUse.toString(),
-        "Proxy should have been socks but wasn't ");
-    conf.set(MRJobConfig.MR_JOB_END_NOTIFICATION_PROXY, "SOCKS@somehost:1000");
-    setConf(conf);
-    assertEquals("SOCKS @ somehost:1000", proxyToUse.toString(),
-        "Proxy should have been socks but wasn't ");
-    conf.set(MRJobConfig.MR_JOB_END_NOTIFICATION_PROXY, "sfafn@somehost:1000");
-    setConf(conf);
-    assertEquals("HTTP @ somehost:1000", proxyToUse.toString(),
-        "Proxy should have been http but wasn't ");
+    // JDK-8225499. The string format of unresolved address has been changed.
+    if (Shell.isJavaVersionAtLeast(14)) {
+      assertEquals("HTTP @ somehost/<unresolved>:1000", proxyToUse.toString(),
+          "Proxy should have been set but wasn't ");
+      conf.set(MRJobConfig.MR_JOB_END_NOTIFICATION_PROXY, "socks@somehost:1000");
+      setConf(conf);
+      assertEquals("SOCKS @ somehost/<unresolved>:1000", proxyToUse.toString(),
+          "Proxy should have been socks but wasn't ");
+      conf.set(MRJobConfig.MR_JOB_END_NOTIFICATION_PROXY, "SOCKS@somehost:1000");
+      setConf(conf);
+      assertEquals("SOCKS @ somehost/<unresolved>:1000", proxyToUse.toString(),
+          "Proxy should have been socks but wasn't ");
+      conf.set(MRJobConfig.MR_JOB_END_NOTIFICATION_PROXY, "sfafn@somehost:1000");
+      setConf(conf);
+      assertEquals("HTTP @ somehost/<unresolved>:1000", proxyToUse.toString(),
+          "Proxy should have been http but wasn't ");
+    } else {
+      assertEquals("HTTP @ somehost:1000", proxyToUse.toString(),
+          "Proxy should have been set but wasn't ");
+      conf.set(MRJobConfig.MR_JOB_END_NOTIFICATION_PROXY, "socks@somehost:1000");
+      setConf(conf);
+      assertEquals("SOCKS @ somehost:1000", proxyToUse.toString(),
+          "Proxy should have been socks but wasn't ");
+      conf.set(MRJobConfig.MR_JOB_END_NOTIFICATION_PROXY, "SOCKS@somehost:1000");
+      setConf(conf);
+      assertEquals("SOCKS @ somehost:1000", proxyToUse.toString(),
+          "Proxy should have been socks but wasn't ");
+      conf.set(MRJobConfig.MR_JOB_END_NOTIFICATION_PROXY, "sfafn@somehost:1000");
+      setConf(conf);
+      assertEquals("HTTP @ somehost:1000", proxyToUse.toString(),
+          "Proxy should have been http but wasn't ");
+    }
   }
 
   /**