diff --git a/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecksTests.java b/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecksTests.java index 34e85a89527..0655da1db08 100644 --- a/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecksTests.java +++ b/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecksTests.java @@ -370,7 +370,7 @@ public class IndexDeprecationChecksTests extends ESTestCase { mappingBuilder.startObject("properties"); { int subfields = randomIntBetween(1, 10); - while (existingFieldNames.size() < subfields) { + while (existingFieldNames.size() < subfields && fieldCount.get() <= fieldLimit) { addRandomField(existingFieldNames, fieldLimit, mappingBuilder, fieldCount); } }