Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix TimeSeriesRateAggregatorTests file leak #115278

Merged
merged 3 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
import org.elasticsearch.index.cache.bitset.BitsetFilterCache;
import org.elasticsearch.index.cache.query.DisabledQueryCache;
import org.elasticsearch.index.cache.query.TrivialQueryCachingPolicy;
import org.elasticsearch.index.engine.Engine;
import org.elasticsearch.index.fielddata.FieldDataContext;
import org.elasticsearch.index.fielddata.IndexFieldData;
import org.elasticsearch.index.fielddata.IndexFieldDataCache;
Expand Down Expand Up @@ -749,6 +750,7 @@ protected <T extends AggregationBuilder, V extends InternalAggregation> void tes
new SortField(TimeSeriesIdFieldMapper.NAME, SortField.Type.STRING, false),
new SortedNumericSortField(DataStreamTimestampFieldMapper.DEFAULT_PATH, SortField.Type.LONG, true)
);
config.setParentField(Engine.ROOT_DOC_FIELD_NAME);
config.setIndexSort(sort);
}
RandomIndexWriter indexWriter = new RandomIndexWriter(random(), directory, config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import static org.hamcrest.Matchers.closeTo;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.startsWith;

public class TimeSeriesRateAggregatorTests extends AggregatorTestCase {

Expand Down Expand Up @@ -155,14 +156,14 @@ public void testNestedWithinAutoDateHistogram() throws IOException {

AggTestConfig aggTestConfig = new AggTestConfig(tsBuilder, timeStampField(), counterField("counter_field"))
.withSplitLeavesIntoSeperateAggregators(false);
expectThrows(IllegalArgumentException.class, () -> testCase(iw -> {
for (Document document : docs(2000, "1", 15, 37, 60, /*reset*/ 14)) {
iw.addDocument(document);
}
for (Document document : docs(2000, "2", 74, 150, /*reset*/ 50, 90, /*reset*/ 40)) {
iw.addDocument(document);
}
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> testCase(iw -> {
iw.addDocuments(docs(2000, "1", 15, 37, 60, /*reset*/ 14));
iw.addDocuments(docs(2000, "2", 74, 150, /*reset*/ 50, 90, /*reset*/ 40));
}, verifier, aggTestConfig));
assertThat(
e.getMessage(),
startsWith("Wrapping a time-series rate aggregation within a DeferableBucketAggregator is not supported.")
);
}

private List<Document> docs(long startTimestamp, String dim, long... values) throws IOException {
Expand Down