use of org.opensearch.ad.model.DetectionDateRange in project anomaly-detection by opensearch-project.
the class SecureADRestIT method testStartDetectorForWriteUser.
public void testStartDetectorForWriteUser() throws IOException {
// User Alice has AD full access, should be able to modify a detector
AnomalyDetector aliceDetector = createRandomAnomalyDetector(false, false, aliceClient);
Assert.assertNotNull(aliceDetector.getDetectorId());
Instant now = Instant.now();
Response response = startAnomalyDetector(aliceDetector.getDetectorId(), new DetectionDateRange(now.minus(10, ChronoUnit.DAYS), now), aliceClient);
Assert.assertEquals(response.getStatusLine().toString(), "HTTP/1.1 200 OK");
}
use of org.opensearch.ad.model.DetectionDateRange in project anomaly-detection by opensearch-project.
the class ADBatchAnomalyResultTransportActionTests method testHistoricalAnalysisWithInvalidHistoricalDateRange.
public void testHistoricalAnalysisWithInvalidHistoricalDateRange() throws IOException, InterruptedException {
DetectionDateRange dateRange = new DetectionDateRange(startTime.minus(10, ChronoUnit.DAYS), startTime);
testInvalidDetectionDateRange(dateRange);
}
use of org.opensearch.ad.model.DetectionDateRange in project anomaly-detection by opensearch-project.
the class ADBatchAnomalyResultTransportActionTests method testHistoricalAnalysisExceedsMaxRunningTaskLimit.
public void testHistoricalAnalysisExceedsMaxRunningTaskLimit() throws IOException, InterruptedException {
updateTransientSettings(ImmutableMap.of(MAX_BATCH_TASK_PER_NODE.getKey(), 1));
updateTransientSettings(ImmutableMap.of(BATCH_TASK_PIECE_INTERVAL_SECONDS.getKey(), 5));
DetectionDateRange dateRange = new DetectionDateRange(startTime, endTime);
int totalDataNodes = getDataNodes().size();
for (int i = 0; i < totalDataNodes; i++) {
client().execute(ADBatchAnomalyResultAction.INSTANCE, adBatchAnomalyResultRequest(dateRange)).actionGet(5000);
}
waitUntil(() -> countDocs(CommonName.DETECTION_STATE_INDEX) >= totalDataNodes, 10, TimeUnit.SECONDS);
ADBatchAnomalyResultRequest request = adBatchAnomalyResultRequest(dateRange);
try {
client().execute(ADBatchAnomalyResultAction.INSTANCE, request).actionGet(5000);
} catch (Exception e) {
assertTrue(ExceptionUtil.getErrorMessage(e).contains("All nodes' executing batch tasks exceeds limitation No eligible node to run detector"));
}
}
use of org.opensearch.ad.model.DetectionDateRange in project anomaly-detection by opensearch-project.
the class HistoricalAnalysisIntegTestCase method startHistoricalAnalysis.
public ADTask startHistoricalAnalysis(String detectorId, Instant startTime, Instant endTime) throws IOException {
DetectionDateRange dateRange = new DetectionDateRange(startTime, endTime);
AnomalyDetectorJobRequest request = new AnomalyDetectorJobRequest(detectorId, dateRange, true, UNASSIGNED_SEQ_NO, UNASSIGNED_PRIMARY_TERM, START_JOB);
AnomalyDetectorJobResponse response = client().execute(AnomalyDetectorJobAction.INSTANCE, request).actionGet(10000);
return getADTask(response.getId());
}
use of org.opensearch.ad.model.DetectionDateRange in project anomaly-detection by opensearch-project.
the class HistoricalAnalysisIntegTestCase method startHistoricalAnalysis.
public ADTask startHistoricalAnalysis(Instant startTime, Instant endTime) throws IOException {
DetectionDateRange dateRange = new DetectionDateRange(startTime, endTime);
AnomalyDetector detector = TestHelpers.randomDetector(ImmutableList.of(maxValueFeature()), testIndex, detectionIntervalInMinutes, timeField);
String detectorId = createDetector(detector);
AnomalyDetectorJobRequest request = new AnomalyDetectorJobRequest(detectorId, dateRange, true, UNASSIGNED_SEQ_NO, UNASSIGNED_PRIMARY_TERM, START_JOB);
AnomalyDetectorJobResponse response = client().execute(AnomalyDetectorJobAction.INSTANCE, request).actionGet(10000);
return getADTask(response.getId());
}
Aggregations