-
Notifications
You must be signed in to change notification settings - Fork 25.6k
add tests to SumAggregatorTests #53568
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 tests to SumAggregatorTests #53568
Conversation
This adds tests for supported ValuesSourceTypes, unmapped fields, scripting, and the missing param. The tests for unmapped fields and scripting are migrated from the SumIT integration test
|
Pinging @elastic/es-analytics-geo (:Analytics/Aggregations) |
| assertThat(sum.getValue(), equalTo(0.0)); | ||
| } | ||
|
|
||
| /** This test has been moved to {@link SumAggregatorTests#testUnmapped()} */ |
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.
These are because this class still extends AbstractNumericTestCase - the remainder of the tests will migrate in another pr
| import static java.util.Collections.singletonList; | ||
| import static java.util.Collections.singletonMap; | ||
| import static java.util.stream.Collectors.toList; | ||
| import static org.elasticsearch.common.lucene.search.Queries.newMatchAllQuery; |
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.
Personally I don't think this is an improvement.
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.
Yeah it's probably a net negative on readability
| .script(new Script(ScriptType.INLINE, MockScriptEngine.NAME, FIELD_SCRIPT_NAME, singletonMap("field", FIELD_NAME)))); | ||
| } | ||
|
|
||
| private void scriptTestCase(int numValuesPerField, SumAggregationBuilder builder) throws IOException { |
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 don't think this name is right. It looks like it is just a generic "does random stuff reduce right" kind of thing.
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.
Had the same thought after writing it - the script specific part is the expectedSum = sum + (numDocs * numValuesPerField); because it expects the script to increment all the fields by 1
I'll see if I can make it less confusing
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 made it a little more general and moved some other test cases to it too. Still not thrilled with its readability
nik9000
left a comment
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.
LGTM. Incremental improvement!
|
Thanks! |
This adds tests for supported ValuesSourceTypes, unmapped fields, scripting, and the missing param. The tests for unmapped fields and scripting are migrated from the SumIT integration test
This adds tests for supported ValuesSourceTypes, unmapped fields, scripting, and the missing param. The tests for unmapped fields and scripting are migrated from the SumIT integration test
This adds tests for supported ValuesSourceTypes, unmapped fields,
scripting, and the missing param. The tests for unmapped fields and
scripting are migrated from the SumIT integration test