Search in sources :

Example 11 with NifiFeedProcessorStats

use of com.thinkbiganalytics.metadata.api.jobrepo.nifi.NifiFeedProcessorStats in project kylo by Teradata.

the class FeedFailureMetricAssessorTest method testBatchFailure2.

/**
 * Test batch jobs that come in  as succes, failure
 * This should fail
 */
@Test
public void testBatchFailure2() throws ParseException {
    DateTime lastAssessedTime = DateTime.now();
    String feedName = "feed";
    List<NifiFeedProcessorStats> streamingStats = new ArrayList<>();
    boolean isStream = false;
    this.metric.setFeedName(feedName);
    when(feedProvider.findByName(feedName)).thenReturn(newOpsManagerFeed(feedName, isStream));
    // completed, failed, completed.
    // should fail
    DateTime startingEvent = DateTime.now().minusMinutes(5);
    List<? extends BatchJobExecution> batchJobs = new ArrayList<>();
    batchJobs.add(newBatchJob(feedName, startingEvent, false));
    batchJobs.add(newBatchJob(feedName, startingEvent.plusMinutes(2), true));
    Mockito.when(this.jobExecutionProvider.findLatestFinishedJobForFeedSince(Mockito.anyString(), Mockito.any(DateTime.class))).thenAnswer(x -> batchJobs);
    this.assessor.assess(metric, this.builder);
    verify(this.builder).result(AssessmentResult.FAILURE);
}
Also used : ArrayList(java.util.ArrayList) NifiFeedProcessorStats(com.thinkbiganalytics.metadata.api.jobrepo.nifi.NifiFeedProcessorStats) DateTime(org.joda.time.DateTime) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 12 with NifiFeedProcessorStats

use of com.thinkbiganalytics.metadata.api.jobrepo.nifi.NifiFeedProcessorStats in project kylo by Teradata.

the class FeedFailureMetricAssessorTest method testStreamingFailure2.

/**
 * Test streaming jobs containing success then failure
 */
@Test
public void testStreamingFailure2() throws ParseException {
    DateTime lastAssessedTime = DateTime.now();
    String feedName = "feed";
    List<NifiFeedProcessorStats> streamingStats = new ArrayList<>();
    boolean isStream = true;
    this.metric.setFeedName(feedName);
    when(feedProvider.findByName(feedName)).thenReturn(newOpsManagerFeed(feedName, isStream));
    // completed, failed, completed.
    // should fail
    DateTime startingEvent = DateTime.now().minusMinutes(5);
    streamingStats.add(newStats(feedName, startingEvent, 0L));
    streamingStats.add(newStats(feedName, startingEvent.plusMinutes(2), 5L));
    when(this.nifiFeedProcessorStatisticsProvider.findLatestFinishedStatsSince(Mockito.anyString(), Mockito.any(DateTime.class))).thenReturn(streamingStats);
    this.assessor.assess(metric, this.builder);
    verify(this.builder).result(AssessmentResult.FAILURE);
}
Also used : ArrayList(java.util.ArrayList) NifiFeedProcessorStats(com.thinkbiganalytics.metadata.api.jobrepo.nifi.NifiFeedProcessorStats) DateTime(org.joda.time.DateTime) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 13 with NifiFeedProcessorStats

use of com.thinkbiganalytics.metadata.api.jobrepo.nifi.NifiFeedProcessorStats in project kylo by Teradata.

the class FeedFailureMetricAssessorTest method testExistingBatchFailure.

/**
 * Tests when no new jobs have been run since the last time, but the last job execution was failed
 */
@Test
public void testExistingBatchFailure() throws ParseException {
    DateTime lastAssessedTime = DateTime.now();
    String feedName = "feed";
    List<NifiFeedProcessorStats> streamingStats = new ArrayList<>();
    boolean isStream = false;
    this.metric.setFeedName(feedName);
    when(feedProvider.findByName(feedName)).thenReturn(newOpsManagerFeed(feedName, isStream));
    DateTime startingEvent = DateTime.now().minusMinutes(5);
    List<? extends BatchJobExecution> batchJobs = new ArrayList<>();
    BatchJobExecution jobExecution = newBatchJob(feedName, startingEvent, true);
    Mockito.when(this.jobExecutionProvider.findLatestFinishedJobForFeedSince(Mockito.anyString(), Mockito.any(DateTime.class))).thenAnswer(x -> batchJobs);
    Mockito.when(this.jobExecutionProvider.findLatestFinishedJobForFeed(Mockito.anyString())).thenAnswer(x -> jobExecution);
    this.assessor.assess(metric, this.builder);
    verify(this.builder).result(AssessmentResult.FAILURE);
}
Also used : BatchJobExecution(com.thinkbiganalytics.metadata.api.jobrepo.job.BatchJobExecution) ArrayList(java.util.ArrayList) NifiFeedProcessorStats(com.thinkbiganalytics.metadata.api.jobrepo.nifi.NifiFeedProcessorStats) DateTime(org.joda.time.DateTime) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 14 with NifiFeedProcessorStats

use of com.thinkbiganalytics.metadata.api.jobrepo.nifi.NifiFeedProcessorStats in project kylo by Teradata.

