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

GlobalAggregation with profile option enabled returns incorrect result #7114

Merged
merged 1 commit into from
Apr 12, 2023

Conversation

sohami
Copy link
Collaborator

@sohami sohami commented Apr 11, 2023

Description

For the case when profile is enabled the check for GlobalAggregator operator will fail as it gets wrapped in the Profiling Aggregator. To fix this the check considers both the cases with profile enabled/disabled and verifies if the unwrapped aggregator instance is of Global type or not.

Issues Resolved

#7088

Check List

  • New functionality includes testing.
    • All tests pass
  • Commits are signed per the DCO using --signoff
  • Commit changes are listed out in CHANGELOG.md file (See: Changelog)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

  • RESULT: null ❌
  • URL: null
  • CommitID: f4ada0c
    Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green.
    Is the failure a flaky test unrelated to your change?

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@codecov-commenter
Copy link

codecov-commenter commented Apr 12, 2023

Codecov Report

Merging #7114 (f6a32bc) into main (a15475a) will increase coverage by 0.00%.
The diff coverage is 0.00%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff            @@
##               main    #7114   +/-   ##
=========================================
  Coverage     70.65%   70.65%           
+ Complexity    59453    59438   -15     
=========================================
  Files          4852     4852           
  Lines        285125   285127    +2     
  Branches      41104    41105    +1     
=========================================
+ Hits         201441   201464   +23     
+ Misses        67131    67124    -7     
+ Partials      16553    16539   -14     
Impacted Files Coverage Δ
...ensearch/search/aggregations/AggregationPhase.java 51.61% <0.00%> (-1.73%) ⬇️

... and 507 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@@ -87,6 +87,7 @@ public void testWithStatsSubAggregator() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.setQuery(QueryBuilders.termQuery("tag", "tag1"))
.addAggregation(global("global").subAggregation(stats("value_stats").field("value")))
.setProfile(randomBoolean())
Copy link
Collaborator

Choose a reason for hiding this comment

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

The test should probably very that results are now correct (vs incorrect results before the fix).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The test should probably very that results are now correct (vs incorrect results before the fix).

The results are asserted below in this test which was failing with profile=true before the fix.

Copy link
Member

Choose a reason for hiding this comment

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

Using randomized testing for coverage is generally an anti-pattern. Probably better to explicitly test both cases of setProfile.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@andrross I thought about it but the post mentions For instance the number of shards should not impact date_histogram aggregations, and the choice of the store type (niofs vs mmapfs) does not affect the results of a query. Such randomization helps improve confidence that we are not relying on implementation details of one component or specifics of some setup.

In this case since profiling should not change the results of query but returns extra information in the response I thought randomization should be fine

Copy link
Member

Choose a reason for hiding this comment

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

My thinking is that at the aggregation layer, something like store type is completely abstracted because all interaction is done through something like a generic directory interface and the aggregation layer has no knowledge of the specific implementation. In that case randomization is fine because it's essentially just verifying nothing is leaking through the abstraction layers. In the profiling case there is now a specific if condition in the aggregation code, so both paths should be explicitly tested.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@andrross Have updated the test to explicitly add for both the profile enabled/disabled case

@@ -87,6 +87,7 @@ public void testWithStatsSubAggregator() throws Exception {
SearchResponse response = client().prepareSearch("idx")
.setQuery(QueryBuilders.termQuery("tag", "tag1"))
.addAggregation(global("global").subAggregation(stats("value_stats").field("value")))
.setProfile(randomBoolean())
Copy link
Member

Choose a reason for hiding this comment

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

Using randomized testing for coverage is generally an anti-pattern. Probably better to explicitly test both cases of setProfile.

Signed-off-by: Sorabh Hamirwasia <sohami.apache@gmail.com>
@andrross andrross added backport 2.x Backport to 2.x branch v2.7.0 labels Apr 12, 2023
@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@andrross andrross merged commit 169e237 into opensearch-project:main Apr 12, 2023
opensearch-trigger-bot bot pushed a commit that referenced this pull request Apr 12, 2023
#7114)

Signed-off-by: Sorabh Hamirwasia <sohami.apache@gmail.com>
(cherry picked from commit 169e237)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
reta pushed a commit that referenced this pull request Apr 12, 2023
#7114) (#7127)

(cherry picked from commit 169e237)

Signed-off-by: Sorabh Hamirwasia <sohami.apache@gmail.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
austintlee pushed a commit to austintlee/OpenSearch that referenced this pull request Apr 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x Backport to 2.x branch v2.7.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants