You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by sj...@apache.org on 2017/03/24 18:45:58 UTC

[1/6] brooklyn-server git commit: Replace http(s)://httpbin.org with a local server

Repository: brooklyn-server
Updated Branches:
  refs/heads/master 23cb3a080 -> 05a86be47


Replace http(s)://httpbin.org with a local server


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

Branch: refs/heads/master
Commit: a682daa65333587ac365dfa1d4a988d77bfbf5e4
Parents: 23cb3a0
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Authored: Fri Mar 24 12:15:47 2017 +0200
Committer: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Committed: Fri Mar 24 12:56:13 2017 +0200

----------------------------------------------------------------------
 .../CompositeEffectorYamlRebindTest.java        |  29 ++-
 .../brooklyn/CompositeEffectorYamlTest.java     |  27 ++-
 .../HttpCommandEffectorYamlRebindTest.java      |  29 ++-
 .../brooklyn/HttpCommandEffectorYamlTest.java   |  29 ++-
 .../http/HttpCommandEffectorHttpBinTest.java    | 192 +++++++++++++++++++
 .../HttpCommandEffectorIntegrationTest.java     | 125 ------------
 6 files changed, 295 insertions(+), 136 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/a682daa6/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/CompositeEffectorYamlRebindTest.java
----------------------------------------------------------------------
diff --git a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/CompositeEffectorYamlRebindTest.java b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/CompositeEffectorYamlRebindTest.java
index 530abf6..1f33c78 100644
--- a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/CompositeEffectorYamlRebindTest.java
+++ b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/CompositeEffectorYamlRebindTest.java
@@ -27,10 +27,14 @@ import org.apache.brooklyn.api.effector.Effector;
 import org.apache.brooklyn.api.entity.Entity;
 import org.apache.brooklyn.core.effector.CompositeEffector;
 import org.apache.brooklyn.core.effector.http.HttpCommandEffector;
+import org.apache.brooklyn.core.effector.http.HttpCommandEffectorHttpBinTest;
 import org.apache.brooklyn.core.entity.EntityPredicates;
 import org.apache.brooklyn.core.entity.StartableApplication;
 import org.apache.brooklyn.core.test.entity.TestEntity;
+import org.apache.brooklyn.test.http.TestHttpServer;
 import org.apache.brooklyn.util.guava.Maybe;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
 import com.google.common.base.Joiner;
