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:
parent
9f7be70f7a
commit
2582e1e8ad
|
@ -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,10 +5843,15 @@ public class InternalEngineTests extends EngineTestCase {
|
|||
assertEquals("the delete and the tombstone", 2, leafReader.numDeletedDocs());
|
||||
assertEquals(numDocs + 1, leafReader.maxDoc());
|
||||
Terms id = leafReader.terms("_id");
|
||||
assertNotNull(id);
|
||||
assertEquals("deleted IDs are pruned away", reader.numDocs(), id.size());
|
||||
TermsEnum iterator = id.iterator();
|
||||
assertFalse(iterator.seekExact(Uid.encodeId("0")));
|
||||
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();
|
||||
assertFalse(iterator.seekExact(Uid.encodeId("0")));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue