[ML] Fix isNoop() for datafeed update (#48046)

max_empty_searches = -1 in a datafeed update implies
max_empty_searches will be unset on the datafeed when
the update is applied.  The isNoop() method needs to
take this -1 to null equivalence into account.
This commit is contained in:
David Roberts 2019-10-15 12:17:32 +01:00
parent 6589617a51
commit 83321b0e5e
2 changed files with 3 additions and 2 deletions

View File

@ -419,7 +419,8 @@ public class DatafeedUpdate implements Writeable, ToXContentObject {
&& (scriptFields == null || Objects.equals(scriptFields, datafeed.getScriptFields()))
&& (delayedDataCheckConfig == null || Objects.equals(delayedDataCheckConfig, datafeed.getDelayedDataCheckConfig()))
&& (chunkingConfig == null || Objects.equals(chunkingConfig, datafeed.getChunkingConfig()))
&& (maxEmptySearches == null || Objects.equals(maxEmptySearches, datafeed.getMaxEmptySearches()));
&& (maxEmptySearches == null || Objects.equals(maxEmptySearches, datafeed.getMaxEmptySearches())
|| (maxEmptySearches == -1 && datafeed.getMaxEmptySearches() == null));
}
public static class Builder {

View File

@ -286,7 +286,7 @@ public class DatafeedUpdateTests extends AbstractSerializingTestCase<DatafeedUpd
DatafeedConfig updatedDatafeed = update.apply(datafeed, Collections.emptyMap());
assertThat(datafeed, not(equalTo(updatedDatafeed)));
assertThat("update was " + update, datafeed, not(equalTo(updatedDatafeed)));
}
}