Fix testShouldPeriodicallyFlushAfterMerge (#52243)

MockRandomMergePolicy randomly determines if a segment should use a 
compound format. This can cause a force merge performing two merges: (1)
merging to a single segment, (2) rewriting the new segment using the
compound format. If the second merge completes after we have flushed,
then it can flip the flag shouldPeriodicallyFlushAfterBigMerge to true.

Closes #52205
This commit is contained in:
Nhat Nguyen 2020-02-12 11:08:14 -05:00
parent 257eb0212c
commit e098e837f7
1 changed files with 3 additions and 0 deletions

View File

@ -5131,6 +5131,9 @@ public class InternalEngineTests extends EngineTestCase {
}
public void testShouldPeriodicallyFlushAfterMerge() throws Exception {
engine.close();
// Do not use MockRandomMergePolicy as it can cause a force merge performing two merges.
engine = createEngine(copy(engine.config(), newMergePolicy(random(), false)));
assertThat("Empty engine does not need flushing", engine.shouldPeriodicallyFlush(), equalTo(false));
ParsedDocument doc =
testParsedDocument(Integer.toString(0), null, testDocumentWithTextField(), SOURCE, null);