You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by sv...@apache.org on 2016/09/05 14:43:29 UTC
[1/2] brooklyn-server git commit: A test to illustrate a failing case
where cross-referencing catalog items fails.
Repository: brooklyn-server
Updated Branches:
refs/heads/master b68f6f840 -> 0188f9657
A test to illustrate a failing case where cross-referencing catalog items fails.
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/61550529
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/61550529
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/61550529
Branch: refs/heads/master
Commit: 61550529c1514d1ff2ac0b183b5aa22a3fe45d6d
Parents: 917e101
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Authored: Mon Apr 25 16:57:30 2016 +0300
Committer: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Committed: Mon Sep 5 17:37:38 2016 +0300
----------------------------------------------------------------------
.../brooklyn/catalog/CatalogYamlEntityTest.java | 23 ++++++++++++++++++++
1 file changed, 23 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/61550529/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlEntityTest.java
----------------------------------------------------------------------
diff --git a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlEntityTest.java b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlEntityTest.java
index 38e2941..dda3c32 100644
--- a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlEntityTest.java
+++ b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlEntityTest.java
@@ -38,6 +38,7 @@ import org.apache.brooklyn.core.mgmt.osgi.OsgiStandaloneTest;
import org.apache.brooklyn.core.test.entity.TestEntity;
import org.apache.brooklyn.core.test.entity.TestEntityImpl;
import org.apache.brooklyn.core.typereg.RegisteredTypes;
+import org.apache.brooklyn.entity.stock.BasicApplication;
import org.apache.brooklyn.entity.stock.BasicEntity;
import org.apache.brooklyn.test.support.TestResourceUnavailableException;
import org.apache.brooklyn.util.collections.MutableList;
@@ -803,6 +804,28 @@ public class CatalogYamlEntityTest extends AbstractYamlTest {
"- type: cluster",
"- type: vanilla");
}
+
+ @Test(groups = "Broken")
+ public void testSameCatalogReferences() {
+ addCatalogItems(
+ "brooklyn.catalog:",
+ " items:",
+ " - id: referenced-entity",
+ " item:",
+ " services:",
+ " - type: " + BasicEntity.class.getName(),
+ " - id: referrer-entity",
+ " item:",
+ " services:",
+ " - type: " + BasicApplication.class.getName(),
+ " brooklyn.children:",
+ " - type: referenced-entity",
+ " brooklyn.config:",
+ " spec: ",
+ " $brooklyn:entitySpec:",
+ " type: referenced-entity");
+
+ }
private void registerAndLaunchAndAssertSimpleEntity(String symbolicName, String serviceType) throws Exception {
addCatalogOSGiEntity(symbolicName, serviceType);
[2/2] brooklyn-server git commit: Closes #125
Posted by sv...@apache.org.
Closes #125
[BROOKLYN-343] A test to illustrate a failing case where cross-referencing catalog items fails
On the other hand removing `services` works just fine.
The problem is that the camp parser doesn't see items which are in the same catalog and already parsed. Only already added items are visible. The catalog parsers does a poor-man's validation on the top level items only, we need to replace that with the normal CAMP parser workflow, but able to see items in the current catalog preceding the current item.
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/0188f965
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/0188f965
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/0188f965
Branch: refs/heads/master
Commit: 0188f9657cf7aecc7eaa79e47230b91718286ef8
Parents: b68f6f8 6155052
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Authored: Mon Sep 5 17:42:47 2016 +0300
Committer: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Committed: Mon Sep 5 17:42:47 2016 +0300
----------------------------------------------------------------------
.../brooklyn/catalog/CatalogYamlEntityTest.java | 22 ++++++++++++++++++++
1 file changed, 22 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/0188f965/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlEntityTest.java
----------------------------------------------------------------------
diff --cc camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlEntityTest.java
index ea62643,dda3c32..a0f59d7
--- a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlEntityTest.java
+++ b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlEntityTest.java
@@@ -821,148 -804,29 +821,170 @@@ public class CatalogYamlEntityTest exte
"- type: cluster",
"- type: vanilla");
}
+
+ @Test(groups = "Broken")
+ public void testSameCatalogReferences() {
+ addCatalogItems(
+ "brooklyn.catalog:",
+ " items:",
+ " - id: referenced-entity",
+ " item:",
+ " services:",
+ " - type: " + BasicEntity.class.getName(),
+ " - id: referrer-entity",
+ " item:",
+ " services:",
+ " - type: " + BasicApplication.class.getName(),
+ " brooklyn.children:",
+ " - type: referenced-entity",
+ " brooklyn.config:",
+ " spec: ",
+ " $brooklyn:entitySpec:",
+ " type: referenced-entity");
+
+ }
+ @Test
+ public void testItemWithBrooklynParameters() throws Exception {
+ String id = "inline_version.app";
+ String version = TEST_VERSION;
+ addCatalogItems(
+ "brooklyn.catalog:",
+ " id: " + id,
+ " version: " + TEST_VERSION,
+ " itemType: entity",
+ " item:",
+ " type: " + BasicApplication.class.getName(),
+ " brooklyn.parameters:",
+ " - name: test.myconf",
+ " type: string",
+ " default: myval",
+ " brooklyn.config:",
+ " myconf2: $brooklyn:config(\"test.myconf\")",
+ " myconf2.from.root: $brooklyn:root().config(\"test.myconf\")",
+ " brooklyn.children:",
+ " - type: "+BasicEntity.class.getName(),
+ " brooklyn.config:",
+ " myconf3: $brooklyn:config(\"test.myconf\")",
+ " myconf3.from.root: $brooklyn:root().config(\"test.myconf\")");
+
+ RegisteredType catalogItem = mgmt().getTypeRegistry().get(id, version);
+ assertEquals(catalogItem.getVersion(), version);
+
+ String yaml = Joiner.on("\n").join(
+ "name: simple-app-yaml",
+ "location: localhost",
+ "services:",
+ " - type: "+id+":"+version);
+ Entity app = createAndStartApplication(yaml);
+ Entity child = Iterables.getOnlyElement(app.getChildren());
+ ConfigKey<?> configKey = app.getEntityType().getConfigKey("test.myconf");
+ assertNotNull(configKey);
+ assertEquals(app.config().get(configKey), "myval");
+ assertEquals(app.config().get(ConfigKeys.newStringConfigKey("myconf2.from.root")), "myval");
+ assertEquals(child.config().get(ConfigKeys.newStringConfigKey("myconf3.from.root")), "myval");
+ assertEquals(app.config().get(ConfigKeys.newStringConfigKey("myconf2")), "myval");
+
+ // TODO Because of https://issues.apache.org/jira/browse/BROOKLYN-267, the assertion below fails:
+ // assertEquals(child.config().get(ConfigKeys.newStringConfigKey("myconf3")), "myval");
+
+ mgmt().getCatalog().deleteCatalogItem(id, version);
+ }
+
+ @Test
+ public void testCreateOsgiSpecFromRegistry() throws Exception {
+ TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_PATH);
+
+ String symbolicName = "my.catalog.app.id.registry.spec";
+ addCatalogItems(
+ "brooklyn.catalog:",
+ " id: " + symbolicName,
+ " name: My Catalog App",
+ " description: My description",
+ " icon_url: classpath://path/to/myicon.jpg",
+ " version: " + TEST_VERSION,
+ " libraries:",
+ " - url: " + OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_URL,
+ " item: " + SIMPLE_ENTITY_TYPE);
+
+ BrooklynTypeRegistry registry = mgmt().getTypeRegistry();
+ RegisteredType item = registry.get(symbolicName, TEST_VERSION);
+ AbstractBrooklynObjectSpec<?, ?> spec = registry.createSpec(item, null, null);
+ assertEquals(spec.getCatalogItemId(), ver(symbolicName));
+
+ deleteCatalogEntity(symbolicName);
+ }
+
+ @Test
+ public void testIndirectCatalogItemCanLoadResources() throws Exception {
+ TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_PATH);
+
+ String symbolicNameInner = "my.catalog.app.id.inner";
+ String symbolicNameOuter = "my.catalog.app.id.outer";
+ addCatalogItems(
+ "brooklyn.catalog:",
+ " version: " + TEST_VERSION,
+ " items:",
+ " - id: " + symbolicNameInner,
+ " name: My Catalog App",
+ " description: My description",
+ " icon_url: classpath://path/to/myicon.jpg",
+ " libraries:",
+ " - url: " + OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_URL,
+ " item: " + SIMPLE_ENTITY_TYPE,
+ " - id: " + symbolicNameOuter,
+ " item: " + symbolicNameInner);
+
+ String yaml = "name: " + symbolicNameOuter + "\n" +
+ "services: \n" +
+ " - serviceType: "+ver(symbolicNameOuter);
+ Entity app = createAndStartApplication(yaml);
+ Entity entity = app.getChildren().iterator().next();
+
+ ResourceUtils.create(entity).getResourceAsString("classpath://yaml-ref-osgi-entity.yaml");
+
+ deleteCatalogEntity(symbolicNameInner);
+ deleteCatalogEntity(symbolicNameOuter);
+ }
+
+ // The test is disabled as it fails. The entity will get assigned the outer-most catalog
+ // item which doesn't have the necessary libraries with visibility to the entity's classpath
+ // When loading resources from inside the entity then we will use the wrong BCLCS. A workaround
+ // has been implemented which explicitly adds the entity's class loader to the fallbacks.
+ @Test(groups="WIP")
+ public void testCatalogItemIdInReferencedItems() throws Exception {
+ TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_PATH);
+
+ String symbolicNameInner = "my.catalog.app.id.inner";
+ String symbolicNameOuter = "my.catalog.app.id.outer";
+ addCatalogItems(
+ "brooklyn.catalog:",
+ " version: " + TEST_VERSION,
+ " items:",
+ " - id: " + symbolicNameInner,
+ " name: My Catalog App",
+ " description: My description",
+ " icon_url: classpath://path/to/myicon.jpg",
+ " libraries:",
+ " - url: " + OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_URL,
+ " item: " + SIMPLE_ENTITY_TYPE,
+ " - id: " + symbolicNameOuter,
+ " item: " + symbolicNameInner);
+
+ String yaml = "name: " + symbolicNameOuter + "\n" +
+ "services: \n" +
+ " - serviceType: "+ver(symbolicNameOuter);
+
+ Entity app = createAndStartApplication(yaml);
+ Entity entity = app.getChildren().iterator().next();
+
+ // Fails
+ assertEquals(entity.getCatalogItemId(), ver(symbolicNameInner));
+
+ deleteCatalogEntity(symbolicNameInner);
+ deleteCatalogEntity(symbolicNameOuter);
+ }
+
private void registerAndLaunchAndAssertSimpleEntity(String symbolicName, String serviceType) throws Exception {
addCatalogOSGiEntity(symbolicName, serviceType);
String yaml = "name: simple-app-yaml\n" +