You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brooklyn.apache.org by ahgittin <gi...@git.apache.org> on 2016/06/09 16:03:36 UTC

[GitHub] brooklyn-server pull request #193: fix for issue where $brooklyn:external re...

GitHub user ahgittin opened a pull request:

    https://github.com/apache/brooklyn-server/pull/193

    fix for issue where $brooklyn:external refs in provisioning.properties are resolved too early

    several more tests, including one which failed before the fix -- and of course the fix itself

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

    $ git pull https://github.com/ahgittin/brooklyn-server external-in-provisioning-properties-breaks

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

    https://github.com/apache/brooklyn-server/pull/193.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 #193
    
----
commit cae88d9e10f03ad87d840b1cb9e71c440d800269
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Date:   2016-06-09T16:01:49Z

    fix for issue where $brooklyn:external refs in provisioning.properties are resolved too early
    
    several more tests, including one which failed before the fix -- and of course the fix itself

----


---
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] brooklyn-server issue #193: fix for issue where $brooklyn:external refs in p...

Posted by ahgittin <gi...@git.apache.org>.
Github user ahgittin commented on the issue:

    https://github.com/apache/brooklyn-server/pull/193
  
    thx @nakomis, all addressed


---
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] brooklyn-server pull request #193: fix for issue where $brooklyn:external re...

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

    https://github.com/apache/brooklyn-server/pull/193#discussion_r66480033
  
    --- Diff: camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/LocationExternalConfigYamlTest.java ---
    @@ -0,0 +1,153 @@
    +/*
    + * 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 org.apache.brooklyn.camp.brooklyn;
    +
    +import static org.testng.Assert.assertEquals;
    +
    +import java.io.StringReader;
    +
    +import org.apache.brooklyn.api.entity.Entity;
    +import org.apache.brooklyn.api.location.Location;
    +import org.apache.brooklyn.camp.brooklyn.ExternalConfigYamlTest.MyExternalConfigSupplier;
    +import org.apache.brooklyn.camp.brooklyn.ExternalConfigYamlTest.MyExternalConfigSupplierWithoutMapArg;
    +import org.apache.brooklyn.config.ConfigKey;
    +import org.apache.brooklyn.core.config.ConfigKeys;
    +import org.apache.brooklyn.core.entity.StartableApplication;
    +import org.apache.brooklyn.core.internal.BrooklynProperties;
    +import org.apache.brooklyn.core.objs.BrooklynObjectInternal;
    +import org.apache.brooklyn.entity.software.base.EmptySoftwareProcess;
    +import org.apache.brooklyn.util.core.task.DeferredSupplier;
    +import org.apache.brooklyn.util.guava.Maybe;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +import org.testng.Assert;
    +import org.testng.annotations.Test;
    +
    +import com.google.common.base.Joiner;
    +import com.google.common.collect.ImmutableList;
    +import com.google.common.collect.Iterables;
    +
    +public class LocationExternalConfigYamlTest extends AbstractYamlRebindTest {
    +
    +	private static final Logger log = LoggerFactory.getLogger(ExternalConfigYamlTest.class);
    --- End diff --
    
    Tab character...


---
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] brooklyn-server pull request #193: fix for issue where $brooklyn:external re...

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

    https://github.com/apache/brooklyn-server/pull/193


---
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] brooklyn-server pull request #193: fix for issue where $brooklyn:external re...

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

    https://github.com/apache/brooklyn-server/pull/193#discussion_r66481067
  
    --- Diff: camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/LocationExternalConfigYamlTest.java ---
    @@ -0,0 +1,153 @@
    +/*
    + * 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 org.apache.brooklyn.camp.brooklyn;
    +
    +import static org.testng.Assert.assertEquals;
    +
    +import java.io.StringReader;
    +
    +import org.apache.brooklyn.api.entity.Entity;
    +import org.apache.brooklyn.api.location.Location;
    +import org.apache.brooklyn.camp.brooklyn.ExternalConfigYamlTest.MyExternalConfigSupplier;
    +import org.apache.brooklyn.camp.brooklyn.ExternalConfigYamlTest.MyExternalConfigSupplierWithoutMapArg;
    +import org.apache.brooklyn.config.ConfigKey;
    +import org.apache.brooklyn.core.config.ConfigKeys;
    +import org.apache.brooklyn.core.entity.StartableApplication;
    +import org.apache.brooklyn.core.internal.BrooklynProperties;
    +import org.apache.brooklyn.core.objs.BrooklynObjectInternal;
    +import org.apache.brooklyn.entity.software.base.EmptySoftwareProcess;
    +import org.apache.brooklyn.util.core.task.DeferredSupplier;
    +import org.apache.brooklyn.util.guava.Maybe;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +import org.testng.Assert;
    +import org.testng.annotations.Test;
    +
    +import com.google.common.base.Joiner;
    +import com.google.common.collect.ImmutableList;
    +import com.google.common.collect.Iterables;
    +
    +public class LocationExternalConfigYamlTest extends AbstractYamlRebindTest {
    +
    +	private static final Logger log = LoggerFactory.getLogger(ExternalConfigYamlTest.class);
    +
    +    private static final ConfigKey<String> MY_CONFIG_KEY = ConfigKeys.newStringConfigKey("my.config.key");
    +    
    +    @Override
    +    protected BrooklynProperties createBrooklynProperties() {
    +        BrooklynProperties props = super.createBrooklynProperties();
    +        props.put("brooklyn.external.myprovider", MyExternalConfigSupplier.class.getName());
    +        props.put("brooklyn.external.myprovider.mykey", "myval");
    +        props.put("brooklyn.external.myproviderWithoutMapArg", MyExternalConfigSupplierWithoutMapArg.class.getName());
    +        return props;
    +    }
    +
    +    @Test(groups="Integration")
    +    public void testLocalhostInheritance() throws Exception {
    +        String yaml = Joiner.on("\n").join(
    +                "services:",
    +                "- type: "+EmptySoftwareProcess.class.getName(),
    +                "location:",
    +                "  localhost:",
    +                "    my.config.key: $brooklyn:external(\"myprovider\", \"mykey\")");
    +
    +        origApp = (StartableApplication) createAndStartApplication(new StringReader(yaml));
    +
    +        Entity entity = Iterables.getOnlyElement( origApp.getChildren() );
    +        Location l = Iterables.getOnlyElement( entity.getLocations() );
    +        log.info("Location: "+l);
    --- End diff --
    
    These log statements don't really give much info in the context of reading a log file, should be removed, or give more context


---
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] brooklyn-server pull request #193: fix for issue where $brooklyn:external re...

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

    https://github.com/apache/brooklyn-server/pull/193#discussion_r66480706
  
    --- Diff: camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/LocationExternalConfigYamlTest.java ---
    @@ -0,0 +1,153 @@
    +/*
    + * 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 org.apache.brooklyn.camp.brooklyn;
    +
    +import static org.testng.Assert.assertEquals;
    +
    +import java.io.StringReader;
    +
    +import org.apache.brooklyn.api.entity.Entity;
    +import org.apache.brooklyn.api.location.Location;
    +import org.apache.brooklyn.camp.brooklyn.ExternalConfigYamlTest.MyExternalConfigSupplier;
    +import org.apache.brooklyn.camp.brooklyn.ExternalConfigYamlTest.MyExternalConfigSupplierWithoutMapArg;
    +import org.apache.brooklyn.config.ConfigKey;
    +import org.apache.brooklyn.core.config.ConfigKeys;
    +import org.apache.brooklyn.core.entity.StartableApplication;
    +import org.apache.brooklyn.core.internal.BrooklynProperties;
    +import org.apache.brooklyn.core.objs.BrooklynObjectInternal;
    +import org.apache.brooklyn.entity.software.base.EmptySoftwareProcess;
    +import org.apache.brooklyn.util.core.task.DeferredSupplier;
    +import org.apache.brooklyn.util.guava.Maybe;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +import org.testng.Assert;
    +import org.testng.annotations.Test;
    +
    +import com.google.common.base.Joiner;
    +import com.google.common.collect.ImmutableList;
    +import com.google.common.collect.Iterables;
    +
    +public class LocationExternalConfigYamlTest extends AbstractYamlRebindTest {
    +
    +	private static final Logger log = LoggerFactory.getLogger(ExternalConfigYamlTest.class);
    +
    +    private static final ConfigKey<String> MY_CONFIG_KEY = ConfigKeys.newStringConfigKey("my.config.key");
    +    
    +    @Override
    +    protected BrooklynProperties createBrooklynProperties() {
    +        BrooklynProperties props = super.createBrooklynProperties();
    +        props.put("brooklyn.external.myprovider", MyExternalConfigSupplier.class.getName());
    +        props.put("brooklyn.external.myprovider.mykey", "myval");
    +        props.put("brooklyn.external.myproviderWithoutMapArg", MyExternalConfigSupplierWithoutMapArg.class.getName());
    +        return props;
    +    }
    +
    +    @Test(groups="Integration")
    +    public void testLocalhostInheritance() throws Exception {
    +        String yaml = Joiner.on("\n").join(
    +                "services:",
    +                "- type: "+EmptySoftwareProcess.class.getName(),
    +                "location:",
    +                "  localhost:",
    +                "    my.config.key: $brooklyn:external(\"myprovider\", \"mykey\")");
    +
    +        origApp = (StartableApplication) createAndStartApplication(new StringReader(yaml));
    +
    +        Entity entity = Iterables.getOnlyElement( origApp.getChildren() );
    +        Location l = Iterables.getOnlyElement( entity.getLocations() );
    +        log.info("Location: "+l);
    +        assertEquals(l.config().get(MY_CONFIG_KEY), "myval");
    +                
    +        Maybe<Object> rawConfig = ((BrooklynObjectInternal.ConfigurationSupportInternal)l.config()).getRaw(MY_CONFIG_KEY);
    +        log.info("Raw config: "+rawConfig);
    +        Assert.assertTrue(rawConfig.isPresentAndNonNull());
    +        Assert.assertTrue(rawConfig.get() instanceof DeferredSupplier, "Expected deferred raw value; got "+rawConfig.get());
    +    }
    +    
    +    @Test(groups="Integration")
    +    public void testLocationFromCatalogInheritanceAndRebind() throws Exception {
    +        ImmutableList.Builder<String> yamlL = ImmutableList.<String>builder().add(
    +                "brooklyn.catalog:",
    +                "  id: l1",
    +                "  item.type: location",
    +                "  item:",
    +                "    type: localhost",
    +                "    brooklyn.config:",
    +                "      simple: 42",
    +                "      my.config.key: $brooklyn:external(\"myprovider\", \"mykey\")");
    +        addCatalogItems(yamlL.build());
    +
    +        String yaml = Joiner.on("\n").join(
    +                "services:",
    +                "- type: "+EmptySoftwareProcess.class.getName(),
    +                "location: l1");
    +
    +        origApp = (StartableApplication) createAndStartApplication(new StringReader(yaml));
    +
    +        Entity entity = Iterables.getOnlyElement( origApp.getChildren() );
    +        Location l = Iterables.getOnlyElement( entity.getLocations() );
    +        log.info("Location: "+l);
    +        assertEquals(l.config().get(ConfigKeys.builder(Integer.class, "simple").build()), (Integer)42);
    +        assertEquals(l.config().get(MY_CONFIG_KEY), "myval");
    +                
    +        Maybe<Object> rawConfig = ((BrooklynObjectInternal.ConfigurationSupportInternal)l.config()).getRaw(MY_CONFIG_KEY);
    +        log.info("Raw config: "+rawConfig);
    +        Assert.assertTrue(rawConfig.isPresentAndNonNull());
    +        Assert.assertTrue(rawConfig.get() instanceof DeferredSupplier, "Expected deferred raw value; got "+rawConfig.get());
    +        
    +        newApp = rebind();
    +        log.info("After catalog rebind: "+newApp);
    +        
    +        entity = Iterables.getOnlyElement( newApp.getChildren() );
    +        l = Iterables.getOnlyElement( entity.getLocations() );
    +        log.info("Location: "+l);
    +        assertEquals(l.config().get(ConfigKeys.builder(Integer.class, "simple").build()), (Integer)42);
    +        assertEquals(l.config().get(MY_CONFIG_KEY), "myval");
    +                
    +        rawConfig = ((BrooklynObjectInternal.ConfigurationSupportInternal)l.config()).getRaw(MY_CONFIG_KEY);
    +        log.info("Raw config: "+rawConfig);
    +        Assert.assertTrue(rawConfig.isPresentAndNonNull());
    +        Assert.assertTrue(rawConfig.get() instanceof DeferredSupplier, "Expected deferred raw value; got "+rawConfig.get());
    +    }
    +    
    +    @Test(groups="Integration")
    +    public void testProvisioningPropertyInheritance() throws Exception {
    +        String yaml = Joiner.on("\n").join(
    +                "services:",
    +                "- type: "+EmptySoftwareProcess.class.getName(),
    +                "  provisioning.properties:",
    +                "      simple: 42",
    --- End diff --
    
    Indentation should be 2 spaces, but doesn't really matter


---
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.
---