-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* ML: fix updating opened jobs scheduled events (#31651) * Adding UpdateParamsTests license header * Adding integration test and addressing PR comments * addressing test and job names
- Loading branch information
Showing
5 changed files
with
129 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/UpdateParamsTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
package org.elasticsearch.xpack.ml.job.process.autodetect; | ||
|
||
import org.elasticsearch.test.ESTestCase; | ||
import org.elasticsearch.xpack.core.ml.job.config.DetectionRule; | ||
import org.elasticsearch.xpack.core.ml.job.config.JobUpdate; | ||
import org.elasticsearch.xpack.core.ml.job.config.ModelPlotConfig; | ||
import org.elasticsearch.xpack.core.ml.job.config.Operator; | ||
import org.elasticsearch.xpack.core.ml.job.config.RuleCondition; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
|
||
public class UpdateParamsTests extends ESTestCase { | ||
|
||
public void testFromJobUpdate() { | ||
String jobId = "foo"; | ||
DetectionRule rule = new DetectionRule.Builder(Arrays.asList( | ||
new RuleCondition(RuleCondition.AppliesTo.ACTUAL, | ||
Operator.GT, 1.0))).build(); | ||
List<DetectionRule> rules = Arrays.asList(rule); | ||
List<JobUpdate.DetectorUpdate> detectorUpdates = Collections.singletonList( | ||
new JobUpdate.DetectorUpdate(2, null, rules)); | ||
JobUpdate.Builder updateBuilder = new JobUpdate.Builder(jobId) | ||
.setModelPlotConfig(new ModelPlotConfig()) | ||
.setDetectorUpdates(detectorUpdates); | ||
|
||
UpdateParams params = UpdateParams.fromJobUpdate(updateBuilder.build()); | ||
|
||
assertFalse(params.isUpdateScheduledEvents()); | ||
assertEquals(params.getDetectorUpdates(), updateBuilder.build().getDetectorUpdates()); | ||
assertEquals(params.getModelPlotConfig(), updateBuilder.build().getModelPlotConfig()); | ||
|
||
params = UpdateParams.fromJobUpdate(updateBuilder.setGroups(Arrays.asList("bar")).build()); | ||
|
||
assertTrue(params.isUpdateScheduledEvents()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters