revise tests for new semantics of inheriting locations also allow nulls in the camp objects since they can come in via `{ location: null }`
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/73f7e736 Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/73f7e736 Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/73f7e736 Branch: refs/heads/master Commit: 73f7e736f08cdda287a1a0eb07b2d2da36da5f66 Parents: add81aa Author: Alex Heneveld <alex.henev...@cloudsoftcorp.com> Authored: Thu Jan 14 15:49:52 2016 +0000 Committer: Alex Heneveld <alex.henev...@cloudsoftcorp.com> Committed: Thu Jan 14 15:51:23 2016 +0000 ---------------------------------------------------------------------- .../brooklyn/camp/spi/AbstractResource.java | 3 +- .../brooklyn/camp/spi/pdp/DeploymentPlan.java | 10 ++--- .../interpret/PlanInterpretationContext.java | 4 +- .../interpret/PlanInterpretationNode.java | 16 ++++---- .../camp/brooklyn/AbstractYamlTest.java | 6 ++- .../camp/brooklyn/EntitiesYamlTest.java | 27 +++++++++++- .../camp/brooklyn/LocationsYamlTest.java | 43 ++++++++++---------- .../catalog/CatalogYamlLocationTest.java | 3 +- .../resources/test-entity-basic-template.yaml | 2 +- .../apache/brooklyn/core/entity/Entities.java | 10 +++++ .../core/mgmt/internal/EffectorUtils.java | 3 ++ 11 files changed, 82 insertions(+), 45 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/73f7e736/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/AbstractResource.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/AbstractResource.java b/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/AbstractResource.java index 56a51f4..c24eab1 100644 --- a/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/AbstractResource.java +++ b/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/AbstractResource.java @@ -30,7 +30,6 @@ import org.apache.brooklyn.util.time.Time; import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; /** Superclass of CAMP resource implementation objects. * Typically used to hold common state of implementation objects @@ -91,7 +90,7 @@ public class AbstractResource { return representationSkew; } public Map<String, Object> getCustomAttributes() { - return ImmutableMap.copyOf(customAttributes); + return MutableMap.copyOf(customAttributes).asUnmodifiable(); } // setters http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/73f7e736/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/pdp/DeploymentPlan.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/pdp/DeploymentPlan.java b/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/pdp/DeploymentPlan.java index 792392e..7ad3164 100644 --- a/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/pdp/DeploymentPlan.java +++ b/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/pdp/DeploymentPlan.java @@ -22,13 +22,11 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import org.apache.brooklyn.util.collections.MutableList; import org.apache.brooklyn.util.collections.MutableMap; import org.apache.brooklyn.util.guava.Maybe; import org.apache.commons.lang3.builder.ToStringBuilder; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; - public class DeploymentPlan { String name; @@ -107,15 +105,15 @@ public class DeploymentPlan { } public List<Artifact> getArtifacts() { - return ImmutableList.copyOf(artifacts); + return MutableList.copyOf(artifacts).asUnmodifiable(); } public List<Service> getServices() { - return ImmutableList.copyOf(services); + return MutableList.copyOf(services).asUnmodifiable(); } public Map<String, Object> getCustomAttributes() { - return ImmutableMap.copyOf(customAttributes); + return MutableMap.copyOf(customAttributes).asUnmodifiable(); } /** http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/73f7e736/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/resolve/interpret/PlanInterpretationContext.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/resolve/interpret/PlanInterpretationContext.java b/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/resolve/interpret/PlanInterpretationContext.java index 26822aa..f45d7c6 100644 --- a/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/resolve/interpret/PlanInterpretationContext.java +++ b/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/resolve/interpret/PlanInterpretationContext.java @@ -22,9 +22,9 @@ import java.util.List; import java.util.Map; import org.apache.brooklyn.camp.spi.resolve.PlanInterpreter; +import org.apache.brooklyn.util.collections.MutableMap; import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; public class PlanInterpretationContext { @@ -34,7 +34,7 @@ public class PlanInterpretationContext { public PlanInterpretationContext(Map<String,?> originalDeploymentPlan, List<PlanInterpreter> interpreters) { super(); - this.originalDeploymentPlan = ImmutableMap.copyOf(originalDeploymentPlan); + this.originalDeploymentPlan = MutableMap.copyOf(originalDeploymentPlan).asUnmodifiable(); this.interpreters = ImmutableList.copyOf(interpreters); this.allInterpreter = new PlanInterpreter() { @Override http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/73f7e736/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/resolve/interpret/PlanInterpretationNode.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/resolve/interpret/PlanInterpretationNode.java b/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/resolve/interpret/PlanInterpretationNode.java index 6542b8b..2cf3d5d 100644 --- a/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/resolve/interpret/PlanInterpretationNode.java +++ b/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/resolve/interpret/PlanInterpretationNode.java @@ -27,8 +27,6 @@ import org.apache.brooklyn.util.text.StringPredicates; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; /** Helper class for {@link PlanInterpreter} instances, doing the recursive work */ @@ -228,7 +226,7 @@ public class PlanInterpretationNode { public void immutable() { if (!isChanged()) { - if (!testCollectionImmutable(getNewValue())) { + if (!checkCollectionImmutable(getNewValue())) { // results of Yaml parse are not typically immutable, // so force them to be changed so result of interpretation is immutable changed = true; @@ -242,19 +240,19 @@ public class PlanInterpretationNode { } private void checkImmutable(Object in) { - if (!testCollectionImmutable(in)) + if (!checkCollectionImmutable(in)) log.warn("Node original value "+in+" at "+this+" should be immutable"); } - private static boolean testCollectionImmutable(Object in) { - if (in instanceof Map) return (in instanceof ImmutableMap); - if (in instanceof Iterable) return (in instanceof ImmutableList); + private static boolean checkCollectionImmutable(Object in) { + // not used -- input might now be UnmodifiableMap, as some args might be null, + // and UnmodifiableMap is private :( ... (and same for list) return true; } private static Object immutable(Object in) { - if (in instanceof Map) return ImmutableMap.copyOf((Map<?,?>)in); - if (in instanceof Iterable) return ImmutableList.copyOf((Iterable<?>)in); + if (in instanceof Map) return MutableMap.copyOf((Map<?,?>)in).asUnmodifiable(); + if (in instanceof Iterable) return MutableList.copyOf((Iterable<?>)in).asUnmodifiable(); return in; } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/73f7e736/brooklyn-server/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/AbstractYamlTest.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/AbstractYamlTest.java b/brooklyn-server/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/AbstractYamlTest.java index 909564c..4478f2b 100644 --- a/brooklyn-server/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/AbstractYamlTest.java +++ b/brooklyn-server/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/AbstractYamlTest.java @@ -20,6 +20,7 @@ package org.apache.brooklyn.camp.brooklyn; import java.io.Reader; import java.io.StringReader; +import java.util.Map; import java.util.Set; import org.apache.brooklyn.api.catalog.BrooklynCatalog; @@ -115,11 +116,14 @@ public abstract class AbstractYamlTest { } protected Entity createAndStartApplication(String input) throws Exception { + return createAndStartApplication(input, MutableMap.<String,String>of()); + } + protected Entity createAndStartApplication(String input, Map<String,String> startParameters) throws Exception { EntitySpec<?> spec = mgmt().getTypeRegistry().createSpecFromPlan(CampTypePlanTransformer.FORMAT, input, RegisteredTypeLoadingContexts.spec(Application.class), EntitySpec.class); final Entity app = brooklynMgmt.getEntityManager().createEntity(spec); // start the app (happens automatically if we use camp to instantiate, but not if we use crate spec approach) - app.invoke(Startable.START, MutableMap.<String,String>of()).get(); + app.invoke(Startable.START, startParameters).get(); return app; } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/73f7e736/brooklyn-server/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/EntitiesYamlTest.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/EntitiesYamlTest.java b/brooklyn-server/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/EntitiesYamlTest.java index 8131208..5872995 100644 --- a/brooklyn-server/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/EntitiesYamlTest.java +++ b/brooklyn-server/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/EntitiesYamlTest.java @@ -60,6 +60,8 @@ import org.apache.brooklyn.util.core.task.Tasks; import org.apache.brooklyn.util.exceptions.Exceptions; import org.apache.brooklyn.util.guava.Functionals; import org.apache.brooklyn.util.guava.Maybe; +import org.apache.brooklyn.util.stream.Streams; +import org.apache.brooklyn.util.text.StringEscapes.JavaStringEscapes; import org.apache.brooklyn.util.time.Duration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -592,7 +594,7 @@ public class EntitiesYamlTest extends AbstractYamlTest { Assert.assertEquals(app.getChildren().size(), 1); Entity entity = app.getChildren().iterator().next(); Assert.assertNotNull(entity); - Assert.assertEquals(entity.getLocations().size(), 1); + Assert.assertEquals(entity.getLocations().size(), 0); } @Test @@ -631,7 +633,8 @@ public class EntitiesYamlTest extends AbstractYamlTest { Assert.assertEquals(app.getChildren().size(), 1); Entity entity = app.getChildren().iterator().next(); Assert.assertNotNull(entity); - Assert.assertEquals(entity.getLocations().size(), 2); + // 2016-01 locations now not set on entity unless explicitly passed to "start" + Assert.assertEquals(entity.getLocations().size(), 0); } @Test @@ -666,6 +669,26 @@ public class EntitiesYamlTest extends AbstractYamlTest { Assert.assertEquals(app.getChildren().size(), 1); Entity entity = app.getChildren().iterator().next(); + Assert.assertEquals(entity.getLocations().size(), 1); + Iterator<Location> entityLocationIterator = entity.getLocations().iterator(); + Assert.assertEquals(entityLocationIterator.next().getDisplayName(), "localhost name"); + + Location appLocation = app.getLocations().iterator().next(); + Assert.assertEquals(appLocation.getDisplayName(), "byon name"); + } + + @Test + public void testWithEntityLocationsAndStartInLocation() throws Exception { + Entity app = createAndStartApplication(Streams.readFully(loadYaml("test-entity-basic-template.yaml", + " location: localhost:(name=localhost name)")), + // must pass as JSON list because otherwise the comma confuses the list parser + MutableMap.of("locations", "[ "+JavaStringEscapes.wrapJavaString( + "byon:(hosts=\"1.1.1.1\", name=\"byon name\")")+" ]") ); + waitForApplicationTasks(app); + Assert.assertEquals(app.getLocations().size(), 1); + Assert.assertEquals(app.getChildren().size(), 1); + Entity entity = app.getChildren().iterator().next(); + Assert.assertEquals(entity.getLocations().size(), 2); Iterator<Location> entityLocationIterator = entity.getLocations().iterator(); Assert.assertEquals(entityLocationIterator.next().getDisplayName(), "localhost name"); http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/73f7e736/brooklyn-server/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/LocationsYamlTest.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/LocationsYamlTest.java b/brooklyn-server/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/LocationsYamlTest.java index 269ff16..371a477 100644 --- a/brooklyn-server/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/LocationsYamlTest.java +++ b/brooklyn-server/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/LocationsYamlTest.java @@ -28,15 +28,16 @@ import java.util.List; import org.apache.brooklyn.api.entity.Entity; import org.apache.brooklyn.api.location.Location; import org.apache.brooklyn.api.location.MachineLocation; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.testng.Assert; -import org.testng.annotations.Test; +import org.apache.brooklyn.core.entity.Entities; import org.apache.brooklyn.location.byon.FixedListMachineProvisioningLocation; import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation; import org.apache.brooklyn.location.multi.MultiLocation; import org.apache.brooklyn.location.ssh.SshMachineLocation; import org.apache.brooklyn.util.text.Strings; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.testng.Assert; +import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; @@ -49,7 +50,7 @@ public class LocationsYamlTest extends AbstractYamlTest { String yaml = "location: localhost\n"+ "services:\n"+ - "- serviceType: org.apache.brooklyn.core.test.entity.TestEntity\n"; + "- type: org.apache.brooklyn.core.test.entity.TestEntity\n"; Entity app = createStartWaitAndLogApplication(new StringReader(yaml)); LocalhostMachineProvisioningLocation loc = (LocalhostMachineProvisioningLocation) Iterables.getOnlyElement(app.getLocations()); @@ -61,7 +62,7 @@ public class LocationsYamlTest extends AbstractYamlTest { String yaml = "location: localhost:(name=myname)\n"+ "services:\n"+ - "- serviceType: org.apache.brooklyn.core.test.entity.TestEntity\n"; + "- type: org.apache.brooklyn.core.test.entity.TestEntity\n"; Entity app = createStartWaitAndLogApplication(new StringReader(yaml)); LocalhostMachineProvisioningLocation loc = (LocalhostMachineProvisioningLocation) Iterables.getOnlyElement(app.getLocations()); @@ -74,7 +75,7 @@ public class LocationsYamlTest extends AbstractYamlTest { "location:\n"+ " localhost\n"+ "services:\n"+ - "- serviceType: org.apache.brooklyn.core.test.entity.TestEntity\n"; + "- type: org.apache.brooklyn.core.test.entity.TestEntity\n"; Entity app = createStartWaitAndLogApplication(new StringReader(yaml)); LocalhostMachineProvisioningLocation loc = (LocalhostMachineProvisioningLocation) Iterables.getOnlyElement(app.getLocations()); @@ -88,7 +89,7 @@ public class LocationsYamlTest extends AbstractYamlTest { "- localhost:(name=loc1)\n"+ "- localhost:(name=loc2)\n"+ "services:\n"+ - "- serviceType: org.apache.brooklyn.core.test.entity.TestEntity\n"; + "- type: org.apache.brooklyn.core.test.entity.TestEntity\n"; Entity app = createStartWaitAndLogApplication(new StringReader(yaml)); List<Location> locs = ImmutableList.copyOf(app.getLocations()); @@ -107,7 +108,7 @@ public class LocationsYamlTest extends AbstractYamlTest { " displayName: myname\n"+ " myconfkey: myconfval\n"+ "services:\n"+ - "- serviceType: org.apache.brooklyn.core.test.entity.TestEntity\n"; + "- type: org.apache.brooklyn.core.test.entity.TestEntity\n"; Entity app = createStartWaitAndLogApplication(new StringReader(yaml)); LocalhostMachineProvisioningLocation loc = (LocalhostMachineProvisioningLocation) Iterables.getOnlyElement(app.getLocations()); @@ -126,7 +127,7 @@ public class LocationsYamlTest extends AbstractYamlTest { " displayName: myname2\n"+ " myconfkey: myconfval2\n"+ "services:\n"+ - "- serviceType: org.apache.brooklyn.core.test.entity.TestEntity\n"; + "- type: org.apache.brooklyn.core.test.entity.TestEntity\n"; Entity app = createStartWaitAndLogApplication(new StringReader(yaml)); List<Location> locs = ImmutableList.copyOf(app.getLocations()); @@ -145,7 +146,7 @@ public class LocationsYamlTest extends AbstractYamlTest { String yaml = "location: \n"+ "services:\n"+ - "- serviceType: org.apache.brooklyn.core.test.entity.TestEntity\n"; + "- type: org.apache.brooklyn.core.test.entity.TestEntity\n"; Entity app = createStartWaitAndLogApplication(new StringReader(yaml)); assertTrue(app.getLocations().isEmpty(), "locs="+app.getLocations()); @@ -158,7 +159,7 @@ public class LocationsYamlTest extends AbstractYamlTest { "locations:\n"+ "- localhost\n"+ "services:\n"+ - "- serviceType: org.apache.brooklyn.core.test.entity.TestEntity\n"; + "- type: org.apache.brooklyn.core.test.entity.TestEntity\n"; try { createStartWaitAndLogApplication(new StringReader(yaml)); @@ -174,7 +175,7 @@ public class LocationsYamlTest extends AbstractYamlTest { "location:\n"+ "- localhost\n"+ "services:\n"+ - "- serviceType: org.apache.brooklyn.core.test.entity.TestEntity\n"; + "- type: org.apache.brooklyn.core.test.entity.TestEntity\n"; try { createStartWaitAndLogApplication(new StringReader(yaml)); @@ -189,11 +190,11 @@ public class LocationsYamlTest extends AbstractYamlTest { "locations:\n"+ "- localhost:(name=loc1)\n"+ "services:\n"+ - "- serviceType: org.apache.brooklyn.core.test.entity.TestEntity\n"; + "- type: org.apache.brooklyn.core.test.entity.TestEntity\n"; Entity app = createStartWaitAndLogApplication(new StringReader(yaml)); Entity child = Iterables.getOnlyElement(app.getChildren()); - LocalhostMachineProvisioningLocation loc = (LocalhostMachineProvisioningLocation) Iterables.getOnlyElement(child.getLocations()); + LocalhostMachineProvisioningLocation loc = (LocalhostMachineProvisioningLocation) Iterables.getOnlyElement(Entities.getAllInheritedLocations(child)); assertEquals(loc.getDisplayName(), "loc1"); } @@ -208,11 +209,11 @@ public class LocationsYamlTest extends AbstractYamlTest { " - 127.0.0.1\n"+ " - brooklyn@127.0.0.2\n"+ "services:\n"+ - "- serviceType: org.apache.brooklyn.core.test.entity.TestEntity\n"; + "- type: org.apache.brooklyn.core.test.entity.TestEntity\n"; Entity app = createStartWaitAndLogApplication(new StringReader(yaml)); Entity child = Iterables.getOnlyElement(app.getChildren()); - FixedListMachineProvisioningLocation<?> loc = (FixedListMachineProvisioningLocation<?>) Iterables.getOnlyElement(child.getLocations()); + FixedListMachineProvisioningLocation<?> loc = (FixedListMachineProvisioningLocation<?>) Iterables.getOnlyElement(Entities.getAllInheritedLocations(child)); Assert.assertEquals(loc.getChildren().size(), 2); SshMachineLocation l1 = (SshMachineLocation)loc.obtain(); @@ -229,11 +230,11 @@ public class LocationsYamlTest extends AbstractYamlTest { " user: root\n"+ " hosts: \"{127.0.{0,127}.{1-2},brooklyn@127.0.0.127}\"\n"+ "services:\n"+ - "- serviceType: org.apache.brooklyn.core.test.entity.TestEntity\n"; + "- type: org.apache.brooklyn.core.test.entity.TestEntity\n"; Entity app = createStartWaitAndLogApplication(new StringReader(yaml)); Entity child = Iterables.getOnlyElement(app.getChildren()); - FixedListMachineProvisioningLocation<?> loc = (FixedListMachineProvisioningLocation<?>) Iterables.getOnlyElement(child.getLocations()); + FixedListMachineProvisioningLocation<?> loc = (FixedListMachineProvisioningLocation<?>) Iterables.getOnlyElement(Entities.getAllInheritedLocations(child)); Assert.assertEquals(loc.getChildren().size(), 5); assertUserAddress((SshMachineLocation)loc.obtain(), "root", "127.0.0.1"); @@ -257,11 +258,11 @@ public class LocationsYamlTest extends AbstractYamlTest { " hosts:\n"+ " - 127.0.0.127\n"+ "services:\n"+ - "- serviceType: org.apache.brooklyn.core.test.entity.TestEntity\n"; + "- type: org.apache.brooklyn.core.test.entity.TestEntity\n"; Entity app = createStartWaitAndLogApplication(new StringReader(yaml)); Entity child = Iterables.getOnlyElement(app.getChildren()); - MultiLocation<?> loc = (MultiLocation<?>) Iterables.getOnlyElement(child.getLocations()); + MultiLocation<?> loc = (MultiLocation<?>) Iterables.getOnlyElement(Entities.getAllInheritedLocations(child)); Assert.assertEquals(loc.getSubLocations().size(), 2); assertUserAddress((SshMachineLocation)loc.obtain(), "root", "127.0.0.1"); http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/73f7e736/brooklyn-server/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlLocationTest.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlLocationTest.java b/brooklyn-server/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlLocationTest.java index 47925e5..f792d65 100644 --- a/brooklyn-server/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlLocationTest.java +++ b/brooklyn-server/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlLocationTest.java @@ -32,6 +32,7 @@ import org.apache.brooklyn.api.typereg.OsgiBundleWithUrl; import org.apache.brooklyn.api.typereg.RegisteredType; import org.apache.brooklyn.camp.brooklyn.AbstractYamlTest; import org.apache.brooklyn.core.config.BasicConfigKey; +import org.apache.brooklyn.core.entity.Entities; import org.apache.brooklyn.core.mgmt.osgi.OsgiStandaloneTest; import org.apache.brooklyn.core.typereg.RegisteredTypePredicates; import org.apache.brooklyn.core.typereg.RegisteredTypes; @@ -187,7 +188,7 @@ public class CatalogYamlLocationTest extends AbstractYamlTest { " - type: org.apache.brooklyn.entity.stock.BasicStartable"); Entity simpleEntity = Iterables.getOnlyElement(app.getChildren()); - Location location = Iterables.getOnlyElement(simpleEntity.getLocations()); + Location location = Iterables.getOnlyElement(Entities.getAllInheritedLocations(simpleEntity)); assertEquals(location.getClass().getName(), locType); assertEquals(location.getConfig(new BasicConfigKey<String>(String.class, "config1")), "config1"); assertEquals(location.getConfig(new BasicConfigKey<String>(String.class, "config2")), "config2 override"); http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/73f7e736/brooklyn-server/camp/camp-brooklyn/src/test/resources/test-entity-basic-template.yaml ---------------------------------------------------------------------- diff --git a/brooklyn-server/camp/camp-brooklyn/src/test/resources/test-entity-basic-template.yaml b/brooklyn-server/camp/camp-brooklyn/src/test/resources/test-entity-basic-template.yaml index b690309..7ace993 100644 --- a/brooklyn-server/camp/camp-brooklyn/src/test/resources/test-entity-basic-template.yaml +++ b/brooklyn-server/camp/camp-brooklyn/src/test/resources/test-entity-basic-template.yaml @@ -19,6 +19,6 @@ name: test-entity-basic-template description: TestEntity with templated brooklyn.config and additional config (such as services) origin: https://github.com/apache/incubator-brooklyn services: -- serviceType: org.apache.brooklyn.core.test.entity.TestEntity +- type: org.apache.brooklyn.core.test.entity.TestEntity name: testentity # should have nothing below here as the test appends things underneath http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/73f7e736/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/entity/Entities.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/entity/Entities.java b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/entity/Entities.java index 59e3ec1..9297388 100644 --- a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/entity/Entities.java +++ b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/entity/Entities.java @@ -80,6 +80,7 @@ import org.apache.brooklyn.core.objs.BrooklynObjectInternal; import org.apache.brooklyn.core.objs.proxy.EntityProxyImpl; import org.apache.brooklyn.core.sensor.DependentConfiguration; import org.apache.brooklyn.util.collections.MutableMap; +import org.apache.brooklyn.util.collections.MutableSet; import org.apache.brooklyn.util.core.ResourceUtils; import org.apache.brooklyn.util.core.config.ConfigBag; import org.apache.brooklyn.util.core.flags.FlagUtils; @@ -1183,4 +1184,13 @@ public class Entities { return root; } + public static Set<Location> getAllInheritedLocations(Entity entity) { + Set<Location> result = MutableSet.of(); + while (entity!=null) { + result.addAll(entity.getLocations()); + entity = entity.getParent(); + } + return result; + } + } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/73f7e736/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/EffectorUtils.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/EffectorUtils.java b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/EffectorUtils.java index c6ec3ac..f8bb7cb 100644 --- a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/EffectorUtils.java +++ b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/EffectorUtils.java @@ -149,6 +149,9 @@ public class EffectorUtils { } if (newArgsNeeded>0) throw new IllegalArgumentException("Invalid arguments (missing "+newArgsNeeded+") for effector "+eff+": "+m); + if (!m.isEmpty()) { + log.warn("Unsupported parameter to "+eff+" (ignoring): "+m); + } return newArgs.toArray(new Object[newArgs.size()]); }