mirror of https://github.com/apache/lucene.git
New attempt at addressing testHasUncommittedChanges() failures.
This commit is contained in:
parent
b45c21f9db
commit
a13a4224d8
|
@ -2376,9 +2376,9 @@ public class TestIndexWriter extends LuceneTestCase {
|
|||
new IndexWriter(
|
||||
dir,
|
||||
newIndexWriterConfig(new MockAnalyzer(random()))
|
||||
// Use a serial merge scheduler to avoid race conditions when checking for
|
||||
// hasPendingMerges()
|
||||
.setMergeScheduler(new SerialMergeScheduler()));
|
||||
// Disable merging to simplify this test, otherwise a commit might trigger
|
||||
// uncommitted merges.
|
||||
.setMergePolicy(NoMergePolicy.INSTANCE));
|
||||
assertTrue(
|
||||
writer.hasUncommittedChanges()); // this will be true because a commit will create an empty
|
||||
// index
|
||||
|
@ -2401,22 +2401,12 @@ public class TestIndexWriter extends LuceneTestCase {
|
|||
writer.addDocument(doc);
|
||||
assertTrue(writer.hasUncommittedChanges());
|
||||
|
||||
// Must commit and wait for merges as long as the commit triggers merges to be certain that
|
||||
// hasUncommittedChanges returns false
|
||||
do {
|
||||
writer.waitForMerges();
|
||||
writer.commit();
|
||||
} while (writer.hasPendingMerges());
|
||||
writer.commit();
|
||||
assertFalse(writer.hasUncommittedChanges());
|
||||
writer.deleteDocuments(new Term("id", "xyz"));
|
||||
assertTrue(writer.hasUncommittedChanges());
|
||||
|
||||
// Must commit and wait for merges as long as the commit triggers merges to be certain that
|
||||
// hasUncommittedChanges returns false
|
||||
do {
|
||||
writer.waitForMerges();
|
||||
writer.commit();
|
||||
} while (writer.hasPendingMerges());
|
||||
writer.commit();
|
||||
assertFalse(writer.hasUncommittedChanges());
|
||||
writer.close();
|
||||
|
||||
|
|
Loading…
Reference in New Issue