-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
Check self references in metric agg after last doc collection (#33593) #34001
Merged
colings86
merged 8 commits into
elastic:master
from
cbismuth:33593_no_ensure_self_ref_after_scripted_metric_agg_exec
Oct 25, 2018
Merged
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0aff5a3
Check self references in metric agg after last doc collection (#33593)
cbismuth cb6e307
Revert 0aff5a30c5dbad9f476be14f34b81e2d1991bb0f (#33593)
cbismuth cc10fec
Check self refs in metric agg only once in post collection hook (#33593)
cbismuth 1b63f10
Merge branch 'master' into 33593_no_ensure_self_ref_after_scripted_me…
cbismuth 4bfa3c3
Merge branch 'master' into 33593_no_ensure_self_ref_after_scripted_me…
cbismuth 572fac7
Merge branch 'master' into 33593_no_ensure_self_ref_after_scripted_me…
cbismuth 671d6c6
Remove unnecessary mocking (#33593)
cbismuth 56a3ea7
Merge branch 'master' into 33593_no_ensure_self_ref_after_scripted_me…
cbismuth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Im not particularly a fan of using
spy()
here. There are a couple of reasons for this:Mockito
which feels a bit weird to me because we are not really testing the class we intend to test. It also has the danger of theMockito
usage being extended in future and us accidentally bypassing the actual logic in theScriptedMetricAggregator
itselfensureNoSelfReferencesInAggState()
method purely so we can do this spying which feels a bit ugly to me.I wonder if we need to do this spying at all and instead could maybe just rely on the existing tests that check we catch when a self-reference occurs and not worry about ensuring its only called once? It feels to me like the downsides of doing this mockito check might outweigh the benefits.
@rjernst do you have any thoughts on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand and I do agree with you @colings86.
Another idea I can suggest would be to throw an exception from the
ScriptedMetricAggregator
if we do ensure no self references in agg state more than once.EDIT But adding a counter and throwing an exception also seems overwhelming to me.
I let @rjernst give us his opinion on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @colings86. I would rely on/improve existing tests. Mocking should not be necessary here. A mock script can be added to the existing tests which creates a cycle, and ScriptedMetricAggregator can call the normal ensureNoSelfReferences method directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @rjernst, I'll remove unnecessary mocking.