[Test] Fix AggregationsTests#testFromXContentWithRandomFields

Exclude "key" field from random modifications in tests, the composite agg uses
an array of object for bucket key and values are checked.
Relates #26800
This commit is contained in:
Jim Ferenczi 2017-11-21 19:28:27 +01:00
parent eed8d1aee5
commit 3427062c3a
1 changed files with 4 additions and 1 deletions

View File

@ -220,12 +220,15 @@ public class AggregationsTests extends ESTestCase {
* - we cannot insert randomly into VALUE or VALUES objects e.g. in Percentiles, the keys need to be numeric there
*
* - we cannot insert into ExtendedMatrixStats "covariance" or "correlation" fields, their syntax is strict
*
* - exclude "key", it can be an array of objects and we need strict values
*/
Predicate<String> excludes = path -> (path.isEmpty() || path.endsWith("aggregations")
|| path.endsWith(Aggregation.CommonFields.META.getPreferredName())
|| path.endsWith(Aggregation.CommonFields.BUCKETS.getPreferredName())
|| path.endsWith(CommonFields.VALUES.getPreferredName()) || path.endsWith("covariance") || path.endsWith("correlation")
|| path.contains(CommonFields.VALUE.getPreferredName()));
|| path.contains(CommonFields.VALUE.getPreferredName())
|| path.endsWith(CommonFields.KEY.getPreferredName()));
mutated = insertRandomFields(xContentType, originalBytes, excludes, random());
} else {
mutated = originalBytes;