use of org.opensearch.ad.model.DetectionDateRange in project anomaly-detection by opensearch-project.
the class ADTaskManagerTests method testStartHistoricalAnalysisWithNoOwningNode.
@SuppressWarnings("unchecked")
public void testStartHistoricalAnalysisWithNoOwningNode() throws IOException {
AnomalyDetector detector = TestHelpers.randomAnomalyDetector(ImmutableList.of());
DetectionDateRange detectionDateRange = TestHelpers.randomDetectionDateRange();
User user = null;
int availableTaskSlots = randomIntBetween(1, 10);
ActionListener<AnomalyDetectorJobResponse> listener = mock(ActionListener.class);
doAnswer(invocation -> {
Consumer<Optional<DiscoveryNode>> function = invocation.getArgument(1);
function.accept(Optional.empty());
return null;
}).when(hashRing).buildAndGetOwningNodeWithSameLocalAdVersion(anyString(), any(), any());
adTaskManager.startHistoricalAnalysis(detector, detectionDateRange, user, availableTaskSlots, transportService, listener);
verify(listener, times(1)).onFailure(any());
}
use of org.opensearch.ad.model.DetectionDateRange in project anomaly-detection by opensearch-project.
the class ADBatchAnomalyResultTransportActionTests method testHistoricalAnalysisWithValidDateRange.
public void testHistoricalAnalysisWithValidDateRange() throws IOException, InterruptedException {
DetectionDateRange dateRange = new DetectionDateRange(startTime, endTime);
ADBatchAnomalyResultRequest request = adBatchAnomalyResultRequest(dateRange);
client().execute(ADBatchAnomalyResultAction.INSTANCE, request).actionGet(5000);
Thread.sleep(20000);
GetResponse doc = getDoc(CommonName.DETECTION_STATE_INDEX, request.getAdTask().getTaskId());
assertTrue(HISTORICAL_ANALYSIS_FINISHED_FAILED_STATS.contains(doc.getSourceAsMap().get(ADTask.STATE_FIELD)));
}
use of org.opensearch.ad.model.DetectionDateRange in project anomaly-detection by opensearch-project.
the class ADBatchAnomalyResultTransportActionTests method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
testIndex = "test_historical_data";
startTime = Instant.now().minus(10, ChronoUnit.DAYS);
endTime = Instant.now();
dateRange = new DetectionDateRange(endTime, endTime.plus(10, ChronoUnit.DAYS));
ingestTestData(testIndex, startTime, detectionIntervalInMinutes, type);
createDetectionStateIndex();
}
use of org.opensearch.ad.model.DetectionDateRange in project anomaly-detection by opensearch-project.
the class ADBatchAnomalyResultTransportActionTests method testHistoricalAnalysisWithFutureDateRange.
public void testHistoricalAnalysisWithFutureDateRange() throws IOException, InterruptedException {
DetectionDateRange dateRange = new DetectionDateRange(endTime, endTime.plus(10, ChronoUnit.DAYS));
testInvalidDetectionDateRange(dateRange);
}
use of org.opensearch.ad.model.DetectionDateRange in project anomaly-detection by opensearch-project.
the class ADBatchAnomalyResultTransportActionTests method testHistoricalAnalysisWithNonExistingIndex.
public void testHistoricalAnalysisWithNonExistingIndex() throws IOException {
ADBatchAnomalyResultRequest request = adBatchAnomalyResultRequest(new DetectionDateRange(startTime, endTime), randomAlphaOfLength(5));
client().execute(ADBatchAnomalyResultAction.INSTANCE, request).actionGet(10_000);
}
Aggregations