You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by al...@apache.org on 2014/11/03 15:24:56 UTC

[4/9] git commit: Fix GeoscalingIntegrationTest

Fix GeoscalingIntegrationTest

- need to clear HostGeoInfo.cachedLookup, otherwise will keep
  using previous HostGeoLookup rather than StubHostGeoLookup

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

Branch: refs/heads/master
Commit: f579b76f31b8d1124a8f7930e73a675a9e24d4c7
Parents: a9d97fa
Author: Aled Sage <al...@gmail.com>
Authored: Mon Nov 3 11:23:32 2014 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Mon Nov 3 11:23:32 2014 +0000

----------------------------------------------------------------------
 .../main/java/brooklyn/location/geo/HostGeoInfo.java |  4 ++++
 .../dns/geoscaling/GeoscalingIntegrationTest.java    | 15 ++++++++-------
 2 files changed, 12 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f579b76f/core/src/main/java/brooklyn/location/geo/HostGeoInfo.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/location/geo/HostGeoInfo.java b/core/src/main/java/brooklyn/location/geo/HostGeoInfo.java
index 028dcc4..137f873 100644
--- a/core/src/main/java/brooklyn/location/geo/HostGeoInfo.java
+++ b/core/src/main/java/brooklyn/location/geo/HostGeoInfo.java
@@ -81,6 +81,10 @@ public class HostGeoInfo implements Serializable {
         return cachedLookup.get();
     }
     
+    public static void clearCachedLookup() {
+        cachedLookup = null;
+    }
+    
     /** returns null if cannot be set */
     public static HostGeoInfo fromLocation(Location l) {
         if (l==null) return null;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f579b76f/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 89b5f5e..53961b4 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
@@ -76,7 +76,8 @@ public class GeoscalingIntegrationTest {
     @BeforeMethod(alwaysRun=true)
     public void setUp() throws Exception {
         origGeoLookupImpl = BrooklynSystemProperties.HOST_GEO_LOOKUP_IMPL.getValue();
-        
+        HostGeoInfo.clearCachedLookup();
+
         app = TestApplication.Factory.newManagedInstanceForTests();
         mgmt = app.getManagementContext();
         
@@ -113,6 +114,7 @@ public class GeoscalingIntegrationTest {
             System.clearProperty(BrooklynSystemProperties.HOST_GEO_LOOKUP_IMPL.getPropertyName());
         }
         if (mgmt != null) Entities.destroyAll(mgmt);
+        HostGeoInfo.clearCachedLookup();
     }
     
     @Test(groups={"Integration"})
@@ -130,13 +132,14 @@ public class GeoscalingIntegrationTest {
     }
     
     @Test(groups={"Integration"})
-    public void testIgnoresAddressWithoutGeography() {
+    public void testIgnoresAddressWithoutGeography() throws Exception {
         System.setProperty(BrooklynSystemProperties.HOST_GEO_LOOKUP_IMPL.getPropertyName(), StubHostGeoLookup.class.getName());
-        target.setAttribute(Attributes.HOSTNAME, StubHostGeoLookup.HOMELESS_IP);
+        ((EntityLocal)geoDns).setConfig(GeoscalingDnsService.INCLUDE_HOMELESS_ENTITIES, false); // false is default
         
         app.start(ImmutableList.of(locWithoutGeo));
+        target.setAttribute(Attributes.HOSTNAME, StubHostGeoLookup.HOMELESS_IP);
         
-        LOG.info("geo-scaling test, using {}.{}; expect to be wired to {}", new Object[] {subDomain, primaryDomain, addrWithoutGeo});
+        LOG.info("geo-scaling test, using {}.{}; expect not to be wired to {}", new Object[] {subDomain, primaryDomain, addrWithoutGeo});
         
         Asserts.succeedsContinually(MutableMap.of("timeout", 10*1000), new Runnable() {
             @Override public void run() {
@@ -149,14 +152,12 @@ public class GeoscalingIntegrationTest {
     public void testIncludesAddressWithoutGeography() {
         System.setProperty(BrooklynSystemProperties.HOST_GEO_LOOKUP_IMPL.getPropertyName(), StubHostGeoLookup.class.getName());
         ((EntityLocal)geoDns).setConfig(GeoscalingDnsService.INCLUDE_HOMELESS_ENTITIES, true);
-        //target.setAttribute(Attributes.HOSTNAME, StubHostGeoLookup.HOMELESS_IP);
         
         app.start(ImmutableList.of(locWithoutGeo));
+        target.setAttribute(Attributes.HOSTNAME, StubHostGeoLookup.HOMELESS_IP);
         
         LOG.info("geo-scaling test, using {}.{}; expect to be wired to {}", new Object[] {subDomain, primaryDomain, addrWithoutGeo});
         
-        target.setAttribute(Attributes.HOSTNAME, StubHostGeoLookup.HOMELESS_IP);
-        
         assertTargetHostsEventually(geoDns, 1);
     }