You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whirr.apache.org by to...@apache.org on 2010/12/21 21:11:53 UTC

svn commit: r1051633 - in /incubator/whirr/trunk: CHANGES.txt core/src/main/java/org/apache/whirr/net/DnsUtil.java core/src/test/java/org/apache/whirr/net/integration/DnsUtilTest.java

Author: tomwhite
Date: Tue Dec 21 20:11:53 2010
New Revision: 1051633

URL: http://svn.apache.org/viewvc?rev=1051633&view=rev
Log:
WHIRR-162. DnsUtilTest fails when offline or for slow connections. Contributed by Andrei Savu.

Modified:
    incubator/whirr/trunk/CHANGES.txt
    incubator/whirr/trunk/core/src/main/java/org/apache/whirr/net/DnsUtil.java
    incubator/whirr/trunk/core/src/test/java/org/apache/whirr/net/integration/DnsUtilTest.java

Modified: incubator/whirr/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/CHANGES.txt?rev=1051633&r1=1051632&r2=1051633&view=diff
==============================================================================
--- incubator/whirr/trunk/CHANGES.txt (original)
+++ incubator/whirr/trunk/CHANGES.txt Tue Dec 21 20:11:53 2010
@@ -53,6 +53,9 @@ Trunk (unreleased changes)
     WHIRR-156. Cli script doesn't launch post-modularization. (Andrei Savu and
     tomwhite via tomwhite)
 
+    WHIRR-162. DnsUtilTest fails when offline or for slow connections.
+    (Andrei Savu via tomwhite)
+
 Release 0.2.0 - 2010-11-04
 
   NEW FEATURES

Modified: incubator/whirr/trunk/core/src/main/java/org/apache/whirr/net/DnsUtil.java
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/core/src/main/java/org/apache/whirr/net/DnsUtil.java?rev=1051633&r1=1051632&r2=1051633&view=diff
==============================================================================
--- incubator/whirr/trunk/core/src/main/java/org/apache/whirr/net/DnsUtil.java (original)
+++ incubator/whirr/trunk/core/src/main/java/org/apache/whirr/net/DnsUtil.java Tue Dec 21 20:11:53 2010
@@ -41,6 +41,7 @@ public class DnsUtil {
    */
   public static String resolveAddress(String hostIp) throws IOException {
     Resolver res = new ExtendedResolver();
+    res.setTimeout(5); // seconds
 
     Name name = ReverseMap.fromAddress(hostIp);
     int type = Type.PTR;

Modified: incubator/whirr/trunk/core/src/test/java/org/apache/whirr/net/integration/DnsUtilTest.java
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/core/src/test/java/org/apache/whirr/net/integration/DnsUtilTest.java?rev=1051633&r1=1051632&r2=1051633&view=diff
==============================================================================
--- incubator/whirr/trunk/core/src/test/java/org/apache/whirr/net/integration/DnsUtilTest.java (original)
+++ incubator/whirr/trunk/core/src/test/java/org/apache/whirr/net/integration/DnsUtilTest.java Tue Dec 21 20:11:53 2010
@@ -49,10 +49,10 @@ public class DnsUtilTest {
           long end = System.currentTimeMillis();
           // we know that java.net.InetAddress's getHostName takes > 4.5s if
           // there is no reverse address assigned to it
-          // but DnsUtil can resolve any address without this delaying problem.
+          // DnsUtil should resolve any address in less than 5 seconds or fail
           assertTrue("DnsUtil.resolveAddress takes " + (end - start)
-              + " millis, it should be shorter than a second",
-              end - start < 1000);
+              + " millis, it should be shorter than five seconds",
+              end - start < 5000);
           if (inetAddress.toString().substring(1).equals(reverse)) {
             out.printf(
                 "InetAddress %s on interface %s does not have reverse dns name, so their reverse remains: %s\n",