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