Skip to content

Commit 3427062

Browse files
committed
[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
1 parent eed8d1a commit 3427062

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

core/src/test/java/org/elasticsearch/search/aggregations/AggregationsTests.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,12 +220,15 @@ private void parseAndAssert(boolean addRandomFields) throws IOException {
220220
* - we cannot insert randomly into VALUE or VALUES objects e.g. in Percentiles, the keys need to be numeric there
221221
*
222222
* - we cannot insert into ExtendedMatrixStats "covariance" or "correlation" fields, their syntax is strict
223+
*
224+
* - exclude "key", it can be an array of objects and we need strict values
223225
*/
224226
Predicate<String> excludes = path -> (path.isEmpty() || path.endsWith("aggregations")
225227
|| path.endsWith(Aggregation.CommonFields.META.getPreferredName())
226228
|| path.endsWith(Aggregation.CommonFields.BUCKETS.getPreferredName())
227229
|| path.endsWith(CommonFields.VALUES.getPreferredName()) || path.endsWith("covariance") || path.endsWith("correlation")
228-
|| path.contains(CommonFields.VALUE.getPreferredName()));
230+
|| path.contains(CommonFields.VALUE.getPreferredName())
231+
|| path.endsWith(CommonFields.KEY.getPreferredName()));
229232
mutated = insertRandomFields(xContentType, originalBytes, excludes, random());
230233
} else {
231234
mutated = originalBytes;

0 commit comments

Comments
 (0)