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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations