brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aleds...@apache.org
Subject [1/2] incubator-brooklyn git commit: more tests for $brooklyn:external, clarifying DSL usage in location block
Date Wed, 07 Oct 2015 23:37:52 GMT
Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master b2986e724 -> 7b89b6644


more tests for $brooklyn:external, clarifying DSL usage in location block


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/b4145129
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/b4145129
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/b4145129

Branch: refs/heads/master
Commit: b41451290c052f8f6b271416c0435d253597a371
Parents: 2995471
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Mon Sep 28 10:46:03 2015 +0100
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Mon Sep 28 10:52:10 2015 +0100

----------------------------------------------------------------------
 .../camp/brooklyn/ExternalConfigYamlTest.java   | 40 ++++++++++++++++++++
 1 file changed, 40 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/b4145129/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/ExternalConfigYamlTest.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/ExternalConfigYamlTest.java
b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/ExternalConfigYamlTest.java
index 7f46861..5d1ab39 100644
--- a/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/ExternalConfigYamlTest.java
+++ b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/ExternalConfigYamlTest.java
@@ -24,16 +24,20 @@ import static org.testng.Assert.fail;
 import java.io.StringReader;
 import java.util.Map;
 
+import org.apache.brooklyn.api.entity.Entity;
 import org.apache.brooklyn.api.mgmt.ManagementContext;
 import org.apache.brooklyn.config.ConfigKey;
 import org.apache.brooklyn.core.config.ConfigKeys;
 import org.apache.brooklyn.core.config.external.AbstractExternalConfigSupplier;
 import org.apache.brooklyn.core.config.external.ExternalConfigSupplier;
 import org.apache.brooklyn.core.internal.BrooklynProperties;
+import org.apache.brooklyn.core.location.cloud.CloudLocationConfig;
 import org.apache.brooklyn.core.mgmt.internal.LocalManagementContext;
 import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests;
 import org.apache.brooklyn.core.test.entity.TestApplication;
+import org.apache.brooklyn.entity.software.base.EmptySoftwareProcess;
 import org.apache.brooklyn.util.exceptions.Exceptions;
+import org.python.google.common.collect.Iterables;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.annotations.Test;
@@ -71,6 +75,42 @@ public class ExternalConfigYamlTest extends AbstractYamlTest {
 
         assertEquals(app.getConfig(MY_CONFIG_KEY), "myval");
     }
+
+    // FIXME fails currently - see comment at ConfigBag.get; fix at AbstractLocation.BasicConfigurationSupport
to enable this?
+//    at org.apache.brooklyn.util.core.config.ConfigBag.coerceFirstNonNullKeyValue(ConfigBag.java:464)
+//    at org.apache.brooklyn.util.core.config.ConfigBag.get(ConfigBag.java:458)
+//    at org.apache.brooklyn.util.core.config.ConfigBag.get(ConfigBag.java:345)
+//    at org.apache.brooklyn.core.location.AbstractLocation$BasicConfigurationSupport.get(AbstractLocation.java:364)
   @Test
+    @Test(groups="WIP")
+    public void testExternalisedLocationConfigReferencedFromYaml() throws Exception {
+        ConfigKey<String> MY_CONFIG_KEY = ConfigKeys.newStringConfigKey("my.config.key");
+        
+        String yaml = Joiner.on("\n").join(
+            "services:",
+            "- type: org.apache.brooklyn.core.test.entity.TestApplication",
+            "location:",
+            "  localhost:",
+            "    my.config.key: $brooklyn:external(\"myprovider\", \"mykey\")");
+        
+        TestApplication app = (TestApplication) createAndStartApplication(new StringReader(yaml));
+        waitForApplicationTasks(app);
+        assertEquals(Iterables.getOnlyElement( app.getLocations() ).config().get(MY_CONFIG_KEY),
"myval");
+    }
+    
+    @Test(groups="Integration")
+    public void testExternalisedLocationConfigSetViaProvisioningPropertiesReferencedFromYaml()
throws Exception {
+        String yaml = Joiner.on("\n").join(
+            "services:",
+            "- type: "+EmptySoftwareProcess.class.getName(),
+            "  provisioning.properties:",
+            "    credential: $brooklyn:external(\"myprovider\", \"mykey\")",
+            "location: localhost");
+        
+        Entity app = createAndStartApplication(new StringReader(yaml));
+        waitForApplicationTasks(app);
+        Entity entity = Iterables.getOnlyElement( app.getChildren() );
+        assertEquals(Iterables.getOnlyElement( entity.getLocations() ).config().get(CloudLocationConfig.ACCESS_CREDENTIAL),
"myval");
+    }
     
     @Test
     public void testExternalisedConfigFromSupplierWithoutMapArg() throws Exception {


Mime
View raw message