Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
fix flaky test case (#376)
Browse files Browse the repository at this point in the history
  • Loading branch information
ylwu-amzn authored Jan 27, 2021
1 parent 852c2af commit 16631c8
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.io.IOException;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.concurrent.TimeUnit;

import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.get.GetResponse;
Expand Down Expand Up @@ -142,12 +143,13 @@ public void testHistoricalDetectorExceedsMaxRunningTaskLimit() throws IOExceptio
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);
for (int i = 0; i < getDataNodes().size(); i++) {
client().execute(ADBatchAnomalyResultAction.INSTANCE, adBatchAnomalyResultRequest(dateRange));
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);

RuntimeException exception = expectThrowsAnyOf(
ImmutableList.of(LimitExceededException.class, NotSerializableExceptionWrapper.class),
() -> client().execute(ADBatchAnomalyResultAction.INSTANCE, request).actionGet(5000)
Expand Down

0 comments on commit 16631c8

Please sign in to comment.