You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by pv...@apache.org on 2016/10/28 08:35:46 UTC
nifi git commit: NIFI-2936: Fix TestExecuteProcess error on Travis.
Repository: nifi
Updated Branches:
refs/heads/master 8dc60c72d -> 9e90aae06
NIFI-2936: Fix TestExecuteProcess error on Travis.
This closes #1162.
Project: http://git-wip-us.apache.org/repos/asf/nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/9e90aae0
Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/9e90aae0
Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/9e90aae0
Branch: refs/heads/master
Commit: 9e90aae066b3dd79261cd0d8999d34090d7be042
Parents: 8dc60c7
Author: Koji Kawamura <ij...@apache.org>
Authored: Thu Oct 27 13:47:18 2016 +0900
Committer: Pierre Villard <pi...@gmail.com>
Committed: Fri Oct 28 10:35:37 2016 +0200
----------------------------------------------------------------------
.../processors/standard/TestExecuteProcess.java | 32 +++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/nifi/blob/9e90aae0/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestExecuteProcess.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestExecuteProcess.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestExecuteProcess.java
index 8af82f1..59bc575 100644
--- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestExecuteProcess.java
+++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestExecuteProcess.java
@@ -221,9 +221,24 @@ public class TestExecuteProcess {
processor.onTrigger(processContext, runner.getProcessSessionFactory());
+ if (isCommandFailed(runner)) return;
+
+ // ExecuteProcess doesn't wait for finishing to drain error stream if it's configure NOT to redirect stream.
+ // This causes test failure when draining the error stream didn't finish
+ // fast enough before the thread of this test case method checks the warn msg count.
+ // So, this loop wait for a while until the log msg count becomes expected number, otherwise let it fail.
+ final int expectedWarningMessages = 1;
+ final int maxRetry = 5;
+ for (int i = 0; i < maxRetry
+ && (runner.getLogger().getWarnMessages().size() < expectedWarningMessages); i++) {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ }
+ }
final List<LogMessage> warnMessages = runner.getLogger().getWarnMessages();
assertEquals("If redirect error stream is false, " +
- "the output should be logged as a warning so that user can notice on bulletin.", 1, warnMessages.size());
+ "the output should be logged as a warning so that user can notice on bulletin.", expectedWarningMessages, warnMessages.size());
final List<MockFlowFile> succeeded = runner.getFlowFilesForRelationship(ExecuteProcess.REL_SUCCESS);
assertEquals(0, succeeded.size());
}
@@ -244,6 +259,8 @@ public class TestExecuteProcess {
processor.onTrigger(processContext, runner.getProcessSessionFactory());
+ if (isCommandFailed(runner)) return;
+
final List<LogMessage> warnMessages = runner.getLogger().getWarnMessages();
assertEquals("If redirect error stream is true " +
"the output should be sent as a content of flow-file.", 0, warnMessages.size());
@@ -251,4 +268,17 @@ public class TestExecuteProcess {
assertEquals(1, succeeded.size());
}
+ /**
+ * On some environment, the test command immediately fail with an IOException
+ * because of the native UnixProcess.init method implementation difference.
+ *
+ * @return true, if the command fails
+ */
+ private boolean isCommandFailed(final TestRunner runner) {
+ final List<LogMessage> errorMessages = runner.getLogger().getErrorMessages();
+ return (errorMessages.size() > 0
+ && errorMessages.stream()
+ .anyMatch(m -> m.getMsg().contains("Failed to create process due to")));
+ }
+
}