Fix intermittently failing TestParallelLeafReader (#12865)

This commit fixes the intermittently failing TestParallelLeafReader.

The ParallelLeafReader requires the document order to be consistent across indexes - each document contains the union of the fields of all documents with the same document number. The test asserts this. But now, with MockRandomMergePolicy potentially reversing the doc ID order while merging, this invalidates the assumption of the test indexes and assertions. The solution is to just ensure that no merging actually happens in these tiny test indexes.
This commit is contained in:
Chris Hegarty 2023-12-02 10:02:13 +00:00 committed by GitHub
parent 65d30ca1af
commit e852dfe550
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -301,7 +301,9 @@ public class TestParallelLeafReader extends LuceneTestCase {
private Directory getDir1(Random random) throws IOException {
Directory dir1 = newDirectory();
IndexWriter w1 = new IndexWriter(dir1, newIndexWriterConfig(new MockAnalyzer(random)));
IndexWriterConfig conf =
newIndexWriterConfig(new MockAnalyzer(random())).setMergePolicy(new LogDocMergePolicy());
IndexWriter w1 = new IndexWriter(dir1, conf);
Document d1 = new Document();
d1.add(newTextField("f1", "v1", Field.Store.YES));
d1.add(newTextField("f2", "v1", Field.Store.YES));
@ -317,7 +319,9 @@ public class TestParallelLeafReader extends LuceneTestCase {
private Directory getDir2(Random random) throws IOException {
Directory dir2 = newDirectory();
IndexWriter w2 = new IndexWriter(dir2, newIndexWriterConfig(new MockAnalyzer(random)));
IndexWriterConfig conf =
newIndexWriterConfig(new MockAnalyzer(random())).setMergePolicy(new LogDocMergePolicy());
IndexWriter w2 = new IndexWriter(dir2, conf);
Document d3 = new Document();
d3.add(newTextField("f3", "v1", Field.Store.YES));
d3.add(newTextField("f4", "v1", Field.Store.YES));