You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by da...@apache.org on 2024/04/02 09:50:18 UTC
(cloudstack) branch 4.19 updated: AllLinesParser: Enable draining of stdout (#8670)
This is an automated email from the ASF dual-hosted git repository.
dahn pushed a commit to branch 4.19
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.19 by this push:
new f7603dcbcc8 AllLinesParser: Enable draining of stdout (#8670)
f7603dcbcc8 is described below
commit f7603dcbcc8866496b7b3e593d81f17492a2a845
Author: Rene Peinthor <re...@linbit.com>
AuthorDate: Tue Apr 2 11:50:11 2024 +0200
AllLinesParser: Enable draining of stdout (#8670)
---
.../java/com/cloud/utils/script/OutputInterpreter.java | 5 +++++
utils/src/test/java/com/cloud/utils/ScriptTest.java | 14 ++++++++++++++
2 files changed, 19 insertions(+)
diff --git a/utils/src/main/java/com/cloud/utils/script/OutputInterpreter.java b/utils/src/main/java/com/cloud/utils/script/OutputInterpreter.java
index 03a9f548236..d54d411e69e 100644
--- a/utils/src/main/java/com/cloud/utils/script/OutputInterpreter.java
+++ b/utils/src/main/java/com/cloud/utils/script/OutputInterpreter.java
@@ -137,6 +137,11 @@ public abstract class OutputInterpreter {
public String getLines() {
return allLines;
}
+
+ @Override
+ public boolean drain() {
+ return true;
+ }
}
public static class LineByLineOutputLogger extends OutputInterpreter {
diff --git a/utils/src/test/java/com/cloud/utils/ScriptTest.java b/utils/src/test/java/com/cloud/utils/ScriptTest.java
index 12963dc2637..e624ffc5e7f 100644
--- a/utils/src/test/java/com/cloud/utils/ScriptTest.java
+++ b/utils/src/test/java/com/cloud/utils/ScriptTest.java
@@ -111,6 +111,20 @@ public class ScriptTest {
Assert.assertNotNull(value);
}
+ @Test
+ public void executeWithOutputInterpreterAllLinesParserLargeOutput() {
+ Assume.assumeTrue(SystemUtils.IS_OS_LINUX);
+ OutputInterpreter.AllLinesParser parser = new OutputInterpreter.AllLinesParser();
+ Script script = new Script("seq");
+ script.add("-f");
+ script.add("my text to test cloudstack %g");
+ script.add("4096"); // AllLinesParser doesn't work with that amount of data
+ String value = script.execute(parser);
+ // it is a stack trace in this case as string
+ Assert.assertNull(value);
+ Assert.assertEquals(129965, parser.getLines().length());
+ }
+
@Test
public void runSimpleBashScriptNotExisting() {
Assume.assumeTrue(SystemUtils.IS_OS_LINUX);