From 8abc9bf1f230e1f50658be62a5254708dd7232a5 Mon Sep 17 00:00:00 2001 From: Michael McCandless Date: Tue, 10 Apr 2007 21:09:32 +0000 Subject: [PATCH] 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 --- src/test/org/apache/lucene/index/TestDeletionPolicy.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/test/org/apache/lucene/index/TestDeletionPolicy.java b/src/test/org/apache/lucene/index/TestDeletionPolicy.java index 2e5b5cfdcf0..cf49f8f4870 100644 --- a/src/test/org/apache/lucene/index/TestDeletionPolicy.java +++ b/src/test/org/apache/lucene/index/TestDeletionPolicy.java @@ -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;