From 7853af429898468c26e2ced78c770c31009e3166 Mon Sep 17 00:00:00 2001 From: Michael McCandless Date: Sun, 21 Nov 2010 10:28:39 +0000 Subject: [PATCH] fix intermittant false test fail git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1037406 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/lucene/index/TermVectorsReader.java | 1 - .../apache/lucene/index/TestIndexWriterOnDiskFull.java | 3 +++ .../org/apache/lucene/store/MockIndexOutputWrapper.java | 9 +++++++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lucene/src/java/org/apache/lucene/index/TermVectorsReader.java b/lucene/src/java/org/apache/lucene/index/TermVectorsReader.java index bc98c488f74..b9a9c6a1b79 100644 --- a/lucene/src/java/org/apache/lucene/index/TermVectorsReader.java +++ b/lucene/src/java/org/apache/lucene/index/TermVectorsReader.java @@ -90,7 +90,6 @@ class TermVectorsReader implements Cloneable { assert format == tvdFormat; assert format == tvfFormat; - assert (tvx.length()-FORMAT_SIZE) % 16 == 0; numTotalDocs = (int) (tvx.length() >> 4); if (-1 == docStoreOffset) { diff --git a/lucene/src/test/org/apache/lucene/index/TestIndexWriterOnDiskFull.java b/lucene/src/test/org/apache/lucene/index/TestIndexWriterOnDiskFull.java index 48687587074..0eefee17db5 100644 --- a/lucene/src/test/org/apache/lucene/index/TestIndexWriterOnDiskFull.java +++ b/lucene/src/test/org/apache/lucene/index/TestIndexWriterOnDiskFull.java @@ -57,6 +57,7 @@ public class TestIndexWriterOnDiskFull extends LuceneTestCase { MockDirectoryWrapper dir = new MockDirectoryWrapper(random, new RAMDirectory()); dir.setMaxSizeInBytes(diskFree); IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer())); + writer.setInfoStream(VERBOSE ? System.out : null); MergeScheduler ms = writer.getConfig().getMergeScheduler(); if (ms instanceof ConcurrentMergeScheduler) // This test intentionally produces exceptions @@ -101,6 +102,7 @@ public class TestIndexWriterOnDiskFull extends LuceneTestCase { // Make sure reader can open the index: IndexReader.open(dir, true).close(); + _TestUtil.checkIndex(dir); } dir.close(); @@ -109,6 +111,7 @@ public class TestIndexWriterOnDiskFull extends LuceneTestCase { diskFree += 500; } else { //_TestUtil.syncConcurrentMerges(writer); + dir.setMaxSizeInBytes(0); writer.close(); dir.close(); break; diff --git a/lucene/src/test/org/apache/lucene/store/MockIndexOutputWrapper.java b/lucene/src/test/org/apache/lucene/store/MockIndexOutputWrapper.java index 58c090035c5..3a4a3e5f8b6 100644 --- a/lucene/src/test/org/apache/lucene/store/MockIndexOutputWrapper.java +++ b/lucene/src/test/org/apache/lucene/store/MockIndexOutputWrapper.java @@ -90,14 +90,19 @@ public class MockIndexOutputWrapper extends IndexOutput { } if (dir.maxSize != 0 && freeSpace <= len) { - if (freeSpace > 0 && freeSpace < len) { + if (freeSpace > 0) { realUsage += freeSpace; delegate.writeBytes(b, offset, (int) freeSpace); } if (realUsage > dir.maxUsedSize) { dir.maxUsedSize = realUsage; } - throw new IOException("fake disk full at " + dir.getRecomputedActualSizeInBytes() + " bytes when writing " + name); + String message = "fake disk full at " + dir.getRecomputedActualSizeInBytes() + " bytes when writing " + name + " (file length=" + delegate.length(); + if (freeSpace > 0) { + message += "; wrote " + freeSpace + " of " + len + " bytes"; + } + message += ")"; + throw new IOException(message); } else { if (dir.randomState.nextBoolean()) { final int half = len/2;