diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/datafeed/extractor/ExtractorUtilsTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/datafeed/extractor/ExtractorUtilsTests.java index 6e11728cdab..8ac70f8fa68 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/datafeed/extractor/ExtractorUtilsTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/datafeed/extractor/ExtractorUtilsTests.java @@ -75,24 +75,19 @@ public class ExtractorUtilsTests extends ESTestCase { public void testGetHistogramIntervalMillis_GivenDateHistogramWithInvalidTimeZone() { MaxAggregationBuilder maxTime = AggregationBuilders.max("time").field("time"); DateHistogramAggregationBuilder dateHistogram = AggregationBuilders.dateHistogram("bucket").field("time") - .interval(300000L).timeZone(ZoneId.of("CET")).subAggregation(maxTime); + .fixedInterval(new DateHistogramInterval(300000 + "ms")).timeZone(ZoneId.of("CET")).subAggregation(maxTime); ElasticsearchException e = expectThrows(ElasticsearchException.class, () -> ExtractorUtils.getHistogramIntervalMillis(dateHistogram)); assertThat(e.getMessage(), equalTo("ML requires date_histogram.time_zone to be UTC")); - assertWarnings("[interval] on [date_histogram] is deprecated, use [fixed_interval] " + - "or [calendar_interval] in the future."); } public void testGetHistogramIntervalMillis_GivenUtcTimeZonesDeprecated() { MaxAggregationBuilder maxTime = AggregationBuilders.max("time").field("time"); ZoneId zone = randomFrom(ZoneOffset.UTC, ZoneId.of("UTC")); DateHistogramAggregationBuilder dateHistogram = AggregationBuilders.dateHistogram("bucket").field("time") - .interval(300000L).timeZone(zone).subAggregation(maxTime); + .fixedInterval(new DateHistogramInterval(300000L + "ms")).timeZone(zone).subAggregation(maxTime); assertThat(ExtractorUtils.getHistogramIntervalMillis(dateHistogram), is(300_000L)); - - assertWarnings("[interval] on [date_histogram] is deprecated, use [fixed_interval] " + - "or [calendar_interval] in the future."); } public void testGetHistogramIntervalMillis_GivenUtcTimeZones() { diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/utils/XContentObjectTransformerTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/utils/XContentObjectTransformerTests.java index 3afcc472751..2238cd49fdc 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/utils/XContentObjectTransformerTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/utils/XContentObjectTransformerTests.java @@ -20,6 +20,7 @@ import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.search.SearchModule; import org.elasticsearch.search.aggregations.AggregationBuilders; import org.elasticsearch.search.aggregations.AggregatorFactories; +import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramInterval; import org.elasticsearch.search.aggregations.metrics.MaxAggregationBuilder; import org.elasticsearch.test.ESTestCase; @@ -112,7 +113,7 @@ public class XContentObjectTransformerTests extends ESTestCase { long aggHistogramInterval = randomNonNegativeLong(); MaxAggregationBuilder maxTime = AggregationBuilders.max("time").field("time"); aggs.addAggregator(AggregationBuilders.dateHistogram("buckets") - .interval(aggHistogramInterval).subAggregation(maxTime).field("time")); + .fixedInterval(new DateHistogramInterval(aggHistogramInterval + "ms")).subAggregation(maxTime).field("time")); assertXContentAreEqual(aggs, aggTransformer.toMap(aggs)); assertXContentAreEqual(aggTransformer.fromMap(aggTransformer.toMap(aggs)), aggTransformer.toMap(aggs)); diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/DataExtractorFactoryTests.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/DataExtractorFactoryTests.java index ccc9df2ad16..79fa4bd7810 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/DataExtractorFactoryTests.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/DataExtractorFactoryTests.java @@ -220,11 +220,14 @@ public class DataExtractorFactoryTests extends ESTestCase { MaxAggregationBuilder myField = AggregationBuilders.max("myField").field("myField"); TermsAggregationBuilder myTerm = AggregationBuilders.terms("termAgg").field("termField").subAggregation(myField); datafeedConfig.setParsedAggregations(AggregatorFactories.builder().addAggregator( - AggregationBuilders.dateHistogram("time").interval(600_000).subAggregation(maxTime).subAggregation(myTerm).field("time"))); + AggregationBuilders.dateHistogram("time") + .fixedInterval(new DateHistogramInterval("600000ms")) + .subAggregation(maxTime) + .subAggregation(myTerm) + .field("time"))); ActionListener listener = ActionListener.wrap( dataExtractorFactory -> { assertThat(dataExtractorFactory, instanceOf(RollupDataExtractorFactory.class)); - assertWarnings("[interval] on [date_histogram] is deprecated, use [fixed_interval] or [calendar_interval] in the future."); }, e -> fail() ); @@ -245,13 +248,16 @@ public class DataExtractorFactoryTests extends ESTestCase { MaxAggregationBuilder myField = AggregationBuilders.max("myField").field("myField"); TermsAggregationBuilder myTerm = AggregationBuilders.terms("termAgg").field("termField").subAggregation(myField); datafeedConfig.setParsedAggregations(AggregatorFactories.builder().addAggregator( - AggregationBuilders.dateHistogram("time").interval(600_000).subAggregation(maxTime).subAggregation(myTerm).field("time"))); + AggregationBuilders.dateHistogram("time") + .fixedInterval(new DateHistogramInterval("600000ms")) + .subAggregation(maxTime) + .subAggregation(myTerm) + .field("time"))); // Test with remote index, aggregation, and no chunking ActionListener listener = ActionListener.wrap( dataExtractorFactory -> { assertThat(dataExtractorFactory, instanceOf(AggregationDataExtractorFactory.class)); - assertWarnings("[interval] on [date_histogram] is deprecated, use [fixed_interval] or [calendar_interval] in the future."); }, e -> fail() ); @@ -302,11 +308,14 @@ public class DataExtractorFactoryTests extends ESTestCase { MaxAggregationBuilder myField = AggregationBuilders.max("myField").field("myField"); TermsAggregationBuilder myTerm = AggregationBuilders.terms("termAgg").field("termField").subAggregation(myField); datafeedConfig.setParsedAggregations(AggregatorFactories.builder().addAggregator( - AggregationBuilders.dateHistogram("time").interval(600_000).subAggregation(maxTime).subAggregation(myTerm).field("time"))); + AggregationBuilders.dateHistogram("time") + .fixedInterval(new DateHistogramInterval("600000ms")) + .subAggregation(maxTime) + .subAggregation(myTerm) + .field("time"))); ActionListener listener = ActionListener.wrap( dataExtractorFactory -> { assertThat(dataExtractorFactory, instanceOf(ChunkedDataExtractorFactory.class)); - assertWarnings("[interval] on [date_histogram] is deprecated, use [fixed_interval] or [calendar_interval] in the future."); }, e -> fail() ); @@ -347,7 +356,11 @@ public class DataExtractorFactoryTests extends ESTestCase { MaxAggregationBuilder myField = AggregationBuilders.max("myField").field("myField"); TermsAggregationBuilder myTerm = AggregationBuilders.terms("termAgg").field("termField").subAggregation(myField); datafeedConfig.setParsedAggregations(AggregatorFactories.builder().addAggregator( - AggregationBuilders.dateHistogram("time").interval(600_000).subAggregation(maxTime).subAggregation(myTerm).field("time"))); + AggregationBuilders.dateHistogram("time") + .fixedInterval(new DateHistogramInterval("600000ms")) + .subAggregation(maxTime) + .subAggregation(myTerm) + .field("time"))); ActionListener listener = ActionListener.wrap( dataExtractorFactory -> fail(), e -> { @@ -355,7 +368,6 @@ public class DataExtractorFactoryTests extends ESTestCase { containsString("Rollup capabilities do not have a [date_histogram] aggregation with an interval " + "that is a multiple of the datafeed's interval.")); assertThat(e, instanceOf(IllegalArgumentException.class)); - assertWarnings("[interval] on [date_histogram] is deprecated, use [fixed_interval] or [calendar_interval] in the future."); } ); DataExtractorFactory.create( @@ -374,14 +386,17 @@ public class DataExtractorFactoryTests extends ESTestCase { MaxAggregationBuilder myField = AggregationBuilders.max("myField").field("myField"); TermsAggregationBuilder myTerm = AggregationBuilders.terms("termAgg").field("termField").subAggregation(myField); datafeedConfig.setParsedAggregations(AggregatorFactories.builder().addAggregator( - AggregationBuilders.dateHistogram("time").interval(600_000).subAggregation(maxTime).subAggregation(myTerm).field("time"))); + AggregationBuilders.dateHistogram("time") + .fixedInterval(new DateHistogramInterval("600000ms")) + .subAggregation(maxTime) + .subAggregation(myTerm) + .field("time"))); ActionListener listener = ActionListener.wrap( dataExtractorFactory -> fail(), e -> { assertThat(e.getMessage(), containsString("Rollup capabilities do not support all the datafeed aggregations at the desired interval.")); assertThat(e, instanceOf(IllegalArgumentException.class)); - assertWarnings("[interval] on [date_histogram] is deprecated, use [fixed_interval] or [calendar_interval] in the future."); } ); DataExtractorFactory.create( @@ -400,14 +415,17 @@ public class DataExtractorFactoryTests extends ESTestCase { MaxAggregationBuilder myField = AggregationBuilders.max("myField").field("otherField"); TermsAggregationBuilder myTerm = AggregationBuilders.terms("termAgg").field("termField").subAggregation(myField); datafeedConfig.setParsedAggregations(AggregatorFactories.builder().addAggregator( - AggregationBuilders.dateHistogram("time").interval(600_000).subAggregation(maxTime).subAggregation(myTerm).field("time"))); + AggregationBuilders.dateHistogram("time") + .fixedInterval(new DateHistogramInterval("600000ms")) + .subAggregation(maxTime) + .subAggregation(myTerm) + .field("time"))); ActionListener listener = ActionListener.wrap( dataExtractorFactory -> fail(), e -> { assertThat(e.getMessage(), containsString("Rollup capabilities do not support all the datafeed aggregations at the desired interval.")); assertThat(e, instanceOf(IllegalArgumentException.class)); - assertWarnings("[interval] on [date_histogram] is deprecated, use [fixed_interval] or [calendar_interval] in the future."); } ); DataExtractorFactory.create( @@ -427,7 +445,9 @@ public class DataExtractorFactoryTests extends ESTestCase { "*/30 * * * * ?", 300, new GroupConfig( - new DateHistogramGroupConfig("time", DateHistogramInterval.minutes(minuteInterval)), null, termsGroupConfig), + new DateHistogramGroupConfig.FixedInterval("time", DateHistogramInterval.minutes(minuteInterval)), + null, + termsGroupConfig), metricConfigs, null); RollupJobCaps rollupJobCaps = new RollupJobCaps(rollupJobConfig);