You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2014/09/19 13:31:25 UTC

[09/16] git commit: Address #161 comments. * Use Duration.sinceUtc instead of ad-hoc logic * Check the process has actually exited in tests

Address #161 comments.
  * Use Duration.sinceUtc instead of ad-hoc logic
  * Check the process has actually exited in 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/34a6d50b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/34a6d50b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/34a6d50b

Branch: refs/heads/master
Commit: 34a6d50b54ae2f5bee807dd44391bedfdea3fce9
Parents: e071802
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Authored: Fri Sep 19 12:39:18 2014 +0300
Committer: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Committed: Fri Sep 19 12:41:49 2014 +0300

----------------------------------------------------------------------
 .../brooklyn/util/http/HttpToolResponse.java    |  9 +++++----
 .../BrooklynNodeIntegrationTest.java            | 20 +++++++++++++++++++-
 2 files changed, 24 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/34a6d50b/core/src/main/java/brooklyn/util/http/HttpToolResponse.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/util/http/HttpToolResponse.java b/core/src/main/java/brooklyn/util/http/HttpToolResponse.java
index dec9253..1722e41 100644
--- a/core/src/main/java/brooklyn/util/http/HttpToolResponse.java
+++ b/core/src/main/java/brooklyn/util/http/HttpToolResponse.java
@@ -35,6 +35,7 @@ import org.slf4j.LoggerFactory;
 import brooklyn.event.feed.http.HttpPollValue;
 import brooklyn.util.guava.Maybe;
 import brooklyn.util.stream.Streams;
+import brooklyn.util.time.Duration;
 import brooklyn.util.time.Time;
 
 import com.google.common.base.Objects;
@@ -67,22 +68,22 @@ public class HttpToolResponse implements HttpPollValue {
             HttpEntity entity = response.getEntity();
             if (entity != null) {
                 entity.getContentLength();
-                durationMillisOfFirstResponse = System.currentTimeMillis() - startTime;
+                durationMillisOfFirstResponse = Duration.sinceUtc(startTime).toMilliseconds();
 
                 ByteStreams.copy(entity.getContent(), out);
                 content = out.toByteArray();
 
                 entity.getContentLength();
             } else {
-                durationMillisOfFirstResponse = System.currentTimeMillis() - startTime;
+                durationMillisOfFirstResponse = Duration.sinceUtc(startTime).toMilliseconds();
                 content = new byte[0];
             }
-            durationMillisOfFullContent = System.currentTimeMillis() - startTime;
+            durationMillisOfFullContent = Duration.sinceUtc(startTime).toMilliseconds();
             if (log.isTraceEnabled())
                 log.trace("HttpPollValue latency "+Time.makeTimeStringRounded(durationMillisOfFirstResponse)+" / "+Time.makeTimeStringRounded(durationMillisOfFullContent)+", content size "+content.length);
         } catch (IOException e) {
             throw Throwables.propagate(e);
-        }        
+        }
     }
 
     public HttpToolResponse(int responseCode, Map<String,List<String>> headers, byte[] content,

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/34a6d50b/software/base/src/test/java/brooklyn/entity/brooklynnode/BrooklynNodeIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/brooklyn/entity/brooklynnode/BrooklynNodeIntegrationTest.java b/software/base/src/test/java/brooklyn/entity/brooklynnode/BrooklynNodeIntegrationTest.java
index 8aac45e..341e258 100644
--- a/software/base/src/test/java/brooklyn/entity/brooklynnode/BrooklynNodeIntegrationTest.java
+++ b/software/base/src/test/java/brooklyn/entity/brooklynnode/BrooklynNodeIntegrationTest.java
@@ -19,9 +19,12 @@
 package brooklyn.entity.brooklynnode;
 
 import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
 import static org.testng.Assert.assertTrue;
 
 import java.io.File;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
 import java.net.URI;
 import java.util.Collections;
 import java.util.List;
@@ -44,6 +47,7 @@ import brooklyn.entity.basic.BasicApplicationImpl;
 import brooklyn.entity.basic.Entities;
 import brooklyn.entity.brooklynnode.BrooklynNode.DeployBlueprintEffector;
 import brooklyn.entity.brooklynnode.BrooklynNode.ExistingFileBehaviour;
+import brooklyn.entity.proxying.EntityProxyImpl;
 import brooklyn.entity.proxying.EntitySpec;
 import brooklyn.event.feed.http.JsonFunctions;
 import brooklyn.location.Location;
@@ -55,6 +59,7 @@ import brooklyn.test.HttpTestUtils;
 import brooklyn.test.entity.TestApplication;
 import brooklyn.util.collections.MutableMap;
 import brooklyn.util.config.ConfigBag;
+import brooklyn.util.exceptions.Exceptions;
 import brooklyn.util.exceptions.PropagatedRuntimeException;
 import brooklyn.util.guava.Functionals;
 import brooklyn.util.http.HttpTool;
@@ -425,7 +430,20 @@ public class BrooklynNodeIntegrationTest {
 
         brooklynNode.invoke(eff, Collections.<String, Object>emptyMap()).getUnchecked();
 
-        EntityTestUtils.assertAttributeEqualsEventually(brooklynNode, BrooklynNode.SERVICE_UP, false);
+        EntityTestUtils.assertAttributeEquals(brooklynNode, BrooklynNode.SERVICE_UP, false);
+        //Use the driver's check of isRunning instead of local command since on Windows
+        //the test would be running remotely (needs some extra hoops to do it).
+        assertFalse(getDriver(brooklynNode).isRunning(), "Service process still running");
+    }
+
+    private BrooklynNodeSshDriver getDriver(BrooklynNode brooklynNode) {
+        try {
+            EntityProxyImpl entityProxy = (EntityProxyImpl)Proxy.getInvocationHandler(brooklynNode);
+            Method getDriver = BrooklynNodeImpl.class.getMethod("getDriver");
+            return (BrooklynNodeSshDriver)entityProxy.invoke(brooklynNode, getDriver, new Object[]{});
+        } catch (Throwable e) {
+            throw Exceptions.propagate(e);
+        }
     }
 
     private BrooklynNode setUpBrooklynNodeWithApp() throws InterruptedException,