You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by gr...@apache.org on 2014/08/21 18:01:16 UTC

[01/11] git commit: Change root URL to use default

Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master 8643fbc78 -> cc1915aaa


Change root URL to use default


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

Branch: refs/heads/master
Commit: a68f4295322a820fa8a2b4922a551091c8e21ed7
Parents: ef23cc1
Author: Andrew Kennedy <gr...@apache.org>
Authored: Thu Jul 31 15:37:30 2014 +0100
Committer: Andrew Kennedy <gr...@apache.org>
Committed: Thu Aug 21 14:50:26 2014 +0100

----------------------------------------------------------------------
 .../entity/webapp/nodejs/NodeJsWebAppServiceImpl.java        | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a68f4295/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppServiceImpl.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppServiceImpl.java b/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppServiceImpl.java
index 802727e..b5fa4c9 100644
--- a/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppServiceImpl.java
+++ b/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppServiceImpl.java
@@ -5,11 +5,14 @@ import org.slf4j.LoggerFactory;
 
 import brooklyn.entity.basic.SoftwareProcessImpl;
 import brooklyn.entity.webapp.WebAppServiceMethods;
+import brooklyn.event.feed.ConfigToAttributes;
 import brooklyn.event.feed.http.HttpFeed;
 import brooklyn.event.feed.http.HttpPollConfig;
 import brooklyn.event.feed.http.HttpValueFunctions;
+import brooklyn.location.access.BrooklynAccessUtils;
 
 import com.google.common.base.Predicates;