the class FeedFailureMetricAssessorTest method testStreamingFailure.

/**
 * Test streaming feed where jobs come in as success, failure, success.
 * This should fail
 */
@Test
public void testStreamingFailure() throws ParseException {
    DateTime lastAssessedTime = DateTime.now();
    String feedName = "feed";
    List<NifiFeedProcessorStats> streamingStats = new ArrayList<>();
    boolean isStream = true;
    this.metric.setFeedName(feedName);
    when(feedProvider.findByName(feedName)).thenReturn(newOpsManagerFeed(feedName, isStream));
    // completed, failed, completed.
    // should fail
    DateTime startingEvent = DateTime.now().minusMinutes(5);
    streamingStats.add(newStats(feedName, startingEvent, 0L));
    streamingStats.add(newStats(feedName, startingEvent.plusMinutes(2), 2L));
    streamingStats.add(newStats(feedName, startingEvent.plusMinutes(4), 0L));
    when(this.nifiFeedProcessorStatisticsProvider.findLatestFinishedStatsSince(Mockito.anyString(), Mockito.any(DateTime.class))).thenReturn(streamingStats);
    this.assessor.assess(metric, this.builder);
    verify(this.builder).result(AssessmentResult.FAILURE);
}
Also used : ArrayList(java.util.ArrayList) NifiFeedProcessorStats(com.thinkbiganalytics.metadata.api.jobrepo.nifi.NifiFeedProcessorStats) DateTime(org.joda.time.DateTime) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 15 with NifiFeedProcessorStats

use of com.thinkbiganalytics.metadata.api.jobrepo.nifi.NifiFeedProcessorStats in project kylo by Teradata.

the class FeedFailureMetricAssessorTest method testBatchFailure.

/**
 * Test Batch Jobs that come in as success, failed, success.
 * This should fail
 */
@Test
public void testBatchFailure() throws ParseException {
    DateTime lastAssessedTime = DateTime.now();
    String feedName = "feed";
    List<NifiFeedProcessorStats> streamingStats = new ArrayList<>();
    boolean isStream = false;
    this.metric.setFeedName(feedName);
    when(feedProvider.findByName(feedName)).thenReturn(newOpsManagerFeed(feedName, isStream));
    // completed, failed, completed.
    // should fail
    DateTime startingEvent = DateTime.now().minusMinutes(5);
    List<? extends BatchJobExecution> batchJobs = new ArrayList<>();
    batchJobs.add(newBatchJob(feedName, startingEvent, false));
    batchJobs.add(newBatchJob(feedName, startingEvent.plusMinutes(2), true));
    batchJobs.add(newBatchJob(feedName, startingEvent.plusMinutes(4), false));
    Mockito.when(this.jobExecutionProvider.findLatestFinishedJobForFeedSince(Mockito.anyString(), Mockito.any(DateTime.class))).thenAnswer(x -> batchJobs);
    this.assessor.assess(metric, this.builder);
    verify(this.builder).result(AssessmentResult.FAILURE);
}
Also used : ArrayList(java.util.ArrayList) NifiFeedProcessorStats(com.thinkbiganalytics.metadata.api.jobrepo.nifi.NifiFeedProcessorStats) DateTime(org.joda.time.DateTime) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

NifiFeedProcessorStats (com.thinkbiganalytics.metadata.api.jobrepo.nifi.NifiFeedProcessorStats)17 DateTime (org.joda.time.DateTime)14 ArrayList (java.util.ArrayList)12 Test (org.junit.Test)9 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)9 JpaNifiFeedProcessorStats (com.thinkbiganalytics.metadata.jpa.jobrepo.nifi.JpaNifiFeedProcessorStats)4 AggregatedFeedProcessorStatisticsHolderV2 (com.thinkbiganalytics.nifi.provenance.model.stats.AggregatedFeedProcessorStatisticsHolderV2)3 MetadataAccess (com.thinkbiganalytics.metadata.api.MetadataAccess)2 OpsManagerFeed (com.thinkbiganalytics.metadata.api.feed.OpsManagerFeed)2 BatchJobExecution (com.thinkbiganalytics.metadata.api.jobrepo.job.BatchJobExecution)2 NifiFeedProcessorErrors (com.thinkbiganalytics.metadata.api.jobrepo.nifi.NifiFeedProcessorErrors)2 NifiFeedProcessorStatisticsProvider (com.thinkbiganalytics.metadata.api.jobrepo.nifi.NifiFeedProcessorStatisticsProvider)2 NifiFeedStatisticsProvider (com.thinkbiganalytics.metadata.api.jobrepo.nifi.NifiFeedStatisticsProvider)2 NifiFeedStats (com.thinkbiganalytics.metadata.api.jobrepo.nifi.NifiFeedStats)2 NiFiFeedProcessorStatsContainer (com.thinkbiganalytics.metadata.rest.jobrepo.nifi.NiFiFeedProcessorStatsContainer)2 AggregatedFeedProcessorStatistics (com.thinkbiganalytics.nifi.provenance.model.stats.AggregatedFeedProcessorStatistics)2 GroupedStatsV2 (com.thinkbiganalytics.nifi.provenance.model.stats.GroupedStatsV2)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2