hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject hadoop git commit: HADOOP-12449. TestDNS and TestNetUtils failing if no network. (stevel)
Date Tue, 13 Oct 2015 20:12:48 GMT
Repository: hadoop
Updated Branches:
  refs/heads/trunk 7f00fcac7 -> 59e998011


HADOOP-12449. TestDNS and TestNetUtils failing if no network. (stevel)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/59e99801
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/59e99801
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/59e99801

Branch: refs/heads/trunk
Commit: 59e9980117888958714b54bcd5c22e7de879cc83
Parents: 7f00fca
Author: Steve Loughran <stevel@apache.org>
Authored: Tue Oct 13 21:11:31 2015 +0100
Committer: Steve Loughran <stevel@apache.org>
Committed: Tue Oct 13 21:12:08 2015 +0100

----------------------------------------------------------------------
 hadoop-common-project/hadoop-common/CHANGES.txt |  2 ++
 .../java/org/apache/hadoop/net/TestDNS.java     |  5 ++--
 .../org/apache/hadoop/net/TestNetUtils.java     | 26 ++++++++++++++------
 3 files changed, 23 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/59e99801/hadoop-common-project/hadoop-common/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt
index 4447351..9d59c25 100644
--- a/hadoop-common-project/hadoop-common/CHANGES.txt
+++ b/hadoop-common-project/hadoop-common/CHANGES.txt
@@ -1211,6 +1211,8 @@ Release 2.8.0 - UNRELEASED
     HADOOP-12284. UserGroupInformation doAs can throw misleading exception
     (Aaron Dosset via stevel)
 
+    HADOOP-12449. TestDNS and TestNetUtils failing if no network. (stevel)
+
   OPTIMIZATIONS
 
     HADOOP-12051. ProtobufRpcEngine.invoke() should use Exception.toString()

http://git-wip-us.apache.org/repos/asf/hadoop/blob/59e99801/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/net/TestDNS.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/net/TestDNS.java
b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/net/TestDNS.java
index 2a3098a..b26c7ca 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/net/TestDNS.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/net/TestDNS.java
@@ -25,6 +25,7 @@ import java.net.SocketException;
 import java.net.UnknownHostException;
 import java.net.InetAddress;
 
+import javax.naming.CommunicationException;
 import javax.naming.NameNotFoundException;
 
 import org.apache.commons.logging.Log;
@@ -165,8 +166,8 @@ public class TestDNS {
     InetAddress localhost = getLocalIPAddr();
     try {
       String s = DNS.reverseDns(localhost, null);
-      LOG.info("Local revers DNS hostname is " + s);
-    } catch (NameNotFoundException e) {
+      LOG.info("Local reverse DNS hostname is " + s);
+    } catch (NameNotFoundException | CommunicationException e) {
       if (!localhost.isLinkLocalAddress() || localhost.isLoopbackAddress()) {
         //these addresses probably won't work with rDNS anyway, unless someone
         //has unusual entries in their DNS server mapping 1.0.0.127 to localhost

http://git-wip-us.apache.org/repos/asf/hadoop/blob/59e99801/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/net/TestNetUtils.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/net/TestNetUtils.java
b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/net/TestNetUtils.java
index a12054b..c93ede8 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/net/TestNetUtils.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/net/TestNetUtils.java
@@ -615,20 +615,30 @@ public class TestNetUtils {
    * Test for {@link NetUtils#normalizeHostNames}
    */
   @Test
-  public void testNormalizeHostName() {	
-    List<String> hosts = Arrays.asList(new String[] {"127.0.0.1",
-        "localhost", "1.kanyezone.appspot.com", "UnknownHost123"});
+  public void testNormalizeHostName() {
+    String oneHost = "1.kanyezone.appspot.com";
+    try {
+      InetAddress.getByName(oneHost);
+    } catch (UnknownHostException e) {
+      Assume.assumeTrue("Network not resolving "+ oneHost, false);
+    }
+    List<String> hosts = Arrays.asList("127.0.0.1",
+        "localhost", oneHost, "UnknownHost123");
     List<String> normalizedHosts = NetUtils.normalizeHostNames(hosts);
+    String summary = "original [" + StringUtils.join(hosts, ", ") + "]"
+        + " normalized [" + StringUtils.join(normalizedHosts, ", ") + "]";
     // when ipaddress is normalized, same address is expected in return
-    assertEquals(normalizedHosts.get(0), hosts.get(0));
+    assertEquals(summary, hosts.get(0), normalizedHosts.get(0));
     // for normalizing a resolvable hostname, resolved ipaddress is expected in return
-    assertFalse(normalizedHosts.get(1).equals(hosts.get(1)));
-    assertEquals(normalizedHosts.get(1), hosts.get(0));
+    assertFalse("Element 1 equal "+ summary,
+        normalizedHosts.get(1).equals(hosts.get(1)));
+    assertEquals(summary, hosts.get(0), normalizedHosts.get(1));
     // this address HADOOP-8372: when normalizing a valid resolvable hostname start with
numeric, 
     // its ipaddress is expected to return
-    assertFalse(normalizedHosts.get(2).equals(hosts.get(2)));
+    assertFalse("Element 2 equal " + summary,
+        normalizedHosts.get(2).equals(hosts.get(2)));
     // return the same hostname after normalizing a irresolvable hostname.
-    assertEquals(normalizedHosts.get(3), hosts.get(3));
+    assertEquals(summary, hosts.get(3), normalizedHosts.get(3));
   }
   
   @Test


Mime
View raw message