use of org.apache.nifi.util.LogMessage in project nifi by apache.
the class TestExecuteProcess method testRedirectErrorStreamWithExpressions.
@Test
public void testRedirectErrorStreamWithExpressions() {
final TestRunner runner = TestRunners.newTestRunner(ExecuteProcess.class);
runner.setProperty(ExecuteProcess.COMMAND, "ls");
runner.setProperty(ExecuteProcess.COMMAND_ARGUMENTS, "${literal('does-not-exist'):toUpper()}");
runner.setProperty(ExecuteProcess.REDIRECT_ERROR_STREAM, "true");
ProcessContext processContext = runner.getProcessContext();
ExecuteProcess processor = (ExecuteProcess) runner.getProcessor();
processor.updateScheduledTrue();
processor.setupExecutor(processContext);
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());
final List<MockFlowFile> succeeded = runner.getFlowFilesForRelationship(ExecuteProcess.REL_SUCCESS);
assertEquals(1, succeeded.size());
assertTrue(new String(succeeded.get(0).toByteArray()).contains("DOES-NOT-EXIST"));
assertEquals(succeeded.get(0).getAttribute(ExecuteProcess.ATTRIBUTE_COMMAND), "ls");
assertEquals(succeeded.get(0).getAttribute(ExecuteProcess.ATTRIBUTE_COMMAND_ARGS), "DOES-NOT-EXIST");
}
use of org.apache.nifi.util.LogMessage in project kylo by Teradata.
the class TdchUtilsTest method testGetExportHiveToTeradataJobTimeTaken_InvalidTimeTakenShort.
@Test
public void testGetExportHiveToTeradataJobTimeTaken_InvalidTimeTakenShort() {
TestRunner runner = TestRunners.newTestRunner(TestAbstractTdchProcessor.class);
MockComponentLog componentLog = runner.getLogger();
TdchUtils tdchUtils = new TdchUtils();
String timeTaken = tdchUtils.getExportHiveToTeradataJobTimeTaken(getTdchProcessResultWithShortInvalidTimeTaken(), componentLog);
Assert.assertEquals("Unable to determine time taken", timeTaken);
List<LogMessage> warnMessages = componentLog.getWarnMessages();
Assert.assertEquals(1, warnMessages.size());
Assert.assertTrue(warnMessages.get(0).getMsg().endsWith("Skipping attempt to retrieve time taken by TDCH job"));
}
use of org.apache.nifi.util.LogMessage in project kylo by Teradata.
the class TdchUtilsTest method testGetExportHiveToTeradataInputRecordsCount_ValidCountAndSuccessExitCode.
@Test
public void testGetExportHiveToTeradataInputRecordsCount_ValidCountAndSuccessExitCode() {
TestRunner runner = TestRunners.newTestRunner(TestAbstractTdchProcessor.class);
MockComponentLog componentLog = runner.getLogger();
TdchUtils tdchUtils = new TdchUtils();
long count = tdchUtils.getExportHiveToTeradataInputRecordsCount(getTdchProcessResultWithInputRecordCountAndSuccessExitCodeInfo(), componentLog);
Assert.assertEquals(6, count);
List<LogMessage> warnMessages = componentLog.getWarnMessages();
Assert.assertEquals(0, warnMessages.size());
}
use of org.apache.nifi.util.LogMessage in project kylo by Teradata.
the class TdchUtilsTest method testGetExportHiveToTeradataInputRecordsCount_ValidCountAndFailureExitCode.
@Test
public void testGetExportHiveToTeradataInputRecordsCount_ValidCountAndFailureExitCode() {
TestRunner runner = TestRunners.newTestRunner(TestAbstractTdchProcessor.class);
MockComponentLog componentLog = runner.getLogger();
TdchUtils tdchUtils = new TdchUtils();
long count = tdchUtils.getExportHiveToTeradataInputRecordsCount(getTdchProcessResultWithInputRecordCountAndFailureExitCodeInfo(), componentLog);
Assert.assertEquals(-1, count);
List<LogMessage> warnMessages = componentLog.getWarnMessages();
Assert.assertEquals(1, warnMessages.size());
Assert.assertTrue(warnMessages.get(0).getMsg().endsWith("Skipping attempt to retrieve number of input records"));
}
use of org.apache.nifi.util.LogMessage in project kylo by Teradata.
the class TdchUtilsTest method testGetExportHiveToTeradataOutputRecordsCount_InvalidRecordCountShort.
@Test
public void testGetExportHiveToTeradataOutputRecordsCount_InvalidRecordCountShort() {
TestRunner runner = TestRunners.newTestRunner(TestAbstractTdchProcessor.class);
MockComponentLog componentLog = runner.getLogger();
TdchUtils tdchUtils = new TdchUtils();
long count = tdchUtils.getExportHiveToTeradataOutputRecordsCount(getTdchProcessResultWithInvalidOutputRecordCountShortLineInfo(), componentLog);
Assert.assertEquals(-1, count);
List<LogMessage> warnMessages = componentLog.getWarnMessages();
Assert.assertEquals(1, warnMessages.size());
Assert.assertTrue(warnMessages.get(0).getMsg().contains("Skipping attempt to retrieve number of output records"));
}
Aggregations