brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sjcorb...@apache.org
Subject [1/9] incubator-brooklyn git commit: Integration test to confirm BindDnsServer entity filter correct
Date Fri, 09 Jan 2015 13:11:45 GMT
Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master 03f019ca9 -> aa317551c


Integration test to confirm BindDnsServer entity filter correct


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

Branch: refs/heads/master
Commit: 1b6ac293ea993a9777ad77b203d96685976c788a
Parents: 7eb1d54
Author: Sam Corbett <sam.corbett@cloudsoftcorp.com>
Authored: Tue Nov 11 13:07:39 2014 +0000
Committer: Sam Corbett <sam.corbett@cloudsoftcorp.com>
Committed: Wed Jan 7 17:14:06 2015 +0000

----------------------------------------------------------------------
 .../entity/network/bind/BindDnsServer.java      |  3 +-
 .../entity/network/bind/BindDnsServerImpl.java  |  8 ++---
 .../bind/BindDnsServerIntegrationTest.java      | 33 ++++++++++++++++++++
 3 files changed, 39 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/1b6ac293/software/network/src/main/java/brooklyn/entity/network/bind/BindDnsServer.java
----------------------------------------------------------------------
diff --git a/software/network/src/main/java/brooklyn/entity/network/bind/BindDnsServer.java
b/software/network/src/main/java/brooklyn/entity/network/bind/BindDnsServer.java
index 0e7e7c1..73a1588 100644
--- a/software/network/src/main/java/brooklyn/entity/network/bind/BindDnsServer.java
+++ b/software/network/src/main/java/brooklyn/entity/network/bind/BindDnsServer.java
@@ -54,7 +54,8 @@ public interface BindDnsServer extends SoftwareProcess {
 
     @SetFromFlag("filter")
     ConfigKey<Predicate<? super Entity>> ENTITY_FILTER = ConfigKeys.newConfigKey(new
TypeToken<Predicate<? super Entity>>() {},
-            "bind.entity.filter", "Filter for entities which will use the BIND DNS service
for name resolution",
+            "bind.entity.filter", "Filter for entities which will use the BIND DNS service
for name resolution." +
+                    "Default is all instances of SoftwareProcess in the application.",
             Predicates.instanceOf(SoftwareProcess.class));
 
     @SetFromFlag("domainName")

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/1b6ac293/software/network/src/main/java/brooklyn/entity/network/bind/BindDnsServerImpl.java
----------------------------------------------------------------------
diff --git a/software/network/src/main/java/brooklyn/entity/network/bind/BindDnsServerImpl.java
b/software/network/src/main/java/brooklyn/entity/network/bind/BindDnsServerImpl.java
index c34ffbf..edfcdea 100644
--- a/software/network/src/main/java/brooklyn/entity/network/bind/BindDnsServerImpl.java
+++ b/software/network/src/main/java/brooklyn/entity/network/bind/BindDnsServerImpl.java
@@ -22,7 +22,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
 
 import java.io.ByteArrayInputStream;
 import java.io.StringReader;
-import java.lang.Long;
 import java.util.Collection;
 import java.util.Map;
 
@@ -56,6 +55,7 @@ import brooklyn.entity.basic.Lifecycle;
 import brooklyn.entity.basic.SoftwareProcessImpl;
 import brooklyn.entity.group.AbstractMembershipTrackingPolicy;
 import brooklyn.entity.proxying.EntitySpec;
+import brooklyn.event.Sensor;
 import brooklyn.location.basic.Machines;
 import brooklyn.location.basic.SshMachineLocation;
 import brooklyn.policy.PolicySpec;
@@ -137,7 +137,7 @@ public class BindDnsServerImpl extends SoftwareProcessImpl implements
BindDnsSer
         super.init();
         checkNotNull(getConfig(HOSTNAME_SENSOR), "{} requires value for {}", getClass().getName(),
HOSTNAME_SENSOR);
         DynamicGroup entities = addChild(EntitySpec.create(DynamicGroup.class)
-                .configure("entityFilter", getConfig(ENTITY_FILTER)));
+                .configure(DynamicGroup.ENTITY_FILTER, getConfig(ENTITY_FILTER)));
         setAttribute(ENTITIES, entities);
         setAttribute(A_RECORDS, ImmutableMap.<String, String>of());
         setAttribute(CNAME_RECORDS, ImmutableMultimap.<String, String>of());
