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

Add parameter object to Aggregator Test Case #90320

Conversation

not-napoleon
Copy link
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
Collaborator

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

@@ -1470,37 +1475,102 @@ public CircuitBreakerStats stats(String name) {
}
}

public record AggTestConfig(
public record AggTestConfig<V extends InternalAggregation> (
IndexSearcher searcher,
Copy link
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
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.

@@ -440,7 +450,7 @@ protected ScriptService getMockScriptService() {
* It runs the aggregation as well using a circuit breaker that randomly throws {@link CircuitBreakingException}
* 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
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
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
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) >tech debt v8.6.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants