You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2012/06/20 17:56:49 UTC
svn commit: r1352174 - in /lucene/dev/branches/branch_4x: ./ lucene/
lucene/core/
lucene/core/src/test/org/apache/lucene/index/TestDeletionPolicy.java
Author: mikemccand
Date: Wed Jun 20 15:56:49 2012
New Revision: 1352174
URL: http://svn.apache.org/viewvc?rev=1352174&view=rev
Log:
rely less on Thread.sleep
Modified:
lucene/dev/branches/branch_4x/ (props changed)
lucene/dev/branches/branch_4x/lucene/ (props changed)
lucene/dev/branches/branch_4x/lucene/core/ (props changed)
lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestDeletionPolicy.java
Modified: lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestDeletionPolicy.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestDeletionPolicy.java?rev=1352174&r1=1352173&r2=1352174&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestDeletionPolicy.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestDeletionPolicy.java Wed Jun 20 15:56:49 2012
@@ -35,6 +35,7 @@ import org.apache.lucene.search.ScoreDoc
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util._TestUtil;
/*
Verify we can read the pre-2.1 file format, do searches
@@ -214,10 +215,9 @@ public class TestDeletionPolicy extends
writer.commit(commitData);
writer.close();
- final int ITER = 9;
-
long lastDeleteTime = 0;
- for(int i=0;i<ITER;i++) {
+ final int targetNumDelete = _TestUtil.nextInt(random(), 1, 5);
+ while (policy.numDelete < targetNumDelete) {
// Record last time when writer performed deletes of
// past commits
lastDeleteTime = System.currentTimeMillis();
@@ -237,16 +237,9 @@ public class TestDeletionPolicy extends
writer.commit(commitData);
writer.close();
- if (i < ITER-1) {
- // Make sure to sleep long enough so that some commit
- // points will be deleted:
- Thread.sleep((int) (1000.0*(SECONDS/5.0)));
- }
+ Thread.sleep((int) (1000.0*(SECONDS/5.0)));
}
- // First, make sure the policy in fact deleted something:
- assertTrue("no commits were deleted", policy.numDelete > 0);
-
// Then simplistic check: just verify that the
// segments_N's that still exist are in fact within SECONDS
// seconds of the last one's mod time, and, that I can