You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brooklyn.apache.org by neykov <gi...@git.apache.org> on 2014/07/16 14:21:36 UTC

[GitHub] incubator-brooklyn pull request: Yaml referencing other Yaml files

GitHub user neykov opened a pull request:

    https://github.com/apache/incubator-brooklyn/pull/71

    Yaml referencing other Yaml files

      * entityResolver.populateSpec is called for both catalog and yaml referencing items now to migrate attributes from the referee to the referred specs.
      * Reference catalog/YAML at any level

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/neykov/incubator-brooklyn yaml-url-references

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-brooklyn/pull/71.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #71
    
----
commit d5a249fe1875dcfb71b041761791a3b44069cd91
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Date:   2014-07-16T08:04:15Z

    AppOrSpec not relevant any more, remove.
    
    The code uses only the spec part.

commit 918a2687053de57560e2a68b858c8a9b117a6f5d
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Date:   2014-07-16T08:13:57Z

    Rename getCatalogIdOrJavaType to getBrooklynType.
    
    The type now can be one of:
      * catalog id
      * java class name
      * URL to yaml file

commit b982e6fea941b499b21736f12bddaa55437f3e38
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Date:   2014-07-16T08:22:16Z

    Split spec creation in separate steps to allow re-use.

commit 201717a367a501a5ee174656780a2e3555f04edd
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Date:   2014-07-16T08:55:40Z

    Load URL referenced YAMLs.
    
    Allow URL references to YAML files in addition to catalog IDs and java types.
    Currently limited to services (PlatformComponentTemplate level).
    
    In the case of more than one service in the referenced plan just use the wrapped app as a child.
    The template referencing the yaml will override the name, IDs of the child. Locations, policies,
    effectors, ect. will be appended to the child's config. Do the same for catalog item references.

commit 6bc8d49f954e4bdbf186fa9581a57766465f1f98
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Date:   2014-07-16T10:20:01Z

    Resolve catalog items and yaml URLs from child entities as well.

commit 22506097a692c5055d1043a6f9e38d57913a863d
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Date:   2014-07-16T10:33:37Z

    Remove unnecessary name in YAML.

commit e517ddd231550010e5039092484df26b91021860
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Date:   2014-07-16T10:55:04Z

    Add tests
    
      * Catalog item does not leak bundles to child catalog items
      * Catalog item DOES leak bundles to URL referenced YAMLs

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-brooklyn pull request: Yaml referencing other Yaml files

