LUCENE-710: fix false-positive failure case of 'delete by time' deletion policy test case

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@527299 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2007-04-10 21:09:32 +00:00
parent b831821324
commit 8abc9bf1f2
1 changed files with 5 additions and 3 deletions

View File

@ -191,7 +191,11 @@ public class TestDeletionPolicy extends TestCase
writer.setUseCompoundFile(useCompoundFile);
writer.close();
long lastDeleteTime = 0;
for(int i=0;i<7;i++) {
// Record last time when writer performed deletes of
// past commits
lastDeleteTime = System.currentTimeMillis();
writer = new IndexWriter(dir, autoCommit, new WhitespaceAnalyzer(), false, policy);
writer.setUseCompoundFile(useCompoundFile);
for(int j=0;j<17;j++) {
@ -216,8 +220,6 @@ public class TestDeletionPolicy extends TestCase
String fileName = IndexFileNames.fileNameFromGeneration(IndexFileNames.SEGMENTS,
"",
gen);
long newestModTime = dir.fileModified(fileName);
while(gen > 0) {
try {
IndexReader reader = IndexReader.open(dir);
@ -226,7 +228,7 @@ public class TestDeletionPolicy extends TestCase
"",
gen);
long modTime = dir.fileModified(fileName);
assertTrue("commit point was older than " + SECONDS + " seconds but did not get deleted", newestModTime - modTime < (SECONDS*1000));
assertTrue("commit point was older than " + SECONDS + " seconds but did not get deleted", lastDeleteTime - modTime < (SECONDS*1000));
} catch (IOException e) {
// OK
break;