@@ -57,7 +61,7 @@ public class CompositeEffectorYamlRebindTest extends AbstractYamlRebindTest {
            "      brooklyn.config:",
            "        name: myEffector",
            "        description: myDescription",
-           "        uri: http://httpbin.org/get?id=myId",
+           "        uri: ${serverUrl}/get?id=myId",
            "        httpVerb: GET",
            "        jsonPath: $.args.id",
            "        publishSensor: results",
@@ -69,9 +73,28 @@ public class CompositeEffectorYamlRebindTest extends AbstractYamlRebindTest {
            "        - myEffector"
    );
 
-    @Test(groups="Integration")
+   private TestHttpServer server;
+   private String serverUrl;
+
+   @Override
+   @BeforeMethod(alwaysRun = true)
+   public void setUp() throws Exception {
+       super.setUp();
+       server = HttpCommandEffectorHttpBinTest.createHttpBinServer();
+       serverUrl = server.getUrl();
+   }
+
+   @Override
+   @AfterMethod(alwaysRun = true)
+   public void tearDown() throws Exception {
+       super.tearDown();
+       server.stop();
+   }
+
+
+   @Test
    public void testRebindWhenHealthy() throws Exception {
-      runRebindWhenIsUp(catalogYamlSimple, appVersionedId);
+      runRebindWhenIsUp(catalogYamlSimple.replace("${serverUrl}", serverUrl), appVersionedId);
    }
 
    protected void runRebindWhenIsUp(String catalogYaml, String appId) throws Exception {

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/a682daa6/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/CompositeEffectorYamlTest.java
----------------------------------------------------------------------
diff --git a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/CompositeEffectorYamlTest.java b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/CompositeEffectorYamlTest.java
index 8d1ff0b..8833507 100644
--- a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/CompositeEffectorYamlTest.java
+++ b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/CompositeEffectorYamlTest.java
@@ -26,9 +26,13 @@ import org.apache.brooklyn.api.effector.Effector;
 import org.apache.brooklyn.api.entity.Entity;
 import org.apache.brooklyn.core.effector.CompositeEffector;
 import org.apache.brooklyn.core.effector.http.HttpCommandEffector;
+import org.apache.brooklyn.core.effector.http.HttpCommandEffectorHttpBinTest;
 import org.apache.brooklyn.entity.software.base.EmptySoftwareProcess;
+import org.apache.brooklyn.test.http.TestHttpServer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
 import com.google.common.collect.ImmutableMap;
@@ -37,7 +41,26 @@ import com.google.common.collect.Iterables;
 public class CompositeEffectorYamlTest extends AbstractYamlTest {
     private static final Logger log = LoggerFactory.getLogger(CompositeEffectorYamlTest.class);
 
-    @Test(groups="Integration")
+    private TestHttpServer server;
+    private String serverUrl;
+
+    @Override
+    @BeforeMethod(alwaysRun = true)
+    public void setUp() throws Exception {
+        super.setUp();
+        server = HttpCommandEffectorHttpBinTest.createHttpBinServer();
+        serverUrl = server.getUrl();
+    }
+
+    @Override
+    @AfterMethod(alwaysRun = true)
+    public void tearDown() throws Exception {
+        super.tearDown();
+        server.stop();
+    }
+
+
+    @Test
     public void testCompositeEffector() throws Exception {
         Entity app = createAndStartApplication(
             "location: localhost",
@@ -51,7 +74,7 @@ public class CompositeEffectorYamlTest extends AbstractYamlTest {
             "    brooklyn.config:",
             "      name: myEffector",
             "      description: myDescription",
-            "      uri: http://httpbin.org/get?id=myId",
+            "      uri: " + serverUrl + "/get?id=myId",
             "      httpVerb: GET",
             "      jsonPath: $.args.id",
             "      publishSensor: results",

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/a682daa6/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/HttpCommandEffectorYamlRebindTest.java
----------------------------------------------------------------------
diff --git a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/HttpCommandEffectorYamlRebindTest.java b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/HttpCommandEffectorYamlRebindTest.java
index 96db7d9..7565379 100644
--- a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/HttpCommandEffectorYamlRebindTest.java
+++ b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/HttpCommandEffectorYamlRebindTest.java
@@ -24,10 +24,14 @@ import static org.testng.Assert.assertEquals;
 import org.apache.brooklyn.api.effector.Effector;
 import org.apache.brooklyn.api.entity.Entity;
 import org.apache.brooklyn.core.effector.http.HttpCommandEffector;
+import org.apache.brooklyn.core.effector.http.HttpCommandEffectorHttpBinTest;
 import org.apache.brooklyn.core.entity.EntityPredicates;
 import org.apache.brooklyn.core.entity.StartableApplication;
 import org.apache.brooklyn.core.test.entity.TestEntity;
+import org.apache.brooklyn.test.http.TestHttpServer;
 import org.apache.brooklyn.util.guava.Maybe;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
 import com.google.common.base.Joiner;
@@ -54,14 +58,33 @@ public class HttpCommandEffectorYamlRebindTest extends AbstractYamlRebindTest {
            "        brooklyn.config:",
            "          name: myEffector",
            "          description: myDescription",
-           "          uri: http://httpbin.org/get?id=myId",
+           "          uri: ${serverUrl}/get?id=myId",
            "          httpVerb: GET",
            "          jsonPath: $.args.id",
            "          publishSensor: results");
 
-   @Test(groups="Integration")
+   private TestHttpServer server;
+   private String serverUrl;
+
+   @Override
+   @BeforeMethod(alwaysRun = true)
+   public void setUp() throws Exception {
+       super.setUp();
+       server = HttpCommandEffectorHttpBinTest.createHttpBinServer();
+       serverUrl = server.getUrl();
+   }
+
+   @Override
+   @AfterMethod(alwaysRun = true)
+   public void tearDown() throws Exception {
+       super.tearDown();
+       server.stop();
+   }
+
+
+   @Test
    public void testRebindWhenHealthy() throws Exception {
-      runRebindWhenIsUp(catalogYamlSimple, appVersionedId);
+      runRebindWhenIsUp(catalogYamlSimple.replace("${serverUrl}", serverUrl), appVersionedId);
    }
 
    protected void runRebindWhenIsUp(String catalogYaml, String appId) throws Exception {

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/a682daa6/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/HttpCommandEffectorYamlTest.java
----------------------------------------------------------------------
diff --git a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/HttpCommandEffectorYamlTest.java b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/HttpCommandEffectorYamlTest.java
index c1a1963..00e7cac 100644
--- a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/HttpCommandEffectorYamlTest.java
+++ b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/HttpCommandEffectorYamlTest.java
@@ -23,9 +23,13 @@ import static org.testng.Assert.assertEquals;
 import org.apache.brooklyn.api.effector.Effector;
 import org.apache.brooklyn.api.entity.Entity;
 import org.apache.brooklyn.core.effector.http.HttpCommandEffector;
+import org.apache.brooklyn.core.effector.http.HttpCommandEffectorHttpBinTest;
 import org.apache.brooklyn.entity.software.base.EmptySoftwareProcess;
+import org.apache.brooklyn.test.http.TestHttpServer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
 import com.google.common.collect.ImmutableMap;
@@ -34,7 +38,26 @@ import com.google.common.collect.Iterables;
 public class HttpCommandEffectorYamlTest extends AbstractYamlTest {
     private static final Logger log = LoggerFactory.getLogger(HttpCommandEffectorYamlTest.class);
 
-    @Test(groups="Integration")
+    private TestHttpServer server;
+    private String serverUrl;
+
+    @Override
+    @BeforeMethod(alwaysRun = true)
+    public void setUp() throws Exception {
+        super.setUp();
+        server = HttpCommandEffectorHttpBinTest.createHttpBinServer();
+        serverUrl = server.getUrl();
+    }
+
+    @Override
+    @AfterMethod(alwaysRun = true)
+    public void tearDown() throws Exception {
+        super.tearDown();
+        server.stop();
+    }
+
+
+    @Test
     public void testHttpCommandEffectorWithParameters() throws Exception {
         Entity app = createAndStartApplication(
             "location: localhost",
@@ -48,7 +71,7 @@ public class HttpCommandEffectorYamlTest extends AbstractYamlTest {
             "    brooklyn.config:",
             "      name: myEffector",
             "      description: myDescription",
-            "      uri: http://httpbin.org/get?id=myId",
+            "      uri: " + serverUrl + "/get?id=myId",
             "      httpVerb: GET",
             "      jsonPath: $.args.id",
             "      publishSensor: results"
@@ -60,7 +83,7 @@ public class HttpCommandEffectorYamlTest extends AbstractYamlTest {
 
         // Invoke with parameters
         {
-            Object result = entity.invoke(effector, ImmutableMap.of("uri", "http://httpbin.org/get?pwd=passwd", "jsonPath", "$.args.pwd")).get();
+            Object result = entity.invoke(effector, ImmutableMap.of("uri", serverUrl + "/get?pwd=passwd", "jsonPath", "$.args.pwd")).get();
             assertEquals(((String)result).trim(), "passwd");
 
         }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/a682daa6/core/src/test/java/org/apache/brooklyn/core/effector/http/HttpCommandEffectorHttpBinTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/effector/http/HttpCommandEffectorHttpBinTest.java b/core/src/test/java/org/apache/brooklyn/core/effector/http/HttpCommandEffectorHttpBinTest.java
new file mode 100644
index 0000000..e9eb491
--- /dev/null
+++ b/core/src/test/java/org/apache/brooklyn/core/effector/http/HttpCommandEffectorHttpBinTest.java
@@ -0,0 +1,192 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.brooklyn.core.effector.http;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.List;
+
+import org.apache.brooklyn.api.effector.Effector;
+import org.apache.brooklyn.api.entity.EntityLocal;
+import org.apache.brooklyn.api.entity.EntitySpec;
+import org.apache.brooklyn.api.location.Location;
+import org.apache.brooklyn.core.effector.Effectors;
+import org.apache.brooklyn.core.entity.Entities;
+import org.apache.brooklyn.core.sensor.Sensors;
+import org.apache.brooklyn.core.test.entity.TestApplication;
+import org.apache.brooklyn.core.test.entity.TestEntity;
+import org.apache.brooklyn.test.http.TestHttpServer;
+import org.apache.brooklyn.util.collections.Jsonya;
+import org.apache.brooklyn.util.collections.Jsonya.Navigator;
+import org.apache.brooklyn.util.collections.MutableMap;
+import org.apache.brooklyn.util.core.config.ConfigBag;
+import org.apache.http.HttpException;
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpResponse;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.utils.URLEncodedUtils;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.message.BasicHttpRequest;
+import org.apache.http.protocol.HttpContext;
+import org.apache.http.protocol.HttpRequestHandler;
+import org.testng.Assert;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.jayway.jsonpath.JsonPath;
+
+public class HttpCommandEffectorHttpBinTest {
+
+    final static Effector<String> EFFECTOR_HTTPBIN = Effectors.effector(String.class, "Httpbin").buildAbstract();
+
+    private TestHttpServer server;
+    private String serverUrl;
+    private TestApplication app;
+    private EntityLocal entity;
+    
+    public static final class HttpBinRequestHandler implements HttpRequestHandler {
+        private String serverUrl;
+        @Override
+        public void handle(HttpRequest request, HttpResponse response, HttpContext context)
+                throws HttpException, IOException {
+            Navigator<MutableMap<Object, Object>> j = Jsonya.newInstance().map();
+            BasicHttpRequest req = (BasicHttpRequest)request;
+            String url = req.getRequestLine().getUri();
+            URI uri = URI.create(url);
+            String method = req.getRequestLine().getMethod();
+            boolean expectsPost = uri.getPath().equals("/post");
+            if (expectsPost && !method.equals("POST") ||
+                    !expectsPost && !method.equals("GET")) {
+                throw new IllegalStateException("Method " + method + " not allowed on " + url);
+            }
+            List<NameValuePair> params = URLEncodedUtils.parse(uri, "UTF-8");
+            if (!params.isEmpty()) {
+                j.push().at("args");
+                for (NameValuePair param : params) {
+                    j.put(param.getName(), param.getValue());
+                }
+                j.pop();
+            }
+            j.put("origin", "127.0.0.1");
+            j.put("url", serverUrl + url);
+
+            response.setHeader("Content-Type", "application/json");
+            response.setStatusCode(200);
+            response.setEntity(new StringEntity(j.toString()));
+        }
+        public void setServerUrl(String serverUrl) {
+            this.serverUrl = serverUrl;
+        }
+    }
+    
+    @BeforeMethod(alwaysRun=true)
+    public void setUp() throws Exception {
+        app = TestApplication.Factory.newManagedInstanceForTests();
+        entity = app.createAndManageChild(EntitySpec.create(TestEntity.class).location(TestApplication.LOCALHOST_MACHINE_SPEC));
+        app.start(ImmutableList.<Location>of());
+        server = createHttpBinServer();
+        serverUrl = server.getUrl();
+    }
+
+    public static TestHttpServer createHttpBinServer() {
+        HttpBinRequestHandler handler = new HttpBinRequestHandler();
+        TestHttpServer server = new TestHttpServer()
+                .handler("/get", handler)
+                .handler("/post", handler)
+                .handler("/ip", handler)
+                .start();
+        handler.setServerUrl(server.getUrl());
+        return server;
+    }
+
+    @AfterMethod(alwaysRun=true)
+    public void tearDown() throws Exception {
+        if (app != null) Entities.destroyAll(app.getManagementContext());
+        server.stop();
+    }
+
+    @Test
+    public void testHttpEffector() throws Exception {
+        new HttpCommandEffector(ConfigBag.newInstance()
+                .configure(HttpCommandEffector.EFFECTOR_NAME, "Httpbin")
+                .configure(HttpCommandEffector.EFFECTOR_URI, serverUrl + "/get?login=myLogin")
+                .configure(HttpCommandEffector.EFFECTOR_HTTP_VERB, "GET")
+        ).apply(entity);
+
+        String val = entity.invoke(EFFECTOR_HTTPBIN, MutableMap.<String,String>of()).get();
+        Assert.assertEquals(JsonPath.parse(val).read("$.args.login", String.class), "myLogin");
+    }
+
+    @Test
+    public void testHttpEffectorWithPayload() throws Exception {
+        new HttpCommandEffector(ConfigBag.newInstance()
+                .configure(HttpCommandEffector.EFFECTOR_NAME, "HttpbinPost")
+                .configure(HttpCommandEffector.EFFECTOR_URI, serverUrl + "/post")
+                .configure(HttpCommandEffector.EFFECTOR_HTTP_VERB, "POST")
+                .configure(HttpCommandEffector.EFFECTOR_HTTP_PAYLOAD, ImmutableMap.<String, Object>of(
+                        "description", "Created via API", 
+                        "public", "false",
+                        "files", ImmutableMap.of("demo.txt", ImmutableMap.of("content","Demo"))))
+                .configure(HttpCommandEffector.EFFECTOR_HTTP_HEADERS, ImmutableMap.of("Content-Type", "application/json"))
+                .configure(HttpCommandEffector.JSON_PATH, "$.url")
+                .configure(HttpCommandEffector.PUBLISH_SENSOR, "result")
+        ).apply(entity);
+
+        String url = entity.invoke(Effectors.effector(String.class, "HttpbinPost").buildAbstract(), MutableMap.<String,String>of()).get();
+        Assert.assertNotNull(url, "url");
+    }
+
+    @Test
+    public void testHttpEffectorWithJsonPath() throws Exception {
+        new HttpCommandEffector(ConfigBag.newInstance()
+                .configure(HttpCommandEffector.EFFECTOR_NAME, "Httpbin")
+                .configure(HttpCommandEffector.EFFECTOR_URI, serverUrl + "/get?id=myId")
+                .configure(HttpCommandEffector.EFFECTOR_HTTP_VERB, "GET")
+                .configure(HttpCommandEffector.JSON_PATH, "$.args.id")
+                .configure(HttpCommandEffector.PUBLISH_SENSOR, "result")
+        ).apply(entity);
+
+        String val = entity.invoke(EFFECTOR_HTTPBIN, MutableMap.<String,String>of()).get();
+        Assert.assertEquals(val, "myId");
+        Assert.assertEquals(entity.sensors().get(Sensors.newStringSensor("result")), "myId");
+    }
+    
+    @Test
+    public void testHttpEffectorWithParameters() throws Exception {
+        new HttpCommandEffector(ConfigBag.newInstance()
+                .configure(HttpCommandEffector.EFFECTOR_NAME, "Httpbin")
+                .configure(HttpCommandEffector.EFFECTOR_URI, serverUrl + "/get")                
+                .configure(HttpCommandEffector.EFFECTOR_HTTP_VERB, "GET")
+                .configure(HttpCommandEffector.EFFECTOR_PARAMETER_DEFS,
+                        MutableMap.<String,Object>of("uri", MutableMap.of("defaultValue", serverUrl + "/get"))))
+                .apply(entity);
+
+        String val;
+        // explicit value
+        val = entity.invoke(EFFECTOR_HTTPBIN, MutableMap.of("uri", serverUrl + "/ip")).get();
+        Assert.assertNotNull(JsonPath.parse(val).read("$.origin", String.class));
+
+        // default value
+        val = entity.invoke(EFFECTOR_HTTPBIN, MutableMap.<String,String>of()).get();
+        Assert.assertEquals(JsonPath.parse(val).read("$.url", String.class), serverUrl + "/get");
+    }
+}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/a682daa6/core/src/test/java/org/apache/brooklyn/core/effector/http/HttpCommandEffectorIntegrationTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/effector/http/HttpCommandEffectorIntegrationTest.java b/core/src/test/java/org/apache/brooklyn/core/effector/http/HttpCommandEffectorIntegrationTest.java
deleted file mode 100644
index c99c9c3..0000000
--- a/core/src/test/java/org/apache/brooklyn/core/effector/http/HttpCommandEffectorIntegrationTest.java
+++ /dev/null
@@ -1,125 +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 org.apache.brooklyn.core.effector.http;
-
-import org.apache.brooklyn.api.effector.Effector;
-import org.apache.brooklyn.api.entity.EntityLocal;
-import org.apache.brooklyn.api.entity.EntitySpec;
-import org.apache.brooklyn.api.location.Location;
-import org.apache.brooklyn.core.effector.Effectors;
-import org.apache.brooklyn.core.entity.Entities;
-import org.apache.brooklyn.core.sensor.Sensors;
-import org.apache.brooklyn.core.test.entity.TestApplication;
-import org.apache.brooklyn.core.test.entity.TestEntity;
-import org.apache.brooklyn.util.collections.MutableMap;
-import org.apache.brooklyn.util.core.config.ConfigBag;
-import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.jayway.jsonpath.JsonPath;
-
-public class HttpCommandEffectorIntegrationTest {
-
-    final static Effector<String> EFFECTOR_HTTPBIN = Effectors.effector(String.class, "Httpbin").buildAbstract();
-
-    private TestApplication app;
-    private EntityLocal entity;
-    
-    @BeforeMethod(alwaysRun=true)
-    public void setUp() throws Exception {
-        app = TestApplication.Factory.newManagedInstanceForTests();
-        entity = app.createAndManageChild(EntitySpec.create(TestEntity.class).location(TestApplication.LOCALHOST_MACHINE_SPEC));
-        app.start(ImmutableList.<Location>of());
-    }
-
-    @AfterMethod(alwaysRun=true)
-    public void tearDown() throws Exception {
-        if (app != null) Entities.destroyAll(app.getManagementContext());
-    }
-
-    @Test(groups="Integration")
-    public void testHttpEffector() throws Exception {
-        new HttpCommandEffector(ConfigBag.newInstance()
-                .configure(HttpCommandEffector.EFFECTOR_NAME, "Httpbin")
-                .configure(HttpCommandEffector.EFFECTOR_URI, "http://httpbin.org/get?login=myLogin")
-                .configure(HttpCommandEffector.EFFECTOR_HTTP_VERB, "GET")
-        ).apply(entity);
-
-        String val = entity.invoke(EFFECTOR_HTTPBIN, MutableMap.<String,String>of()).get();
-        Assert.assertEquals(JsonPath.parse(val).read("$.args.login", String.class), "myLogin");
-    }
-
-    @Test(groups="Integration")
-    public void testHttpEffectorWithPayload() throws Exception {
-        new HttpCommandEffector(ConfigBag.newInstance()
-                .configure(HttpCommandEffector.EFFECTOR_NAME, "HttpbinPost")
-                .configure(HttpCommandEffector.EFFECTOR_URI, "http://httpbin.org/post")
-                .configure(HttpCommandEffector.EFFECTOR_HTTP_VERB, "POST")
-                .configure(HttpCommandEffector.EFFECTOR_HTTP_PAYLOAD, ImmutableMap.<String, Object>of(
-                        "description", "Created via API", 
-                        "public", "false",
-                        "files", ImmutableMap.of("demo.txt", ImmutableMap.of("content","Demo"))))
-                .configure(HttpCommandEffector.EFFECTOR_HTTP_HEADERS, ImmutableMap.of("Content-Type", "application/json"))
-                .configure(HttpCommandEffector.JSON_PATH, "$.url")
-                .configure(HttpCommandEffector.PUBLISH_SENSOR, "result")
-        ).apply(entity);
-
-        String url = entity.invoke(Effectors.effector(String.class, "HttpbinPost").buildAbstract(), MutableMap.<String,String>of()).get();
-        Assert.assertNotNull(url, "url");
-    }
-
-    @Test(groups="Integration")
-    public void testHttpEffectorWithJsonPath() throws Exception {
-        new HttpCommandEffector(ConfigBag.newInstance()
-                .configure(HttpCommandEffector.EFFECTOR_NAME, "Httpbin")
-                .configure(HttpCommandEffector.EFFECTOR_URI, "http://httpbin.org/get?id=myId")
-                .configure(HttpCommandEffector.EFFECTOR_HTTP_VERB, "GET")
-                .configure(HttpCommandEffector.JSON_PATH, "$.args.id")
-                .configure(HttpCommandEffector.PUBLISH_SENSOR, "result")
-        ).apply(entity);
-
-        String val = entity.invoke(EFFECTOR_HTTPBIN, MutableMap.<String,String>of()).get();
-        Assert.assertEquals(val, "myId");
-        Assert.assertEquals(entity.sensors().get(Sensors.newStringSensor("result")), "myId");
-    }
-    
-    @Test(groups="Integration")
-    public void testHttpEffectorWithParameters() throws Exception {
-        new HttpCommandEffector(ConfigBag.newInstance()
-                .configure(HttpCommandEffector.EFFECTOR_NAME, "Httpbin")
-                .configure(HttpCommandEffector.EFFECTOR_URI, "http://httpbin.org/get")
-                .configure(HttpCommandEffector.EFFECTOR_HTTP_VERB, "GET")
-                .configure(HttpCommandEffector.EFFECTOR_PARAMETER_DEFS,
-                        MutableMap.<String,Object>of("uri", MutableMap.of("defaultValue", "http://httpbin.org/get"))))
-                .apply(entity);
-
-        String val;
-        // explicit value
-        val = entity.invoke(EFFECTOR_HTTPBIN, MutableMap.of("uri", "http://httpbin.org/ip")).get();
-        Assert.assertNotNull(JsonPath.parse(val).read("$.origin", String.class));
-
-        // default value
-        val = entity.invoke(EFFECTOR_HTTPBIN, MutableMap.<String,String>of()).get();
-        Assert.assertEquals(JsonPath.parse(val).read("$.url", String.class), "http://httpbin.org/get");
-    }
-}


[5/6] brooklyn-server git commit: SoftwareProcessEntityTest.testDoubleStopEntity - add some troubleshooting checks

Posted by sj...@apache.org.
SoftwareProcessEntityTest.testDoubleStopEntity - add some troubleshooting checks

Failed with the following exception, but not obvious why:

java.lang.AssertionError: entity=EmptySoftwareProcessImpl{id=i5jf7l77wu}; attribute=Sensor: service.state (org.apache.brooklyn.core.entity.lifecycle.Lifecycle) expected [stopped] but found [stopping]
    at org.apache.brooklyn.test.Asserts.fail(Asserts.java:758)
    at org.apache.brooklyn.test.Asserts.failNotEquals(Asserts.java:148)
    at org.apache.brooklyn.test.Asserts.assertEquals(Asserts.java:470)
    at org.apache.brooklyn.core.entity.EntityAsserts.assertAttributeEquals(EntityAsserts.java:58)
    at org.apache.brooklyn.entity.software.base.SoftwareProcessEntityTest.testDoubleStopEntity(SoftwareProcessEntityTest.java:496)


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

Branch: refs/heads/master
Commit: dc2eb153488bb3974db7f7707db2de69089c5c36
Parents: 363874e
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Authored: Fri Mar 24 17:19:55 2017 +0200
Committer: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Committed: Fri Mar 24 17:19:55 2017 +0200

----------------------------------------------------------------------
 .../entity/software/base/SoftwareProcessEntityTest.java   | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/dc2eb153/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessEntityTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessEntityTest.java b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessEntityTest.java
index b1564e9..3fa464c 100644
--- a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessEntityTest.java
+++ b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessEntityTest.java
@@ -481,7 +481,10 @@ public class SoftwareProcessEntityTest extends BrooklynAppUnitTestSupport {
                     assertTrue(loc.isBlocked());
                 }
             });
-    
+
+            assertEquals(ServiceStateLogic.getExpectedState(entity), Lifecycle.STOPPING);
+            EntityAsserts.assertAttributeEquals(entity, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.STOPPING);
+
             // Subsequent stops will end quickly - no location to release,
             // while the first one is still releasing the machine.
             final Task<Void> secondStop = entity.invoke(Startable.STOP, ImmutableMap.<String, Object>of());;
@@ -492,7 +495,10 @@ public class SoftwareProcessEntityTest extends BrooklynAppUnitTestSupport {
                 }
             });
     
-            // Entity state is STOPPED even though first location is still releasing
+            // Entity state is supposed to be STOPPED even though first location is still releasing. This is because the second
+            // release completed successfully. It's debatable whether this is the right behaviour - we could be calling the STOP
+            // effector exactly because the first call is blocked. The test is asserting the current behaviour.
+            assertEquals(ServiceStateLogic.getExpectedState(entity), Lifecycle.STOPPED);
             EntityAsserts.assertAttributeEquals(entity, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.STOPPED);
             Asserts.succeedsContinually(new Runnable() {
                 @Override


[3/6] brooklyn-server git commit: WinRmFeedIntegrationTest relies on an external resource, mark as Live

Posted by sj...@apache.org.
WinRmFeedIntegrationTest relies on an external resource, mark as Live

Requires that the user spins up a windows machine and configures its location in his local brooklyn.properties.


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

Branch: refs/heads/master
Commit: f74ce8fc7c80d6cc3f2d2d97878d5faf4da7761d
Parents: a682daa
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Authored: Fri Mar 24 12:17:04 2017 +0200
Committer: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Committed: Fri Mar 24 12:56:14 2017 +0200

----------------------------------------------------------------------
 .../feed/windows/WinRmFeedIntegrationTest.java  | 262 ------------------
 .../feed/windows/WinRmFeedLiveTest.java         | 263 +++++++++++++++++++
 2 files changed, 263 insertions(+), 262 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f74ce8fc/software/winrm/src/test/java/org/apache/brooklyn/feed/windows/WinRmFeedIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/winrm/src/test/java/org/apache/brooklyn/feed/windows/WinRmFeedIntegrationTest.java b/software/winrm/src/test/java/org/apache/brooklyn/feed/windows/WinRmFeedIntegrationTest.java
deleted file mode 100644
index afaedb4..0000000
--- a/software/winrm/src/test/java/org/apache/brooklyn/feed/windows/WinRmFeedIntegrationTest.java
+++ /dev/null
@@ -1,262 +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 org.apache.brooklyn.feed.windows;
-
-import com.google.common.base.Function;
-import com.google.common.base.Predicates;
-import com.google.common.base.Supplier;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import org.apache.brooklyn.api.entity.EntityInitializer;
-import org.apache.brooklyn.api.entity.EntityLocal;
-import org.apache.brooklyn.api.entity.EntitySpec;
-import org.apache.brooklyn.api.location.MachineProvisioningLocation;
-import org.apache.brooklyn.api.sensor.AttributeSensor;
-import org.apache.brooklyn.core.entity.Attributes;
-import org.apache.brooklyn.core.entity.EntityAsserts;
-import org.apache.brooklyn.core.entity.EntityInternal;
-import org.apache.brooklyn.core.entity.EntityInternal.FeedSupport;
-import org.apache.brooklyn.core.sensor.Sensors;
-import org.apache.brooklyn.core.test.BrooklynAppLiveTestSupport;
-import org.apache.brooklyn.core.test.entity.TestEntity;
-import org.apache.brooklyn.feed.CommandPollConfig;
-import org.apache.brooklyn.feed.ssh.SshPollValue;
-import org.apache.brooklyn.feed.ssh.SshValueFunctions;
-import org.apache.brooklyn.location.winrm.WinRmMachineLocation;
-import org.apache.brooklyn.util.collections.MutableMap;
-import org.apache.brooklyn.util.exceptions.Exceptions;
-import org.apache.brooklyn.util.text.StringFunctions;
-import org.apache.brooklyn.util.text.StringPredicates;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicInteger;
-
-/**
- * Test is almost identical to {@link org.apache.brooklyn.feed.ssh.SshFeedIntegrationTest}.
- * To launch the test I put in ~/.brooklyn/brooklyn.properties
- *   brooklyn.location.named.WindowsLiveTest=byon:(hosts=192.168.1.2,osFamily=windows,user=winUser,password=p0ssw0rd)
- */
-public class WinRmFeedIntegrationTest extends BrooklynAppLiveTestSupport {
-
-    private static final Logger log = LoggerFactory.getLogger(WinRmFeedIntegrationTest.class);
-
-    private static final String LOCATION_SPEC = "named:WindowsLiveTest";
-    
-    final static AttributeSensor<String> SENSOR_STRING = Sensors.newStringSensor("aString", "");
-    final static AttributeSensor<Integer> SENSOR_INT = Sensors.newIntegerSensor("aLong", "");
-
-    private WinRmMachineLocation machine;
-    private TestEntity entity;
-    private CmdFeed feed;
-    
-    @BeforeMethod(alwaysRun=true)
-    @Override
-    public void setUp() throws Exception {
-        super.setUp();
-
-        MachineProvisioningLocation<?> provisioningLocation = (MachineProvisioningLocation<?>)
-                mgmt.getLocationRegistry().getLocationManaged(LOCATION_SPEC);
-        machine = (WinRmMachineLocation)provisioningLocation.obtain(ImmutableMap.of());
-        entity = app.createAndManageChild(EntitySpec.create(TestEntity.class));
-        app.start(ImmutableList.of(machine));
-    }
-
-    @AfterMethod(alwaysRun=true)
-    @Override
-    public void tearDown() throws Exception {
-        if (feed != null) feed.stop();
-        super.tearDown();
-    }
-    
-    /** this is one of the most common pattern */
-    @Test(groups="Integration")
-    public void testReturnsStdoutAndInfersMachine() throws Exception {
-        final TestEntity entity2 = app.createAndManageChild(EntitySpec.create(TestEntity.class)
-            // inject the machine location, because the app was started with a provisioning location
-            // and TestEntity doesn't provision
-            .location(machine));
-        
-        feed = CmdFeed.builder()
-                .entity(entity2)
-                .poll(new CommandPollConfig<String>(SENSOR_STRING)
-                        .command("echo hello")
-                        .onSuccess(SshValueFunctions.stdout()))
-                .build();
-        
-        EntityAsserts.assertAttributeEventuallyNonNull(entity2, SENSOR_STRING);
-        String val = entity2.getAttribute(SENSOR_STRING);
-        Assert.assertTrue(val.contains("hello"), "val="+val);
-        Assert.assertEquals(val.trim(), "hello");
-    }
-
-    @Test(groups="Integration")
-    public void testFeedDeDupe() throws Exception {
-        testReturnsStdoutAndInfersMachine();
-        entity.addFeed(feed);
-        log.info("Feed 0 is: "+feed);
-        
-        testReturnsStdoutAndInfersMachine();
-        log.info("Feed 1 is: "+feed);
-        entity.addFeed(feed);
-                
-        FeedSupport feeds = ((EntityInternal)entity).feeds();
-        Assert.assertEquals(feeds.getFeeds().size(), 1, "Wrong feed count: "+feeds.getFeeds());
-    }
-    
-    @Test(groups="Integration")
-    public void testReturnsSshExitStatus() throws Exception {
-        feed = CmdFeed.builder()
-                .entity(entity)
-                .machine(machine)
-                .poll(new CommandPollConfig<Integer>(SENSOR_INT)
-                        .command("exit 123")
-                        .checkSuccess(Predicates.alwaysTrue())
-                        .onSuccess(SshValueFunctions.exitStatus()))
-                .build();
-
-        EntityAsserts.assertAttributeEqualsEventually(entity, SENSOR_INT, 123);
-    }
-    
-    @Test(groups="Integration")
-    public void testReturnsStdout() throws Exception {
-        feed = CmdFeed.builder()
-                .entity(entity)
-                .machine(machine)
-                .poll(new CommandPollConfig<String>(SENSOR_STRING)
-                        .command("echo hello")
-                        .onSuccess(SshValueFunctions.stdout()))
-                .build();
-        
-        EntityAsserts.assertAttributeEventually(entity, SENSOR_STRING, 
-            Predicates.compose(Predicates.equalTo("hello"), StringFunctions.trim()));
-    }
-
-    @Test(groups="Integration")
-    public void testReturnsStderr() throws Exception {
-        final String cmd = "thiscommanddoesnotexist";
-        
-        feed = CmdFeed.builder()
-                .entity(entity)
-                .machine(machine)
-                .poll(new CommandPollConfig<String>(SENSOR_STRING)
-                        .command(cmd)
-                        .onFailure(SshValueFunctions.stderr()))
-                .build();
-        
-        EntityAsserts.assertAttributeEventually(entity, SENSOR_STRING, StringPredicates.containsLiteral(cmd));
-    }
-    
-    @Test(groups="Integration")
-    public void testFailsOnNonZero() throws Exception {
-        feed = CmdFeed.builder()
-                .entity(entity)
-                .machine(machine)
-                .poll(new CommandPollConfig<String>(SENSOR_STRING)
-                        .command("exit 123")
-                        .onFailure(new Function<SshPollValue, String>() {
-                            @Override
-                            public String apply(SshPollValue input) {
-                                return "Exit status " + input.getExitStatus();
-                            }}))
-                .build();
-        
-        EntityAsserts.assertAttributeEventually(entity, SENSOR_STRING, StringPredicates.containsLiteral("Exit status 123"));
-    }
-    
-    @Test(groups="Integration")
-    public void testAddedEarly() throws Exception {
-        final TestEntity entity2 = app.addChild(EntitySpec.create(TestEntity.class)
-            .location(machine)
-            .addInitializer(new EntityInitializer() {
-                @Override
-                public void apply(EntityLocal entity) {
-                    CmdFeed.builder()
-                        .entity(entity)
-                        .onlyIfServiceUp()
-                        .poll(new CommandPollConfig<String>(SENSOR_STRING)
-                            .command("echo hello")
-                            .onSuccess(SshValueFunctions.stdout()))
-                        .build();
-                }
-            }));
-
-        // TODO would be nice to hook in and assert no errors
-        EntityAsserts.assertAttributeEqualsContinually(entity2, SENSOR_STRING, null);
-
-        entity2.sensors().set(Attributes.SERVICE_UP, true);
-        EntityAsserts.assertAttributeEventually(entity2, SENSOR_STRING, StringPredicates.containsLiteral("hello"));
-    }
-
-    
-    @Test(groups="Integration")
-    public void testDynamicEnvAndCommandSupplier() throws Exception {
-        final TestEntity entity2 = app.createAndManageChild(EntitySpec.create(TestEntity.class).location(machine));
-        
-        final AtomicInteger count = new AtomicInteger();
-        Supplier<Map<String, String>> envSupplier = new Supplier<Map<String,String>>() {
-            @Override
-            public Map<String, String> get() {
-                return MutableMap.of("COUNT", ""+count.incrementAndGet());
-            }
-        };
-        Supplier<String> cmdSupplier = new Supplier<String>() {
-            @Override
-            public String get() {
-                return "echo count-"+count.incrementAndGet()+"-%COUNT%";
-            }
-        };
-        
-        feed = CmdFeed.builder()
-                .entity(entity2)
-                .poll(new CommandPollConfig<String>(SENSOR_STRING)
-                        .env(envSupplier)
-                        .command(cmdSupplier)
-                        .onSuccess(SshValueFunctions.stdout()))
-                .build();
-        
-        EntityAsserts.assertAttributeEventuallyNonNull(entity2, SENSOR_STRING);
-        final String val1 = assertDifferentOneInOutput(entity2);
-        
-        EntityAsserts.assertAttributeEventually(entity2, SENSOR_STRING, Predicates.not(Predicates.equalTo(val1)));        
-        final String val2 = assertDifferentOneInOutput(entity2);
-        log.info("vals from dynamic sensors are: "+val1.trim()+" and "+val2.trim());
-    }
-
-    private String assertDifferentOneInOutput(final TestEntity entity2) {
-        String val = entity2.getAttribute(SENSOR_STRING);
-        Assert.assertTrue(val.startsWith("count"), "val="+val);
-        try {
-            String[] fields = val.trim().split("-");
-            int field1 = Integer.parseInt(fields[1]); 
-            int field2 = Integer.parseInt(fields[2]);
-            Assert.assertEquals(Math.abs(field2-field1), 1, "expected difference of 1");
-        } catch (Throwable t) {
-            Exceptions.propagateIfFatal(t);
-            Assert.fail("Wrong output from sensor, got '"+val.trim()+"', giving error: "+t);
-        }
-        return val;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f74ce8fc/software/winrm/src/test/java/org/apache/brooklyn/feed/windows/WinRmFeedLiveTest.java
----------------------------------------------------------------------
diff --git a/software/winrm/src/test/java/org/apache/brooklyn/feed/windows/WinRmFeedLiveTest.java b/software/winrm/src/test/java/org/apache/brooklyn/feed/windows/WinRmFeedLiveTest.java
new file mode 100644
index 0000000..32eeedd
--- /dev/null
+++ b/software/winrm/src/test/java/org/apache/brooklyn/feed/windows/WinRmFeedLiveTest.java
@@ -0,0 +1,263 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.brooklyn.feed.windows;
+
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.brooklyn.api.entity.EntityInitializer;
+import org.apache.brooklyn.api.entity.EntityLocal;
+import org.apache.brooklyn.api.entity.EntitySpec;
+import org.apache.brooklyn.api.location.MachineProvisioningLocation;
+import org.apache.brooklyn.api.sensor.AttributeSensor;
+import org.apache.brooklyn.core.entity.Attributes;
+import org.apache.brooklyn.core.entity.EntityAsserts;
+import org.apache.brooklyn.core.entity.EntityInternal;
+import org.apache.brooklyn.core.entity.EntityInternal.FeedSupport;
+import org.apache.brooklyn.core.sensor.Sensors;
+import org.apache.brooklyn.core.test.BrooklynAppLiveTestSupport;
+import org.apache.brooklyn.core.test.entity.TestEntity;
+import org.apache.brooklyn.feed.CommandPollConfig;
+import org.apache.brooklyn.feed.ssh.SshPollValue;
+import org.apache.brooklyn.feed.ssh.SshValueFunctions;
+import org.apache.brooklyn.location.winrm.WinRmMachineLocation;
+import org.apache.brooklyn.util.collections.MutableMap;
+import org.apache.brooklyn.util.exceptions.Exceptions;
+import org.apache.brooklyn.util.text.StringFunctions;
+import org.apache.brooklyn.util.text.StringPredicates;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.Assert;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Function;
+import com.google.common.base.Predicates;
+import com.google.common.base.Supplier;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * Test is almost identical to {@link org.apache.brooklyn.feed.ssh.SshFeedIntegrationTest}.
+ * To launch the test I put in ~/.brooklyn/brooklyn.properties
+ *   brooklyn.location.named.WindowsLiveTest=byon:(hosts=192.168.1.2,osFamily=windows,user=winUser,password=p0ssw0rd)
+ */
+public class WinRmFeedLiveTest extends BrooklynAppLiveTestSupport {
+
+    private static final Logger log = LoggerFactory.getLogger(WinRmFeedLiveTest.class);
+
+    private static final String LOCATION_SPEC = "named:WindowsLiveTest";
+    
+    final static AttributeSensor<String> SENSOR_STRING = Sensors.newStringSensor("aString", "");
+    final static AttributeSensor<Integer> SENSOR_INT = Sensors.newIntegerSensor("aLong", "");
+
+    private WinRmMachineLocation machine;
+    private TestEntity entity;
+    private CmdFeed feed;
+    
+    @BeforeMethod(alwaysRun=true)
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+
+        MachineProvisioningLocation<?> provisioningLocation = (MachineProvisioningLocation<?>)
+                mgmt.getLocationRegistry().getLocationManaged(LOCATION_SPEC);
+        machine = (WinRmMachineLocation)provisioningLocation.obtain(ImmutableMap.of());
+        entity = app.createAndManageChild(EntitySpec.create(TestEntity.class));
+        app.start(ImmutableList.of(machine));
+    }
+
+    @AfterMethod(alwaysRun=true)
+    @Override
+    public void tearDown() throws Exception {
+        if (feed != null) feed.stop();
+        super.tearDown();
+    }
+    
+    /** this is one of the most common pattern */
+    @Test(groups="Live")
+    public void testReturnsStdoutAndInfersMachine() throws Exception {
+        final TestEntity entity2 = app.createAndManageChild(EntitySpec.create(TestEntity.class)
+            // inject the machine location, because the app was started with a provisioning location
+            // and TestEntity doesn't provision
+            .location(machine));
+        
+        feed = CmdFeed.builder()
+                .entity(entity2)
+                .poll(new CommandPollConfig<String>(SENSOR_STRING)
+                        .command("echo hello")
+                        .onSuccess(SshValueFunctions.stdout()))
+                .build();
+        
+        EntityAsserts.assertAttributeEventuallyNonNull(entity2, SENSOR_STRING);
+        String val = entity2.getAttribute(SENSOR_STRING);
+        Assert.assertTrue(val.contains("hello"), "val="+val);
+        Assert.assertEquals(val.trim(), "hello");
+    }
+
+    @Test(groups="Live")
+    public void testFeedDeDupe() throws Exception {
+        testReturnsStdoutAndInfersMachine();
+        entity.addFeed(feed);
+        log.info("Feed 0 is: "+feed);
+        
+        testReturnsStdoutAndInfersMachine();
+        log.info("Feed 1 is: "+feed);
+        entity.addFeed(feed);
+                
+        FeedSupport feeds = ((EntityInternal)entity).feeds();
+        Assert.assertEquals(feeds.getFeeds().size(), 1, "Wrong feed count: "+feeds.getFeeds());
+    }
+    
+    @Test(groups="Live")
+    public void testReturnsSshExitStatus() throws Exception {
+        feed = CmdFeed.builder()
+                .entity(entity)
+                .machine(machine)
+                .poll(new CommandPollConfig<Integer>(SENSOR_INT)
+                        .command("exit 123")
+                        .checkSuccess(Predicates.alwaysTrue())
+                        .onSuccess(SshValueFunctions.exitStatus()))
+                .build();
+
+        EntityAsserts.assertAttributeEqualsEventually(entity, SENSOR_INT, 123);
+    }
+    
+    @Test(groups="Live")
+    public void testReturnsStdout() throws Exception {
+        feed = CmdFeed.builder()
+                .entity(entity)
+                .machine(machine)
+                .poll(new CommandPollConfig<String>(SENSOR_STRING)
+                        .command("echo hello")
+                        .onSuccess(SshValueFunctions.stdout()))
+                .build();
+        
+        EntityAsserts.assertAttributeEventually(entity, SENSOR_STRING, 
+            Predicates.compose(Predicates.equalTo("hello"), StringFunctions.trim()));
+    }
+
+    @Test(groups="Live")
+    public void testReturnsStderr() throws Exception {
+        final String cmd = "thiscommanddoesnotexist";
+        
+        feed = CmdFeed.builder()
+                .entity(entity)
+                .machine(machine)
+                .poll(new CommandPollConfig<String>(SENSOR_STRING)
+                        .command(cmd)
+                        .onFailure(SshValueFunctions.stderr()))
+                .build();
+        
+        EntityAsserts.assertAttributeEventually(entity, SENSOR_STRING, StringPredicates.containsLiteral(cmd));
+    }
+    
+    @Test(groups="Live")
+    public void testFailsOnNonZero() throws Exception {
+        feed = CmdFeed.builder()
+                .entity(entity)
+                .machine(machine)
+                .poll(new CommandPollConfig<String>(SENSOR_STRING)
+                        .command("exit 123")
+                        .onFailure(new Function<SshPollValue, String>() {
+                            @Override
+                            public String apply(SshPollValue input) {
+                                return "Exit status " + input.getExitStatus();
+                            }}))
+                .build();
+        
+        EntityAsserts.assertAttributeEventually(entity, SENSOR_STRING, StringPredicates.containsLiteral("Exit status 123"));
+    }
+    
+    @Test(groups="Live")
+    public void testAddedEarly() throws Exception {
+        final TestEntity entity2 = app.addChild(EntitySpec.create(TestEntity.class)
+            .location(machine)
+            .addInitializer(new EntityInitializer() {
+                @Override
+                public void apply(EntityLocal entity) {
+                    CmdFeed.builder()
+                        .entity(entity)
+                        .onlyIfServiceUp()
+                        .poll(new CommandPollConfig<String>(SENSOR_STRING)
+                            .command("echo hello")
+                            .onSuccess(SshValueFunctions.stdout()))
+                        .build();
+                }
+            }));
+
+        // TODO would be nice to hook in and assert no errors
+        EntityAsserts.assertAttributeEqualsContinually(entity2, SENSOR_STRING, null);
+
+        entity2.sensors().set(Attributes.SERVICE_UP, true);
+        EntityAsserts.assertAttributeEventually(entity2, SENSOR_STRING, StringPredicates.containsLiteral("hello"));
+    }
+
+    
+    @Test(groups="Live")
+    public void testDynamicEnvAndCommandSupplier() throws Exception {
+        final TestEntity entity2 = app.createAndManageChild(EntitySpec.create(TestEntity.class).location(machine));
+        
+        final AtomicInteger count = new AtomicInteger();
+        Supplier<Map<String, String>> envSupplier = new Supplier<Map<String,String>>() {
+            @Override
+            public Map<String, String> get() {
+                return MutableMap.of("COUNT", ""+count.incrementAndGet());
+            }
+        };
+        Supplier<String> cmdSupplier = new Supplier<String>() {
+            @Override
+            public String get() {
+                return "echo count-"+count.incrementAndGet()+"-%COUNT%";
+            }
+        };
+        
+        feed = CmdFeed.builder()
+                .entity(entity2)
+                .poll(new CommandPollConfig<String>(SENSOR_STRING)
+                        .env(envSupplier)
+                        .command(cmdSupplier)
+                        .onSuccess(SshValueFunctions.stdout()))
+                .build();
+        
+        EntityAsserts.assertAttributeEventuallyNonNull(entity2, SENSOR_STRING);
+        final String val1 = assertDifferentOneInOutput(entity2);
+        
+        EntityAsserts.assertAttributeEventually(entity2, SENSOR_STRING, Predicates.not(Predicates.equalTo(val1)));        
+        final String val2 = assertDifferentOneInOutput(entity2);
+        log.info("vals from dynamic sensors are: "+val1.trim()+" and "+val2.trim());
+    }
+
+    private String assertDifferentOneInOutput(final TestEntity entity2) {
+        String val = entity2.getAttribute(SENSOR_STRING);
+        Assert.assertTrue(val.startsWith("count"), "val="+val);
+        try {
+            String[] fields = val.trim().split("-");
+            int field1 = Integer.parseInt(fields[1]); 
+            int field2 = Integer.parseInt(fields[2]);
+            Assert.assertEquals(Math.abs(field2-field1), 1, "expected difference of 1");
+        } catch (Throwable t) {
+            Exceptions.propagateIfFatal(t);
+            Assert.fail("Wrong output from sensor, got '"+val.trim()+"', giving error: "+t);
+        }
+        return val;
+    }
+
+}


[4/6] brooklyn-server git commit: Fixes integration tests

Posted by sj...@apache.org.
Fixes integration tests

* One is a real problem - http://jsonip.com redirects to https://jsonip.com, which is signed by a certificate issued by "Let's Encrypt", not supported by java
* The other changes the incorrect expectation in the test


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

Branch: refs/heads/master
Commit: 363874e6f8a2d0d25930f4bf00038d8fbad15a94
Parents: 32ccd24
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Authored: Fri Mar 24 12:50:35 2017 +0200
Committer: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Committed: Fri Mar 24 12:56:15 2017 +0200

----------------------------------------------------------------------
 .../brooklyn/location/geo/external-ip-address-resolvers.txt     | 5 +++--
 .../util/json/BrooklynJacksonSerializerIntegrationTest.java     | 4 ++--
 2 files changed, 5 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/363874e6/core/src/main/resources/org/apache/brooklyn/location/geo/external-ip-address-resolvers.txt
----------------------------------------------------------------------
diff --git a/core/src/main/resources/org/apache/brooklyn/location/geo/external-ip-address-resolvers.txt b/core/src/main/resources/org/apache/brooklyn/location/geo/external-ip-address-resolvers.txt
index c51b394..f1cd8ab 100644
--- a/core/src/main/resources/org/apache/brooklyn/location/geo/external-ip-address-resolvers.txt
+++ b/core/src/main/resources/org/apache/brooklyn/location/geo/external-ip-address-resolvers.txt
@@ -15,10 +15,11 @@
 # specific language governing permissions and limitations
 # under the License.
 
-http://jsonip.com/
+# Uses Let's Encrypt certificate, not supported by current JRE (1.8.0_121-b13)
+# https://jsonip.com/
 http://myip.dnsomatic.com/
 http://checkip.dyndns.org/
-# Uses Let's Encrypt certificate supported only in Java 8u101+
+# Uses Let's Encrypt certificate, not supported by current JRE (1.8.0_121-b13)
 # https://wtfismyip.com/text
 http://whatismyip.akamai.com/
 http://myip.wampdeveloper.com/

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/363874e6/rest/rest-server/src/test/java/org/apache/brooklyn/rest/util/json/BrooklynJacksonSerializerIntegrationTest.java
----------------------------------------------------------------------
diff --git a/rest/rest-server/src/test/java/org/apache/brooklyn/rest/util/json/BrooklynJacksonSerializerIntegrationTest.java b/rest/rest-server/src/test/java/org/apache/brooklyn/rest/util/json/BrooklynJacksonSerializerIntegrationTest.java
index edad261..4b016ed 100644
--- a/rest/rest-server/src/test/java/org/apache/brooklyn/rest/util/json/BrooklynJacksonSerializerIntegrationTest.java
+++ b/rest/rest-server/src/test/java/org/apache/brooklyn/rest/util/json/BrooklynJacksonSerializerIntegrationTest.java
@@ -25,8 +25,8 @@ import java.util.Map;
 import javax.ws.rs.core.MediaType;
 
 import org.apache.brooklyn.api.entity.Entity;
+import org.apache.brooklyn.api.mgmt.ManagementContext;
 import org.apache.brooklyn.core.test.BrooklynAppUnitTestSupport;
-import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests;
 import org.apache.brooklyn.core.test.entity.TestApplication;
 import org.apache.brooklyn.core.test.entity.TestEntity;
 import org.apache.brooklyn.rest.BrooklynRestApiLauncher;
@@ -103,7 +103,7 @@ public class BrooklynJacksonSerializerIntegrationTest extends BrooklynAppUnitTes
     public void testWithMgmt() throws Exception {
         setConfig(mgmt);
         Map<?, ?> values = getConfigValueAsJson();
-        Assert.assertEquals(values, ImmutableMap.of("type", LocalManagementContextForTests.class.getCanonicalName()), "values="+values);
+        Assert.assertEquals(values, ImmutableMap.of("type", ManagementContext.class.getCanonicalName()), "values="+values);
 
         // assert normal API returns the same, containing links
         values = getRestValueAsJson(entityUrl);


[6/6] brooklyn-server git commit: This closes #610

Posted by sj...@apache.org.
This closes #610

Various integration test fixes


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

Branch: refs/heads/master
Commit: 05a86be471ea7776b62999b004b61eb69cefd2ca
Parents: 23cb3a0 dc2eb15
Author: Sam Corbett <sa...@cloudsoftcorp.com>
Authored: Fri Mar 24 18:43:23 2017 +0000
Committer: Sam Corbett <sa...@cloudsoftcorp.com>
Committed: Fri Mar 24 18:43:23 2017 +0000

----------------------------------------------------------------------
 .../CompositeEffectorYamlRebindTest.java        |  29 +-
 .../brooklyn/CompositeEffectorYamlTest.java     |  27 +-
 .../HttpCommandEffectorYamlRebindTest.java      |  29 +-
 .../brooklyn/HttpCommandEffectorYamlTest.java   |  29 +-
 .../geo/external-ip-address-resolvers.txt       |   5 +-
 .../http/HttpCommandEffectorHttpBinTest.java    | 192 ++++++++++++++
 .../HttpCommandEffectorIntegrationTest.java     | 125 ---------
 .../brooklyn/policy/ha/ServiceReplacerTest.java |  16 +-
 ...rooklynJacksonSerializerIntegrationTest.java |   4 +-
 .../base/SoftwareProcessEntityTest.java         |  10 +-
 .../lifecycle/ScriptHelperIntegrationTest.java  |  53 +++-
 .../feed/windows/WinRmFeedIntegrationTest.java  | 262 ------------------
 .../feed/windows/WinRmFeedLiveTest.java         | 263 +++++++++++++++++++
 13 files changed, 624 insertions(+), 420 deletions(-)
----------------------------------------------------------------------



[2/6] brooklyn-server git commit: Mark failing integration tests as Broken

Posted by sj...@apache.org.
Mark failing integration tests as Broken


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

Branch: refs/heads/master
Commit: 32ccd248988c1f90cdde26aa23e6d8597c14a33d
Parents: f74ce8f
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Authored: Fri Mar 24 12:49:25 2017 +0200
Committer: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Committed: Fri Mar 24 12:56:14 2017 +0200

----------------------------------------------------------------------
 .../brooklyn/policy/ha/ServiceReplacerTest.java | 16 +++++-
 .../lifecycle/ScriptHelperIntegrationTest.java  | 53 ++++++++++++++------
 2 files changed, 53 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/32ccd248/policy/src/test/java/org/apache/brooklyn/policy/ha/ServiceReplacerTest.java
----------------------------------------------------------------------
diff --git a/policy/src/test/java/org/apache/brooklyn/policy/ha/ServiceReplacerTest.java b/policy/src/test/java/org/apache/brooklyn/policy/ha/ServiceReplacerTest.java
index 4aead1a..9c17614 100644
--- a/policy/src/test/java/org/apache/brooklyn/policy/ha/ServiceReplacerTest.java
+++ b/policy/src/test/java/org/apache/brooklyn/policy/ha/ServiceReplacerTest.java
@@ -177,7 +177,19 @@ public class ServiceReplacerTest {
         assertEventuallyHasEntityReplacementFailedEvent(cluster);
     }
     
-    @Test(groups="Integration") // has a 1 second wait
+
+//    Fails with:
+//    java.lang.AssertionError: Unexpected ON_FIRE state
+//        at org.testng.Assert.fail(Assert.java:94)
+//        at org.testng.Assert.assertNotEquals(Assert.java:832)
+//        at org.apache.brooklyn.policy.ha.ServiceReplacerTest$3.run(ServiceReplacerTest.java:204)
+//        at org.apache.brooklyn.test.Asserts$RunnableAdapter.call(Asserts.java:1359)
+//        at org.apache.brooklyn.test.Asserts.succeedsContinually(Asserts.java:1039)
+//        at org.apache.brooklyn.test.Asserts.succeedsContinually(Asserts.java:1018)
+//        at org.apache.brooklyn.test.Asserts.succeedsContinually(Asserts.java:1014)
+//        at org.apache.brooklyn.policy.ha.ServiceReplacerTest.testDoesNotOnFireWhenFailToReplaceMember(ServiceReplacerTest.java:214)
+//
+    @Test(groups={"Integration", "Broken"}) // has a 1 second wait
     public void testDoesNotOnFireWhenFailToReplaceMember() throws Exception {
         app.subscriptions().subscribe(null, ServiceReplacer.ENTITY_REPLACEMENT_FAILED, eventListener);
         
@@ -201,7 +213,7 @@ public class ServiceReplacerTest {
         // Configured to not mark cluster as on fire
         Asserts.succeedsContinually(new Runnable() {
             @Override public void run() {
-                assertNotEquals(cluster.getAttribute(Attributes.SERVICE_STATE_ACTUAL), Lifecycle.ON_FIRE);
+                assertNotEquals(cluster.getAttribute(Attributes.SERVICE_STATE_ACTUAL), Lifecycle.ON_FIRE, "Unexpected ON_FIRE state");
             }});
         
         // And will have received notification event about it

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/32ccd248/software/base/src/test/java/org/apache/brooklyn/entity/software/base/lifecycle/ScriptHelperIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/lifecycle/ScriptHelperIntegrationTest.java b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/lifecycle/ScriptHelperIntegrationTest.java
index 0566f39..0a1d4b2 100644
--- a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/lifecycle/ScriptHelperIntegrationTest.java
+++ b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/lifecycle/ScriptHelperIntegrationTest.java
@@ -18,11 +18,13 @@
  */
 package org.apache.brooklyn.entity.software.base.lifecycle;
 
-import com.google.common.base.Joiner;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Iterables;
-import org.apache.brooklyn.api.entity.EntityLocal;
+import static java.lang.String.format;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotEquals;
+
+import java.io.StringReader;
+
 import org.apache.brooklyn.api.entity.EntitySpec;
 import org.apache.brooklyn.api.location.Location;
 import org.apache.brooklyn.core.test.BrooklynAppLiveTestSupport;
@@ -42,10 +44,10 @@ import org.slf4j.LoggerFactory;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
-import java.io.StringReader;
-
-import static java.lang.String.format;
-import static org.testng.Assert.*;
+import com.google.common.base.Joiner;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Iterables;
 
 public class ScriptHelperIntegrationTest extends BrooklynAppLiveTestSupport
 {
@@ -54,14 +56,25 @@ public class ScriptHelperIntegrationTest extends BrooklynAppLiveTestSupport
     private Location loc;
 
     @BeforeMethod(alwaysRun=true)
-    @SuppressWarnings("unchecked")
     @Override
     public void setUp() throws Exception {
         super.setUp();
         loc = app.getManagementContext().getLocationRegistry().getLocationManaged("localhost");
     }
 
-    @Test(groups = "Integration")
+//    Fails with:
+//    Message: SIGTERM should be tried one time expected [1] but found [16]
+//
+//        Stacktrace:
+//
+//        at org.testng.Assert.fail(Assert.java:94)
+//        at org.testng.Assert.failNotEquals(Assert.java:513)
+//        at org.testng.Assert.assertEqualsImpl(Assert.java:135)
+//        at org.testng.Assert.assertEquals(Assert.java:116)
+//        at org.testng.Assert.assertEquals(Assert.java:389)
+//        at org.apache.brooklyn.entity.software.base.lifecycle.ScriptHelperIntegrationTest.testStopCommandWaitsToStopWithSigTerm(ScriptHelperIntegrationTest.java:83)
+//        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
+    @Test(groups={"Integration","Broken"})
     public void testStopCommandWaitsToStopWithSigTerm() {
         StopCommandSoftwareProcess entity = app.createAndManageChild(EntitySpec.create(StopCommandSoftwareProcess.class, StopCommandSoftwareProcessImpl.class));
         entity.start(ImmutableList.of(loc));
@@ -88,8 +101,18 @@ public class ScriptHelperIntegrationTest extends BrooklynAppLiveTestSupport
         assertEquals(checkPidFileExitCode, 2, "pid file should be deleted.");
     }
 
-
-    @Test(groups = "Integration")
+//    Fails with:
+//    Exception java.lang.AssertionError
+//
+//    Message: null
+//
+//    Stacktrace:
+//
+//        at org.testng.Assert.fail(Assert.java:94)
+//        at org.testng.Assert.assertNotEquals(Assert.java:832)
+//        at org.testng.Assert.assertNotEquals(Assert.java:837)
+//        at org.apache.brooklyn.entity.software.base.lifecycle.ScriptHelperIntegrationTest.testStopWithSigtermIsKilledWithSigKill(ScriptHelperIntegrationTest.java:126)
+    @Test(groups={"Integration","Broken"})
     public void testStopWithSigtermIsKilledWithSigKill() {
         StopCommandSoftwareProcess entity = app.createAndManageChild(EntitySpec.create(StopCommandSoftwareProcess.class, StopCommandSoftwareProcessImpl.class));
         entity.start(ImmutableList.of(loc));
@@ -138,7 +161,9 @@ public class ScriptHelperIntegrationTest extends BrooklynAppLiveTestSupport
     }
 
     public static class VanillaSoftwareProcessSshDriver extends AbstractSoftwareProcessSshDriver {
-        public VanillaSoftwareProcessSshDriver(EntityLocal entity, SshMachineLocation machine) {
+        public VanillaSoftwareProcessSshDriver(
+                @SuppressWarnings("deprecation") org.apache.brooklyn.api.entity.EntityLocal entity,
+                SshMachineLocation machine) {
             super(entity, machine);
         }