Posted by sjcorbett <gi...@git.apache.org>.
Github user sjcorbett commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/71#discussion_r15052999
  
    --- Diff: usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynAssemblyTemplateInstantiator.java ---
    @@ -240,46 +204,94 @@ protected boolean shouldUnwrap(AssemblyTemplate template, EntitySpec<? extends A
             for (ResolvableLink<PlatformComponentTemplate> ctl: template.getPlatformComponentTemplates().links()) {
                 PlatformComponentTemplate appChildComponentTemplate = ctl.resolve();
                 BrooklynComponentTemplateResolver entityResolver = BrooklynComponentTemplateResolver.Factory.newInstance(loader, appChildComponentTemplate);
    -            ManagementContext mgmt = loader.getManagementContext();
    +            EntitySpec<?> spec = resolveSpec(entityResolver, encounteredCatalogTypes);
    +            
    +            result.add(spec);
    +        }
    +        return result;
    +    }
     
    -            String catalogIdOrJavaType = entityResolver.getCatalogIdOrJavaType();
    -            CatalogItem<Entity, EntitySpec<?>> item = entityResolver.getCatalogItem();
    +    private EntitySpec<?> resolveSpec(
    +            BrooklynComponentTemplateResolver entityResolver, 
    +            Set<String> encounteredCatalogTypes) {
    +        ManagementContext mgmt = entityResolver.loader.getManagementContext();
     
    -            boolean firstOccurrence = encounteredCatalogTypes.add(catalogIdOrJavaType);
    -            boolean recursiveButTryJava = !firstOccurrence;
    -                         
    -            if (log.isTraceEnabled()) log.trace("Building CAMP template services: type="+catalogIdOrJavaType+"; item="+item+"; loader="+loader+"; template="+template+"; encounteredCatalogTypes="+encounteredCatalogTypes);
    +        String brooklynType = entityResolver.getBrooklynType();
    +        CatalogItem<Entity, EntitySpec<?>> item = entityResolver.getCatalogItem();
    +
    +        boolean firstOccurrence = encounteredCatalogTypes.add(brooklynType);
    +        boolean recursiveButTryJava = !firstOccurrence;
    +        
    +        if (log.isTraceEnabled()) log.trace("Building CAMP template services: type="+brooklynType+"; item="+item+"; loader="+entityResolver.loader+"; encounteredCatalogTypes="+encounteredCatalogTypes);
     
    -            EntitySpec<?> spec;
    +        EntitySpec<?> spec = null;
    +        if (BrooklynCampConstants.YAML_URL_PROTOCOL_WHITELIST.contains(Urls.getProtocol(brooklynType))) {
    --- End diff --
    
    Or rather, if `Urls.getProtocol(brooklynType)` is not null and not whitelisted.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-brooklyn pull request: Yaml referencing other Yaml files

Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on the pull request:

    https://github.com/apache/incubator-brooklyn/pull/71#issuecomment-49329062
  
    Sam, thank you for reviewing. Addressed comments.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-brooklyn pull request: Yaml referencing other Yaml files

Posted by sjcorbett <gi...@git.apache.org>.
Github user sjcorbett commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/71#discussion_r15052274
  
    --- Diff: usage/camp/src/test/java/io/brooklyn/camp/brooklyn/ReferencedYamlTest.java ---
    @@ -0,0 +1,172 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +package io.brooklyn.camp.brooklyn;
    +
    +import static org.testng.Assert.assertTrue;
    +
    +import java.util.Collection;
    +
    +import org.testng.Assert;
    +import org.testng.annotations.Test;
    +
    +import brooklyn.entity.Entity;
    +import brooklyn.entity.basic.BasicApplication;
    +import brooklyn.entity.basic.BasicEntity;
    +import brooklyn.management.osgi.OsgiStandaloneTest;
    +
    +import com.google.common.collect.Iterables;
    +
    +public class ReferencedYamlTest extends AbstractYamlTest {
    +    
    +    @Test
    +    public void testReferenceEntityYamlAsPlatformComponent() throws Exception {
    +        String entityName = "Reference child name";
    +        Entity app = createAndStartApplication(
    +            "services:",
    +            "- name: " + entityName,
    +            "  type: classpath://yaml-ref-entity.yaml");
    +        
    +        checkChildEntitySpec(app, entityName);
    +    }
    +
    +    @Test
    +    public void testAnonymousReferenceEntityYamlAsPlatformComponent() throws Exception {
    +        Entity app = createAndStartApplication(
    +            "services:",
    +            "- type: classpath://yaml-ref-entity.yaml");
    +        
    +        checkChildEntitySpec(app, "service");
    +    }
    +
    +    @Test
    +    public void testReferenceAppYamlAsPlatformComponent() throws Exception {
    +        Entity app = createAndStartApplication(
    +            "services:",
    +            "- name: Reference child name",
    +            "  type: classpath://yaml-ref-app.yaml");
    +        
    +        Assert.assertEquals(app.getChildren().size(), 0);
    +        Assert.assertEquals(app.getDisplayName(), "Reference child name");
    +
    +        //child is a proxy so equality test won't do
    +        Assert.assertEquals(app.getEntityType().getName(), BasicApplication.class.getName());
    +    }
    +
    +    @Test
    +    public void testReferenceYamlAsChild() throws Exception {
    +        String entityName = "Reference child name";
    +        Entity createAndStartApplication = createAndStartApplication(
    +            "services:",
    +            "- type: brooklyn.entity.basic.BasicEntity",
    +            "  brooklyn.children:",
    +            "  - name: " + entityName,
    +            "    type: classpath://yaml-ref-entity.yaml");
    +        
    +        checkGrandchildEntitySpec(createAndStartApplication, entityName);
    +    }
    +
    +    @Test
    +    public void testAnonymousReferenceYamlAsChild() throws Exception {
    +        Entity createAndStartApplication = createAndStartApplication(
    +            "services:",
    +            "- type: brooklyn.entity.basic.BasicEntity",
    +            "  brooklyn.children:",
    +            "  - type: classpath://yaml-ref-entity.yaml");
    +        
    +        checkGrandchildEntitySpec(createAndStartApplication, "service");
    +    }
    +
    +    @Test
    +    public void testCatalogReferencingYamlUrl() throws Exception {
    +        addCatalogItem(
    +            "brooklyn.catalog:",
    +            "  id: yaml.reference",
    +            "services:",
    +            "- type: classpath://yaml-ref-entity.yaml");
    +        
    +        String entityName = "YAML -> catalog item -> yaml url";
    +        Entity app = createAndStartApplication(
    +            "services:",
    +            "- name: " + entityName,
    +            "  type: yaml.reference");
    +        
    +        checkChildEntitySpec(app, entityName);
    +    }
    +
    +    @Test
    +    public void testYamlUrlReferencingCatalog() throws Exception {
    +        addCatalogItem(
    +            "brooklyn.catalog:",
    +            "  id: yaml.basic",
    +            "services:",
    +            "- type: brooklyn.entity.basic.BasicEntity");
    +        
    +        String entityName = "YAML -> yaml url -> catalog item";
    +        Entity app = createAndStartApplication(
    +            "services:",
    +            "- name: " + entityName,
    +            "  type: classpath://yaml-ref-catalog.yaml");
    +        
    +        checkChildEntitySpec(app, entityName);
    +    }
    +
    +    @Test(invocationCount = 1000)
    --- End diff --
    
    Why 1000 times? It adds over a minute onto the build time on my machine.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-brooklyn pull request: Yaml referencing other Yaml files

Posted by sjcorbett <gi...@git.apache.org>.
Github user sjcorbett commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/71#discussion_r15052966
  
    --- Diff: usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynAssemblyTemplateInstantiator.java ---
    @@ -240,46 +204,94 @@ protected boolean shouldUnwrap(AssemblyTemplate template, EntitySpec<? extends A
             for (ResolvableLink<PlatformComponentTemplate> ctl: template.getPlatformComponentTemplates().links()) {
                 PlatformComponentTemplate appChildComponentTemplate = ctl.resolve();
                 BrooklynComponentTemplateResolver entityResolver = BrooklynComponentTemplateResolver.Factory.newInstance(loader, appChildComponentTemplate);
    -            ManagementContext mgmt = loader.getManagementContext();
    +            EntitySpec<?> spec = resolveSpec(entityResolver, encounteredCatalogTypes);
    +            
    +            result.add(spec);
    +        }
    +        return result;
    +    }
     
    -            String catalogIdOrJavaType = entityResolver.getCatalogIdOrJavaType();
    -            CatalogItem<Entity, EntitySpec<?>> item = entityResolver.getCatalogItem();
    +    private EntitySpec<?> resolveSpec(
    +            BrooklynComponentTemplateResolver entityResolver, 
    +            Set<String> encounteredCatalogTypes) {
    +        ManagementContext mgmt = entityResolver.loader.getManagementContext();
     
    -            boolean firstOccurrence = encounteredCatalogTypes.add(catalogIdOrJavaType);
    -            boolean recursiveButTryJava = !firstOccurrence;
    -                         
    -            if (log.isTraceEnabled()) log.trace("Building CAMP template services: type="+catalogIdOrJavaType+"; item="+item+"; loader="+loader+"; template="+template+"; encounteredCatalogTypes="+encounteredCatalogTypes);
    +        String brooklynType = entityResolver.getBrooklynType();
    +        CatalogItem<Entity, EntitySpec<?>> item = entityResolver.getCatalogItem();
    +
    +        boolean firstOccurrence = encounteredCatalogTypes.add(brooklynType);
    +        boolean recursiveButTryJava = !firstOccurrence;
    +        
    +        if (log.isTraceEnabled()) log.trace("Building CAMP template services: type="+brooklynType+"; item="+item+"; loader="+entityResolver.loader+"; encounteredCatalogTypes="+encounteredCatalogTypes);
     
    -            EntitySpec<?> spec;
    +        EntitySpec<?> spec = null;
    +        if (BrooklynCampConstants.YAML_URL_PROTOCOL_WHITELIST.contains(Urls.getProtocol(brooklynType))) {
    --- End diff --
    
    I think it's worth logging a warning if brooklynType is not null and is not whitelisted.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-brooklyn pull request: Yaml referencing other Yaml files

Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/71#discussion_r15053910
  
    --- Diff: usage/camp/src/test/java/io/brooklyn/camp/brooklyn/CatalogYamlTest.java ---
    @@ -49,7 +51,7 @@ public void testLaunchApplicationReferencingCatalog() throws Exception {
             String registeredTypeName = "my.catalog.app.id.launch";
             registerAndLaunchAndAssertSimpleEntity(registeredTypeName, SIMPLE_ENTITY_TYPE);
         }
    -
    +    
    --- End diff --
    
    I am using Eclipse and have the option to strip all trailing spaces on save, but this will be applied on the whole file leading to even more instances of the above edit (in the opposite direction). If anyone knows of a way to force Eclipse not to add spaces on new lines while editing please share.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-brooklyn pull request: Yaml referencing other Yaml files

Posted by sjcorbett <gi...@git.apache.org>.
Github user sjcorbett commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/71#discussion_r15052353
  
    --- Diff: usage/camp/src/test/java/io/brooklyn/camp/brooklyn/ReferencedYamlTest.java ---
    @@ -0,0 +1,172 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +package io.brooklyn.camp.brooklyn;
    +
    +import static org.testng.Assert.assertTrue;
    +
    +import java.util.Collection;
    +
    +import org.testng.Assert;
    +import org.testng.annotations.Test;
    +
    +import brooklyn.entity.Entity;
    +import brooklyn.entity.basic.BasicApplication;
    +import brooklyn.entity.basic.BasicEntity;
    +import brooklyn.management.osgi.OsgiStandaloneTest;
    +
    +import com.google.common.collect.Iterables;
    +
    +public class ReferencedYamlTest extends AbstractYamlTest {
    +    
    +    @Test
    +    public void testReferenceEntityYamlAsPlatformComponent() throws Exception {
    +        String entityName = "Reference child name";
    +        Entity app = createAndStartApplication(
    +            "services:",
    +            "- name: " + entityName,
    +            "  type: classpath://yaml-ref-entity.yaml");
    +        
    +        checkChildEntitySpec(app, entityName);
    +    }
    +
    +    @Test
    +    public void testAnonymousReferenceEntityYamlAsPlatformComponent() throws Exception {
    +        Entity app = createAndStartApplication(
    +            "services:",
    +            "- type: classpath://yaml-ref-entity.yaml");
    +        
    +        checkChildEntitySpec(app, "service");
    +    }
    +
    +    @Test
    +    public void testReferenceAppYamlAsPlatformComponent() throws Exception {
    +        Entity app = createAndStartApplication(
    +            "services:",
    +            "- name: Reference child name",
    +            "  type: classpath://yaml-ref-app.yaml");
    +        
    +        Assert.assertEquals(app.getChildren().size(), 0);
    +        Assert.assertEquals(app.getDisplayName(), "Reference child name");
    +
    +        //child is a proxy so equality test won't do
    +        Assert.assertEquals(app.getEntityType().getName(), BasicApplication.class.getName());
    +    }
    +
    +    @Test
    +    public void testReferenceYamlAsChild() throws Exception {
    +        String entityName = "Reference child name";
    +        Entity createAndStartApplication = createAndStartApplication(
    +            "services:",
    +            "- type: brooklyn.entity.basic.BasicEntity",
    +            "  brooklyn.children:",
    +            "  - name: " + entityName,
    +            "    type: classpath://yaml-ref-entity.yaml");
    +        
    +        checkGrandchildEntitySpec(createAndStartApplication, entityName);
    +    }
    +
    +    @Test
    +    public void testAnonymousReferenceYamlAsChild() throws Exception {
    +        Entity createAndStartApplication = createAndStartApplication(
    +            "services:",
    +            "- type: brooklyn.entity.basic.BasicEntity",
    +            "  brooklyn.children:",
    +            "  - type: classpath://yaml-ref-entity.yaml");
    +        
    +        checkGrandchildEntitySpec(createAndStartApplication, "service");
    +    }
    +
    +    @Test
    +    public void testCatalogReferencingYamlUrl() throws Exception {
    +        addCatalogItem(
    +            "brooklyn.catalog:",
    +            "  id: yaml.reference",
    +            "services:",
    +            "- type: classpath://yaml-ref-entity.yaml");
    +        
    +        String entityName = "YAML -> catalog item -> yaml url";
    +        Entity app = createAndStartApplication(
    +            "services:",
    +            "- name: " + entityName,
    +            "  type: yaml.reference");
    +        
    +        checkChildEntitySpec(app, entityName);
    +    }
    +
    +    @Test
    +    public void testYamlUrlReferencingCatalog() throws Exception {
    +        addCatalogItem(
    +            "brooklyn.catalog:",
    +            "  id: yaml.basic",
    +            "services:",
    +            "- type: brooklyn.entity.basic.BasicEntity");
    +        
    +        String entityName = "YAML -> yaml url -> catalog item";
    +        Entity app = createAndStartApplication(
    +            "services:",
    +            "- name: " + entityName,
    +            "  type: classpath://yaml-ref-catalog.yaml");
    +        
    +        checkChildEntitySpec(app, entityName);
    +    }
    +
    +    @Test(invocationCount = 1000)
    +    public void testCatalogLeaksBundlesToReferencedYaml() throws Exception {
    --- End diff --
    
    What is the reason for the discrepancy between this scenario and the one tested in `CatalogYamlTest. testParentCatalogDoesNotLeakBundlesToChildCatalogItems`?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-brooklyn pull request: Yaml referencing other Yaml files

Posted by sjcorbett <gi...@git.apache.org>.
Github user sjcorbett commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/71#discussion_r15052278
  
    --- Diff: usage/camp/src/test/java/io/brooklyn/camp/brooklyn/ReferencedYamlTest.java ---
    @@ -0,0 +1,172 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +package io.brooklyn.camp.brooklyn;
    +
    +import static org.testng.Assert.assertTrue;
    +
    +import java.util.Collection;
    +
    +import org.testng.Assert;
    +import org.testng.annotations.Test;
    +
    +import brooklyn.entity.Entity;
    +import brooklyn.entity.basic.BasicApplication;
    +import brooklyn.entity.basic.BasicEntity;
    +import brooklyn.management.osgi.OsgiStandaloneTest;
    +
    +import com.google.common.collect.Iterables;
    +
    +public class ReferencedYamlTest extends AbstractYamlTest {
    +    
    +    @Test
    +    public void testReferenceEntityYamlAsPlatformComponent() throws Exception {
    +        String entityName = "Reference child name";
    +        Entity app = createAndStartApplication(
    +            "services:",
    +            "- name: " + entityName,
    +            "  type: classpath://yaml-ref-entity.yaml");
    +        
    +        checkChildEntitySpec(app, entityName);
    +    }
    +
    +    @Test
    +    public void testAnonymousReferenceEntityYamlAsPlatformComponent() throws Exception {
    +        Entity app = createAndStartApplication(
    +            "services:",
    +            "- type: classpath://yaml-ref-entity.yaml");
    +        
    +        checkChildEntitySpec(app, "service");
    +    }
    +
    +    @Test
    +    public void testReferenceAppYamlAsPlatformComponent() throws Exception {
    +        Entity app = createAndStartApplication(
    +            "services:",
    +            "- name: Reference child name",
    +            "  type: classpath://yaml-ref-app.yaml");
    +        
    +        Assert.assertEquals(app.getChildren().size(), 0);
    +        Assert.assertEquals(app.getDisplayName(), "Reference child name");
    +
    +        //child is a proxy so equality test won't do
    +        Assert.assertEquals(app.getEntityType().getName(), BasicApplication.class.getName());
    +    }
    +
    +    @Test
    +    public void testReferenceYamlAsChild() throws Exception {
    +        String entityName = "Reference child name";
    +        Entity createAndStartApplication = createAndStartApplication(
    +            "services:",
    +            "- type: brooklyn.entity.basic.BasicEntity",
    +            "  brooklyn.children:",
    +            "  - name: " + entityName,
    +            "    type: classpath://yaml-ref-entity.yaml");
    +        
    +        checkGrandchildEntitySpec(createAndStartApplication, entityName);
    +    }
    +
    +    @Test
    +    public void testAnonymousReferenceYamlAsChild() throws Exception {
    +        Entity createAndStartApplication = createAndStartApplication(
    +            "services:",
    +            "- type: brooklyn.entity.basic.BasicEntity",
    +            "  brooklyn.children:",
    +            "  - type: classpath://yaml-ref-entity.yaml");
    +        
    +        checkGrandchildEntitySpec(createAndStartApplication, "service");
    +    }
    +
    +    @Test
    +    public void testCatalogReferencingYamlUrl() throws Exception {
    +        addCatalogItem(
    +            "brooklyn.catalog:",
    +            "  id: yaml.reference",
    +            "services:",
    +            "- type: classpath://yaml-ref-entity.yaml");
    +        
    +        String entityName = "YAML -> catalog item -> yaml url";
    +        Entity app = createAndStartApplication(
    +            "services:",
    +            "- name: " + entityName,
    +            "  type: yaml.reference");
    +        
    +        checkChildEntitySpec(app, entityName);
    +    }
    +
    +    @Test
    +    public void testYamlUrlReferencingCatalog() throws Exception {
    +        addCatalogItem(
    +            "brooklyn.catalog:",
    +            "  id: yaml.basic",
    +            "services:",
    +            "- type: brooklyn.entity.basic.BasicEntity");
    +        
    +        String entityName = "YAML -> yaml url -> catalog item";
    +        Entity app = createAndStartApplication(
    +            "services:",
    +            "- name: " + entityName,
    +            "  type: classpath://yaml-ref-catalog.yaml");
    +        
    +        checkChildEntitySpec(app, entityName);
    +    }
    +
    +    @Test(invocationCount = 1000)
    +    public void testCatalogLeaksBundlesToReferencedYaml() throws Exception {
    +        String parentCatalogId = "my.catalog.app.id.url.parent";
    +        addCatalogItem(
    +            "brooklyn.catalog:",
    +            "  id: " + parentCatalogId,
    +            "  libraries:",
    +            "  - url: " + OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_URL,
    +            "",
    +            "services:",
    +            "- type: classpath:/yaml-ref-bundle-without-libraries.yaml");
    --- End diff --
    
    Just one slash? Test passes anyway so not sure if it matters.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-brooklyn pull request: Yaml referencing other Yaml files

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/incubator-brooklyn/pull/71


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-brooklyn pull request: Yaml referencing other Yaml files

Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/71#discussion_r15053637
  
    --- Diff: usage/camp/src/test/java/io/brooklyn/camp/brooklyn/ReferencedYamlTest.java ---
    @@ -0,0 +1,172 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +package io.brooklyn.camp.brooklyn;
    +
    +import static org.testng.Assert.assertTrue;
    +
    +import java.util.Collection;
    +
    +import org.testng.Assert;
    +import org.testng.annotations.Test;
    +
    +import brooklyn.entity.Entity;
    +import brooklyn.entity.basic.BasicApplication;
    +import brooklyn.entity.basic.BasicEntity;
    +import brooklyn.management.osgi.OsgiStandaloneTest;
    +
    +import com.google.common.collect.Iterables;
    +
    +public class ReferencedYamlTest extends AbstractYamlTest {
    +    
    +    @Test
    +    public void testReferenceEntityYamlAsPlatformComponent() throws Exception {
    +        String entityName = "Reference child name";
    +        Entity app = createAndStartApplication(
    +            "services:",
    +            "- name: " + entityName,
    +            "  type: classpath://yaml-ref-entity.yaml");
    +        
    +        checkChildEntitySpec(app, entityName);
    +    }
    +
    +    @Test
    +    public void testAnonymousReferenceEntityYamlAsPlatformComponent() throws Exception {
    +        Entity app = createAndStartApplication(
    +            "services:",
    +            "- type: classpath://yaml-ref-entity.yaml");
    +        
    +        checkChildEntitySpec(app, "service");
    +    }
    +
    +    @Test
    +    public void testReferenceAppYamlAsPlatformComponent() throws Exception {
    +        Entity app = createAndStartApplication(
    +            "services:",
    +            "- name: Reference child name",
    +            "  type: classpath://yaml-ref-app.yaml");
    +        
    +        Assert.assertEquals(app.getChildren().size(), 0);
    +        Assert.assertEquals(app.getDisplayName(), "Reference child name");
    +
    +        //child is a proxy so equality test won't do
    +        Assert.assertEquals(app.getEntityType().getName(), BasicApplication.class.getName());
    +    }
    +
    +    @Test
    +    public void testReferenceYamlAsChild() throws Exception {
    +        String entityName = "Reference child name";
    +        Entity createAndStartApplication = createAndStartApplication(
    +            "services:",
    +            "- type: brooklyn.entity.basic.BasicEntity",
    +            "  brooklyn.children:",
    +            "  - name: " + entityName,
    +            "    type: classpath://yaml-ref-entity.yaml");
    +        
    +        checkGrandchildEntitySpec(createAndStartApplication, entityName);
    +    }
    +
    +    @Test
    +    public void testAnonymousReferenceYamlAsChild() throws Exception {
    +        Entity createAndStartApplication = createAndStartApplication(
    +            "services:",
    +            "- type: brooklyn.entity.basic.BasicEntity",
    +            "  brooklyn.children:",
    +            "  - type: classpath://yaml-ref-entity.yaml");
    +        
    +        checkGrandchildEntitySpec(createAndStartApplication, "service");
    +    }
    +
    +    @Test
    +    public void testCatalogReferencingYamlUrl() throws Exception {
    +        addCatalogItem(
    +            "brooklyn.catalog:",
    +            "  id: yaml.reference",
    +            "services:",
    +            "- type: classpath://yaml-ref-entity.yaml");
    +        
    +        String entityName = "YAML -> catalog item -> yaml url";
    +        Entity app = createAndStartApplication(
    +            "services:",
    +            "- name: " + entityName,
    +            "  type: yaml.reference");
    +        
    +        checkChildEntitySpec(app, entityName);
    +    }
    +
    +    @Test
    +    public void testYamlUrlReferencingCatalog() throws Exception {
    +        addCatalogItem(
    +            "brooklyn.catalog:",
    +            "  id: yaml.basic",
    +            "services:",
    +            "- type: brooklyn.entity.basic.BasicEntity");
    +        
    +        String entityName = "YAML -> yaml url -> catalog item";
    +        Entity app = createAndStartApplication(
    +            "services:",
    +            "- name: " + entityName,
    +            "  type: classpath://yaml-ref-catalog.yaml");
    +        
    +        checkChildEntitySpec(app, entityName);
    +    }
    +
    +    @Test(invocationCount = 1000)
    +    public void testCatalogLeaksBundlesToReferencedYaml() throws Exception {
    +        String parentCatalogId = "my.catalog.app.id.url.parent";
    +        addCatalogItem(
    +            "brooklyn.catalog:",
    +            "  id: " + parentCatalogId,
    +            "  libraries:",
    +            "  - url: " + OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_URL,
    +            "",
    +            "services:",
    +            "- type: classpath:/yaml-ref-bundle-without-libraries.yaml");
    --- End diff --
    
    Copied the format from elsewhere. The implementation supports any number of leading slashes. I will add a slash as it looks more consistent though.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-brooklyn pull request: Yaml referencing other Yaml files

Posted by sjcorbett <gi...@git.apache.org>.
Github user sjcorbett commented on the pull request:

    https://github.com/apache/incubator-brooklyn/pull/71#issuecomment-49411783
  
    Thanks @neykov. This is good to merge.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-brooklyn pull request: Yaml referencing other Yaml files

Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/71#discussion_r15053775
  
    --- Diff: usage/camp/src/test/java/io/brooklyn/camp/brooklyn/ReferencedYamlTest.java ---
    @@ -0,0 +1,172 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +package io.brooklyn.camp.brooklyn;
    +
    +import static org.testng.Assert.assertTrue;
    +
    +import java.util.Collection;
    +
    +import org.testng.Assert;
    +import org.testng.annotations.Test;
    +
    +import brooklyn.entity.Entity;
    +import brooklyn.entity.basic.BasicApplication;
    +import brooklyn.entity.basic.BasicEntity;
    +import brooklyn.management.osgi.OsgiStandaloneTest;
    +
    +import com.google.common.collect.Iterables;
    +
    +public class ReferencedYamlTest extends AbstractYamlTest {
    +    
    +    @Test
    +    public void testReferenceEntityYamlAsPlatformComponent() throws Exception {
    +        String entityName = "Reference child name";
    +        Entity app = createAndStartApplication(
    +            "services:",
    +            "- name: " + entityName,
    +            "  type: classpath://yaml-ref-entity.yaml");
    +        
    +        checkChildEntitySpec(app, entityName);
    +    }
    +
    +    @Test
    +    public void testAnonymousReferenceEntityYamlAsPlatformComponent() throws Exception {
    +        Entity app = createAndStartApplication(
    +            "services:",
    +            "- type: classpath://yaml-ref-entity.yaml");
    +        
    +        checkChildEntitySpec(app, "service");
    +    }
    +
    +    @Test
    +    public void testReferenceAppYamlAsPlatformComponent() throws Exception {
    +        Entity app = createAndStartApplication(
    +            "services:",
    +            "- name: Reference child name",
    +            "  type: classpath://yaml-ref-app.yaml");
    +        
    +        Assert.assertEquals(app.getChildren().size(), 0);
    +        Assert.assertEquals(app.getDisplayName(), "Reference child name");
    +
    +        //child is a proxy so equality test won't do
    +        Assert.assertEquals(app.getEntityType().getName(), BasicApplication.class.getName());
    +    }
    +
    +    @Test
    +    public void testReferenceYamlAsChild() throws Exception {
    +        String entityName = "Reference child name";
    +        Entity createAndStartApplication = createAndStartApplication(
    +            "services:",
    +            "- type: brooklyn.entity.basic.BasicEntity",
    +            "  brooklyn.children:",
    +            "  - name: " + entityName,
    +            "    type: classpath://yaml-ref-entity.yaml");
    +        
    +        checkGrandchildEntitySpec(createAndStartApplication, entityName);
    +    }
    +
    +    @Test
    +    public void testAnonymousReferenceYamlAsChild() throws Exception {
    +        Entity createAndStartApplication = createAndStartApplication(
    +            "services:",
    +            "- type: brooklyn.entity.basic.BasicEntity",
    +            "  brooklyn.children:",
    +            "  - type: classpath://yaml-ref-entity.yaml");
    +        
    +        checkGrandchildEntitySpec(createAndStartApplication, "service");
    +    }
    +
    +    @Test
    +    public void testCatalogReferencingYamlUrl() throws Exception {
    +        addCatalogItem(
    +            "brooklyn.catalog:",
    +            "  id: yaml.reference",
    +            "services:",
    +            "- type: classpath://yaml-ref-entity.yaml");
    +        
    +        String entityName = "YAML -> catalog item -> yaml url";
    +        Entity app = createAndStartApplication(
    +            "services:",
    +            "- name: " + entityName,
    +            "  type: yaml.reference");
    +        
    +        checkChildEntitySpec(app, entityName);
    +    }
    +
    +    @Test
    +    public void testYamlUrlReferencingCatalog() throws Exception {
    +        addCatalogItem(
    +            "brooklyn.catalog:",
    +            "  id: yaml.basic",
    +            "services:",
    +            "- type: brooklyn.entity.basic.BasicEntity");
    +        
    +        String entityName = "YAML -> yaml url -> catalog item";
    +        Entity app = createAndStartApplication(
    +            "services:",
    +            "- name: " + entityName,
    +            "  type: classpath://yaml-ref-catalog.yaml");
    +        
    +        checkChildEntitySpec(app, entityName);
    +    }
    +
    +    @Test(invocationCount = 1000)
    +    public void testCatalogLeaksBundlesToReferencedYaml() throws Exception {
    --- End diff --
    
      * Catalog items referencing other catalog items (testParentCatalogDoesNotLeakBundlesToChildCatalogItems) should not make their bundles visible to the referenced catalog item.
      * Catalog items referencing external YAML (testCatalogLeaksBundlesToReferencedYaml) should make their bundles visible to the referenced yaml as discusses in the spring planning conference.
    
    I will add comments as the method names to not describe the intent clearly.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-brooklyn pull request: Yaml referencing other Yaml files

Posted by sjcorbett <gi...@git.apache.org>.
Github user sjcorbett commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/71#discussion_r15052382
  
    --- Diff: usage/camp/src/test/java/io/brooklyn/camp/brooklyn/CatalogYamlTest.java ---
    @@ -49,7 +51,7 @@ public void testLaunchApplicationReferencingCatalog() throws Exception {
             String registeredTypeName = "my.catalog.app.id.launch";
             registerAndLaunchAndAssertSimpleEntity(registeredTypeName, SIMPLE_ENTITY_TYPE);
         }
    -
    +    
    --- End diff --
    
    Really minor: Not sure what IDE you're using but IntelliJ has a handy config option to strip trailing spaces from lines you've edited that is great for removing changes like the line above.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-brooklyn pull request: Yaml referencing other Yaml files

Posted by sjcorbett <gi...@git.apache.org>.
Github user sjcorbett commented on the pull request:

    https://github.com/apache/incubator-brooklyn/pull/71#issuecomment-49298356
  
    A handful of comments, otherwise this looks really good.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-brooklyn pull request: Yaml referencing other Yaml files

Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/71#discussion_r15053547
  
    --- Diff: usage/camp/src/test/java/io/brooklyn/camp/brooklyn/ReferencedYamlTest.java ---
    @@ -0,0 +1,172 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +package io.brooklyn.camp.brooklyn;
    +
    +import static org.testng.Assert.assertTrue;
    +
    +import java.util.Collection;
    +
    +import org.testng.Assert;
    +import org.testng.annotations.Test;
    +
    +import brooklyn.entity.Entity;
    +import brooklyn.entity.basic.BasicApplication;
    +import brooklyn.entity.basic.BasicEntity;
    +import brooklyn.management.osgi.OsgiStandaloneTest;
    +
    +import com.google.common.collect.Iterables;
    +
    +public class ReferencedYamlTest extends AbstractYamlTest {
    +    
    +    @Test
    +    public void testReferenceEntityYamlAsPlatformComponent() throws Exception {
    +        String entityName = "Reference child name";
    +        Entity app = createAndStartApplication(
    +            "services:",
    +            "- name: " + entityName,
    +            "  type: classpath://yaml-ref-entity.yaml");
    +        
    +        checkChildEntitySpec(app, entityName);
    +    }
    +
    +    @Test
    +    public void testAnonymousReferenceEntityYamlAsPlatformComponent() throws Exception {
    +        Entity app = createAndStartApplication(
    +            "services:",
    +            "- type: classpath://yaml-ref-entity.yaml");
    +        
    +        checkChildEntitySpec(app, "service");
    +    }
    +
    +    @Test
    +    public void testReferenceAppYamlAsPlatformComponent() throws Exception {
    +        Entity app = createAndStartApplication(
    +            "services:",
    +            "- name: Reference child name",
    +            "  type: classpath://yaml-ref-app.yaml");
    +        
    +        Assert.assertEquals(app.getChildren().size(), 0);
    +        Assert.assertEquals(app.getDisplayName(), "Reference child name");
    +
    +        //child is a proxy so equality test won't do
    +        Assert.assertEquals(app.getEntityType().getName(), BasicApplication.class.getName());
    +    }
    +
    +    @Test
    +    public void testReferenceYamlAsChild() throws Exception {
    +        String entityName = "Reference child name";
    +        Entity createAndStartApplication = createAndStartApplication(
    +            "services:",
    +            "- type: brooklyn.entity.basic.BasicEntity",
    +            "  brooklyn.children:",
    +            "  - name: " + entityName,
    +            "    type: classpath://yaml-ref-entity.yaml");
    +        
    +        checkGrandchildEntitySpec(createAndStartApplication, entityName);
    +    }
    +
    +    @Test
    +    public void testAnonymousReferenceYamlAsChild() throws Exception {
    +        Entity createAndStartApplication = createAndStartApplication(
    +            "services:",
    +            "- type: brooklyn.entity.basic.BasicEntity",
    +            "  brooklyn.children:",
    +            "  - type: classpath://yaml-ref-entity.yaml");
    +        
    +        checkGrandchildEntitySpec(createAndStartApplication, "service");
    +    }
    +
    +    @Test
    +    public void testCatalogReferencingYamlUrl() throws Exception {
    +        addCatalogItem(
    +            "brooklyn.catalog:",
    +            "  id: yaml.reference",
    +            "services:",
    +            "- type: classpath://yaml-ref-entity.yaml");
    +        
    +        String entityName = "YAML -> catalog item -> yaml url";
    +        Entity app = createAndStartApplication(
    +            "services:",
    +            "- name: " + entityName,
    +            "  type: yaml.reference");
    +        
    +        checkChildEntitySpec(app, entityName);
    +    }
    +
    +    @Test
    +    public void testYamlUrlReferencingCatalog() throws Exception {
    +        addCatalogItem(
    +            "brooklyn.catalog:",
    +            "  id: yaml.basic",
    +            "services:",
    +            "- type: brooklyn.entity.basic.BasicEntity");
    +        
    +        String entityName = "YAML -> yaml url -> catalog item";
    +        Entity app = createAndStartApplication(
    +            "services:",
    +            "- name: " + entityName,
    +            "  type: classpath://yaml-ref-catalog.yaml");
    +        
    +        checkChildEntitySpec(app, entityName);
    +    }
    +
    +    @Test(invocationCount = 1000)
    --- End diff --
    
    I was suspecting random failure here and added it to confirm everything is OK. Forgot to delete it afterwards. Removing.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---