Search in sources :

Example 16 with LogMessage

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.
}
Also used : LogMessage(org.apache.nifi.util.LogMessage) TestRunner(org.apache.nifi.util.TestRunner) Test(org.junit.Test)

Example 17 with LogMessage

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"));
}
Also used : TdchUtils(com.thinkbiganalytics.kylo.nifi.teradata.tdch.core.processor.export.utils.TdchUtils) LogMessage(org.apache.nifi.util.LogMessage) TestRunner(org.apache.nifi.util.TestRunner) MockComponentLog(org.apache.nifi.util.MockComponentLog) Test(org.junit.Test)

Example 18 with LogMessage

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"));
}
Also used : TdchUtils(com.thinkbiganalytics.kylo.nifi.teradata.tdch.core.processor.export.utils.TdchUtils) LogMessage(org.apache.nifi.util.LogMessage) TestRunner(org.apache.nifi.util.TestRunner) MockComponentLog(org.apache.nifi.util.MockComponentLog) Test(org.junit.Test)

Example 19 with LogMessage

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"));
}
Also used : TdchUtils(com.thinkbiganalytics.kylo.nifi.teradata.tdch.core.processor.export.utils.TdchUtils) LogMessage(org.apache.nifi.util.LogMessage) TestRunner(org.apache.nifi.util.TestRunner) MockComponentLog(org.apache.nifi.util.MockComponentLog) Test(org.junit.Test)

Example 20 with LogMessage

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"));
}
Also used : LogMessage(org.apache.nifi.util.LogMessage) TestRunner(org.apache.nifi.util.TestRunner) MockComponentLog(org.apache.nifi.util.MockComponentLog) TdchBuilder(com.thinkbiganalytics.kylo.nifi.teradata.tdch.core.processor.export.utils.TdchBuilder) Test(org.junit.Test)

Aggregations

LogMessage (org.apache.nifi.util.LogMessage)30 Test (org.junit.Test)30 TestRunner (org.apache.nifi.util.TestRunner)29 MockComponentLog (org.apache.nifi.util.MockComponentLog)25 TdchUtils (com.thinkbiganalytics.kylo.nifi.teradata.tdch.core.processor.export.utils.TdchUtils)24 ProcessContext (org.apache.nifi.processor.ProcessContext)3 MockFlowFile (org.apache.nifi.util.MockFlowFile)3 TdchBuilder (com.thinkbiganalytics.kylo.nifi.teradata.tdch.core.processor.export.utils.TdchBuilder)1