TEST: testDocStats should always use forceMerge (#32450)

Due to the recent change in LUCENE-8263, we need to adjust the deletion
ration to between 10% to 33% to preserve the current behavior of the
test. However, we may need another refinement if soft-deletes is enabled
as the actual deletes are different because of delete tombstones.

This commit prefers to always execute forceMerge instead of adjusting
the deletion ratio so that this test can focus on testing docStats.

Closes #32449
This commit is contained in:
Nhat Nguyen 2018-07-28 07:41:30 -04:00 committed by GitHub
parent 6e98615cc1
commit 5b1ad8099b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2376,15 +2376,12 @@ public class IndexShardTests extends IndexShardTestCase {
closeShards(sourceShard, targetShard); closeShards(sourceShard, targetShard);
} }
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/32449")
public void testDocStats() throws IOException { public void testDocStats() throws IOException {
IndexShard indexShard = null; IndexShard indexShard = null;
try { try {
indexShard = newStartedShard(); indexShard = newStartedShard();
final long numDocs = randomIntBetween(2, 32); // at least two documents so we have docs to delete final long numDocs = randomIntBetween(2, 32); // at least two documents so we have docs to delete
// Delete at least numDocs/10 documents otherwise the number of deleted docs will be below 10% final long numDocsToDelete = randomLongBetween(1, numDocs);
// and forceMerge will refuse to expunge deletes
final long numDocsToDelete = randomIntBetween((int) Math.ceil(Math.nextUp(numDocs / 10.0)), Math.toIntExact(numDocs));
for (int i = 0; i < numDocs; i++) { for (int i = 0; i < numDocs; i++) {
final String id = Integer.toString(i); final String id = Integer.toString(i);
indexDoc(indexShard, "_doc", id); indexDoc(indexShard, "_doc", id);
@ -2434,7 +2431,6 @@ public class IndexShardTests extends IndexShardTestCase {
// merge them away // merge them away
final ForceMergeRequest forceMergeRequest = new ForceMergeRequest(); final ForceMergeRequest forceMergeRequest = new ForceMergeRequest();
forceMergeRequest.onlyExpungeDeletes(randomBoolean());
forceMergeRequest.maxNumSegments(1); forceMergeRequest.maxNumSegments(1);
indexShard.forceMerge(forceMergeRequest); indexShard.forceMerge(forceMergeRequest);