You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2016/01/15 00:54:22 UTC
[08/24] incubator-brooklyn git commit: enable and fix test for yaml
source being set correctly
enable and fix test for yaml source being set correctly
also transfer catalog item id and test for that
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/649a08d6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/649a08d6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/649a08d6
Branch: refs/heads/master
Commit: 649a08d614d8afb9404e45c17f4adaeacd6db4d1
Parents: 0781c10
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Wed Jan 13 22:58:16 2016 +0000
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Wed Jan 13 22:58:16 2016 +0000
----------------------------------------------------------------------
.../BrooklynComponentTemplateResolver.java | 3 ++-
.../catalog/CatalogYamlTemplateTest.java | 28 +++++++++++---------
.../core/mgmt/EntityManagementUtils.java | 16 ++++++++---
3 files changed, 30 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/649a08d6/brooklyn-server/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/BrooklynComponentTemplateResolver.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/BrooklynComponentTemplateResolver.java b/brooklyn-server/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/BrooklynComponentTemplateResolver.java
index e930635..b1a4764 100644
--- a/brooklyn-server/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/BrooklynComponentTemplateResolver.java
+++ b/brooklyn-server/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/BrooklynComponentTemplateResolver.java
@@ -212,8 +212,9 @@ public class BrooklynComponentTemplateResolver {
}
}
- if (source!=null)
+ if (source!=null) {
spec.tag(BrooklynTags.newYamlSpecTag(source));
+ }
if (!Strings.isBlank(name))
spec.displayName(name);
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/649a08d6/brooklyn-server/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlTemplateTest.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlTemplateTest.java b/brooklyn-server/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlTemplateTest.java
index 06ac681..165fd49 100644
--- a/brooklyn-server/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlTemplateTest.java
+++ b/brooklyn-server/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlTemplateTest.java
@@ -192,18 +192,22 @@ public class CatalogYamlTemplateTest extends AbstractYamlTest {
assertTrue(t1 instanceof TestEntity);
}
- // XXX this should be made to work!
-// @Test
-// public void testPlanYamlTagOnSpecFromItem() throws Exception {
-// makeItem();
-// EntitySpec<? extends Application> spec = EntityManagementUtils.createEntitySpecForApplication(mgmt(),
-// "services: [ { type: t1 } ]\n" +
-// "location: localhost");
-// List<NamedStringTag> yamls = BrooklynTags.findAll(BrooklynTags.YAML_SPEC_KIND, spec.getTags());
-// Assert.assertEquals(yamls.size(), 1, "Expected 1 yaml tag; instead had: "+yamls);
-// String yaml = Iterables.getOnlyElement(yamls).getContents();
-// Asserts.assertStringContains(yaml, "services:", "t1", "localhost");
-// }
+ @Test
+ public void testMetadataOnSpecCreatedFromItem() throws Exception {
+ makeItem();
+ EntitySpec<? extends Application> spec = EntityManagementUtils.createEntitySpecForApplication(mgmt(),
+ "services: [ { type: t1 } ]\n" +
+ "location: localhost");
+
+ List<NamedStringTag> yamls = BrooklynTags.findAll(BrooklynTags.YAML_SPEC_KIND, spec.getTags());
+ Assert.assertEquals(yamls.size(), 1, "Expected 1 yaml tag; instead had: "+yamls);
+ String yaml = Iterables.getOnlyElement(yamls).getContents();
+ Asserts.assertStringContains(yaml, "services:", "t1", "localhost");
+
+ EntitySpec<?> child = Iterables.getOnlyElement( spec.getChildren() );
+ Assert.assertEquals(child.getType().getName(), SIMPLE_ENTITY_TYPE);
+ Assert.assertEquals(child.getCatalogItemId(), "t1:"+TEST_VERSION);
+ }
private RegisteredType makeItem() {
TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_PATH);
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/649a08d6/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/mgmt/EntityManagementUtils.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/mgmt/EntityManagementUtils.java b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/mgmt/EntityManagementUtils.java
index 4b6b8ce..d0f5b14 100644
--- a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/mgmt/EntityManagementUtils.java
+++ b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/mgmt/EntityManagementUtils.java
@@ -245,13 +245,18 @@ public class EntityManagementUtils {
* for use when unwrapping specific children, but a name or other item may have been set on the parent.
* See {@link #WRAPPER_APP_MARKER}. */
private static void mergeWrapperParentSpecToChildEntity(EntitySpec<? extends Application> wrapperParent, EntitySpec<?> wrappedChild) {
- if (Strings.isNonEmpty(wrapperParent.getDisplayName()))
+ if (Strings.isNonEmpty(wrapperParent.getDisplayName())) {
wrappedChild.displayName(wrapperParent.getDisplayName());
- if (!wrapperParent.getLocations().isEmpty())
+ }
+ if (!wrapperParent.getLocations().isEmpty()) {
wrappedChild.locations(wrapperParent.getLocations());
+ }
if (!wrapperParent.getParameters().isEmpty()) {
wrappedChild.parameters(wrapperParent.getParameters());
}
+ if (wrappedChild.getCatalogItemId()==null) {
+ wrappedChild.catalogItemId(wrapperParent.getCatalogItemId());
+ }
// NB: this clobbers child config; might prefer to deeply merge maps etc
// (but this should not be surprising, as unwrapping is often parameterising the nested blueprint, so outer config should dominate)
@@ -259,8 +264,11 @@ public class EntityManagementUtils {
wrappedChild.configure(configWithoutWrapperMarker);
wrappedChild.configure(wrapperParent.getFlags());
- // TODO copying tags to all entities is not ideal;
- // in particular the BrooklynTags.YAML_SPEC tag will show all entities if the root has multiple
+ // copying tags to all entities may be something the caller wants to control,
+ // e.g. if we're creating a list of entities which will be added,
+ // ignoring the parent Application holder;
+ // in that case each child's BrooklynTags.YAML_SPEC tag will show all entities;
+ // but in the normal case where we're unwrapping one, it's probably right.
wrappedChild.tags(wrapperParent.getTags());
}