From 4240159b44c6b3549c8dacab69748e7aaee3bfa4 Mon Sep 17 00:00:00 2001 From: Adrien Grand Date: Wed, 18 May 2022 23:31:47 +0200 Subject: [PATCH] LUCENE-10574: Fix test failure. If a LogByteSizeMergePolicy is used, then it might decide to not merge the two one-document segments if their on-disk sizes are too different. Using a LogDocMergePolicy addresses the issue as both segments are always considered the same size. --- .../org/apache/lucene/index/TestIndexWriterOnDiskFull.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterOnDiskFull.java b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterOnDiskFull.java index 4001fb982ba..0847ff63fd1 100644 --- a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterOnDiskFull.java +++ b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterOnDiskFull.java @@ -539,6 +539,8 @@ public class TestIndexWriterOnDiskFull extends LuceneTestCase { MockDirectoryWrapper dir = newMockDirectory(); // IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(new // MockAnalyzer(random)).setReaderPooling(true)); + LogDocMergePolicy mp = new LogDocMergePolicy(); + mp.setMergeFactor(2); IndexWriter w = new IndexWriter( dir, @@ -546,7 +548,7 @@ public class TestIndexWriterOnDiskFull extends LuceneTestCase { .setMergeScheduler(new SerialMergeScheduler()) .setReaderPooling(true) .setMergePolicy( - new FilterMergePolicy(newLogMergePolicy(2)) { + new FilterMergePolicy(mp) { @Override public boolean keepFullyDeletedSegment( IOSupplier readerIOSupplier) throws IOException {