@@ -193,8 +193,8 @@ public class BindDnsServerImpl extends SoftwareProcessImpl implements
BindDnsSer
 
         addPolicy(PolicySpec.create(MemberTrackingPolicy.class)
                 .displayName("Address tracker")
-                .configure("sensorsToTrack", ImmutableSet.of(getConfig(HOSTNAME_SENSOR)))
-                .configure("group", getEntities()));
+                .configure(AbstractMembershipTrackingPolicy.SENSORS_TO_TRACK, ImmutableSet.<Sensor<?>>of(getConfig(HOSTNAME_SENSOR)))
+                .configure(AbstractMembershipTrackingPolicy.GROUP, getEntities()));
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/1b6ac293/software/network/src/test/java/brooklyn/entity/network/bind/BindDnsServerIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/network/src/test/java/brooklyn/entity/network/bind/BindDnsServerIntegrationTest.java
b/software/network/src/test/java/brooklyn/entity/network/bind/BindDnsServerIntegrationTest.java
index d354e6e..0305727 100644
--- a/software/network/src/test/java/brooklyn/entity/network/bind/BindDnsServerIntegrationTest.java
+++ b/software/network/src/test/java/brooklyn/entity/network/bind/BindDnsServerIntegrationTest.java
@@ -92,6 +92,39 @@ public class BindDnsServerIntegrationTest extends RebindTestFixture<TestApplicat
     }
 
     @Test(groups = "Integration")
+    public void testCanConfigureToListenToChildrenOfEntityOtherThanParent() {
+        // Ignoring origApp
+        TestApplication app = ApplicationBuilder.newManagedApp(TestApplication.class, origManagementContext);
+
+        EnricherSpec<PrefixAndIdEnricher> dnsEnricher = EnricherSpec.create(PrefixAndIdEnricher.class)
+                .configure(PrefixAndIdEnricher.PREFIX, "dns-integration-test-")
+                .configure(PrefixAndIdEnricher.MONITOR, Attributes.HOSTNAME);
+        EntitySpec<EmptySoftwareProcess> emptySoftwareProcessSpec = EntitySpec.create(EmptySoftwareProcess.class)
+                .enricher(dnsEnricher);
+
+        // App DNS will listen to
+        cluster = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
+                .configure(DynamicCluster.MEMBER_SPEC, emptySoftwareProcessSpec)
+                .configure(DynamicCluster.INITIAL_SIZE, 3));
+
+        // Apps that DNS should not listen to. Appreciate that their having dnsEnricher is
unrealistic!
+        app.createAndManageChild(emptySoftwareProcessSpec);
+        app.createAndManageChild(emptySoftwareProcessSpec);
+
+        Predicate<Entity> entityFilter = Predicates.and(
+                Predicates.instanceOf(EmptySoftwareProcess.class),
+                EntityPredicates.isChildOf(cluster));
+        dns = app.createAndManageChild(EntitySpec.create(BindDnsServer.class, TestBindDnsServerImpl.class)
+                .configure(BindDnsServer.ENTITY_FILTER, entityFilter)
+                .configure(BindDnsServer.HOSTNAME_SENSOR, PrefixAndIdEnricher.SENSOR));
+
+        app.start(ImmutableList.of(app.newLocalhostProvisioningLocation()));
+        logDnsMappings();
+        assertEquals(dns.getAttribute(BindDnsServer.ADDRESS_MAPPINGS).keySet().size(), 1);
+        assertMapSizes(3, 1, 2, 1);
+    }
+
+    @Test(invocationCount=1, groups = "Integration")
     public void testRebindDns() throws Throwable {
         origApp.start(ImmutableList.of(origApp.newLocalhostProvisioningLocation()));
         logDnsMappings();


Mime
View raw message