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/07/29 21:32:24 UTC

[29/31] git commit: fix QA-monitoring test failure on osx

fix QA-monitoring test failure on osx


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

Branch: refs/heads/master
Commit: 28c0cac35c79b0e57919ed7189a3560cb9c3c69e
Parents: 339736d
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Tue Jul 29 15:27:04 2014 -0400
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Tue Jul 29 15:27:04 2014 -0400

----------------------------------------------------------------------
 .../java/brooklyn/qa/longevity/MonitorUtils.java     | 15 ++++++++++++++-
 .../java/brooklyn/qa/longevity/MonitorUtilsTest.java |  8 +++++++-
 2 files changed, 21 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/28c0cac3/usage/qa/src/main/java/brooklyn/qa/longevity/MonitorUtils.java
----------------------------------------------------------------------
diff --git a/usage/qa/src/main/java/brooklyn/qa/longevity/MonitorUtils.java b/usage/qa/src/main/java/brooklyn/qa/longevity/MonitorUtils.java
index 65f0d00..290a555 100644
--- a/usage/qa/src/main/java/brooklyn/qa/longevity/MonitorUtils.java
+++ b/usage/qa/src/main/java/brooklyn/qa/longevity/MonitorUtils.java
@@ -271,6 +271,19 @@ public class MonitorUtils {
         }
     }
 
+    public static class ProcessHasStderr extends IllegalStateException {
+        private static final long serialVersionUID = -937871002993888405L;
+        
+        byte[] stderrBytes;
+        public ProcessHasStderr(byte[] stderrBytes) {
+            this("Process printed to stderr: " + new String(stderrBytes), stderrBytes);
+        }
+        public ProcessHasStderr(String message, byte[] stderrBytes) {
+            super(message);
+            this.stderrBytes = stderrBytes;
+        }
+    }
+    
     /**
      * Waits for the given process to complete, consuming its stdout and returning it as a string.
      * If there is any output on stderr an exception will be thrown.
@@ -292,7 +305,7 @@ public class MonitorUtils {
             gobblerErr.blockUntilFinished();
 
             if (bytesErr.size() > 0) {
-                throw new IllegalStateException("Process printed to stderr: " + new String(bytesErr.toByteArray()));
+                throw new ProcessHasStderr(bytesErr.toByteArray());
             }
 
             return new String(bytesOut.toByteArray());

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/28c0cac3/usage/qa/src/test/java/brooklyn/qa/longevity/MonitorUtilsTest.java
----------------------------------------------------------------------
diff --git a/usage/qa/src/test/java/brooklyn/qa/longevity/MonitorUtilsTest.java b/usage/qa/src/test/java/brooklyn/qa/longevity/MonitorUtilsTest.java
index b43df13..2f1e854 100644
--- a/usage/qa/src/test/java/brooklyn/qa/longevity/MonitorUtilsTest.java
+++ b/usage/qa/src/test/java/brooklyn/qa/longevity/MonitorUtilsTest.java
@@ -32,6 +32,7 @@ import java.util.List;
 
 import org.testng.annotations.Test;
 
+import brooklyn.qa.longevity.MonitorUtils.ProcessHasStderr;
 import brooklyn.util.os.Os;
 import brooklyn.util.text.Strings;
 
@@ -99,7 +100,12 @@ public class MonitorUtilsTest {
 
         assertTrue(MonitorUtils.isPidRunning(usedPid));
         assertFalse(MonitorUtils.isPidRunning(unusedPid));
-        assertFalse(MonitorUtils.isPidRunning(1234567)); // too large
+        
+        try {
+            assertFalse(MonitorUtils.isPidRunning(1234567)); // too large
+        } catch (ProcessHasStderr e) {
+            // expected on osx
+        }
     }
 
     @Test(groups="UNIX")