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

Use the AggTestConfig object in testCase #90699

Merged
merged 5 commits into from
Oct 6, 2022

Conversation

not-napoleon
Copy link
Member

This is a second attempt at #90320. I've left out the more challenging parts of that PR, notably reconciling the buildIndex callback with aggregations that want to pass in searchers directly and making the aggTestConfig object generic over the verify method. For the verify method, I just didn't touch it. For the buildIndex/Searcher conflict, I've taken a different approach: I factored the searcher out of the config object, and pass it directly to search and reduce. Likewise test case can just accept the builder and use it to make a searcher, which it passes to search and reduce.

So what's the point of this, you may ask. The point is that now both testCase and searchAndReduce use the same config object for many of their common settings. This will make life easier converting bespoke tests to use one or the other, and thus get the memory checking benefits of routing through searchAndReduce without requiring endless configuration overrides. This change should remove the need for this config function for example (/cc @romseygeek ).

Once again, I apologize for the huge diff from a largely automated refactor.

@elasticsearchmachine
Copy link
Collaborator

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

@elasticsearchmachine elasticsearchmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Oct 5, 2022
Copy link
Member

@martijnvg martijnvg left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@@ -1044,7 +1054,7 @@ public void testAggregationWithQueryFilter() throws IOException {
ipPrefix.getBuckets().stream().sorted(IP_ADDRESS_KEY_COMPARATOR).map(InternalIpPrefix.Bucket::getDocCount).toList(),
List.of(4L)
);
}, fieldType);
}, new AggTestConfig(aggregationBuilder, fieldType));
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 withQuery(query) needs to be added here?

Copy link
Member Author

Choose a reason for hiding this comment

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

yup, looks like I dropped that by accident.

@@ -470,7 +466,7 @@ public void testNestedOrdering() throws IOException {
nestedBuilder.subAggregation(maxAgg);
termsBuilder.subAggregation(nestedBuilder);

terms = searchAndReduce(new AggTestConfig(newSearcher(indexReader, false, true), termsBuilder, fieldType1, fieldType2));
terms = searchAndReduce(newSearcher(indexReader, false, true), aggTestConfig);
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 aggTestConfig = new AggTestConfig(termsBuilder, fieldType1, fieldType2); needs to be added before this line? termsBuilder is changed in the lines above here, so a new AggTestConfig instance should be created?

Copy link
Member Author

Choose a reason for hiding this comment

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

yup, well spotted.

@not-napoleon
Copy link
Member Author

@elasticmachine update branch

@not-napoleon not-napoleon merged commit 4a26dda into elastic:main Oct 6, 2022
@not-napoleon not-napoleon deleted the test-case-config-object branch October 6, 2022 17:34
weizijun added a commit to weizijun/elasticsearch that referenced this pull request Oct 10, 2022
* main: (150 commits)
  Remove ToXContent interface from ChunkedToXContent (elastic#90409)
  Remove extra SearchService constructor (elastic#90733)
  Update min version for the diagnosis yaml test (elastic#90731)
  Use the AggTestConfig object in testCase (elastic#90699)
  [DOCS] Add links to clear trained model deployment cache API (elastic#90727)
  Assert wildcards are not expanded as specified by request options  (elastic#90641)
  [TEST] Fix exit snapshot restore exit condition (elastic#90696)
  [TEST] Change to atomic file contents save (elastic#90695)
  Update forbiddenapis to 3.4 (elastic#90624)
  [Tests] Don't use concurrent search in scripted field type tests (elastic#90712)
  [ML] Move scaling is possible check for starting trained model (elastic#90706)
  Add new base test case for chunked xcontent types  (elastic#90707)
  Fix testRedNoBlockedIndicesAndRedAllRoleNodes (elastic#90671)
  Fix nullpointer in docs test setup (elastic#90660)
  Don't produce build logs artifact when in a composite build
  Fixing a race condition in EnrichCoordinatorProxyAction that can leave an item stuck in its queue (elastic#90688)
  docs: update fleet/agent pipeline docs (elastic#90659)
  [HealthAPI] Use plural consistently in resource types (elastic#90682)
  [Testing] Enable bwc and fix sorting for 500_date_range (elastic#90681)
  Add profiling and documentation for dfs phase (elastic#90536)
  ...

# Conflicts:
#	x-pack/plugin/mapper-aggregate-metric/src/test/java/org/elasticsearch/xpack/aggregatemetric/mapper/AggregateDoubleMetricFieldMapperTests.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/Aggregations Aggregations >non-issue 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.

4 participants