lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rm...@apache.org
Subject svn commit: r1644124 - in /lucene/dev/branches/branch_5x/lucene: core/src/test/org/apache/lucene/index/ test-framework/src/java/org/apache/lucene/store/
Date Tue, 09 Dec 2014 17:23:15 GMT
Author: rmuir
Date: Tue Dec  9 17:23:15 2014
New Revision: 1644124

URL: http://svn.apache.org/r1644124
Log:
fix test bug

Modified:
    lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestForTooMuchCloning.java
    lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/store/MockDirectoryWrapper.java
    lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/store/MockIndexInputWrapper.java

Modified: lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestForTooMuchCloning.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestForTooMuchCloning.java?rev=1644124&r1=1644123&r2=1644124&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestForTooMuchCloning.java
(original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestForTooMuchCloning.java
Tue Dec  9 17:23:15 2014
@@ -32,7 +32,7 @@ import org.apache.lucene.util.TestUtil;
 public class TestForTooMuchCloning extends LuceneTestCase {
 
   // Make sure we don't clone IndexInputs too frequently
-  // during merging:
+  // during merging and searching:
   public void test() throws Exception {
     final MockDirectoryWrapper dir = newMockDirectory();
     final TieredMergePolicy tmp = new TieredMergePolicy();
@@ -55,12 +55,14 @@ public class TestForTooMuchCloning exten
     final IndexReader r = w.getReader();
     w.close();
 
-    final int cloneCount = dir.getInputCloneCount();
     //System.out.println("merge clone count=" + cloneCount);
-    assertTrue("too many calls to IndexInput.clone during merging: " + dir.getInputCloneCount(),
cloneCount < 500);
+    assertTrue("too many calls to IndexInput.clone during merging: " + dir.getInputCloneCount(),
dir.getInputCloneCount() < 500);
 
     final IndexSearcher s = newSearcher(r);
-
+    // important: set this after newSearcher, it might have run checkindex
+    final int cloneCount = dir.getInputCloneCount();
+    // dir.setVerboseClone(true);
+    
     // MTQ that matches all terms so the AUTO_REWRITE should
     // cutover to filter rewrite and reuse a single DocsEnum
     // across all terms;

Modified: lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/store/MockDirectoryWrapper.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/store/MockDirectoryWrapper.java?rev=1644124&r1=1644123&r2=1644124&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/store/MockDirectoryWrapper.java
(original)
+++ lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/store/MockDirectoryWrapper.java
Tue Dec  9 17:23:15 2014
@@ -134,6 +134,16 @@ public class MockDirectoryWrapper extend
   public int getInputCloneCount() {
     return inputCloneCount.get();
   }
+  
+  boolean verboseClone;
+  
+  /** 
+   * If set to true, we print a fake exception
+   * with filename and stacktrace on every indexinput clone()
+   */
+  public void setVerboseClone(boolean v) {
+    verboseClone = v;
+  }
 
   public void setTrackDiskUsage(boolean v) {
     trackDiskUsage = v;

Modified: lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/store/MockIndexInputWrapper.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/store/MockIndexInputWrapper.java?rev=1644124&r1=1644123&r2=1644124&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/store/MockIndexInputWrapper.java
(original)
+++ lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/store/MockIndexInputWrapper.java
Tue Dec  9 17:23:15 2014
@@ -67,6 +67,9 @@ public class MockIndexInputWrapper exten
   @Override
   public MockIndexInputWrapper clone() {
     ensureOpen();
+    if (dir.verboseClone) {
+      new Exception("clone: " + this).printStackTrace(System.out);
+    }
     dir.inputCloneCount.incrementAndGet();
     IndexInput iiclone = delegate.clone();
     MockIndexInputWrapper clone = new MockIndexInputWrapper(dir, name, iiclone);
@@ -91,6 +94,9 @@ public class MockIndexInputWrapper exten
   @Override
   public IndexInput slice(String sliceDescription, long offset, long length) throws IOException
{
     ensureOpen();
+    if (dir.verboseClone) {
+      new Exception("slice: " + this).printStackTrace(System.out);
+    }
     dir.inputCloneCount.incrementAndGet();
     IndexInput slice = delegate.slice(sliceDescription, offset, length);
     MockIndexInputWrapper clone = new MockIndexInputWrapper(dir, sliceDescription, slice);



Mime
View raw message