You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by ge...@apache.org on 2018/04/19 12:51:27 UTC

[2/3] brooklyn-server git commit: Adds test for SshcommandSensor DSL resolution

Adds test for SshcommandSensor DSL resolution


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

Branch: refs/heads/master
Commit: 4e5dfc3418bc362000a760fd48230862cda6c5c2
Parents: ea59dee
Author: Martin Harris <gi...@nakomis.com>
Authored: Tue Apr 17 17:18:11 2018 +0100
Committer: Martin Harris <gi...@nakomis.com>
Committed: Tue Apr 17 17:18:11 2018 +0100

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


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/4e5dfc34/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/SshCommandSensorYamlTest.java
----------------------------------------------------------------------
diff --git a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/SshCommandSensorYamlTest.java b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/SshCommandSensorYamlTest.java
index 09c99ac..1efc04c 100644
--- a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/SshCommandSensorYamlTest.java
+++ b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/SshCommandSensorYamlTest.java
@@ -110,7 +110,46 @@ public class SshCommandSensorYamlTest extends AbstractYamlTest {
                 listener.assertEventCount(1);
             }});
     }
-    
+
+    // "Integration" because takes a couple of seconds
+    @Test(groups="Integration")
+    public void testDslWithSshSensor() throws Exception {
+        AttributeSensor<String> mySensor = Sensors.newStringSensor("mySensor");
+        AttributeSensor<String> sourceSensor = Sensors.newStringSensor("sourceSensor");
+
+        Entity app = createAndStartApplication(
+                "location:",
+                "  localhost",
+                "services:",
+                "- type: " + VanillaSoftwareProcess.class.getName(),
+                "  brooklyn.config:",
+                "    onbox.base.dir.skipResolution: true",
+                "    checkRunning.command: true",
+                "  brooklyn.initializers:",
+                "  - type: org.apache.brooklyn.core.sensor.StaticSensor",
+                "    brooklyn.config:",
+                "      name: " + sourceSensor.getName(),
+                "      sensorType: string",
+                "      static.value: someValue",
+                "  - type: org.apache.brooklyn.core.sensor.ssh.SshCommandSensor",
+                "    brooklyn.config:",
+                "      name: " + mySensor.getName(),
+                "      command: ",
+                "        $brooklyn:formatString:",
+                "        - echo %s",
+                "        - $brooklyn:attributeWhenReady(\"sourceSensor\")",
+                "      suppressDuplicates: true",
+                "      period: 10ms",
+                "      onlyIfServiceUp: false");
+        waitForApplicationTasks(app);
+
+        VanillaSoftwareProcess entity = (VanillaSoftwareProcess) Iterables.getOnlyElement(app.getChildren());
+        EntityAsserts.assertAttributeEqualsEventually(entity, mySensor, "someValue");
+
+        entity.sensors().set(sourceSensor, "newValue");
+        EntityAsserts.assertAttributeEqualsEventually(entity, mySensor, "someValue");
+    }
+
     @Override
     protected Logger getLogger() {
         return log;