brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aleds...@apache.org
Subject [1/6] brooklyn-server git commit: new test showing changed behaviour of default config value resolution
Date Mon, 07 Nov 2016 15:17:07 GMT
Repository: brooklyn-server
Updated Branches:
  refs/heads/master 8f24d230e -> 0bf82808e


new test showing changed behaviour of default config value resolution

as included in the release notes


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

Branch: refs/heads/master
Commit: e9c1f4cbb67d1bd89d1e7d84f8730225047ea337
Parents: ef39421
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Mon Nov 7 11:21:41 2016 +0000
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Mon Nov 7 11:22:59 2016 +0000

----------------------------------------------------------------------
 .../brooklyn/ConfigTypeCoercionYamlTest.java    | 77 ++++++++++++++++++++
 .../brooklyn/config-type-coercion-test.yaml     | 47 ++++++++++++
 2 files changed, 124 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/e9c1f4cb/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ConfigTypeCoercionYamlTest.java
----------------------------------------------------------------------
diff --git a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ConfigTypeCoercionYamlTest.java
b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ConfigTypeCoercionYamlTest.java
new file mode 100644
index 0000000..0919443
--- /dev/null
+++ b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ConfigTypeCoercionYamlTest.java
@@ -0,0 +1,77 @@
+/*
+ * 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 java.util.Map;
+
+import org.apache.brooklyn.api.entity.Entity;
+import org.apache.brooklyn.test.Asserts;
+import org.apache.brooklyn.util.core.internal.ssh.RecordingSshTool;
+import org.apache.brooklyn.util.text.StringPredicates;
+import org.apache.brooklyn.util.text.Strings;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.Assert;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+public class ConfigTypeCoercionYamlTest extends AbstractYamlTest {
+    private static final Logger log = LoggerFactory.getLogger(ConfigTypeCoercionYamlTest.class);
+
+    @BeforeMethod(alwaysRun=true)
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+        RecordingSshTool.clear();
+    }
+    
+    @Test
+    public void testSshConfigFromDefault() throws Exception {
+        RecordingSshTool.setCustomResponse(".*myCommand.*", new RecordingSshTool.CustomResponse(0,
"myResponse", null));
+        
+        String bp = loadYaml("config-type-coercion-test.yaml",
+            "location:",
+            "  localhost:",
+            "    sshToolClass: "+RecordingSshTool.class.getName());
+        // remove all lines referring to "exact" -- that's useful for expository and running
in UI
+        // but it will fail (timeout) if the port isn't available so not good in tests
+        bp = Strings.removeLines(bp, StringPredicates.containsLiteralIgnoreCase("exact"));
+        
+        Entity app = createAndStartApplication(bp);
+        waitForApplicationTasks(app);
+
+        Map<?, ?> props = RecordingSshTool.getLastExecCmd().env;
+        
+        Assert.assertEquals(props.get("RANGE_PORT_SENSOR"), "20003");
+        Asserts.assertStringContains((String)props.get("RANGE_PORT_CONFIG"), "{\"start\"",
"20003");
+        
+        Assert.assertEquals(props.get("INT_PORT_CONFIG"), "20001");
+        Assert.assertEquals(props.get("INT_PORT_DEFAULT_CONFIG"), "30001");
+        
+        Assert.assertEquals(props.get("RANGE_PORT_DEFAULT_SENSOR"), "30003");
+        // NB: change in Oct 2016, default values are now coerced just like explicit value
+        // (previous to Oct 2016 this would have returned just "30003+", no json)
+        Asserts.assertStringContains((String)props.get("RANGE_PORT_DEFAULT_CONFIG"), "{\"start\"",
"30003");
+    }
+    
+    @Override
+    protected Logger getLogger() {
+        return log;
+    }
+}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/e9c1f4cb/camp/camp-brooklyn/src/test/resources/org/apache/brooklyn/camp/brooklyn/config-type-coercion-test.yaml
----------------------------------------------------------------------
diff --git a/camp/camp-brooklyn/src/test/resources/org/apache/brooklyn/camp/brooklyn/config-type-coercion-test.yaml
b/camp/camp-brooklyn/src/test/resources/org/apache/brooklyn/camp/brooklyn/config-type-coercion-test.yaml
new file mode 100644
index 0000000..9cf81b6
--- /dev/null
+++ b/camp/camp-brooklyn/src/test/resources/org/apache/brooklyn/camp/brooklyn/config-type-coercion-test.yaml
@@ -0,0 +1,47 @@
+services:
+- type: org.apache.brooklyn.entity.software.base.VanillaSoftwareProcess
+  shell.env:
+    EXACT_PORT_CONFIG: $brooklyn:config("exact.port")
+    EXACT_PORT_SENSOR: $brooklyn:attributeWhenReady("exact.port")
+    RANGE_PORT_CONFIG: $brooklyn:config("range.port")
+    RANGE_PORT_SENSOR: $brooklyn:attributeWhenReady("range.port")
+    INT_PORT_CONFIG: $brooklyn:config("int.port")
+    EXACT_PORT_DEFAULT_CONFIG: $brooklyn:config("exact.default.port")
+    EXACT_PORT_DEFAULT_SENSOR: $brooklyn:attributeWhenReady("exact.default.port")
+    RANGE_PORT_DEFAULT_CONFIG: $brooklyn:config("range.default.port")
+    RANGE_PORT_DEFAULT_SENSOR: $brooklyn:attributeWhenReady("range.default.port")
+    INT_PORT_DEFAULT_CONFIG: $brooklyn:config("int.default.port")
+  install.command: true
+  checkRunning.command: true
+  launch.command: |
+    echo EXACT_PORT_CONFIG is $EXACT_PORT_CONFIG
+    echo EXACT_PORT_SENSOR is $EXACT_PORT_SENSOR
+    echo RANGE_PORT_CONFIG is $RANGE_PORT_CONFIG
+    echo RANGE_PORT_SENSOR is $RANGE_PORT_SENSOR
+    echo INT_PORT_CONFIG is $INT_PORT_CONFIG
+    echo EXACT_PORT_DEFAULT_CONFIG is $EXACT_PORT_DEFAULT_CONFIG
+    echo EXACT_PORT_DEFAULT_SENSOR is $EXACT_PORT_DEFAULT_SENSOR
+    echo RANGE_PORT_DEFAULT_CONFIG is $RANGE_PORT_DEFAULT_CONFIG
+    echo RANGE_PORT_DEFAULT_SENSOR is $RANGE_PORT_DEFAULT_SENSOR
+    echo INT_PORT_DEFAULT_CONFIG is $INT_PORT_DEFAULT_CONFIG
+  brooklyn.parameters:
+  - name: int.port
+    type: int
+  # ("exact" items are put on one line so we can filter them in tests)
+  - { name: exact.port, type: port }
+  - name: range.port
+    type: port
+  - name: int.default.port
+    type: int
+    default: 30001
+  - { name: exact.default.port, type: port, default: 30002 }
+  - name: range.default.port
+    type: port
+    default: 30003+
+  brooklyn.config:
+    int.port: 20001
+    exact.port: 20002
+    range.port: 20003+
+
+# if running manually, add this:
+# location: localhost
\ No newline at end of file


Mime
View raw message