use of org.apache.nifi.util.LogMessage in project nifi by apache.
the class ListGCSBucketTest method testFailedPersistState.
@Test
public void testFailedPersistState() throws Exception {
reset(storage);
final ListGCSBucket processor = getProcessor();
final TestRunner runner = buildNewRunner(processor);
addRequiredPropertiesToRunner(runner);
runner.assertValid();
runner.getStateManager().setFailOnStateSet(Scope.CLUSTER, true);
processor.currentKeys = ImmutableSet.of("test-key-0", "test-key-1");
processor.currentTimestamp = 4L;
assertTrue(runner.getLogger().getErrorMessages().isEmpty());
processor.persistState(runner.getProcessContext());
// The method should have caught the error and reported it to the logger.
final List<LogMessage> logMessages = runner.getLogger().getErrorMessages();
assertFalse(logMessages.isEmpty());
assertEquals(1, logMessages.size());
// We could do more specific things like check the contents of the LogMessage,
// but that seems too nitpicky.
}
use of org.apache.nifi.util.LogMessage in project kylo by Teradata.
the class TdchUtilsTest method testGetExportHiveToTeradataOutputRecordsCount_ValidCountAndFailureExitCode.
@Test
public void testGetExportHiveToTeradataOutputRecordsCount_ValidCountAndFailureExitCode() {
TestRunner runner = TestRunners.newTestRunner(TestAbstractTdchProcessor.class);
MockComponentLog componentLog = runner.getLogger();
TdchUtils tdchUtils = new TdchUtils();
long count = tdchUtils.getExportHiveToTeradataOutputRecordsCount(getTdchProcessResultWithOutputRecordCountAndFailureExitCodeInfo(), 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 output records"));
}
use of org.apache.nifi.util.LogMessage in project kylo by Teradata.
the class TdchUtilsTest method testGetExportHiveToTeradataOutputRecordsCount_InvalidRecordCountLong.
@Test
public void testGetExportHiveToTeradataOutputRecordsCount_InvalidRecordCountLong() {
TestRunner runner = TestRunners.newTestRunner(TestAbstractTdchProcessor.class);
MockComponentLog componentLog = runner.getLogger();
TdchUtils tdchUtils = new TdchUtils();
long count = tdchUtils.getExportHiveToTeradataOutputRecordsCount(getTdchProcessResultWithInvalidOutputRecordCountLongLineInfo(), componentLog);
Assert.assertEquals(-1, count);
List<LogMessage> warnMessages = componentLog.getWarnMessages();
Assert.assertEquals(1, warnMessages.size());
Assert.assertTrue(warnMessages.get(0).getMsg().contains("Unable to parse number of output records processed"));
}
use of org.apache.nifi.util.LogMessage in project kylo by Teradata.
the class TdchUtilsTest method testGetExportHiveToTeradataInputRecordsCount_InvalidRecordCountShort.
@Test
public void testGetExportHiveToTeradataInputRecordsCount_InvalidRecordCountShort() {
TestRunner runner = TestRunners.newTestRunner(TestAbstractTdchProcessor.class);
MockComponentLog componentLog = runner.getLogger();
TdchUtils tdchUtils = new TdchUtils();
long count = tdchUtils.getExportHiveToTeradataInputRecordsCount(getTdchProcessResultWithInvalidInputRecordCountShortLineInfo(), 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 input records"));
}
use of org.apache.nifi.util.LogMessage in project kylo by Teradata.
the class TdchBuilderTest method testSetting_Tdch_Import_OperationType.
@Test
public void testSetting_Tdch_Import_OperationType() {
TdchBuilder tdchBuilder = new TdchBuilder();
TestRunner runner = TestRunners.newTestRunner(TestAbstractTdchProcessor.class);
MockComponentLog componentLog = runner.getLogger();
tdchBuilder.setLogger(componentLog).setTdchJarEnvironmentVariable("USERLIBTDCH").setTdchLibraryJarsVariable("LIBJARS").setTdchHadoopClassPathVariable("HADOOP_CLASSPATH").setTdchOperationType(TdchOperationType.TDCH_IMPORT).setCommonExportToolJobType("hive");
String command = tdchBuilder.build();
Assert.assertEquals("", command);
List<LogMessage> warnMessages = componentLog.getWarnMessages();
Assert.assertEquals(1, warnMessages.size());
Assert.assertTrue(warnMessages.get(0).getMsg().endsWith("TDCH Import not yet implemented"));
}
Aggregations