You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brooklyn.apache.org by Sam Corbett <sa...@cloudsoftcorp.com> on 2016/06/17 10:24:41 UTC

Testing children of group members

Hi,

I want to use Brooklyn's test entities to test an app with the following 
structure:

   cluster:
   - member 1
      - child 1
   - member 2
      - child 2

The things I want to test are on the child entities. Every child has the 
same CAMP id.

LoopOverGroupMembersTestCase gets me the members, but can I get from 
them to the children? Having experimented lots I currently think the 
answer is no.

I'm wondering whether there's a case for a `RelativeEntityTestCase` 
class, that resolves its target relative to its parent entity. (I had 
assumed that that was what LOGMTC would do, but in fact it overwrites 
any test spec target with the group member.)

Can anyone help?

Thanks,

Sam.

Re: Testing children of group members

Posted by Sam Corbett <sa...@cloudsoftcorp.com>.
Thanks Graeme.

I've come to the same conclusion. More generally, I think we can add a 
test entity that uses both `target` and `targetId` parameters from 
TargetableTestComponent with a `scope` parameter (of type 
org.apache.brooklyn.camp.brooklyn.spi.dsl.methods.DslComponent.Scope). 
The entity to be tested is the combination of `targetId` and `scope` 
resolved against `target`.

If we call this a "relative" test case, I would then structure my test 
case along the lines of this pseudocode:

loopOverGroupMembers:
   spec:
     relative:
       # target entity (= group member) set by loopOverGroupMembers
       targetId: foo
       scope: child

I'm mid-way through testing this idea, will report back if it proves useful.

Sam


On 17/06/2016 12:50, Graeme Miller wrote:
> I think what we are missing is a LoopOverChildrenTestCase. It would be very
> similar to LoopOverGroupMembersTestCase and can probably share some code. A
> combination of LoopOverGroupMembersTestCase followed by
> LoopOverChildrenTestCase should allow you to test the structure you
> mentioned.
>
> Regards,
> Graeme
>
> On 17 June 2016 at 11:24, Sam Corbett <sa...@cloudsoftcorp.com> wrote:
>
>> Hi,
>>
>> I want to use Brooklyn's test entities to test an app with the following
>> structure:
>>
>>    cluster:
>>    - member 1
>>       - child 1
>>    - member 2
>>       - child 2
>>
>> The things I want to test are on the child entities. Every child has the
>> same CAMP id.
>>
>> LoopOverGroupMembersTestCase gets me the members, but can I get from them
>> to the children? Having experimented lots I currently think the answer is
>> no.
>>
>> I'm wondering whether there's a case for a `RelativeEntityTestCase` class,
>> that resolves its target relative to its parent entity. (I had assumed that
>> that was what LOGMTC would do, but in fact it overwrites any test spec
>> target with the group member.)
>>
>> Can anyone help?
>>
>> Thanks,
>>
>> Sam.
>>


Re: Testing children of group members

Posted by Graeme Miller <gr...@cloudsoftcorp.com>.
Hello,

Target resolution is relative, and you can currently test multiple levels
down with the test framework, but only for groups. Have a look at the
following YAML. I have a group of groups of software processes. I have a
test which will loop over the first group, and run the configured entity
spec against them. The configured entity spec is also a
LoopOverGroupMembersTestCase, so it will loop over the children of the
second level of groups (these children are the software processes).

services:
> - type: org.apache.brooklyn.entity.group.BasicGroup
>   id: level_one
>   brooklyn.config:
>     brooklyn.BasicGroup.childrenAsMembers: true
>   brooklyn.children:
>     - type: org.apache.brooklyn.entity.group.BasicGroup
>       brooklyn.config:
>         brooklyn.BasicGroup.childrenAsMembers: true
>       brooklyn.children:
>         - type:
> org.apache.brooklyn.entity.software.base.EmptySoftwareProcess
>         - type:
> org.apache.brooklyn.entity.software.base.EmptySoftwareProcess
>     - type: org.apache.brooklyn.entity.group.BasicGroup
>       brooklyn.config:
>         brooklyn.BasicGroup.childrenAsMembers: true
>       brooklyn.children:
>         - type:
> org.apache.brooklyn.entity.software.base.EmptySoftwareProcess
>         - type:
> org.apache.brooklyn.entity.software.base.EmptySoftwareProcess
> - type: org.apache.brooklyn.test.framework.LoopOverGroupMembersTestCase
>   brooklyn.config:
>     targetId: level_one
>     testSpec:
>       $brooklyn:entitySpec:
>         type:
> org.apache.brooklyn.test.framework.LoopOverGroupMembersTestCase
>         brooklyn.config:
>           testSpec:
>             $brooklyn:entitySpec:
>               type: org.apache.brooklyn.test.framework.TestCase


You can run that YAML in Brooklyn to get a better idea of what it does. It
is all empty processes so it wont actually provision anything.

I think what we are missing is a LoopOverChildrenTestCase. It would be very
similar to LoopOverGroupMembersTestCase and can probably share some code. A
combination of LoopOverGroupMembersTestCase followed by
LoopOverChildrenTestCase should allow you to test the structure you
mentioned.

Regards,
Graeme

On 17 June 2016 at 11:24, Sam Corbett <sa...@cloudsoftcorp.com> wrote:

> Hi,
>
> I want to use Brooklyn's test entities to test an app with the following
> structure:
>
>   cluster:
>   - member 1
>      - child 1
>   - member 2
>      - child 2
>
> The things I want to test are on the child entities. Every child has the
> same CAMP id.
>
> LoopOverGroupMembersTestCase gets me the members, but can I get from them
> to the children? Having experimented lots I currently think the answer is
> no.
>
> I'm wondering whether there's a case for a `RelativeEntityTestCase` class,
> that resolves its target relative to its parent entity. (I had assumed that
> that was what LOGMTC would do, but in fact it overwrites any test spec
> target with the group member.)
>
> Can anyone help?
>
> Thanks,
>
> Sam.
>