Fix `InternalEngineTests#testPruneAwayDeletedButRetainedIds`

The test failed because we had only a single document in the index
that got deleted such that some assertions that expected at least
one live doc failed.

Relates to: #40741
This commit is contained in:
Simon Willnauer 2019-06-06 14:14:41 +02:00
parent 9f7be70f7a
commit 2582e1e8ad
1 changed files with 10 additions and 4 deletions

View File

@ -5810,6 +5810,7 @@ public class InternalEngineTests extends EngineTestCase {
policy.setMinMergeDocs(10000);
try (InternalEngine engine = createEngine(indexSettings, store, createTempDir(), policy)) {
int numDocs = between(1, 20);
logger.info("" + numDocs);
for (int i = 0; i < numDocs; i++) {
index(engine, i);
}
@ -5842,6 +5843,10 @@ public class InternalEngineTests extends EngineTestCase {
assertEquals("the delete and the tombstone", 2, leafReader.numDeletedDocs());
assertEquals(numDocs + 1, leafReader.maxDoc());
Terms id = leafReader.terms("_id");
if (numDocs == 1) {
assertNull(id); // everything is pruned away
assertEquals(0, leafReader.numDocs());
} else {
assertNotNull(id);
assertEquals("deleted IDs are pruned away", reader.numDocs(), id.size());
TermsEnum iterator = id.iterator();
@ -5850,3 +5855,4 @@ public class InternalEngineTests extends EngineTestCase {
}
}
}
}