From 3cb164b22ebf225e4f0f6dea0114fe82f2a5377e Mon Sep 17 00:00:00 2001 From: Adrien Grand Date: Mon, 26 Dec 2016 20:19:11 +0100 Subject: [PATCH] Fix IndexShardTests.testDocStats. --- .../java/org/elasticsearch/index/shard/IndexShardTests.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java b/core/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java index d01aeb2bf00..972232debaa 100644 --- a/core/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java +++ b/core/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java @@ -1368,7 +1368,9 @@ public class IndexShardTests extends IndexShardTestCase { try { indexShard = newStartedShard(); final long numDocs = randomIntBetween(2, 32); // at least two documents so we have docs to delete - final long numDocsToDelete = randomIntBetween(1, Math.toIntExact(numDocs)); + // Delete at least numDocs/10 documents otherwise the number of deleted docs will be below 10% + // and forceMerge will refuse to expunge deletes + final long numDocsToDelete = randomIntBetween((int) Math.ceil(numDocs / 10.0), Math.toIntExact(numDocs)); for (int i = 0; i < numDocs; i++) { final String id = Integer.toString(i); final ParsedDocument doc =