brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aleds...@apache.org
Subject [7/9] git commit: Attempt fix for GeoscalingIntegrationTest
Date Fri, 31 Oct 2014 14:10:12 GMT
Attempt fix for GeoscalingIntegrationTest

- Fails in jenkins but nowhere else (not even on same machine)
- Add more logging to GeoscalingIntegrationTest.StubHostGeoLookup
- Tidy up AbstractGeoDnsServiceImpl.inferHostGeoInfo: use
  Networking.getInetAddressWithFixedName even for hostname, in case
  the hostname is an IP for that entity!


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/56bd68e0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/56bd68e0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/56bd68e0

Branch: refs/heads/master
Commit: 56bd68e03839b13b3de8bceb2775feb4eb854c43
Parents: 77f68cf
Author: Aled Sage <aled.sage@gmail.com>
Authored: Fri Oct 31 12:26:36 2014 +0000
Committer: Aled Sage <aled.sage@gmail.com>
Committed: Fri Oct 31 14:08:03 2014 +0000

----------------------------------------------------------------------
 .../entity/dns/AbstractGeoDnsServiceImpl.java   | 27 ++++++++++++--------
 .../geoscaling/GeoscalingIntegrationTest.java   | 18 ++++++++++---
 2 files changed, 30 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/56bd68e0/software/webapp/src/main/java/brooklyn/entity/dns/AbstractGeoDnsServiceImpl.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/dns/AbstractGeoDnsServiceImpl.java
b/software/webapp/src/main/java/brooklyn/entity/dns/AbstractGeoDnsServiceImpl.java
index 4c66e5d..195020e 100644
--- a/software/webapp/src/main/java/brooklyn/entity/dns/AbstractGeoDnsServiceImpl.java
+++ b/software/webapp/src/main/java/brooklyn/entity/dns/AbstractGeoDnsServiceImpl.java
@@ -49,6 +49,7 @@ import brooklyn.entity.webapp.WebAppService;
 import brooklyn.location.geo.HostGeoInfo;
 import brooklyn.policy.PolicySpec;
 import brooklyn.util.collections.MutableSet;
+import brooklyn.util.exceptions.Exceptions;
 import brooklyn.util.flags.SetFromFlag;
 import brooklyn.util.net.Networking;
 import brooklyn.util.time.Duration;
@@ -335,17 +336,21 @@ public abstract class AbstractGeoDnsServiceImpl extends AbstractEntity
implement
     }
     
     protected HostGeoInfo inferHostGeoInfo(String hostname, String ip) throws UnknownHostException
{
-        // Look up the geo-info from the hostname/ip
-        HostGeoInfo geoH;
-        try {
-            InetAddress addr = (hostname == null) ? null : InetAddress.getByName(hostname);
-            geoH = (addr == null) ? null : HostGeoInfo.fromIpAddress(addr);
-        } catch (UnknownHostException e) {
-            if (ip == null) {
-                throw e;
-            } else {
-                if (log.isTraceEnabled()) log.trace("GeoDns failed to infer GeoInfo from
hostname {}; will try with IP {} ({})", new Object[] {hostname, ip, e});
-                geoH = null;
+        HostGeoInfo geoH = null;
+        if (hostname != null) {
+            try {
+                // For some entities, the hostname can actually be an IP! Therefore use Networking.getInetAddressWithFixedName
+                InetAddress addr = Networking.getInetAddressWithFixedName(hostname);
+                geoH = HostGeoInfo.fromIpAddress(addr);
+            } catch (RuntimeException e) {
+                // Most likely caused by (a wrapped) UnknownHostException
+                Exceptions.propagateIfFatal(e);
+                if (ip == null) {
+                    if (log.isTraceEnabled()) log.trace("inferHostGeoInfo failing ("+Exceptions.getFirstInteresting(e)+"):
hostname="+hostname+"; ip="+ip);
+                    throw e;
+                } else {
+                    if (log.isTraceEnabled()) log.trace("GeoDns failed to infer GeoInfo from
hostname {}; will try with IP {} ({})", new Object[] {hostname, ip, e});
+                }
             }
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/56bd68e0/software/webapp/src/test/java/brooklyn/entity/dns/geoscaling/GeoscalingIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/dns/geoscaling/GeoscalingIntegrationTest.java
b/software/webapp/src/test/java/brooklyn/entity/dns/geoscaling/GeoscalingIntegrationTest.java
index 6359d94..89b5f5e 100644
--- a/software/webapp/src/test/java/brooklyn/entity/dns/geoscaling/GeoscalingIntegrationTest.java
+++ b/software/webapp/src/test/java/brooklyn/entity/dns/geoscaling/GeoscalingIntegrationTest.java
@@ -44,6 +44,7 @@ import brooklyn.test.Asserts;
 import brooklyn.test.entity.TestApplication;
 import brooklyn.test.entity.TestEntity;
 import brooklyn.util.collections.MutableMap;
+import brooklyn.util.exceptions.Exceptions;
 import brooklyn.util.internal.BrooklynSystemProperties;
 import brooklyn.util.net.Networking;
 
@@ -190,10 +191,19 @@ public class GeoscalingIntegrationTest {
 
         @Override
         public HostGeoInfo getHostGeoInfo(InetAddress address) throws Exception {
-            if (HOMELESS_IP.equals(address.getHostAddress())) {
-                return null;
-            } else {
-                return delegate.getHostGeoInfo(address);
+            // Saw strange test failure on jenkins: hence paranoid logging, just in case
exception is swallowed somehow.
+            try {
+                HostGeoInfo result;
+                if (HOMELESS_IP.equals(address.getHostAddress())) {
+                    result = null;
+                } else {
+                    result = delegate.getHostGeoInfo(address);
+                }
+                LOG.info("StubHostGeoLookup.getHostGeoInfo queried: address="+address+";
hostAddress="+address.getHostAddress()+"; result="+result);
+                return result;
+            } catch (Throwable t) {
+                LOG.error("StubHostGeoLookup.getHostGeoInfo encountered problem (rethrowing):
address="+address+"; hostAddress="+address.getHostAddress(), t);
+                throw Exceptions.propagate(t);
             }
         }
     }


Mime
View raw message