+import com.google.common.net.HostAndPort;
 
 public class NodeJsWebAppServiceImpl extends SoftwareProcessImpl implements NodeJsWebAppService {
 
@@ -31,7 +34,10 @@ public class NodeJsWebAppServiceImpl extends SoftwareProcessImpl implements Node
     protected void connectSensors() {
         super.connectSensors();
 
-        String nodeJsUrl = WebAppServiceMethods.inferBrooklynAccessibleRootUrl(this);
+        ConfigToAttributes.apply(this);
+
+        HostAndPort accessible = BrooklynAccessUtils.getBrooklynAccessibleAddress(this, getAttribute(HTTP_PORT));
+        String nodeJsUrl = String.format("http://%s:%d", accessible.getHostText(), accessible.getPort());
         LOG.info("Connecting to {}", nodeJsUrl);
 
         httpFeed = HttpFeed.builder()


[07/11] git commit: Updated test code with example Todo application

Posted by gr...@apache.org.
Updated test code with example Todo application


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

Branch: refs/heads/master
Commit: a97b7682cca2660ff66abc8f49c80666061ad3f1
Parents: a26970a
Author: Andrew Kennedy <gr...@apache.org>
Authored: Fri Aug 15 16:36:32 2014 +0100
Committer: Andrew Kennedy <gr...@apache.org>
Committed: Thu Aug 21 14:50:27 2014 +0100

----------------------------------------------------------------------
 software/webapp/pom.xml                         |   8 +-
 .../webapp/nodejs/NodeJsWebAppService.java      |   4 +
 .../webapp/src/main/resources/jetty-logo.svg    |  88 -------------------
 .../webapp/src/main/resources/nodejs-logo.png   | Bin 0 -> 9620 bytes
 .../webapp/nodejs/NodeJsTodoApplication.java    |  56 ++++++++++++
 .../webapp/nodejs/NodeJsWebAppEc2LiveTest.java  |   8 ++
 .../NodeJsWebAppFixtureIntegrationTest.java     |   4 -
 .../NodeJsWebAppSimpleIntegrationTest.java      |  22 ++---
 .../webapp/nodejs/nodejs-hello-world.yaml       |  31 +++++++
 9 files changed, 113 insertions(+), 108 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a97b7682/software/webapp/pom.xml
----------------------------------------------------------------------
diff --git a/software/webapp/pom.xml b/software/webapp/pom.xml
index 43f95ac..a7aa180 100644
--- a/software/webapp/pom.xml
+++ b/software/webapp/pom.xml
@@ -111,7 +111,6 @@
         <dependency>
             <groupId>mx4j</groupId>
             <artifactId>mx4j-tools</artifactId>
-            <version>${mx4j.version}</version>
             <scope>test</scope>
         </dependency>
         <dependency>
@@ -141,6 +140,13 @@
             <classifier>tests</classifier>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>io.brooklyn</groupId>
+            <artifactId>brooklyn-software-nosql</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+
         <!-- bring in jclouds for testing -->
         <dependency>
             <groupId>io.brooklyn</groupId>

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a97b7682/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppService.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppService.java b/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppService.java
index d4fe793..7e6b840 100644
--- a/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppService.java
+++ b/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppService.java
@@ -20,6 +20,7 @@ package brooklyn.entity.webapp.nodejs;
 
 import java.util.List;
 
+import brooklyn.catalog.Catalog;
 import brooklyn.config.ConfigKey;
 import brooklyn.entity.basic.Attributes;
 import brooklyn.entity.basic.ConfigKeys;
@@ -33,6 +34,9 @@ import brooklyn.util.flags.SetFromFlag;
 import com.google.common.collect.ImmutableList;
 import com.google.common.reflect.TypeToken;
 
+@Catalog(name="Node.JS Application",
+        description="Node.JS Web Application",
+        iconUrl="classpath:///nodejs-logo.png")
 @ImplementedBy(NodeJsWebAppServiceImpl.class)
 public interface NodeJsWebAppService extends SoftwareProcess, WebAppService {
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a97b7682/software/webapp/src/main/resources/jetty-logo.svg
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/resources/jetty-logo.svg b/software/webapp/src/main/resources/jetty-logo.svg
deleted file mode 100644
index 5f8d6fd..0000000
--- a/software/webapp/src/main/resources/jetty-logo.svg
+++ /dev/null
@@ -1,88 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-<svg
-   xmlns:dc="http://purl.org/dc/elements/1.1/"
-   xmlns:cc="http://creativecommons.org/ns#"
-   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
-   xmlns:svg="http://www.w3.org/2000/svg"
-   xmlns="http://www.w3.org/2000/svg"
-   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
-   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
-   width="1400"
-   height="400"
-   id="svg2"
-   sodipodi:version="0.32"
-   inkscape:version="0.46"
-   version="1.0"
-   sodipodi:docname="jetty-logo.svg"
-   inkscape:output_extension="org.inkscape.output.svg.inkscape"
-   inkscape:export-filename="/home/joakim/documents/Webtide/jetty-logo.png"
-   inkscape:export-xdpi="90"
-   inkscape:export-ydpi="90">
-  <defs
-     id="defs4">
-    <inkscape:perspective
-       sodipodi:type="inkscape:persp3d"
-       inkscape:vp_x="0 : 526.18109 : 1"
-       inkscape:vp_y="0 : 1000 : 0"
-       inkscape:vp_z="744.09448 : 526.18109 : 1"
-       inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
-       id="perspective10" />
-    <inkscape:perspective
-       id="perspective2390"
-       inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
-       inkscape:vp_z="744.09448 : 526.18109 : 1"
-       inkscape:vp_y="0 : 1000 : 0"
-       inkscape:vp_x="0 : 526.18109 : 1"
-       sodipodi:type="inkscape:persp3d" />
-  </defs>
-  <sodipodi:namedview
-     id="base"
-     pagecolor="#ffffff"
-     bordercolor="#666666"
-     borderopacity="1.0"
-     gridtolerance="10000"
-     guidetolerance="10"
-     objecttolerance="10"
-     inkscape:pageopacity="0.0"
-     inkscape:pageshadow="2"
-     inkscape:zoom="0.87428571"
-     inkscape:cx="700"
-     inkscape:cy="200"
-     inkscape:document-units="px"
-     inkscape:current-layer="layer2"
-     showgrid="false"
-     inkscape:window-width="1679"
-     inkscape:window-height="1001"
-     inkscape:window-x="1"
-     inkscape:window-y="48"
-     showguides="true"
-     inkscape:guide-bbox="true"
-     showborder="true" />
-  <metadata
-     id="metadata7">
-    <rdf:RDF>
-      <cc:Work
-         rdf:about="">
-        <dc:format>image/svg+xml</dc:format>
-        <dc:type
-           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
-      </cc:Work>
-    </rdf:RDF>
-  </metadata>
-  <g
-     inkscape:groupmode="layer"
-     id="layer2"
-     inkscape:label="Jetty"
-     style="display:inline"
-     transform="translate(-1.845606,-221.31978)">
-    <path
-       id="path3193"
-       style="fill:#fc390e;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:25;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
-       d="M 468.5751,304.59386 L 460.4501,339.75011 L 430.85635,339.75011 L 423.54385,371.50011 L 453.1376,371.50011 L 435.6376,447.21886 C 431.11514,466.80783 434.69559,501.46886 475.60635,501.46886 L 574.3876,501.46886 L 582.3876,466.81261 C 513.82035,466.81262 513.81207,466.80768 518.8251,445.09386 L 535.8251,371.50011 L 598.2626,371.50011 L 604.3876,371.50011 L 627.85635,371.50011 L 610.35635,447.21886 C 605.83388,466.80782 609.41434,501.46886 650.3251,501.46886 L 749.10635,501.46886 L 757.10635,466.81261 C 688.53909,466.81261 688.53082,466.80768 693.54385,445.09386 L 710.54385,371.50011 L 779.10635,371.50011 L 786.4501,339.75011 L 717.85635,339.75011 L 725.98135,304.59386 L 643.29385,304.59386 L 635.16885,339.75011 L 611.73135,339.75011 L 605.5751,339.75011 L 543.1376,339.75011 L 551.2626,304.59386 L 468.5751,304.59386 z M 106.32205,339.73892 L 65.825288,515.14967 C 63.418773,522.20878 59.752966,521.8319 51.570815,522.15277 L 50.608209,562.10092 L 117.99063,561.86026 C 131.0660
 3,561.13831 139.21491,553.72589 144.58946,535.43638 L 189.76977,339.73892 L 106.32205,339.73892 z M 119.98951,280.53864 L 109.65558,325.29983 L 193.1033,325.29983 L 203.43723,280.53864 L 119.98951,280.53864 z M 239.29385,339.75011 C 224.85477,339.75012 208.26802,352.04925 204.6376,371.50011 L 188.6376,436.96886 C 179.27284,477.53211 184.20976,501.46886 214.48135,501.46886 L 385.3251,501.46886 L 393.3251,466.81261 L 265.29385,466.81261 L 272.16885,436.96886 L 400.2001,436.96886 C 402.2537,428.07372 410.80305,415.14706 415.3251,371.50011 C 416.6053,365.955 407.76262,339.75011 374.5126,339.75011 L 239.29385,339.75011 z M 307.98135,371.50011 C 325.75108,371.50011 330.91518,377.05789 325.2001,401.81261 L 280.29385,401.81261 C 285.80848,377.9261 293.45487,371.5001 307.98135,371.50011 z M 799.21238,339.73892 L 769.87735,466.80292 C 769.87735,466.80292 761.87689,501.45673 810.59962,501.45673 L 893.34691,501.45673 C 889.21672,519.34655 887.23544,527.9284 839.14197,527.9284 L 755.76542,527.92
 84 L 748.32055,560.1757 L 879.79056,560.1757 C 940.41876,560.1757 962.20636,560.1757 969.65123,527.9284 L 1013.0982,339.73892 L 930.6824,339.73892 L 901.34737,466.80292 L 853.2539,466.80292 L 882.58893,339.73892 L 799.21238,339.73892 z M 1045.4591,339.73892 L 1031.1249,401.82701 L 1114.8716,401.82701 L 1129.2058,339.73892 L 1045.4591,339.73892 z M 1022.4578,439.36864 L 1008.1236,501.45673 L 1091.8702,501.45673 L 1106.2044,439.36864 L 1022.4578,439.36864 z M 1217.5384,280.53864 L 1102.1787,527.9284 L 1144.3505,527.9284 L 1259.7102,280.53864 L 1217.5384,280.53864 z M 1310.9112,280.53864 L 1195.5515,527.9284 L 1237.7233,527.9284 L 1353.083,280.53864 L 1310.9112,280.53864 z" />
-    <path
-       d="M 468.5751,304.59386 L 460.4501,339.75011 L 430.85635,339.75011 L 423.54385,371.50011 L 453.1376,371.50011 L 435.6376,447.21886 C 431.11514,466.80783 434.69559,501.46886 475.60635,501.46886 L 574.3876,501.46886 L 582.3876,466.81261 C 513.82035,466.81262 513.81207,466.80768 518.8251,445.09386 L 535.8251,371.50011 L 598.2626,371.50011 L 604.3876,371.50011 L 627.85635,371.50011 L 610.35635,447.21886 C 605.83388,466.80782 609.41434,501.46886 650.3251,501.46886 L 749.10635,501.46886 L 757.10635,466.81261 C 688.53909,466.81261 688.53082,466.80768 693.54385,445.09386 L 710.54385,371.50011 L 779.10635,371.50011 L 786.4501,339.75011 L 717.85635,339.75011 L 725.98135,304.59386 L 643.29385,304.59386 L 635.16885,339.75011 L 611.73135,339.75011 L 605.5751,339.75011 L 543.1376,339.75011 L 551.2626,304.59386 L 468.5751,304.59386 z M 106.32205,339.73892 L 65.825288,515.14967 C 63.418773,522.20878 59.752966,521.8319 51.570815,522.15277 L 50.608209,562.10092 L 117.99063,561.86026 C 131.0660
 3,561.13831 139.21491,553.72589 144.58946,535.43638 L 189.76977,339.73892 L 106.32205,339.73892 z M 119.98951,280.53864 L 109.65558,325.29983 L 193.1033,325.29983 L 203.43723,280.53864 L 119.98951,280.53864 z M 239.29385,339.75011 C 224.85477,339.75012 208.26802,352.04925 204.6376,371.50011 L 188.6376,436.96886 C 179.27284,477.53211 184.20976,501.46886 214.48135,501.46886 L 385.3251,501.46886 L 393.3251,466.81261 L 265.29385,466.81261 L 272.16885,436.96886 L 400.2001,436.96886 C 402.2537,428.07372 410.80305,415.14706 415.3251,371.50011 C 416.6053,365.955 407.76262,339.75011 374.5126,339.75011 L 239.29385,339.75011 z M 307.98135,371.50011 C 325.75108,371.50011 330.91518,377.05789 325.2001,401.81261 L 280.29385,401.81261 C 285.80848,377.9261 293.45487,371.5001 307.98135,371.50011 z M 799.21238,339.73892 L 769.87735,466.80292 C 769.87735,466.80292 761.87689,501.45673 810.59962,501.45673 L 893.34691,501.45673 C 889.21672,519.34655 887.23544,527.9284 839.14197,527.9284 L 755.76542,527.92
 84 L 748.32055,560.1757 L 879.79056,560.1757 C 940.41876,560.1757 962.20636,560.1757 969.65123,527.9284 L 1013.0982,339.73892 L 930.6824,339.73892 L 901.34737,466.80292 L 853.2539,466.80292 L 882.58893,339.73892 L 799.21238,339.73892 z M 1045.4591,339.73892 L 1031.1249,401.82701 L 1114.8716,401.82701 L 1129.2058,339.73892 L 1045.4591,339.73892 z M 1022.4578,439.36864 L 1008.1236,501.45673 L 1091.8702,501.45673 L 1106.2044,439.36864 L 1022.4578,439.36864 z M 1217.5384,280.53864 L 1102.1787,527.9284 L 1144.3505,527.9284 L 1259.7102,280.53864 L 1217.5384,280.53864 z M 1310.9112,280.53864 L 1195.5515,527.9284 L 1237.7233,527.9284 L 1353.083,280.53864 L 1310.9112,280.53864 z"
-       style="fill:#fc390e;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:30;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
-       id="path3316" />
-  </g>
-</svg>

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a97b7682/software/webapp/src/main/resources/nodejs-logo.png
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/resources/nodejs-logo.png b/software/webapp/src/main/resources/nodejs-logo.png
new file mode 100644
index 0000000..c6c7b97
Binary files /dev/null and b/software/webapp/src/main/resources/nodejs-logo.png differ

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a97b7682/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsTodoApplication.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsTodoApplication.java b/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsTodoApplication.java
new file mode 100644
index 0000000..32043d5
--- /dev/null
+++ b/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsTodoApplication.java
@@ -0,0 +1,56 @@
+/*
+ * 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 brooklyn.entity.webapp.nodejs;
+
+import static brooklyn.event.basic.DependentConfiguration.attributeWhenReady;
+import brooklyn.catalog.Catalog;
+import brooklyn.entity.basic.AbstractApplication;
+import brooklyn.entity.basic.Attributes;
+import brooklyn.entity.basic.SoftwareProcess;
+import brooklyn.entity.basic.StartableApplication;
+import brooklyn.entity.nosql.redis.RedisStore;
+import brooklyn.entity.proxying.EntitySpec;
+import brooklyn.event.basic.DependentConfiguration;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * Node.JS Todo Application
+ */
+@Catalog(name="NodeJS Todo",
+        description="Node.JS Todo Application.",
+        iconUrl="classpath://nodejs-logo.png")
+public class NodeJsTodoApplication extends AbstractApplication implements StartableApplication {
+
+    @Override
+    public void init() {
+        RedisStore redis = addChild(EntitySpec.create(RedisStore.class));
+
+        addChild(EntitySpec.create(NodeJsWebAppService.class)
+                .configure(NodeJsWebAppService.APP_GIT_REPOSITORY_URL, "https://github.com/amirrajan/nodejs-todo/")
+                .configure(NodeJsWebAppService.APP_FILE, "server.js")
+                .configure(NodeJsWebAppService.APP_NAME, "nodejs-todo")
+                .configure(NodeJsWebAppService.NODE_PACKAGE_LIST, ImmutableList.of("express", "ejs", "redis"))
+                .configure(SoftwareProcess.SHELL_ENVIRONMENT, ImmutableMap.<String, Object>of(
+                        "REDISTOGO_URL", DependentConfiguration.formatString("redis://%s:%d/",
+                                attributeWhenReady(redis, Attributes.HOSTNAME), attributeWhenReady(redis, RedisStore.REDIS_PORT)))));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a97b7682/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppEc2LiveTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppEc2LiveTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppEc2LiveTest.java
index d89c94e..ac8e32d 100644
--- a/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppEc2LiveTest.java
+++ b/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppEc2LiveTest.java
@@ -21,6 +21,8 @@ package brooklyn.entity.webapp.nodejs;
 import static brooklyn.entity.webapp.nodejs.NodeJsWebAppFixtureIntegrationTest.*;
 import static org.testng.Assert.assertNotNull;
 
+import org.testng.annotations.Test;
+
 import brooklyn.entity.AbstractEc2LiveTest;
 import brooklyn.entity.proxying.EntitySpec;
 import brooklyn.location.Location;
@@ -56,4 +58,10 @@ public class NodeJsWebAppEc2LiveTest extends AbstractEc2LiveTest {
             }});
     }
 
+    @Test(groups = {"Live", "Live-sanity"})
+    @Override
+    public void test_Ubuntu_12_0() throws Exception {
+        super.test_Ubuntu_12_0();
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a97b7682/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppFixtureIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppFixtureIntegrationTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppFixtureIntegrationTest.java
index 3b24c14..fa56a34 100644
--- a/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppFixtureIntegrationTest.java
+++ b/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppFixtureIntegrationTest.java
@@ -18,8 +18,6 @@
  */
 package brooklyn.entity.webapp.nodejs;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.testng.annotations.DataProvider;
 
 import brooklyn.entity.basic.SoftwareProcess;
@@ -31,8 +29,6 @@ import brooklyn.test.entity.TestApplication;
 
 public class NodeJsWebAppFixtureIntegrationTest extends AbstractWebAppFixtureIntegrationTest {
 
-    private static final Logger LOG = LoggerFactory.getLogger(NodeJsWebAppFixtureIntegrationTest.class);
-
     public static final String GIT_REPO_URL = "https://github.com/grkvlt/node-hello-world.git";
     public static final String APP_FILE = "app.js";
     public static final String APP_NAME = "node-hello-world";

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a97b7682/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSimpleIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSimpleIntegrationTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSimpleIntegrationTest.java
index 34ebb3a..54e6c7f 100644
--- a/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSimpleIntegrationTest.java
+++ b/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSimpleIntegrationTest.java
@@ -25,15 +25,13 @@ import java.net.ServerSocket;
 import java.util.Iterator;
 
 import org.jclouds.util.Throwables2;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
-import brooklyn.entity.basic.ApplicationBuilder;
 import brooklyn.entity.basic.Entities;
 import brooklyn.entity.proxying.EntitySpec;
+import brooklyn.location.LocationSpec;
 import brooklyn.location.PortRange;
 import brooklyn.location.basic.LocalhostMachineProvisioningLocation;
 import brooklyn.location.basic.PortRanges;
@@ -44,15 +42,10 @@ import com.google.common.collect.ImmutableList;
 
 /**
  * This tests the operation of the {@link NodeJsWebAppService} entity.
- *
- * FIXME this test is largely superseded by WebApp*IntegrationTest which tests inter alia Tomcat
  */
 public class NodeJsWebAppSimpleIntegrationTest {
-    @SuppressWarnings("unused")
-    private static final Logger LOG = LoggerFactory.getLogger(NodeJsWebAppSimpleIntegrationTest.class);
 
-    /** don't use 8080 since that is commonly used by testing software; use different from other tests. */
-    static PortRange DEFAULT_HTTP_PORT_RANGE = PortRanges.fromString("7880-7980");
+    private static PortRange DEFAULT_PORT_RANGE = PortRanges.fromString("3000-3099");
 
     private TestApplication app;
     private NodeJsWebAppService nodejs;
@@ -60,14 +53,14 @@ public class NodeJsWebAppSimpleIntegrationTest {
 
     @BeforeMethod(alwaysRun=true)
     public void pickFreePort() {
-        for (Iterator<Integer> iter = DEFAULT_HTTP_PORT_RANGE.iterator(); iter.hasNext();) {
+        for (Iterator<Integer> iter = DEFAULT_PORT_RANGE.iterator(); iter.hasNext();) {
             Integer port = iter.next();
             if (Networking.isPortAvailable(port)) {
                 httpPort = port;
                 return;
             }
         }
-        fail("someone is already listening on ports "+DEFAULT_HTTP_PORT_RANGE+"; tests assume that port is free on localhost");
+        fail("someone is already listening on ports "+DEFAULT_PORT_RANGE+"; tests assume that port is free on localhost");
     }
 
     @AfterMethod(alwaysRun=true)
@@ -76,14 +69,13 @@ public class NodeJsWebAppSimpleIntegrationTest {
     }
 
     @Test(groups="Integration")
-    public void detectFailureIfTomcanodejsantBindToPort() throws Exception {
+    public void detectFailureIfNodeJsBindToPort() throws Exception {
         ServerSocket listener = new ServerSocket(httpPort);
         try {
-            app = ApplicationBuilder.newManagedApp(TestApplication.class);
+            app = TestApplication.Factory.newManagedInstanceForTests();
             nodejs = app.createAndManageChild(EntitySpec.create(NodeJsWebAppService.class).configure("httpPort", httpPort));
-
             try {
-                nodejs.start(ImmutableList.of(app.getManagementContext().getLocationManager().manage(new LocalhostMachineProvisioningLocation())));
+                nodejs.start(ImmutableList.of(app.getManagementContext().getLocationManager().createLocation(LocationSpec.create(LocalhostMachineProvisioningLocation.class))));
                 fail("Should have thrown start-exception");
             } catch (Exception e) {
                 // LocalhostMachineProvisioningLocation does NetworkUtils.isPortAvailable, so get -1

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a97b7682/software/webapp/src/test/resources/brooklyn/entity/webapp/nodejs/nodejs-hello-world.yaml
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/resources/brooklyn/entity/webapp/nodejs/nodejs-hello-world.yaml b/software/webapp/src/test/resources/brooklyn/entity/webapp/nodejs/nodejs-hello-world.yaml
new file mode 100644
index 0000000..0ac274e
--- /dev/null
+++ b/software/webapp/src/test/resources/brooklyn/entity/webapp/nodejs/nodejs-hello-world.yaml
@@ -0,0 +1,31 @@
+# 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.
+
+id: nodejs-hello-world-application
+name: "Node.JS Hello World Application"
+origin: "https://github.com/grkvlt/node-hello-world.git/"
+locations:
+- jclouds:softlayer:ams01
+services:
+- serviceType: brooklyn.entity.webapp.nodejs.NodeJsWebAppService
+  id: nodejs
+  name: "Node.JS"
+  brooklyn.config:
+    gitRepoUrl:
+      "https://github.com/grkvlt/node-hello-world.git"
+    appFileName: app.js
+    appName: node-hello-world
\ No newline at end of file


[05/11] git commit: Add APACHE-2.0 license header

Posted by gr...@apache.org.
Add APACHE-2.0 license header


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

Branch: refs/heads/master
Commit: 7b42a27530ba38cd68fba100734a31dc11d0ef17
Parents: a694716
Author: Andrew Kennedy <gr...@apache.org>
Authored: Thu Jul 31 17:52:29 2014 +0100
Committer: Andrew Kennedy <gr...@apache.org>
Committed: Thu Aug 21 14:50:27 2014 +0100

----------------------------------------------------------------------
 .../entity/webapp/nodejs/NodeJsWebAppDriver.java  | 18 ++++++++++++++++++
 .../entity/webapp/nodejs/NodeJsWebAppService.java | 18 ++++++++++++++++++
 .../webapp/nodejs/NodeJsWebAppServiceImpl.java    | 18 ++++++++++++++++++
 .../webapp/nodejs/NodeJsWebAppSshDriver.java      | 18 ++++++++++++++++++
 .../webapp/nodejs/NodeJsWebAppEc2LiveTest.java    | 18 ++++++++++++++++++
 .../NodeJsWebAppFixtureIntegrationTest.java       | 18 ++++++++++++++++++
 .../nodejs/NodeJsWebAppSimpleIntegrationTest.java | 18 ++++++++++++++++++
 .../nodejs/NodeJsWebAppSoftlayerLiveTest.java     | 18 ++++++++++++++++++
 8 files changed, 144 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7b42a275/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppDriver.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppDriver.java b/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppDriver.java
index 00c908d..7638018 100644
--- a/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppDriver.java
+++ b/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppDriver.java
@@ -1,3 +1,21 @@
+/*
+ * 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 brooklyn.entity.webapp.nodejs;
 
 import brooklyn.entity.basic.SoftwareProcessDriver;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7b42a275/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppService.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppService.java b/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppService.java
index 6ed2580..afc2817 100644
--- a/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppService.java
+++ b/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppService.java
@@ -1,3 +1,21 @@
+/*
+ * 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 brooklyn.entity.webapp.nodejs;
 
 import java.util.List;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7b42a275/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppServiceImpl.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppServiceImpl.java b/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppServiceImpl.java
index b5fa4c9..c42bae5 100644
--- a/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppServiceImpl.java
+++ b/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppServiceImpl.java
@@ -1,3 +1,21 @@
+/*
+ * 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 brooklyn.entity.webapp.nodejs;
 
 import org.slf4j.Logger;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7b42a275/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSshDriver.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSshDriver.java b/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSshDriver.java
index f653976..d9e81b7 100644
--- a/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSshDriver.java
+++ b/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSshDriver.java
@@ -1,3 +1,21 @@
+/*
+ * 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 brooklyn.entity.webapp.nodejs;
 
 import java.util.List;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7b42a275/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppEc2LiveTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppEc2LiveTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppEc2LiveTest.java
index 7738516..d89c94e 100644
--- a/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppEc2LiveTest.java
+++ b/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppEc2LiveTest.java
@@ -1,3 +1,21 @@
+/*
+ * 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 brooklyn.entity.webapp.nodejs;
 
 import static brooklyn.entity.webapp.nodejs.NodeJsWebAppFixtureIntegrationTest.*;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7b42a275/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppFixtureIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppFixtureIntegrationTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppFixtureIntegrationTest.java
index af6a593..3b24c14 100644
--- a/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppFixtureIntegrationTest.java
+++ b/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppFixtureIntegrationTest.java
@@ -1,3 +1,21 @@
+/*
+ * 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 brooklyn.entity.webapp.nodejs;
 
 import org.slf4j.Logger;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7b42a275/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSimpleIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSimpleIntegrationTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSimpleIntegrationTest.java
index 1ad8cf8..34ebb3a 100644
--- a/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSimpleIntegrationTest.java
+++ b/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSimpleIntegrationTest.java
@@ -1,3 +1,21 @@
+/*
+ * 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 brooklyn.entity.webapp.nodejs;
 
 import static org.testng.Assert.assertFalse;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7b42a275/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSoftlayerLiveTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSoftlayerLiveTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSoftlayerLiveTest.java
index 3aa13ca..ce4de92 100644
--- a/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSoftlayerLiveTest.java
+++ b/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSoftlayerLiveTest.java
@@ -1,3 +1,21 @@
+/*
+ * 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 brooklyn.entity.webapp.nodejs;
 
 import static brooklyn.entity.webapp.nodejs.NodeJsWebAppFixtureIntegrationTest.*;


[04/11] git commit: Add example YAML

Posted by gr...@apache.org.
Add example YAML


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

Branch: refs/heads/master
Commit: a26970a20b0d11d11150aa6c02ac72dafd0504be
Parents: 7b42a27
Author: Andrew Kennedy <gr...@apache.org>
Authored: Mon Aug 11 15:26:08 2014 +0100
Committer: Andrew Kennedy <gr...@apache.org>
Committed: Thu Aug 21 14:50:27 2014 +0100

----------------------------------------------------------------------
 .../webapp/nodejs/NodeJsWebAppService.java      |  6 +++
 .../webapp/nodejs/NodeJsWebAppServiceImpl.java  |  5 ++-
 .../entity/webapp/nodejs/nodejs-todo.yaml       | 42 ++++++++++++++++++++
 .../webapp/nodejs/nodejs-word-finder.yaml       | 34 ++++++++++++++++
 4 files changed, 85 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a26970a2/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppService.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppService.java b/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppService.java
index afc2817..d4fe793 100644
--- a/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppService.java
+++ b/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppService.java
@@ -21,10 +21,13 @@ package brooklyn.entity.webapp.nodejs;
 import java.util.List;
 
 import brooklyn.config.ConfigKey;
+import brooklyn.entity.basic.Attributes;
 import brooklyn.entity.basic.ConfigKeys;
 import brooklyn.entity.basic.SoftwareProcess;
 import brooklyn.entity.proxying.ImplementedBy;
 import brooklyn.entity.webapp.WebAppService;
+import brooklyn.location.PortRange;
+import brooklyn.location.basic.PortRanges;
 import brooklyn.util.flags.SetFromFlag;
 
 import com.google.common.collect.ImmutableList;
@@ -35,6 +38,9 @@ public interface NodeJsWebAppService extends SoftwareProcess, WebAppService {
 
     ConfigKey<String> SUGGESTED_VERSION = ConfigKeys.newConfigKeyWithDefault(SoftwareProcess.SUGGESTED_VERSION, "stable");
 
+    @SetFromFlag("httpPort")
+    ConfigKey<PortRange> HTTP_PORT = ConfigKeys.newConfigKeyWithDefault(Attributes.HTTP_PORT.getConfigKey(), PortRanges.fromInteger(3000));
+
     @SetFromFlag("gitRepoUrl")
     ConfigKey<String> APP_GIT_REPOSITORY_URL = ConfigKeys.newStringConfigKey("nodejs.gitRepo.url", "The Git repository where the application is hosted");
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a26970a2/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppServiceImpl.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppServiceImpl.java b/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppServiceImpl.java
index c42bae5..83aace7 100644
--- a/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppServiceImpl.java
+++ b/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppServiceImpl.java
@@ -21,6 +21,7 @@ package brooklyn.entity.webapp.nodejs;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import brooklyn.entity.basic.Attributes;
 import brooklyn.entity.basic.SoftwareProcessImpl;
 import brooklyn.entity.webapp.WebAppServiceMethods;
 import brooklyn.event.feed.ConfigToAttributes;
@@ -54,7 +55,7 @@ public class NodeJsWebAppServiceImpl extends SoftwareProcessImpl implements Node
 
         ConfigToAttributes.apply(this);
 
-        HostAndPort accessible = BrooklynAccessUtils.getBrooklynAccessibleAddress(this, getAttribute(HTTP_PORT));
+        HostAndPort accessible = BrooklynAccessUtils.getBrooklynAccessibleAddress(this, getAttribute(Attributes.HTTP_PORT));
         String nodeJsUrl = String.format("http://%s:%d", accessible.getHostText(), accessible.getPort());
         LOG.info("Connecting to {}", nodeJsUrl);
 
@@ -86,6 +87,6 @@ public class NodeJsWebAppServiceImpl extends SoftwareProcessImpl implements Node
     }
 
     @Override
-    public Integer getHttpPort() { return getAttribute(HTTP_PORT); }
+    public Integer getHttpPort() { return getAttribute(Attributes.HTTP_PORT); }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a26970a2/software/webapp/src/test/resources/brooklyn/entity/webapp/nodejs/nodejs-todo.yaml
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/resources/brooklyn/entity/webapp/nodejs/nodejs-todo.yaml b/software/webapp/src/test/resources/brooklyn/entity/webapp/nodejs/nodejs-todo.yaml
new file mode 100644
index 0000000..879a9c1
--- /dev/null
+++ b/software/webapp/src/test/resources/brooklyn/entity/webapp/nodejs/nodejs-todo.yaml
@@ -0,0 +1,42 @@
+# 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.
+
+id: nodejs-todo-application
+name: "Node.JS Todo Application"
+origin: "https://github.com/amirrajan/nodejs-todo/"
+locations:
+- jclouds:softlayer:ams01
+services:
+- serviceType: brooklyn.entity.nosql.redis.RedisStore
+  id: redis
+- serviceType: brooklyn.entity.webapp.nodejs.NodeJsWebAppService
+  id: nodejs
+  name: "Node.JS"
+  brooklyn.config:
+    gitRepoUrl:
+      "https://github.com/amirrajan/nodejs-todo/"
+    appFileName: server.js
+    appName: nodejs-todo
+    nodePackages:
+    - express
+    - ejs
+    - redis
+    env:
+      REDISTOGO_URL: >
+        $brooklyn:formatString("redis://%s:%d/",
+        component("redis").attributeWhenReady("host.name"),
+        component("redis").attributeWhenReady("redis.port"))

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a26970a2/software/webapp/src/test/resources/brooklyn/entity/webapp/nodejs/nodejs-word-finder.yaml
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/resources/brooklyn/entity/webapp/nodejs/nodejs-word-finder.yaml b/software/webapp/src/test/resources/brooklyn/entity/webapp/nodejs/nodejs-word-finder.yaml
new file mode 100644
index 0000000..5af00fc
--- /dev/null
+++ b/software/webapp/src/test/resources/brooklyn/entity/webapp/nodejs/nodejs-word-finder.yaml
@@ -0,0 +1,34 @@
+# 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.
+
+id: nodejs-word-finder-application
+name: "Node.JS Word Finder Application"
+origin: "https://github.com/amirrajan/word-finder/"
+locations:
+- jclouds:softlayer:ams01
+services:
+- serviceType: brooklyn.entity.webapp.nodejs.NodeJsWebAppService
+  id: nodejs
+  name: "Node.JS"
+  brooklyn.config:
+    gitRepoUrl:
+      "https://github.com/amirrajan/word-finder/"
+    appFileName: server.js
+    appName: word-finder
+    nodePackages:
+    - express
+    - ejs
\ No newline at end of file


[10/11] git commit: Update example blueprint for Node.JS Todo application

Posted by gr...@apache.org.
Update example blueprint for Node.JS Todo application


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

Branch: refs/heads/master
Commit: e18474f3e438ec5867447033c045f01d1f25cd0e
Parents: d2e63ca
Author: Andrew Kennedy <gr...@apache.org>
Authored: Wed Aug 20 18:07:59 2014 +0100
Committer: Andrew Kennedy <gr...@apache.org>
Committed: Thu Aug 21 16:35:24 2014 +0100

----------------------------------------------------------------------
 .../brooklyn/demo/NodeJsTodoApplication.java    |  6 ++-
 .../resources/brooklyn/demo/nodejs-todo.yaml    | 53 ++++++++++++++++++++
 .../webapp/nodejs/NodeJsWebAppSshDriver.java    |  2 +-
 .../src/test/resources/nodejs-todo.yaml         | 42 ----------------
 .../src/test/resources/nodejs-word-finder.yaml  | 34 -------------
 5 files changed, 58 insertions(+), 79 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e18474f3/examples/simple-web-cluster/src/main/java/brooklyn/demo/NodeJsTodoApplication.java
----------------------------------------------------------------------
diff --git a/examples/simple-web-cluster/src/main/java/brooklyn/demo/NodeJsTodoApplication.java b/examples/simple-web-cluster/src/main/java/brooklyn/demo/NodeJsTodoApplication.java
index cba766c..54eb008 100644
--- a/examples/simple-web-cluster/src/main/java/brooklyn/demo/NodeJsTodoApplication.java
+++ b/examples/simple-web-cluster/src/main/java/brooklyn/demo/NodeJsTodoApplication.java
@@ -26,6 +26,7 @@ import brooklyn.entity.basic.SoftwareProcess;
 import brooklyn.entity.basic.StartableApplication;
 import brooklyn.entity.nosql.redis.RedisStore;
 import brooklyn.entity.proxying.EntitySpec;
+import brooklyn.entity.trait.Startable;
 import brooklyn.entity.webapp.nodejs.NodeJsWebAppService;
 import brooklyn.event.basic.DependentConfiguration;
 
@@ -48,10 +49,11 @@ public class NodeJsTodoApplication extends AbstractApplication implements Starta
                 .configure(NodeJsWebAppService.APP_GIT_REPOSITORY_URL, "https://github.com/amirrajan/nodejs-todo/")
                 .configure(NodeJsWebAppService.APP_FILE, "server.js")
                 .configure(NodeJsWebAppService.APP_NAME, "nodejs-todo")
-                .configure(NodeJsWebAppService.NODE_PACKAGE_LIST, ImmutableList.of("express", "ejs", "redis"))
+                .configure(NodeJsWebAppService.NODE_PACKAGE_LIST, ImmutableList.of("express", "ejs", "jasmine-node", "underscore", "method-override", "cookie-parser", "express-session", "body-parser", "cookie-session", "redis", "redis-url", "connect"))
                 .configure(SoftwareProcess.SHELL_ENVIRONMENT, ImmutableMap.<String, Object>of(
                         "REDISTOGO_URL", DependentConfiguration.formatString("redis://%s:%d/",
-                                attributeWhenReady(redis, Attributes.HOSTNAME), attributeWhenReady(redis, RedisStore.REDIS_PORT)))));
+                                attributeWhenReady(redis, Attributes.HOSTNAME), attributeWhenReady(redis, RedisStore.REDIS_PORT))))
+                .configure(SoftwareProcess.LAUNCH_LATCH, attributeWhenReady(redis, Startable.SERVICE_UP)));
     }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e18474f3/examples/simple-web-cluster/src/main/resources/brooklyn/demo/nodejs-todo.yaml
----------------------------------------------------------------------
diff --git a/examples/simple-web-cluster/src/main/resources/brooklyn/demo/nodejs-todo.yaml b/examples/simple-web-cluster/src/main/resources/brooklyn/demo/nodejs-todo.yaml
new file mode 100644
index 0000000..8bf3f7f
--- /dev/null
+++ b/examples/simple-web-cluster/src/main/resources/brooklyn/demo/nodejs-todo.yaml
@@ -0,0 +1,53 @@
+# 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.
+
+id: nodejs-todo-application
+name: "Node.JS Todo Application"
+origin: "https://github.com/amirrajan/nodejs-todo/"
+locations:
+- jclouds:softlayer:ams01
+services:
+- serviceType: brooklyn.entity.nosql.redis.RedisStore
+  id: redis
+  name: "Redis"
+- serviceType: brooklyn.entity.webapp.nodejs.NodeJsWebAppService
+  id: nodejs
+  name: "Node.JS"
+  brooklyn.config:
+    gitRepoUrl:
+      "https://github.com/grkvlt/nodejs-todo/"
+    appFileName: server.js
+    appName: nodejs-todo
+    nodePackages:
+    - express
+    - ejs
+    - jasmine-node
+    - underscore
+    - method-override
+    - cookie-parser
+    - express-session
+    - body-parser
+    - cookie-session
+    - redis
+    - redis-url
+    - connect
+    env:
+      REDISTOGO_URL: >
+        $brooklyn:formatString("redis://%s:%d/",
+        component("redis").attributeWhenReady("host.name"),
+        component("redis").attributeWhenReady("redis.port"))
+    launch.latch: $brooklyn:component("redis").attributeWhenReady("service.isUp")
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e18474f3/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSshDriver.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSshDriver.java b/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSshDriver.java
index 24c8581..839d434 100644
--- a/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSshDriver.java
+++ b/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSshDriver.java
@@ -139,7 +139,7 @@ public class NodeJsWebAppSshDriver extends AbstractSoftwareProcessSshDriver impl
         }
 
         commands.add(String.format("cd %s", Os.mergePathsUnix(getRunDir(), appName)));
-        commands.add(BashCommands.sudo("nohup " + appCommandLine + " &"));
+        commands.add("nohup " + appCommandLine + " > console.out 2>&1 &");
 
         newScript(MutableMap.of(USE_PID_FILE, true), LAUNCHING)
                 .body.append(commands)

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e18474f3/usage/launcher/src/test/resources/nodejs-todo.yaml
----------------------------------------------------------------------
diff --git a/usage/launcher/src/test/resources/nodejs-todo.yaml b/usage/launcher/src/test/resources/nodejs-todo.yaml
deleted file mode 100644
index 879a9c1..0000000
--- a/usage/launcher/src/test/resources/nodejs-todo.yaml
+++ /dev/null
@@ -1,42 +0,0 @@
-# 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.
-
-id: nodejs-todo-application
-name: "Node.JS Todo Application"
-origin: "https://github.com/amirrajan/nodejs-todo/"
-locations:
-- jclouds:softlayer:ams01
-services:
-- serviceType: brooklyn.entity.nosql.redis.RedisStore
-  id: redis
-- serviceType: brooklyn.entity.webapp.nodejs.NodeJsWebAppService
-  id: nodejs
-  name: "Node.JS"
-  brooklyn.config:
-    gitRepoUrl:
-      "https://github.com/amirrajan/nodejs-todo/"
-    appFileName: server.js
-    appName: nodejs-todo
-    nodePackages:
-    - express
-    - ejs
-    - redis
-    env:
-      REDISTOGO_URL: >
-        $brooklyn:formatString("redis://%s:%d/",
-        component("redis").attributeWhenReady("host.name"),
-        component("redis").attributeWhenReady("redis.port"))

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e18474f3/usage/launcher/src/test/resources/nodejs-word-finder.yaml
----------------------------------------------------------------------
diff --git a/usage/launcher/src/test/resources/nodejs-word-finder.yaml b/usage/launcher/src/test/resources/nodejs-word-finder.yaml
deleted file mode 100644
index 5af00fc..0000000
--- a/usage/launcher/src/test/resources/nodejs-word-finder.yaml
+++ /dev/null
@@ -1,34 +0,0 @@
-# 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.
-
-id: nodejs-word-finder-application
-name: "Node.JS Word Finder Application"
-origin: "https://github.com/amirrajan/word-finder/"
-locations:
-- jclouds:softlayer:ams01
-services:
-- serviceType: brooklyn.entity.webapp.nodejs.NodeJsWebAppService
-  id: nodejs
-  name: "Node.JS"
-  brooklyn.config:
-    gitRepoUrl:
-      "https://github.com/amirrajan/word-finder/"
-    appFileName: server.js
-    appName: word-finder
-    nodePackages:
-    - express
-    - ejs
\ No newline at end of file


[11/11] git commit: This closes #94

Posted by gr...@apache.org.
This closes #94

* github/pr/94:
  Update example blueprint for Node.JS Todo application
  Moved test blueprints to example and launcher projects
  Added command line config key  to replace entire Node.JS start command string
  Updated test code with example Todo application
  Add example YAML
  Add APACHE-2.0 license header
  Added simple integration and live tests
  Change root URL to use default
  Updated NodeJS entity
  Initial NodeJS entity


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

Branch: refs/heads/master
Commit: cc1915aaa5d8e91626de290057a6ca41ec1a7d2d
Parents: 8643fbc e18474f
Author: Andrew Kennedy <gr...@apache.org>
Authored: Thu Aug 21 17:00:53 2014 +0100
Committer: Andrew Kennedy <gr...@apache.org>
Committed: Thu Aug 21 17:00:53 2014 +0100

----------------------------------------------------------------------
 .../brooklyn/demo/NodeJsTodoApplication.java    |  59 +++++++
 .../resources/brooklyn/demo/nodejs-todo.yaml    |  53 ++++++
 software/webapp/pom.xml                         |   2 +-
 .../webapp/JavaWebAppSoftwareProcessImpl.java   |  31 ----
 .../entity/webapp/WebAppServiceMethods.java     |  52 +++++-
 .../entity/webapp/jboss/JBoss7ServerImpl.java   |   5 +-
 .../webapp/nodejs/NodeJsWebAppDriver.java       |  27 +++
 .../webapp/nodejs/NodeJsWebAppService.java      |  74 +++++++++
 .../webapp/nodejs/NodeJsWebAppServiceImpl.java  |  92 ++++++++++
 .../webapp/nodejs/NodeJsWebAppSshDriver.java    | 166 +++++++++++++++++++
 .../webapp/src/main/resources/jetty-logo.svg    |  88 ----------
 .../webapp/src/main/resources/nodejs-logo.png   | Bin 0 -> 9620 bytes
 .../webapp/nodejs/NodeJsWebAppEc2LiveTest.java  |  67 ++++++++
 .../NodeJsWebAppFixtureIntegrationTest.java     |  58 +++++++
 .../NodeJsWebAppSimpleIntegrationTest.java      |  92 ++++++++++
 .../nodejs/NodeJsWebAppSoftlayerLiveTest.java   |  66 ++++++++
 .../webapp/nodejs/nodejs-hello-world.yaml       |  31 ++++
 17 files changed, 833 insertions(+), 130 deletions(-)
----------------------------------------------------------------------



[09/11] git commit: Added command line config key to replace entire Node.JS start command string

Posted by gr...@apache.org.
Added command line config key  to replace entire Node.JS start command string


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

Branch: refs/heads/master
Commit: 2ce9c52811dacb21a1f10ea1fbb66e95cd2e83c2
Parents: a97b768
Author: Andrew Kennedy <gr...@apache.org>
Authored: Fri Aug 15 16:48:14 2014 +0100
Committer: Andrew Kennedy <gr...@apache.org>
Committed: Thu Aug 21 14:50:27 2014 +0100

----------------------------------------------------------------------
 .../entity/webapp/nodejs/NodeJsWebAppService.java      |  5 ++++-
 .../entity/webapp/nodejs/NodeJsWebAppSshDriver.java    | 13 +++++++++----
 2 files changed, 13 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2ce9c528/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppService.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppService.java b/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppService.java
index 7e6b840..1711563 100644
--- a/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppService.java
+++ b/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppService.java
@@ -58,7 +58,10 @@ public interface NodeJsWebAppService extends SoftwareProcess, WebAppService {
     ConfigKey<String> APP_NAME = ConfigKeys.newStringConfigKey("nodejs.app.name", "The name of the NodeJS application");
 
     @SetFromFlag("appCommand")
-    ConfigKey<String> APP_COMMAND = ConfigKeys.newStringConfigKey("nodejs.app.command", "Command to start the NodeJS application", "node");
+    ConfigKey<String> APP_COMMAND = ConfigKeys.newStringConfigKey("nodejs.app.command", "Command to start the NodeJS application (defaults to node)", "node");
+
+    @SetFromFlag("appCommandLine")
+    ConfigKey<String> APP_COMMAND_LINE = ConfigKeys.newStringConfigKey("nodejs.app.commandLine", "Replacement command line to start the NodeJS application (ignores command and file if set)");
 
     @SetFromFlag("nodePackages")
     ConfigKey<List<String>> NODE_PACKAGE_LIST = ConfigKeys.newConfigKey(new TypeToken<List<String>>() { },

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2ce9c528/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSshDriver.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSshDriver.java b/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSshDriver.java
index d9e81b7..24c8581 100644
--- a/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSshDriver.java
+++ b/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSshDriver.java
@@ -67,7 +67,7 @@ public class NodeJsWebAppSshDriver extends AbstractSoftwareProcessSshDriver impl
     }
 
     protected Map<String, Integer> getPortMap() {
-        return ImmutableMap.of("http", getEntity().getAttribute(WebAppService.HTTP_PORT));
+        return ImmutableMap.of("http", getHttpPort());
     }
 
     @Override
@@ -111,13 +111,13 @@ public class NodeJsWebAppSshDriver extends AbstractSoftwareProcessSshDriver impl
         String appName = getEntity().getConfig(NodeJsWebAppService.APP_NAME);
 
         if (Strings.isNonBlank(gitRepoUrl) && Strings.isNonBlank(archiveUrl)) {
-            throw new IllegalStateException("Only one of Git or archive URL must be set");
+            throw new IllegalStateException("Only one of Git or archive URL must be set for " + getEntity());
         } else if (Strings.isNonBlank(gitRepoUrl)) {
             commands.add(String.format("git clone %s %s", gitRepoUrl, appName));
         } else if (Strings.isNonBlank(archiveUrl)) {
             ArchiveUtils.deploy(archiveUrl, getMachine(), getRunDir());
         } else {
-            throw new IllegalStateException("At least one of Git or archive URL must be set");
+            throw new IllegalStateException("At least one of Git or archive URL must be set for " + getEntity());
         }
 
         newScript(CUSTOMIZING)
@@ -132,9 +132,14 @@ public class NodeJsWebAppSshDriver extends AbstractSoftwareProcessSshDriver impl
         String appName = getEntity().getConfig(NodeJsWebAppService.APP_NAME);
         String appFile = getEntity().getConfig(NodeJsWebAppService.APP_FILE);
         String appCommand = getEntity().getConfig(NodeJsWebAppService.APP_COMMAND);
+        String appCommandLine = getEntity().getConfig(NodeJsWebAppService.APP_COMMAND_LINE);
+
+        if (Strings.isBlank(appCommandLine)) {
+            appCommandLine = appCommand + " " + appFile;
+        }
 
         commands.add(String.format("cd %s", Os.mergePathsUnix(getRunDir(), appName)));
-        commands.add(BashCommands.sudo("nohup " + appCommand + " " + appFile + " &"));
+        commands.add(BashCommands.sudo("nohup " + appCommandLine + " &"));
 
         newScript(MutableMap.of(USE_PID_FILE, true), LAUNCHING)
                 .body.append(commands)


[02/11] git commit: Updated NodeJS entity

Posted by gr...@apache.org.
Updated NodeJS entity


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

Branch: refs/heads/master
Commit: ef23cc19395d8f9b0bf1129635e79a091b7abf5b
Parents: a9ad442
Author: Andrew Kennedy <gr...@apache.org>
Authored: Thu Jul 24 16:49:50 2014 +0100
Committer: Andrew Kennedy <gr...@apache.org>
Committed: Thu Aug 21 14:50:26 2014 +0100

----------------------------------------------------------------------
 .../webapp/nodejs/NodeJsWebAppService.java      | 26 +++++-
 .../webapp/nodejs/NodeJsWebAppServiceImpl.java  | 67 ++++++++++++++++
 .../nodejs/NodeJsWebAppSoftwareProcess.java     | 15 ----
 .../nodejs/NodeJsWebAppSoftwareProcessImpl.java | 54 -------------
 .../webapp/nodejs/NodeJsWebAppSshDriver.java    | 84 ++++++++++++--------
 5 files changed, 143 insertions(+), 103 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ef23cc19/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppService.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppService.java b/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppService.java
index 19c8c3e..6ed2580 100644
--- a/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppService.java
+++ b/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppService.java
@@ -1,19 +1,43 @@
 package brooklyn.entity.webapp.nodejs;
 
+import java.util.List;
+
 import brooklyn.config.ConfigKey;
 import brooklyn.entity.basic.ConfigKeys;
+import brooklyn.entity.basic.SoftwareProcess;
+import brooklyn.entity.proxying.ImplementedBy;
 import brooklyn.entity.webapp.WebAppService;
 import brooklyn.util.flags.SetFromFlag;
 
-public interface NodeJsWebAppService extends WebAppService {
+import com.google.common.collect.ImmutableList;
+import com.google.common.reflect.TypeToken;
+
+@ImplementedBy(NodeJsWebAppServiceImpl.class)
+public interface NodeJsWebAppService extends SoftwareProcess, WebAppService {
+
+    ConfigKey<String> SUGGESTED_VERSION = ConfigKeys.newConfigKeyWithDefault(SoftwareProcess.SUGGESTED_VERSION, "stable");
 
     @SetFromFlag("gitRepoUrl")
     ConfigKey<String> APP_GIT_REPOSITORY_URL = ConfigKeys.newStringConfigKey("nodejs.gitRepo.url", "The Git repository where the application is hosted");
 
+    @SetFromFlag("archiveUrl")
+    ConfigKey<String> APP_ARCHIVE_URL = ConfigKeys.newStringConfigKey("nodejs.archive.url", "The URL where the application archive is hosted");
+
     @SetFromFlag("appFileName")
     ConfigKey<String> APP_FILE = ConfigKeys.newStringConfigKey("nodejs.app.fileName", "The NodeJS application file to start", "app.js");
 
     @SetFromFlag("appName")
     ConfigKey<String> APP_NAME = ConfigKeys.newStringConfigKey("nodejs.app.name", "The name of the NodeJS application");
 
+    @SetFromFlag("appCommand")
+    ConfigKey<String> APP_COMMAND = ConfigKeys.newStringConfigKey("nodejs.app.command", "Command to start the NodeJS application", "node");
+
+    @SetFromFlag("nodePackages")
+    ConfigKey<List<String>> NODE_PACKAGE_LIST = ConfigKeys.newConfigKey(new TypeToken<List<String>>() { },
+            "nodejs.packages", "The NPM packages to install", ImmutableList.<String>of());
+
+    ConfigKey<String> SERVICE_UP_PATH = ConfigKeys.newStringConfigKey("nodejs.serviceUp.path", "Path to use when checking the NodeJS application is running", "/");
+
+    Integer getHttpPort();
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ef23cc19/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppServiceImpl.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppServiceImpl.java b/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppServiceImpl.java
new file mode 100644
index 0000000..802727e
--- /dev/null
+++ b/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppServiceImpl.java
@@ -0,0 +1,67 @@
+package brooklyn.entity.webapp.nodejs;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import brooklyn.entity.basic.SoftwareProcessImpl;
+import brooklyn.entity.webapp.WebAppServiceMethods;
+import brooklyn.event.feed.http.HttpFeed;
+import brooklyn.event.feed.http.HttpPollConfig;
+import brooklyn.event.feed.http.HttpValueFunctions;
+
+import com.google.common.base.Predicates;
+
+public class NodeJsWebAppServiceImpl extends SoftwareProcessImpl implements NodeJsWebAppService {
+
+    private static final Logger LOG = LoggerFactory.getLogger(NodeJsWebAppService.class);
+
+    private transient HttpFeed httpFeed;
+
+    @Override
+    public Class<?> getDriverInterface() {
+        return NodeJsWebAppDriver.class;
+    }
+
+    @Override
+    public NodeJsWebAppDriver getDriver() {
+        return (NodeJsWebAppDriver) super.getDriver();
+    }
+
+    @Override
+    protected void connectSensors() {
+        super.connectSensors();
+
+        String nodeJsUrl = WebAppServiceMethods.inferBrooklynAccessibleRootUrl(this);
+        LOG.info("Connecting to {}", nodeJsUrl);
+
+        httpFeed = HttpFeed.builder()
+                .entity(this)
+                .baseUri(nodeJsUrl)
+                .poll(new HttpPollConfig<Boolean>(SERVICE_UP)
+                        .suburl(getConfig(NodeJsWebAppService.SERVICE_UP_PATH))
+                        .checkSuccess(Predicates.alwaysTrue())
+                        .onSuccess(HttpValueFunctions.responseCodeEquals(200))
+                        .setOnException(false))
+                .build();
+
+        WebAppServiceMethods.connectWebAppServerPolicies(this);
+    }
+
+    @Override
+    public void disconnectSensors() {
+        if (httpFeed != null) httpFeed.stop();
+        super.disconnectSensors();
+    }
+
+    @Override
+    protected void doStop() {
+        super.doStop();
+
+        setAttribute(REQUESTS_PER_SECOND_LAST, 0D);
+        setAttribute(REQUESTS_PER_SECOND_IN_WINDOW, 0D);
+    }
+
+    @Override
+    public Integer getHttpPort() { return getAttribute(HTTP_PORT); }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ef23cc19/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSoftwareProcess.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSoftwareProcess.java b/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSoftwareProcess.java
deleted file mode 100644
index 999440d..0000000
--- a/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSoftwareProcess.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package brooklyn.entity.webapp.nodejs;
-
-import brooklyn.config.ConfigKey;
-import brooklyn.entity.basic.ConfigKeys;
-import brooklyn.entity.basic.SoftwareProcess;
-import brooklyn.util.flags.SetFromFlag;
-
-public interface NodeJsWebAppSoftwareProcess extends SoftwareProcess, NodeJsWebAppService {
-
-    ConfigKey<String> SUGGESTED_VERSION = ConfigKeys.newConfigKeyWithDefault(SoftwareProcess.SUGGESTED_VERSION, "stable");
-
-    @SetFromFlag("appUser")
-    ConfigKey<String> APP_USER = ConfigKeys.newStringConfigKey("nodejs.app.user", "The user to run the NodeJS application as", "webapp");
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ef23cc19/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSoftwareProcessImpl.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSoftwareProcessImpl.java b/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSoftwareProcessImpl.java
deleted file mode 100644
index d0d2207..0000000
--- a/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSoftwareProcessImpl.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package brooklyn.entity.webapp.nodejs;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import brooklyn.entity.annotation.Effector;
-import brooklyn.entity.annotation.EffectorParam;
-import brooklyn.entity.basic.SoftwareProcessImpl;
-import brooklyn.entity.java.JavaAppUtils;
-import brooklyn.entity.webapp.WebAppServiceMethods;
-import brooklyn.location.access.BrooklynAccessUtils;
-
-import com.google.common.base.Throwables;
-import com.google.common.collect.Sets;
-import com.google.common.net.HostAndPort;
-
-public abstract class NodeJsWebAppSoftwareProcessImpl extends SoftwareProcessImpl implements NodeJsWebAppSoftwareProcess {
-
-    private static final Logger LOG = LoggerFactory.getLogger(NodeJsWebAppSoftwareProcessImpl.class);
-
-    public NodeJsWebAppSoftwareProcessImpl() {
-        super();
-    }
-
-    @Override
-    protected void connectSensors() {
-        super.connectSensors();
-
-        WebAppServiceMethods.connectWebAppServerPolicies(this);
-    }
-
-    public NodeJsWebAppDriver getDriver() {
-        return (NodeJsWebAppDriver) super.getDriver();
-    }
-    
-    @Override
-    protected void doStop() {
-        super.doStop();
-        // zero our workrate derived workrates.
-        // TODO might not be enough, as policy may still be executing and have a record of historic vals; should remove policies
-        // (also not sure we want this; implies more generally a responsibility for sensors to announce things when disconnected,
-        // vs them just showing the last known value...)
-        setAttribute(REQUESTS_PER_SECOND_LAST, 0D);
-        setAttribute(REQUESTS_PER_SECOND_IN_WINDOW, 0D);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ef23cc19/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSshDriver.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSshDriver.java b/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSshDriver.java
index 611b3b7..f653976 100644
--- a/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSshDriver.java
+++ b/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSshDriver.java
@@ -4,47 +4,52 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import brooklyn.entity.basic.AbstractSoftwareProcessSshDriver;
 import brooklyn.entity.basic.Attributes;
 import brooklyn.entity.basic.SoftwareProcess;
 import brooklyn.entity.webapp.WebAppService;
-import brooklyn.entity.webapp.WebAppServiceMethods;
 import brooklyn.location.basic.SshMachineLocation;
+import brooklyn.util.collections.MutableList;
 import brooklyn.util.collections.MutableMap;
+import brooklyn.util.file.ArchiveUtils;
 import brooklyn.util.os.Os;
 import brooklyn.util.ssh.BashCommands;
+import brooklyn.util.text.Strings;
 
-import com.google.common.collect.ImmutableList;
+import com.google.common.base.Joiner;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+
+public class NodeJsWebAppSshDriver extends AbstractSoftwareProcessSshDriver implements NodeJsWebAppDriver {
 
-public abstract class NodeJsWebAppSshDriver extends AbstractSoftwareProcessSshDriver implements NodeJsWebAppDriver {
+    private static final Logger LOG = LoggerFactory.getLogger(NodeJsWebAppService.class);
 
-    public NodeJsWebAppSshDriver(NodeJsWebAppSoftwareProcessImpl entity, SshMachineLocation machine) {
+    public NodeJsWebAppSshDriver(NodeJsWebAppServiceImpl entity, SshMachineLocation machine) {
         super(entity, machine);
     }
 
-    public NodeJsWebAppSoftwareProcessImpl getEntity() {
-        return (NodeJsWebAppSoftwareProcessImpl) super.getEntity();
+    public NodeJsWebAppServiceImpl getEntity() {
+        return (NodeJsWebAppServiceImpl) super.getEntity();
     }
 
     @Override
     public Integer getHttpPort() {
-        return entity.getAttribute(Attributes.HTTP_PORT);
-    }
-
-    protected String inferRootUrl() {
-        return WebAppServiceMethods.inferBrooklynAccessibleRootUrl(getEntity());
+        return getEntity().getAttribute(Attributes.HTTP_PORT);
     }
 
     @Override
     public void postLaunch() {
-        String rootUrl = inferRootUrl();
+        String rootUrl = String.format("http://%s:%d/", getHostname(), getHttpPort());
         entity.setAttribute(WebAppService.ROOT_URL, rootUrl);
     }
 
     protected Map<String, Integer> getPortMap() {
-        return ImmutableMap.of("httpPort", entity.getAttribute(WebAppService.HTTP_PORT));
+        return ImmutableMap.of("http", getEntity().getAttribute(WebAppService.HTTP_PORT));
     }
 
     @Override
@@ -57,15 +62,23 @@ public abstract class NodeJsWebAppSshDriver extends AbstractSoftwareProcessSshDr
 
     @Override
     public void install() {
-        log.debug("Installing {}", getEntity());
-
-        List<String> commands = ImmutableList.<String>builder()
-                .add(BashCommands.installPackage(MutableMap.of("yum", "git nodejs npm"), null))
+        List<String> packages = getEntity().getConfig(NodeJsWebAppService.NODE_PACKAGE_LIST);
+        LOG.info("Installing Node.JS {} {}", getEntity().getConfig(SoftwareProcess.SUGGESTED_VERSION), Iterables.toString(packages));
+
+        List<String> commands = MutableList.<String>builder()
+                .add(BashCommands.INSTALL_CURL)
+                .add(BashCommands.ifExecutableElse0("apt-get", BashCommands.chain(
+                        BashCommands.installPackage("python-software-properties python g++ make"),
+                        BashCommands.sudo("add-apt-repository ppa:chris-lea/node.js"))))
+                .add(BashCommands.installPackage(MutableMap.of("yum", "git nodejs npm", "apt", "git-core nodejs"), null))
                 .add(BashCommands.sudo("npm install -g n"))
                 .add(BashCommands.sudo("n " + getEntity().getConfig(SoftwareProcess.SUGGESTED_VERSION)))
-                .add(BashCommands.sudo("useradd -mrU " + getEntity().getConfig(NodeJsWebAppSoftwareProcess.APP_USER)))
                 .build();
 
+        if (packages != null && packages.size() > 0) {
+            commands.add(BashCommands.sudo("npm install -g " + Joiner.on(' ').join(packages)));
+        }
+
         newScript(INSTALLING)
                 .body.append(commands)
                 .execute();
@@ -73,15 +86,21 @@ public abstract class NodeJsWebAppSshDriver extends AbstractSoftwareProcessSshDr
 
     @Override
     public void customize() {
-        log.debug("Customising {}", getEntity());
+        List<String> commands = Lists.newLinkedList();
 
-        String appUser = getEntity().getConfig(NodeJsWebAppSoftwareProcess.APP_USER);
+        String gitRepoUrl = getEntity().getConfig(NodeJsWebAppService.APP_GIT_REPOSITORY_URL);
+        String archiveUrl = getEntity().getConfig(NodeJsWebAppService.APP_ARCHIVE_URL);
         String appName = getEntity().getConfig(NodeJsWebAppService.APP_NAME);
 
-        List<String> commands = ImmutableList.<String>builder()
-                .add(String.format("git clone %s %s", getEntity().getConfig(NodeJsWebAppService.APP_GIT_REPOSITORY_URL), appName))
-                .add(BashCommands.sudo(String.format("chown -R %1$s:%1$s %2$s", appUser, appName)))
-                .build();
+        if (Strings.isNonBlank(gitRepoUrl) && Strings.isNonBlank(archiveUrl)) {
+            throw new IllegalStateException("Only one of Git or archive URL must be set");
+        } else if (Strings.isNonBlank(gitRepoUrl)) {
+            commands.add(String.format("git clone %s %s", gitRepoUrl, appName));
+        } else if (Strings.isNonBlank(archiveUrl)) {
+            ArchiveUtils.deploy(archiveUrl, getMachine(), getRunDir());
+        } else {
+            throw new IllegalStateException("At least one of Git or archive URL must be set");
+        }
 
         newScript(CUSTOMIZING)
                 .body.append(commands)
@@ -90,29 +109,28 @@ public abstract class NodeJsWebAppSshDriver extends AbstractSoftwareProcessSshDr
 
     @Override
     public void launch() {
-        log.debug("Launching {}", getEntity());
+        List<String> commands = Lists.newLinkedList();
 
-        String appUser = getEntity().getConfig(NodeJsWebAppSoftwareProcess.APP_USER);
         String appName = getEntity().getConfig(NodeJsWebAppService.APP_NAME);
+        String appFile = getEntity().getConfig(NodeJsWebAppService.APP_FILE);
+        String appCommand = getEntity().getConfig(NodeJsWebAppService.APP_COMMAND);
 
-        List<String> commands = ImmutableList.<String>builder()
-                .add(String.format("cd %s", Os.mergePathsUnix(getRunDir(), appName)))
-                .add(BashCommands.sudoAsUser(appUser, "nohup node " + getEntity().getConfig(NodeJsWebAppService.APP_FILE) + " &"))
-                .build();
+        commands.add(String.format("cd %s", Os.mergePathsUnix(getRunDir(), appName)));
+        commands.add(BashCommands.sudo("nohup " + appCommand + " " + appFile + " &"));
 
-        newScript(LAUNCHING)
+        newScript(MutableMap.of(USE_PID_FILE, true), LAUNCHING)
                 .body.append(commands)
                 .execute();
     }
 
     @Override
     public boolean isRunning() {
-        return newScript(CHECK_RUNNING).execute() == 0;
+        return newScript(MutableMap.of(USE_PID_FILE, true), CHECK_RUNNING).execute() == 0;
     }
 
     @Override
     public void stop() {
-        newScript(STOPPING).execute();
+        newScript(MutableMap.of(USE_PID_FILE, true), STOPPING).execute();
     }
 
     @Override


[08/11] git commit: Moved test blueprints to example and launcher projects

Posted by gr...@apache.org.
Moved test blueprints to example and launcher projects


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

Branch: refs/heads/master
Commit: d2e63ca7672aaabfb5f5ad3a8d8a4e78e5e100ea
Parents: 2ce9c52
Author: Andrew Kennedy <gr...@apache.org>
Authored: Wed Aug 20 12:29:06 2014 +0100
Committer: Andrew Kennedy <gr...@apache.org>
Committed: Thu Aug 21 14:50:27 2014 +0100

----------------------------------------------------------------------
 .../brooklyn/demo/NodeJsTodoApplication.java    | 57 ++++++++++++++++++++
 software/webapp/pom.xml                         |  6 ---
 .../webapp/nodejs/NodeJsTodoApplication.java    | 56 -------------------
 .../entity/webapp/nodejs/nodejs-todo.yaml       | 42 ---------------
 .../webapp/nodejs/nodejs-word-finder.yaml       | 34 ------------
 .../src/test/resources/nodejs-todo.yaml         | 42 +++++++++++++++
 .../src/test/resources/nodejs-word-finder.yaml  | 34 ++++++++++++
 7 files changed, 133 insertions(+), 138 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d2e63ca7/examples/simple-web-cluster/src/main/java/brooklyn/demo/NodeJsTodoApplication.java
----------------------------------------------------------------------
diff --git a/examples/simple-web-cluster/src/main/java/brooklyn/demo/NodeJsTodoApplication.java b/examples/simple-web-cluster/src/main/java/brooklyn/demo/NodeJsTodoApplication.java
new file mode 100644
index 0000000..cba766c
--- /dev/null
+++ b/examples/simple-web-cluster/src/main/java/brooklyn/demo/NodeJsTodoApplication.java
@@ -0,0 +1,57 @@
+/*
+ * 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 brooklyn.demo;
+
+import static brooklyn.event.basic.DependentConfiguration.attributeWhenReady;
+import brooklyn.catalog.Catalog;
+import brooklyn.entity.basic.AbstractApplication;
+import brooklyn.entity.basic.Attributes;
+import brooklyn.entity.basic.SoftwareProcess;
+import brooklyn.entity.basic.StartableApplication;
+import brooklyn.entity.nosql.redis.RedisStore;
+import brooklyn.entity.proxying.EntitySpec;
+import brooklyn.entity.webapp.nodejs.NodeJsWebAppService;
+import brooklyn.event.basic.DependentConfiguration;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * Node.JS Todo Application
+ */
+@Catalog(name="NodeJS Todo",
+        description="Node.JS Todo Application.",
+        iconUrl="classpath://nodejs-logo.png")
+public class NodeJsTodoApplication extends AbstractApplication implements StartableApplication {
+
+    @Override
+    public void init() {
+        RedisStore redis = addChild(EntitySpec.create(RedisStore.class));
+
+        addChild(EntitySpec.create(NodeJsWebAppService.class)
+                .configure(NodeJsWebAppService.APP_GIT_REPOSITORY_URL, "https://github.com/amirrajan/nodejs-todo/")
+                .configure(NodeJsWebAppService.APP_FILE, "server.js")
+                .configure(NodeJsWebAppService.APP_NAME, "nodejs-todo")
+                .configure(NodeJsWebAppService.NODE_PACKAGE_LIST, ImmutableList.of("express", "ejs", "redis"))
+                .configure(SoftwareProcess.SHELL_ENVIRONMENT, ImmutableMap.<String, Object>of(
+                        "REDISTOGO_URL", DependentConfiguration.formatString("redis://%s:%d/",
+                                attributeWhenReady(redis, Attributes.HOSTNAME), attributeWhenReady(redis, RedisStore.REDIS_PORT)))));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d2e63ca7/software/webapp/pom.xml
----------------------------------------------------------------------
diff --git a/software/webapp/pom.xml b/software/webapp/pom.xml
index a7aa180..5a44cc2 100644
--- a/software/webapp/pom.xml
+++ b/software/webapp/pom.xml
@@ -140,12 +140,6 @@
             <classifier>tests</classifier>
             <scope>test</scope>
         </dependency>
-        <dependency>
-            <groupId>io.brooklyn</groupId>
-            <artifactId>brooklyn-software-nosql</artifactId>
-            <version>${project.version}</version>
-            <scope>test</scope>
-        </dependency>
 
         <!-- bring in jclouds for testing -->
         <dependency>

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d2e63ca7/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsTodoApplication.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsTodoApplication.java b/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsTodoApplication.java
deleted file mode 100644
index 32043d5..0000000
--- a/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsTodoApplication.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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 brooklyn.entity.webapp.nodejs;
-
-import static brooklyn.event.basic.DependentConfiguration.attributeWhenReady;
-import brooklyn.catalog.Catalog;
-import brooklyn.entity.basic.AbstractApplication;
-import brooklyn.entity.basic.Attributes;
-import brooklyn.entity.basic.SoftwareProcess;
-import brooklyn.entity.basic.StartableApplication;
-import brooklyn.entity.nosql.redis.RedisStore;
-import brooklyn.entity.proxying.EntitySpec;
-import brooklyn.event.basic.DependentConfiguration;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-
-/**
- * Node.JS Todo Application
- */
-@Catalog(name="NodeJS Todo",
-        description="Node.JS Todo Application.",
-        iconUrl="classpath://nodejs-logo.png")
-public class NodeJsTodoApplication extends AbstractApplication implements StartableApplication {
-
-    @Override
-    public void init() {
-        RedisStore redis = addChild(EntitySpec.create(RedisStore.class));
-
-        addChild(EntitySpec.create(NodeJsWebAppService.class)
-                .configure(NodeJsWebAppService.APP_GIT_REPOSITORY_URL, "https://github.com/amirrajan/nodejs-todo/")
-                .configure(NodeJsWebAppService.APP_FILE, "server.js")
-                .configure(NodeJsWebAppService.APP_NAME, "nodejs-todo")
-                .configure(NodeJsWebAppService.NODE_PACKAGE_LIST, ImmutableList.of("express", "ejs", "redis"))
-                .configure(SoftwareProcess.SHELL_ENVIRONMENT, ImmutableMap.<String, Object>of(
-                        "REDISTOGO_URL", DependentConfiguration.formatString("redis://%s:%d/",
-                                attributeWhenReady(redis, Attributes.HOSTNAME), attributeWhenReady(redis, RedisStore.REDIS_PORT)))));
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d2e63ca7/software/webapp/src/test/resources/brooklyn/entity/webapp/nodejs/nodejs-todo.yaml
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/resources/brooklyn/entity/webapp/nodejs/nodejs-todo.yaml b/software/webapp/src/test/resources/brooklyn/entity/webapp/nodejs/nodejs-todo.yaml
deleted file mode 100644
index 879a9c1..0000000
--- a/software/webapp/src/test/resources/brooklyn/entity/webapp/nodejs/nodejs-todo.yaml
+++ /dev/null
@@ -1,42 +0,0 @@
-# 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.
-
-id: nodejs-todo-application
-name: "Node.JS Todo Application"
-origin: "https://github.com/amirrajan/nodejs-todo/"
-locations:
-- jclouds:softlayer:ams01
-services:
-- serviceType: brooklyn.entity.nosql.redis.RedisStore
-  id: redis
-- serviceType: brooklyn.entity.webapp.nodejs.NodeJsWebAppService
-  id: nodejs
-  name: "Node.JS"
-  brooklyn.config:
-    gitRepoUrl:
-      "https://github.com/amirrajan/nodejs-todo/"
-    appFileName: server.js
-    appName: nodejs-todo
-    nodePackages:
-    - express
-    - ejs
-    - redis
-    env:
-      REDISTOGO_URL: >
-        $brooklyn:formatString("redis://%s:%d/",
-        component("redis").attributeWhenReady("host.name"),
-        component("redis").attributeWhenReady("redis.port"))

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d2e63ca7/software/webapp/src/test/resources/brooklyn/entity/webapp/nodejs/nodejs-word-finder.yaml
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/resources/brooklyn/entity/webapp/nodejs/nodejs-word-finder.yaml b/software/webapp/src/test/resources/brooklyn/entity/webapp/nodejs/nodejs-word-finder.yaml
deleted file mode 100644
index 5af00fc..0000000
--- a/software/webapp/src/test/resources/brooklyn/entity/webapp/nodejs/nodejs-word-finder.yaml
+++ /dev/null
@@ -1,34 +0,0 @@
-# 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.
-
-id: nodejs-word-finder-application
-name: "Node.JS Word Finder Application"
-origin: "https://github.com/amirrajan/word-finder/"
-locations:
-- jclouds:softlayer:ams01
-services:
-- serviceType: brooklyn.entity.webapp.nodejs.NodeJsWebAppService
-  id: nodejs
-  name: "Node.JS"
-  brooklyn.config:
-    gitRepoUrl:
-      "https://github.com/amirrajan/word-finder/"
-    appFileName: server.js
-    appName: word-finder
-    nodePackages:
-    - express
-    - ejs
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d2e63ca7/usage/launcher/src/test/resources/nodejs-todo.yaml
----------------------------------------------------------------------
diff --git a/usage/launcher/src/test/resources/nodejs-todo.yaml b/usage/launcher/src/test/resources/nodejs-todo.yaml
new file mode 100644
index 0000000..879a9c1
--- /dev/null
+++ b/usage/launcher/src/test/resources/nodejs-todo.yaml
@@ -0,0 +1,42 @@
+# 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.
+
+id: nodejs-todo-application
+name: "Node.JS Todo Application"
+origin: "https://github.com/amirrajan/nodejs-todo/"
+locations:
+- jclouds:softlayer:ams01
+services:
+- serviceType: brooklyn.entity.nosql.redis.RedisStore
+  id: redis
+- serviceType: brooklyn.entity.webapp.nodejs.NodeJsWebAppService
+  id: nodejs
+  name: "Node.JS"
+  brooklyn.config:
+    gitRepoUrl:
+      "https://github.com/amirrajan/nodejs-todo/"
+    appFileName: server.js
+    appName: nodejs-todo
+    nodePackages:
+    - express
+    - ejs
+    - redis
+    env:
+      REDISTOGO_URL: >
+        $brooklyn:formatString("redis://%s:%d/",
+        component("redis").attributeWhenReady("host.name"),
+        component("redis").attributeWhenReady("redis.port"))

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d2e63ca7/usage/launcher/src/test/resources/nodejs-word-finder.yaml
----------------------------------------------------------------------
diff --git a/usage/launcher/src/test/resources/nodejs-word-finder.yaml b/usage/launcher/src/test/resources/nodejs-word-finder.yaml
new file mode 100644
index 0000000..5af00fc
--- /dev/null
+++ b/usage/launcher/src/test/resources/nodejs-word-finder.yaml
@@ -0,0 +1,34 @@
+# 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.
+
+id: nodejs-word-finder-application
+name: "Node.JS Word Finder Application"
+origin: "https://github.com/amirrajan/word-finder/"
+locations:
+- jclouds:softlayer:ams01
+services:
+- serviceType: brooklyn.entity.webapp.nodejs.NodeJsWebAppService
+  id: nodejs
+  name: "Node.JS"
+  brooklyn.config:
+    gitRepoUrl:
+      "https://github.com/amirrajan/word-finder/"
+    appFileName: server.js
+    appName: word-finder
+    nodePackages:
+    - express
+    - ejs
\ No newline at end of file


[03/11] git commit: Initial NodeJS entity

Posted by gr...@apache.org.
Initial NodeJS entity


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

Branch: refs/heads/master
Commit: a9ad442de4d5576df24cf81bb4b07d66de3e46ed
Parents: f56233a
Author: Andrew Kennedy <an...@cloudsoftcorp.com>
Authored: Tue Jun 3 22:43:42 2014 +0100
Committer: Andrew Kennedy <gr...@apache.org>
Committed: Thu Aug 21 14:50:26 2014 +0100

----------------------------------------------------------------------
 .../webapp/JavaWebAppSoftwareProcessImpl.java   |  31 -----
 .../entity/webapp/WebAppServiceMethods.java     |  52 ++++++--
 .../entity/webapp/jboss/JBoss7ServerImpl.java   |   5 +-
 .../webapp/nodejs/NodeJsWebAppDriver.java       |   9 ++
 .../webapp/nodejs/NodeJsWebAppService.java      |  19 +++
 .../nodejs/NodeJsWebAppSoftwareProcess.java     |  15 +++
 .../nodejs/NodeJsWebAppSoftwareProcessImpl.java |  54 ++++++++
 .../webapp/nodejs/NodeJsWebAppSshDriver.java    | 125 +++++++++++++++++++
 8 files changed, 269 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a9ad442d/software/webapp/src/main/java/brooklyn/entity/webapp/JavaWebAppSoftwareProcessImpl.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/JavaWebAppSoftwareProcessImpl.java b/software/webapp/src/main/java/brooklyn/entity/webapp/JavaWebAppSoftwareProcessImpl.java
index 2ea3f48..5c89497 100644
--- a/software/webapp/src/main/java/brooklyn/entity/webapp/JavaWebAppSoftwareProcessImpl.java
+++ b/software/webapp/src/main/java/brooklyn/entity/webapp/JavaWebAppSoftwareProcessImpl.java
@@ -34,11 +34,9 @@ import brooklyn.entity.annotation.Effector;
 import brooklyn.entity.annotation.EffectorParam;
 import brooklyn.entity.basic.SoftwareProcessImpl;
 import brooklyn.entity.java.JavaAppUtils;
-import brooklyn.location.access.BrooklynAccessUtils;
 
 import com.google.common.base.Throwables;
 import com.google.common.collect.Sets;
-import com.google.common.net.HostAndPort;
 
 public abstract class JavaWebAppSoftwareProcessImpl extends SoftwareProcessImpl implements JavaWebAppService, JavaWebAppSoftwareProcess {
 
@@ -178,33 +176,4 @@ public abstract class JavaWebAppSoftwareProcessImpl extends SoftwareProcessImpl
         setAttribute(REQUESTS_PER_SECOND_LAST, 0D);
         setAttribute(REQUESTS_PER_SECOND_IN_WINDOW, 0D);
     }
-    
-    protected Set<String> getEnabledProtocols() {
-        return getAttribute(JavaWebAppSoftwareProcess.ENABLED_PROTOCOLS);
-    }
-    
-    protected boolean isProtocolEnabled(String protocol) {
-        for (String contender : getEnabledProtocols()) {
-            if (protocol.equalsIgnoreCase(contender)) {
-                return true;
-            }
-        }
-        return false;
-    }
-    
-    protected String inferBrooklynAccessibleRootUrl() {
-        if (isProtocolEnabled("https")) {
-            Integer rawPort = getAttribute(HTTPS_PORT);
-            checkNotNull(rawPort, "HTTPS_PORT sensors not set for %s; is an acceptable port available?", this);
-            HostAndPort hp = BrooklynAccessUtils.getBrooklynAccessibleAddress(this, rawPort);
-            return String.format("https://%s:%s/", hp.getHostText(), hp.getPort());
-        } else if (isProtocolEnabled("http")) {
-            Integer rawPort = getAttribute(HTTP_PORT);
-            checkNotNull(rawPort, "HTTP_PORT sensors not set for %s; is an acceptable port available?", this);
-            HostAndPort hp = BrooklynAccessUtils.getBrooklynAccessibleAddress(this, rawPort);
-            return String.format("http://%s:%s/", hp.getHostText(), hp.getPort());
-        } else {
-            throw new IllegalStateException("HTTP and HTTPS protocols not enabled for "+this+"; enabled protocols are "+getEnabledProtocols());
-        }
-    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a9ad442d/software/webapp/src/main/java/brooklyn/entity/webapp/WebAppServiceMethods.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/WebAppServiceMethods.java b/software/webapp/src/main/java/brooklyn/entity/webapp/WebAppServiceMethods.java
index 7104830..c6fbe29 100644
--- a/software/webapp/src/main/java/brooklyn/entity/webapp/WebAppServiceMethods.java
+++ b/software/webapp/src/main/java/brooklyn/entity/webapp/WebAppServiceMethods.java
@@ -18,36 +18,72 @@
  */
 package brooklyn.entity.webapp;
 
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Set;
 import java.util.concurrent.TimeUnit;
 
 import brooklyn.enricher.RollingTimeWindowMeanEnricher;
 import brooklyn.enricher.TimeFractionDeltaEnricher;
 import brooklyn.enricher.TimeWeightedDeltaEnricher;
+import brooklyn.entity.Entity;
 import brooklyn.entity.basic.EntityLocal;
+import brooklyn.location.access.BrooklynAccessUtils;
 import brooklyn.util.time.Duration;
 
+import com.google.common.net.HostAndPort;
+
 public class WebAppServiceMethods implements WebAppServiceConstants {
-    
+
     public static final Duration DEFAULT_WINDOW_DURATION = Duration.TEN_SECONDS;
-    
+
     public static void connectWebAppServerPolicies(EntityLocal entity) {
         connectWebAppServerPolicies(entity, DEFAULT_WINDOW_DURATION);
     }
-    
+
     public static void connectWebAppServerPolicies(EntityLocal entity, Duration windowPeriod) {
         entity.addEnricher(TimeWeightedDeltaEnricher.<Integer>getPerSecondDeltaEnricher(entity, REQUEST_COUNT, REQUESTS_PER_SECOND_LAST));
-        
+
         if (windowPeriod!=null) {
-            entity.addEnricher(new RollingTimeWindowMeanEnricher<Double>(entity, REQUESTS_PER_SECOND_LAST, 
+            entity.addEnricher(new RollingTimeWindowMeanEnricher<Double>(entity, REQUESTS_PER_SECOND_LAST,
                     REQUESTS_PER_SECOND_IN_WINDOW, windowPeriod));
         }
-        
+
         entity.addEnricher(new TimeFractionDeltaEnricher<Integer>(entity, TOTAL_PROCESSING_TIME, PROCESSING_TIME_FRACTION_LAST, TimeUnit.MILLISECONDS));
-        
+
         if (windowPeriod!=null) {
-            entity.addEnricher(new RollingTimeWindowMeanEnricher<Double>(entity, PROCESSING_TIME_FRACTION_LAST, 
+            entity.addEnricher(new RollingTimeWindowMeanEnricher<Double>(entity, PROCESSING_TIME_FRACTION_LAST,
                     PROCESSING_TIME_FRACTION_IN_WINDOW, windowPeriod));
         }
 
     }
+
+    public static Set<String> getEnabledProtocols(Entity entity) {
+        return entity.getAttribute(WebAppService.ENABLED_PROTOCOLS);
+    }
+
+    public static boolean isProtocolEnabled(Entity entity, String protocol) {
+        for (String contender : getEnabledProtocols(entity)) {
+            if (protocol.equalsIgnoreCase(contender)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public static String inferBrooklynAccessibleRootUrl(Entity entity) {
+        if (isProtocolEnabled(entity, "https")) {
+            Integer rawPort = entity.getAttribute(HTTPS_PORT);
+            checkNotNull(rawPort, "HTTPS_PORT sensors not set for %s; is an acceptable port available?", entity);
+            HostAndPort hp = BrooklynAccessUtils.getBrooklynAccessibleAddress(entity, rawPort);
+            return String.format("https://%s:%s/", hp.getHostText(), hp.getPort());
+        } else if (isProtocolEnabled(entity, "http")) {
+            Integer rawPort = entity.getAttribute(HTTP_PORT);
+            checkNotNull(rawPort, "HTTP_PORT sensors not set for %s; is an acceptable port available?", entity);
+            HostAndPort hp = BrooklynAccessUtils.getBrooklynAccessibleAddress(entity, rawPort);
+            return String.format("http://%s:%s/", hp.getHostText(), hp.getPort());
+        } else {
+            throw new IllegalStateException("HTTP and HTTPS protocols not enabled for "+entity+"; enabled protocols are "+getEnabledProtocols(entity));
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a9ad442d/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/JBoss7ServerImpl.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/JBoss7ServerImpl.java b/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/JBoss7ServerImpl.java
index df59259..2cb1303 100644
--- a/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/JBoss7ServerImpl.java
+++ b/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/JBoss7ServerImpl.java
@@ -27,6 +27,7 @@ import brooklyn.enricher.Enrichers;
 import brooklyn.entity.Entity;
 import brooklyn.entity.webapp.HttpsSslConfig;
 import brooklyn.entity.webapp.JavaWebAppSoftwareProcessImpl;
+import brooklyn.entity.webapp.WebAppServiceMethods;
 import brooklyn.event.feed.http.HttpFeed;
 import brooklyn.event.feed.http.HttpPollConfig;
 import brooklyn.event.feed.http.HttpValueFunctions;
@@ -173,11 +174,11 @@ public class JBoss7ServerImpl extends JavaWebAppSoftwareProcessImpl implements J
     }
 
     public boolean isHttpEnabled() {
-        return isProtocolEnabled("HTTP");
+        return WebAppServiceMethods.isProtocolEnabled(this, "HTTP");
     }
     
     public boolean isHttpsEnabled() {
-        return isProtocolEnabled("HTTPS");
+        return WebAppServiceMethods.isProtocolEnabled(this, "HTTPS");
     }
     
     public Integer getHttpPort() {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a9ad442d/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppDriver.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppDriver.java b/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppDriver.java
new file mode 100644
index 0000000..00c908d
--- /dev/null
+++ b/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppDriver.java
@@ -0,0 +1,9 @@
+package brooklyn.entity.webapp.nodejs;
+
+import brooklyn.entity.basic.SoftwareProcessDriver;
+
+public interface NodeJsWebAppDriver extends SoftwareProcessDriver {
+
+    Integer getHttpPort();
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a9ad442d/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppService.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppService.java b/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppService.java
new file mode 100644
index 0000000..19c8c3e
--- /dev/null
+++ b/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppService.java
@@ -0,0 +1,19 @@
+package brooklyn.entity.webapp.nodejs;
+
+import brooklyn.config.ConfigKey;
+import brooklyn.entity.basic.ConfigKeys;
+import brooklyn.entity.webapp.WebAppService;
+import brooklyn.util.flags.SetFromFlag;
+
+public interface NodeJsWebAppService extends WebAppService {
+
+    @SetFromFlag("gitRepoUrl")
+    ConfigKey<String> APP_GIT_REPOSITORY_URL = ConfigKeys.newStringConfigKey("nodejs.gitRepo.url", "The Git repository where the application is hosted");
+
+    @SetFromFlag("appFileName")
+    ConfigKey<String> APP_FILE = ConfigKeys.newStringConfigKey("nodejs.app.fileName", "The NodeJS application file to start", "app.js");
+
+    @SetFromFlag("appName")
+    ConfigKey<String> APP_NAME = ConfigKeys.newStringConfigKey("nodejs.app.name", "The name of the NodeJS application");
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a9ad442d/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSoftwareProcess.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSoftwareProcess.java b/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSoftwareProcess.java
new file mode 100644
index 0000000..999440d
--- /dev/null
+++ b/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSoftwareProcess.java
@@ -0,0 +1,15 @@
+package brooklyn.entity.webapp.nodejs;
+
+import brooklyn.config.ConfigKey;
+import brooklyn.entity.basic.ConfigKeys;
+import brooklyn.entity.basic.SoftwareProcess;
+import brooklyn.util.flags.SetFromFlag;
+
+public interface NodeJsWebAppSoftwareProcess extends SoftwareProcess, NodeJsWebAppService {
+
+    ConfigKey<String> SUGGESTED_VERSION = ConfigKeys.newConfigKeyWithDefault(SoftwareProcess.SUGGESTED_VERSION, "stable");
+
+    @SetFromFlag("appUser")
+    ConfigKey<String> APP_USER = ConfigKeys.newStringConfigKey("nodejs.app.user", "The user to run the NodeJS application as", "webapp");
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a9ad442d/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSoftwareProcessImpl.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSoftwareProcessImpl.java b/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSoftwareProcessImpl.java
new file mode 100644
index 0000000..d0d2207
--- /dev/null
+++ b/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSoftwareProcessImpl.java
@@ -0,0 +1,54 @@
+package brooklyn.entity.webapp.nodejs;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import brooklyn.entity.annotation.Effector;
+import brooklyn.entity.annotation.EffectorParam;
+import brooklyn.entity.basic.SoftwareProcessImpl;
+import brooklyn.entity.java.JavaAppUtils;
+import brooklyn.entity.webapp.WebAppServiceMethods;
+import brooklyn.location.access.BrooklynAccessUtils;
+
+import com.google.common.base.Throwables;
+import com.google.common.collect.Sets;
+import com.google.common.net.HostAndPort;
+
+public abstract class NodeJsWebAppSoftwareProcessImpl extends SoftwareProcessImpl implements NodeJsWebAppSoftwareProcess {
+
+    private static final Logger LOG = LoggerFactory.getLogger(NodeJsWebAppSoftwareProcessImpl.class);
+
+    public NodeJsWebAppSoftwareProcessImpl() {
+        super();
+    }
+
+    @Override
+    protected void connectSensors() {
+        super.connectSensors();
+
+        WebAppServiceMethods.connectWebAppServerPolicies(this);
+    }
+
+    public NodeJsWebAppDriver getDriver() {
+        return (NodeJsWebAppDriver) super.getDriver();
+    }
+    
+    @Override
+    protected void doStop() {
+        super.doStop();
+        // zero our workrate derived workrates.
+        // TODO might not be enough, as policy may still be executing and have a record of historic vals; should remove policies
+        // (also not sure we want this; implies more generally a responsibility for sensors to announce things when disconnected,
+        // vs them just showing the last known value...)
+        setAttribute(REQUESTS_PER_SECOND_LAST, 0D);
+        setAttribute(REQUESTS_PER_SECOND_IN_WINDOW, 0D);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a9ad442d/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSshDriver.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSshDriver.java b/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSshDriver.java
new file mode 100644
index 0000000..611b3b7
--- /dev/null
+++ b/software/webapp/src/main/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSshDriver.java
@@ -0,0 +1,125 @@
+package brooklyn.entity.webapp.nodejs;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import brooklyn.entity.basic.AbstractSoftwareProcessSshDriver;
+import brooklyn.entity.basic.Attributes;
+import brooklyn.entity.basic.SoftwareProcess;
+import brooklyn.entity.webapp.WebAppService;
+import brooklyn.entity.webapp.WebAppServiceMethods;
+import brooklyn.location.basic.SshMachineLocation;
+import brooklyn.util.collections.MutableMap;
+import brooklyn.util.os.Os;
+import brooklyn.util.ssh.BashCommands;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+
+public abstract class NodeJsWebAppSshDriver extends AbstractSoftwareProcessSshDriver implements NodeJsWebAppDriver {
+
+    public NodeJsWebAppSshDriver(NodeJsWebAppSoftwareProcessImpl entity, SshMachineLocation machine) {
+        super(entity, machine);
+    }
+
+    public NodeJsWebAppSoftwareProcessImpl getEntity() {
+        return (NodeJsWebAppSoftwareProcessImpl) super.getEntity();
+    }
+
+    @Override
+    public Integer getHttpPort() {
+        return entity.getAttribute(Attributes.HTTP_PORT);
+    }
+
+    protected String inferRootUrl() {
+        return WebAppServiceMethods.inferBrooklynAccessibleRootUrl(getEntity());
+    }
+
+    @Override
+    public void postLaunch() {
+        String rootUrl = inferRootUrl();
+        entity.setAttribute(WebAppService.ROOT_URL, rootUrl);
+    }
+
+    protected Map<String, Integer> getPortMap() {
+        return ImmutableMap.of("httpPort", entity.getAttribute(WebAppService.HTTP_PORT));
+    }
+
+    @Override
+    public Set<Integer> getPortsUsed() {
+        return ImmutableSet.<Integer>builder()
+                .addAll(super.getPortsUsed())
+                .addAll(getPortMap().values())
+                .build();
+    }
+
+    @Override
+    public void install() {
+        log.debug("Installing {}", getEntity());
+
+        List<String> commands = ImmutableList.<String>builder()
+                .add(BashCommands.installPackage(MutableMap.of("yum", "git nodejs npm"), null))
+                .add(BashCommands.sudo("npm install -g n"))
+                .add(BashCommands.sudo("n " + getEntity().getConfig(SoftwareProcess.SUGGESTED_VERSION)))
+                .add(BashCommands.sudo("useradd -mrU " + getEntity().getConfig(NodeJsWebAppSoftwareProcess.APP_USER)))
+                .build();
+
+        newScript(INSTALLING)
+                .body.append(commands)
+                .execute();
+    }
+
+    @Override
+    public void customize() {
+        log.debug("Customising {}", getEntity());
+
+        String appUser = getEntity().getConfig(NodeJsWebAppSoftwareProcess.APP_USER);
+        String appName = getEntity().getConfig(NodeJsWebAppService.APP_NAME);
+
+        List<String> commands = ImmutableList.<String>builder()
+                .add(String.format("git clone %s %s", getEntity().getConfig(NodeJsWebAppService.APP_GIT_REPOSITORY_URL), appName))
+                .add(BashCommands.sudo(String.format("chown -R %1$s:%1$s %2$s", appUser, appName)))
+                .build();
+
+        newScript(CUSTOMIZING)
+                .body.append(commands)
+                .execute();
+    }
+
+    @Override
+    public void launch() {
+        log.debug("Launching {}", getEntity());
+
+        String appUser = getEntity().getConfig(NodeJsWebAppSoftwareProcess.APP_USER);
+        String appName = getEntity().getConfig(NodeJsWebAppService.APP_NAME);
+
+        List<String> commands = ImmutableList.<String>builder()
+                .add(String.format("cd %s", Os.mergePathsUnix(getRunDir(), appName)))
+                .add(BashCommands.sudoAsUser(appUser, "nohup node " + getEntity().getConfig(NodeJsWebAppService.APP_FILE) + " &"))
+                .build();
+
+        newScript(LAUNCHING)
+                .body.append(commands)
+                .execute();
+    }
+
+    @Override
+    public boolean isRunning() {
+        return newScript(CHECK_RUNNING).execute() == 0;
+    }
+
+    @Override
+    public void stop() {
+        newScript(STOPPING).execute();
+    }
+
+    @Override
+    public Map<String, String> getShellEnvironment() {
+        return MutableMap.<String, String>builder().putAll(super.getShellEnvironment())
+                .put("PORT", Integer.toString(getHttpPort()))
+                .build();
+    }
+
+}


[06/11] git commit: Added simple integration and live tests

Posted by gr...@apache.org.
Added simple integration and live tests


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

Branch: refs/heads/master
Commit: a694716ff09f21da8fa5f0192d92dd61d3ebc21a
Parents: a68f429
Author: Andrew Kennedy <gr...@apache.org>
Authored: Thu Jul 31 16:21:46 2014 +0100
Committer: Andrew Kennedy <gr...@apache.org>
Committed: Thu Aug 21 14:50:27 2014 +0100

----------------------------------------------------------------------
 .../webapp/nodejs/NodeJsWebAppEc2LiveTest.java  | 41 ++++++++++
 .../NodeJsWebAppFixtureIntegrationTest.java     | 44 +++++++++++
 .../NodeJsWebAppSimpleIntegrationTest.java      | 82 ++++++++++++++++++++
 .../nodejs/NodeJsWebAppSoftlayerLiveTest.java   | 48 ++++++++++++
 4 files changed, 215 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a694716f/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppEc2LiveTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppEc2LiveTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppEc2LiveTest.java
new file mode 100644
index 0000000..7738516
--- /dev/null
+++ b/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppEc2LiveTest.java
@@ -0,0 +1,41 @@
+package brooklyn.entity.webapp.nodejs;
+
+import static brooklyn.entity.webapp.nodejs.NodeJsWebAppFixtureIntegrationTest.*;
+import static org.testng.Assert.assertNotNull;
+
+import brooklyn.entity.AbstractEc2LiveTest;
+import brooklyn.entity.proxying.EntitySpec;
+import brooklyn.location.Location;
+import brooklyn.test.Asserts;
+import brooklyn.test.HttpTestUtils;
+
+import com.google.common.collect.ImmutableList;
+
+/**
+ * A simple test of installing+running on AWS-EC2, using various OS distros and versions.
+ */
+public class NodeJsWebAppEc2LiveTest extends AbstractEc2LiveTest {
+
+    @Override
+    protected void doTest(Location loc) throws Exception {
+        final NodeJsWebAppService server = app.createAndManageChild(EntitySpec.create(NodeJsWebAppService.class)
+                .configure("gitRepoUrl", GIT_REPO_URL)
+                .configure("appFileName", APP_FILE)
+                .configure("appName", APP_NAME));
+
+        app.start(ImmutableList.of(loc));
+
+        String url = server.getAttribute(NodeJsWebAppService.ROOT_URL);
+
+        HttpTestUtils.assertHttpStatusCodeEventuallyEquals(url, 200);
+        HttpTestUtils.assertContentContainsText(url, "Hello");
+
+        Asserts.succeedsEventually(new Runnable() {
+            @Override public void run() {
+                assertNotNull(server.getAttribute(NodeJsWebAppService.REQUEST_COUNT));
+                assertNotNull(server.getAttribute(NodeJsWebAppService.ERROR_COUNT));
+                assertNotNull(server.getAttribute(NodeJsWebAppService.TOTAL_PROCESSING_TIME));
+            }});
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a694716f/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppFixtureIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppFixtureIntegrationTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppFixtureIntegrationTest.java
new file mode 100644
index 0000000..af6a593
--- /dev/null
+++ b/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppFixtureIntegrationTest.java
@@ -0,0 +1,44 @@
+package brooklyn.entity.webapp.nodejs;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.annotations.DataProvider;
+
+import brooklyn.entity.basic.SoftwareProcess;
+import brooklyn.entity.proxying.EntitySpec;
+import brooklyn.entity.webapp.AbstractWebAppFixtureIntegrationTest;
+import brooklyn.entity.webapp.WebAppService;
+import brooklyn.location.basic.PortRanges;
+import brooklyn.test.entity.TestApplication;
+
+public class NodeJsWebAppFixtureIntegrationTest extends AbstractWebAppFixtureIntegrationTest {
+
+    private static final Logger LOG = LoggerFactory.getLogger(NodeJsWebAppFixtureIntegrationTest.class);
+
+    public static final String GIT_REPO_URL = "https://github.com/grkvlt/node-hello-world.git";
+    public static final String APP_FILE = "app.js";
+    public static final String APP_NAME = "node-hello-world";
+
+    @DataProvider(name = "basicEntities")
+    public Object[][] basicEntities() {
+        TestApplication nodejsApp = newTestApplication();
+        NodeJsWebAppService nodejs = nodejsApp.createAndManageChild(EntitySpec.create(NodeJsWebAppService.class)
+                .configure(NodeJsWebAppService.HTTP_PORT, PortRanges.fromString(DEFAULT_HTTP_PORT))
+                .configure("gitRepoUrl", GIT_REPO_URL)
+                .configure("appFileName", APP_FILE)
+                .configure("appName", APP_NAME));
+
+        return new WebAppService[][] {
+                new WebAppService[] { nodejs }
+        };
+    }
+
+    public static void main(String ...args) throws Exception {
+        NodeJsWebAppFixtureIntegrationTest t = new NodeJsWebAppFixtureIntegrationTest();
+        t.setUp();
+        t.testReportsServiceDownWhenKilled((SoftwareProcess) t.basicEntities()[0][0]);
+        t.shutdownApp();
+        t.shutdownMgmt();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a694716f/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSimpleIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSimpleIntegrationTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSimpleIntegrationTest.java
new file mode 100644
index 0000000..1ad8cf8
--- /dev/null
+++ b/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSimpleIntegrationTest.java
@@ -0,0 +1,82 @@
+package brooklyn.entity.webapp.nodejs;
+
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.fail;
+
+import java.net.ServerSocket;
+import java.util.Iterator;
+
+import org.jclouds.util.Throwables2;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import brooklyn.entity.basic.ApplicationBuilder;
+import brooklyn.entity.basic.Entities;
+import brooklyn.entity.proxying.EntitySpec;
+import brooklyn.location.PortRange;
+import brooklyn.location.basic.LocalhostMachineProvisioningLocation;
+import brooklyn.location.basic.PortRanges;
+import brooklyn.test.entity.TestApplication;
+import brooklyn.util.net.Networking;
+
+import com.google.common.collect.ImmutableList;
+
+/**
+ * This tests the operation of the {@link NodeJsWebAppService} entity.
+ *
+ * FIXME this test is largely superseded by WebApp*IntegrationTest which tests inter alia Tomcat
+ */
+public class NodeJsWebAppSimpleIntegrationTest {
+    @SuppressWarnings("unused")
+    private static final Logger LOG = LoggerFactory.getLogger(NodeJsWebAppSimpleIntegrationTest.class);
+
+    /** don't use 8080 since that is commonly used by testing software; use different from other tests. */
+    static PortRange DEFAULT_HTTP_PORT_RANGE = PortRanges.fromString("7880-7980");
+
+    private TestApplication app;
+    private NodeJsWebAppService nodejs;
+    private int httpPort;
+
+    @BeforeMethod(alwaysRun=true)
+    public void pickFreePort() {
+        for (Iterator<Integer> iter = DEFAULT_HTTP_PORT_RANGE.iterator(); iter.hasNext();) {
+            Integer port = iter.next();
+            if (Networking.isPortAvailable(port)) {
+                httpPort = port;
+                return;
+            }
+        }
+        fail("someone is already listening on ports "+DEFAULT_HTTP_PORT_RANGE+"; tests assume that port is free on localhost");
+    }
+
+    @AfterMethod(alwaysRun=true)
+    public void tearDown() throws Exception {
+        if (app != null) Entities.destroyAll(app.getManagementContext());
+    }
+
+    @Test(groups="Integration")
+    public void detectFailureIfTomcanodejsantBindToPort() throws Exception {
+        ServerSocket listener = new ServerSocket(httpPort);
+        try {
+            app = ApplicationBuilder.newManagedApp(TestApplication.class);
+            nodejs = app.createAndManageChild(EntitySpec.create(NodeJsWebAppService.class).configure("httpPort", httpPort));
+
+            try {
+                nodejs.start(ImmutableList.of(app.getManagementContext().getLocationManager().manage(new LocalhostMachineProvisioningLocation())));
+                fail("Should have thrown start-exception");
+            } catch (Exception e) {
+                // LocalhostMachineProvisioningLocation does NetworkUtils.isPortAvailable, so get -1
+                IllegalArgumentException iae = Throwables2.getFirstThrowableOfType(e, IllegalArgumentException.class);
+                if (iae == null || iae.getMessage() == null || !iae.getMessage().equals("port for httpPort is null")) throw e;
+            } finally {
+                nodejs.stop();
+            }
+            assertFalse(nodejs.getAttribute(NodeJsWebAppServiceImpl.SERVICE_UP));
+        } finally {
+            listener.close();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a694716f/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSoftlayerLiveTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSoftlayerLiveTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSoftlayerLiveTest.java
new file mode 100644
index 0000000..3aa13ca
--- /dev/null
+++ b/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSoftlayerLiveTest.java
@@ -0,0 +1,48 @@
+package brooklyn.entity.webapp.nodejs;
+
+import static brooklyn.entity.webapp.nodejs.NodeJsWebAppFixtureIntegrationTest.*;
+import static org.testng.Assert.assertNotNull;
+
+import org.testng.annotations.Test;
+
+import brooklyn.entity.AbstractSoftlayerLiveTest;
+import brooklyn.entity.proxying.EntitySpec;
+import brooklyn.location.Location;
+import brooklyn.test.Asserts;
+import brooklyn.test.HttpTestUtils;
+
+import com.google.common.collect.ImmutableList;
+
+/**
+ * A simple test of installing+running on Softlayer, using various OS distros and versions.
+ */
+public class NodeJsWebAppSoftlayerLiveTest extends AbstractSoftlayerLiveTest {
+
+    @Override
+    protected void doTest(Location loc) throws Exception {
+        final NodeJsWebAppService server = app.createAndManageChild(EntitySpec.create(NodeJsWebAppService.class)
+                .configure("gitRepoUrl", GIT_REPO_URL)
+                .configure("appFileName", APP_FILE)
+                .configure("appName", APP_NAME));
+
+        app.start(ImmutableList.of(loc));
+
+        String url = server.getAttribute(NodeJsWebAppService.ROOT_URL);
+
+        HttpTestUtils.assertHttpStatusCodeEventuallyEquals(url, 200);
+        HttpTestUtils.assertContentContainsText(url, "Hello");
+
+        Asserts.succeedsEventually(new Runnable() {
+            @Override public void run() {
+                assertNotNull(server.getAttribute(NodeJsWebAppService.REQUEST_COUNT));
+                assertNotNull(server.getAttribute(NodeJsWebAppService.ERROR_COUNT));
+                assertNotNull(server.getAttribute(NodeJsWebAppService.TOTAL_PROCESSING_TIME));
+            }});
+    }
+
+    @Test(groups = {"Live", "Live-sanity"})
+    @Override
+    public void test_Ubuntu_12_0_4() throws Exception {
+        super.test_Ubuntu_12_0_4();
+    }
+}