Github user alasdairhodge commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/790#discussion_r36393147
  
    --- Diff: 
usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/CatalogYamlAppTest.java
 ---
    @@ -0,0 +1,59 @@
    +/*
    + * 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.catalog;
    +
    +import org.testng.annotations.Test;
    +
    +import io.brooklyn.camp.brooklyn.AbstractYamlTest;
    +
    +
    +public class CatalogYamlAppTest extends AbstractYamlTest {
    +    
    +    // "Contrived" example was encountered by a customer in a real 
use-case!
    +    // I couldn't yet simplify it further while still reproducing the 
failure.
    +    // Throws StackOverlfowError, without giving a nice error message 
about 
    +    // "BasicEntity" cyclic reference
    +    @Test(groups="WIP") // TODO Fix this!
    +    public void testAddCatalogItemWithCircularReference() throws Exception 
{
    +        addCatalogItems(
    +                "brooklyn.catalog:",
    +                "  id: brooklyn.entity.basic.BasicEntity",
    +                "  version: "+TEST_VERSION,
    +                "services:",
    +                "- type: brooklyn.entity.basic.BasicApplication",
    +                "  brooklyn.config:",
    +                "    memberSpec:",
    +                "      $brooklyn:entitySpec:",
    +                "      - type: brooklyn.entity.basic.BasicApplication",
    +                "        brooklyn.children:",
    +                "        - type: brooklyn.entity.basic.BasicEntity");
    +
    +        try {
    +            addCatalogItems(
    +                    "brooklyn.catalog:",
    +                    "  id: another.app.in.the.catalog",
    +                    "  version: "+TEST_VERSION,
    +                    "services:",
    +                    "- type: brooklyn.entity.basic.BasicEntity");
    +            deleteCatalogEntity("another.app.in.the.catalog");
    +        } finally {
    +            deleteCatalogEntity("brooklyn.entity.basic.BasicEntity");
    +        }
    +    }
    +}
    --- End diff --
    
    This could be clearer to human readers:
    * It's not readily apparent where the circular reference stems from; I'm 
guessing it's the member spec referring to the ID of the enclosing app?
    * Is it necessary to have a catalog ID that resembles a Java classname? If 
it's not pertinent, use something distinct.
    * `memberSpec` looks odd, as it's not actually one of `BasicApplication`'s 
config keys; I guess it doesn't matter what the key is, just that it's value is 
an `EntitySpec`? Maybe use "foo" instead, to clarify that it's not important.
    * Where does the actual stack overflow occur? In the *second* 
`addCatalogItems` call? That's just weird.
    
    A sprinkling of comments will guide the tester to what's important.


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to