Skip to content

Add parameter object to Aggregator Test Case#90320

Closed
not-napoleon wants to merge 18 commits intoelastic:mainfrom
not-napoleon:refactor-aggregator-test-case-part-2
Closed

Add parameter object to Aggregator Test Case#90320
not-napoleon wants to merge 18 commits intoelastic:mainfrom
not-napoleon:refactor-aggregator-test-case-part-2

Conversation

@not-napoleon
Copy link
Copy Markdown
Member

I apologize for the huge, largely automated, refactoring PR. This extends the refactoring from #90149 by applying the same parameter object to AggregatorTestCase#testCase, and extending it to include that method's parameters, which allows removing some useless wrapper functions. By being a bit more explicit about type parameters, I was also able to remove some useless casting. This should make it easier to write tests and extend the testing framework going forward.

@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-analytics-geo (Team:Analytics)


public record AggTestConfig(
public record AggTestConfig<V extends InternalAggregation> (
IndexSearcher searcher,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make this into a CheckedSupplier<Searcher, IOException> and remove the buildIndex - instead we can have a withBuildIndex or something that converts a buildIndex into Supplier<....>.

public AggTestConfig(IndexSearcher searcher, Query query, AggregationBuilder builder, MappedFieldType... fieldTypes) {
this(searcher, query, builder, DEFAULT_MAX_BUCKETS, randomBoolean(), true, fieldTypes);
this(searcher, query, null, null, builder, DEFAULT_MAX_BUCKETS, randomBoolean(), true, fieldTypes);
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be super cool if we could have one ctor for this one day. But that doesn't seem like today.

* in order to mak sure the implementation does not leak.
*/
protected <A extends InternalAggregation, C extends Aggregator> A searchAndReduce(AggTestConfig aggTestConfig) throws IOException {
protected <A extends InternalAggregation, C extends Aggregator> A searchAndReduce(AggTestConfig<A> aggTestConfig) throws IOException {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should call verify on the context. If we're going to have a verify member on AggTestConfig we should call it in every possible place.

splitLeavesIntoSeparateAggregators,
shouldBeCached,
fieldTypes
);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work?

public <V> AggTestCase withVerifier(Consumer<V> verifier) {
  Consumer<InternalAggregation> = i -> verifier((V) i);
  new Agg.....

@not-napoleon
Copy link
Copy Markdown
Member Author

Upon reflection, this doesn't seem like it will be worth the work at this point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Analytics/Aggregations Aggregations >non-issue >refactoring Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v8.6.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants