You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by dc...@apache.org on 2020/08/06 16:25:38 UTC
[cassandra] branch trunk updated: ToolRunner added in
CASSANDRA-15942 stdErr checks improvements
This is an automated email from the ASF dual-hosted git repository.
dcapwell pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra.git
The following commit(s) were added to refs/heads/trunk by this push:
new 9a23a8a ToolRunner added in CASSANDRA-15942 stdErr checks improvements
9a23a8a is described below
commit 9a23a8a6af5ab1ee8c947f363b0e32f71369746f
Author: Berenguer Blasi <be...@gmail.com>
AuthorDate: Thu Aug 6 09:00:17 2020 -0700
ToolRunner added in CASSANDRA-15942 stdErr checks improvements
patch by Berenguer Blasi; reviewed by David Capwell for CASSANDRA-16003
---
.../org/apache/cassandra/tools/ToolRunner.java | 41 ++++++++++++++++++++--
1 file changed, 38 insertions(+), 3 deletions(-)
diff --git a/test/unit/org/apache/cassandra/tools/ToolRunner.java b/test/unit/org/apache/cassandra/tools/ToolRunner.java
index 61e32b0..ab6dc0d 100644
--- a/test/unit/org/apache/cassandra/tools/ToolRunner.java
+++ b/test/unit/org/apache/cassandra/tools/ToolRunner.java
@@ -34,6 +34,7 @@ import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
import org.apache.commons.io.IOUtils;
@@ -49,6 +50,8 @@ import static org.junit.Assert.fail;
public class ToolRunner implements AutoCloseable
{
protected static final Logger logger = LoggerFactory.getLogger(ToolRunner.class);
+
+ private static final ImmutableList<String> DEFAULT_CLEANERS = ImmutableList.of("(?im)^picked up.*\\R");
private final List<String> allArgs = new ArrayList<>();
private Process process;
@@ -330,12 +333,18 @@ public class ToolRunner implements AutoCloseable
public ToolRunner waitAndAssertOnCleanExit()
{
- return waitAndAssertOnExitCode().assertEmptyStdErr();
+ return waitAndAssertOnExitCode().assertCleanStdErr();
}
- public ToolRunner assertEmptyStdErr()
+ /**
+ * Checks if the stdErr is empty after removing any potential JVM env info output and other noise
+ *
+ * Some JVM configs may output env info on stdErr. We need to remove those to see what was the tool's actual stdErr
+ * @return The ToolRunner instance
+ */
+ public ToolRunner assertCleanStdErr()
{
- assertTrue(getStderr().isEmpty());
+ assertTrue("Failed because cleaned stdErr wasn't empty: " + getCleanedStderr(), getCleanedStderr().isEmpty());
return this;
}
@@ -371,6 +380,32 @@ public class ToolRunner implements AutoCloseable
return errBuffer.toString();
}
+ /**
+ * Checks if the stdErr is empty after removing any potential JVM env info output and other noise
+ *
+ * Some JVM configs may output env info on stdErr. We need to remove those to see what was the tool's actual stdErr
+ *
+ * @param regExpCleaners List of regExps to remove from stdErr
+ * @return The stdErr with all excludes removed
+ */
+ public String getCleanedStderr(List<String> regExpCleaners)
+ {
+ String sanitizedStderr = getStderr();
+ for (String regExp: regExpCleaners)
+ sanitizedStderr = sanitizedStderr.replaceAll(regExp, "");
+ return sanitizedStderr;
+ }
+
+ /**
+ * Checks if the stdErr is empty after removing any potential JVM env info output. Uses default list of excludes
+ *
+ * {@link #getCleanedStderr(List)}
+ */
+ public String getCleanedStderr()
+ {
+ return getCleanedStderr(DEFAULT_CLEANERS);
+ }
+
public void forceKill()
{
try
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org