Skip to content

Commit

Permalink
fix window delay test and add macos to ci
Browse files Browse the repository at this point in the history
Signed-off-by: Amit Galitzky <[email protected]>
  • Loading branch information
amitgalitz committed Dec 5, 2022
1 parent e5b0f12 commit 92f9aa3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test_build_multi_platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
strategy:
matrix:
java: [8, 11, 14]
os: [ubuntu-latest]
os: [ubuntu-latest, macos-latest]
fail-fast: false

name: Build and Test Anomaly detection Plugin on multipule platforms
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,14 @@ public void testValidationIntervalRecommendation() throws Exception {

public void testValidationWindowDelayRecommendation() throws Exception {
RestClient client = client();
long recDetectorIntervalMillis = 180000;
long recDetectorIntervalMillisForDataSet = 180000;
// this would be equivalent to the window delay in this data test
long recDetectorIntervalMinutes = recDetectorIntervalMillis / 60000;
List<JsonObject> data = createData(2000, recDetectorIntervalMillis);
List<JsonObject> data = createData(2000, recDetectorIntervalMillisForDataSet);
indexTrainData("validation", data, 2000, client);
long detectorInterval = 4;
long expectedWindowDelayMillis = Instant.now().toEpochMilli() - data.get(0).get("timestamp").getAsLong();
// we always round up for window delay recommendation to reduce chance of missed data.
long expectedWindowDelayMinutes = (long) Math.ceil(expectedWindowDelayMillis / 60000.0);
String requestBody = String
.format(
Locale.ROOT,
Expand All @@ -171,10 +173,8 @@ public void testValidationWindowDelayRecommendation() throws Exception {
@SuppressWarnings("unchecked")
Map<String, Map<String, String>> messageMap = (Map<String, Map<String, String>>) XContentMapValues
.extractValue("model", responseMap);
// adding plus one since window delay always rounds up another minute
assertEquals(
String
.format(Locale.ROOT, CommonErrorMessages.WINDOW_DELAY_REC, +recDetectorIntervalMinutes + 1, recDetectorIntervalMinutes + 1),
String.format(Locale.ROOT, CommonErrorMessages.WINDOW_DELAY_REC, expectedWindowDelayMinutes, expectedWindowDelayMinutes),
messageMap.get("window_delay").get("message")
);
}
Expand Down

0 comments on commit 92f9aa3

Please sign in to comment.