Apache Solr open-source search software
LUCENE-3667: make tests reasonable if you dont have a supercomputer
Robert Muirf5d1e967dbd4
diff --git a/lucene/build.xml b/lucene/build.xmlindex 90043dfd516..35a9c732a54 100644--- a/lucene/build.xml+++ b/lucene/build.xml@@ -150,14 +150,10 @@<target name="junit-backwards-parallel" unless="tests.sequential"><parallel threadsPerProcessor="${tests.threadspercpu}">- <backwards-test-macro threadNum="1" threadTotal="8"/>- <backwards-test-macro threadNum="2" threadTotal="8"/>- <backwards-test-macro threadNum="3" threadTotal="8"/>- <backwards-test-macro threadNum="4" threadTotal="8"/>- <backwards-test-macro threadNum="5" threadTotal="8"/>- <backwards-test-macro threadNum="6" threadTotal="8"/>- <backwards-test-macro threadNum="7" threadTotal="8"/>- <backwards-test-macro threadNum="8" threadTotal="8"/>+ <backwards-test-macro threadNum="1" threadTotal="4"/>+ <backwards-test-macro threadNum="2" threadTotal="4"/>+ <backwards-test-macro threadNum="3" threadTotal="4"/>+ <backwards-test-macro threadNum="4" threadTotal="4"/></parallel></target>diff --git a/lucene/common-build.xml b/lucene/common-build.xmlindex 9a437c43c89..da90ca8867c 100644--- a/lucene/common-build.xml+++ b/lucene/common-build.xml@@ -654,14 +654,10 @@<target name="junit-parallel" unless="tests.sequential"><parallel threadsPerProcessor="${tests.threadspercpu}">- <test-macro threadNum="1" threadTotal="8"/>- <test-macro threadNum="2" threadTotal="8"/>- <test-macro threadNum="3" threadTotal="8"/>- <test-macro threadNum="4" threadTotal="8"/>- <test-macro threadNum="5" threadTotal="8"/>- <test-macro threadNum="6" threadTotal="8"/>- <test-macro threadNum="7" threadTotal="8"/>- <test-macro threadNum="8" threadTotal="8"/>+ <test-macro threadNum="1" threadTotal="4"/>+ <test-macro threadNum="2" threadTotal="4"/>+ <test-macro threadNum="3" threadTotal="4"/>+ <test-macro threadNum="4" threadTotal="4"/></parallel></target>diff --git a/lucene/src/test-framework/java/org/apache/lucene/analysis/MockTokenizer.java b/lucene/src/test-framework/java/org/apache/lucene/analysis/MockTokenizer.javaindex 37e0b36cda0..316fe9fbfb0 100644--- a/lucene/src/test-framework/java/org/apache/lucene/analysis/MockTokenizer.java+++ b/lucene/src/test-framework/java/org/apache/lucene/analysis/MockTokenizer.java@@ -48,9 +48,9 @@ public class MockTokenizer extends Tokenizer {public static final CharacterRunAutomaton KEYWORD =new CharacterRunAutomaton(new RegExp(".*").toAutomaton());/** Acts like LetterTokenizer. */- // the ugly regex below is Unicode 5.2 [:Letter:]+ // the ugly regex below is incomplete Unicode 5.2 [:Letter:]public static final CharacterRunAutomaton SIMPLE =- new CharacterRunAutomaton(new RegExp("[A-Za-zªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԥԱ-Ֆՙա-ևא-תװ-ײء-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨऄ-हऽॐक़-ॡॱॲॹ-ॿঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-ళవ-హఽౘౙౠౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡഅ-ഌഎ-ഐഒ-നപ-ഹഽൠൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ະາຳຽເ-ໄໆໜໝༀཀ-ཇཉ-ཬྈ-ྋက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-Ⴥა-ჺჼᄀ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤜᥐ-ᥭᥰ-ᥴᦀ-ᦫᧁ-ᧇᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᰀ-ᰣᱍ-ᱏᱚ-ᱽᳩ-ᳬᳮ-ᳱᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₔℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎↃↄⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⴀ-ⴥⴰ-ⵥⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⸯ々〆〱-〵〻〼ぁ-ゖゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆷㇰ-ㇿ㐀-䶵一-鿋ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙟꙢ-ꙮꙿ-ꚗꚠ-ꛥꜗ-ꜟꜢ-ꞈꞋꞌꟻ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꪀ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꯀ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-鶴侮-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ𐀀-𐀋𐀍-𐀦𐀨-𐀺𐀼𐀽𐀿-𐁍𐁐-𐁝𐂀-𐃺𐊀-𐊜𐊠-𐋐𐌀-𐌞𐌰-𐍀𐍂-𐍉𐎀-𐎝𐎠-𐏃𐏈-𐏏𐐀-𐒝𐠀-𐠅𐠈𐠊-𐠵𐠷𐠸𐠼𐠿-𐡕𐤀-𐤕𐤠-𐤹𐨀𐨐-𐨓𐨕-𐨗𐨙-𐨳𐩠-𐩼𐬀-𐬵𐭀-𐭕𐭠-𐭲𐰀-𐱈𑂃-𑂯𒀀-𒍮𓀀-𓐮𝐀-𝑔𝑖-𝒜𝒞𝒟𝒢𝒥𝒦𝒩-𝒬𝒮-𝒹𝒻𝒽-𝓃𝓅-𝔅𝔇-𝔊𝔍-𝔔𝔖-𝔜𝔞-𝔹𝔻-𝔾𝕀-𝕄𝕆𝕊-𝕐𝕒-𝚥𝚨-𝛀𝛂-𝛚𝛜-𝛺𝛼-𝜔𝜖-𝜴𝜶-𝝎𝝐-𝝮𝝰-𝞈𝞊-𝞨𝞪-𝟂𝟄-𝟋𠀀-𪛖𪜀-𫜴丽-𪘀]+").toAutomaton());+ new CharacterRunAutomaton(new RegExp("[A-Za-zªµºÀ-ÖØ-öø-Z]+").toAutomaton());private final CharacterRunAutomaton runAutomaton;private final boolean lowerCase;diff --git a/lucene/src/test-framework/java/org/apache/lucene/search/CheckHits.java b/lucene/src/test-framework/java/org/apache/lucene/search/CheckHits.javaindex 083226c3fff..0206cfc736c 100644--- a/lucene/src/test-framework/java/org/apache/lucene/search/CheckHits.java+++ b/lucene/src/test-framework/java/org/apache/lucene/search/CheckHits.java@@ -28,6 +28,7 @@ import junit.framework.Assert;import org.apache.lucene.index.IndexReader;import org.apache.lucene.index.IndexReader.AtomicReaderContext;import org.apache.lucene.store.Directory;+import org.apache.lucene.util.LuceneTestCase;public class CheckHits {@@ -177,7 +178,7 @@ public class CheckHits {Assert.assertEquals(query.toString(defaultFieldName), correct, actual);- QueryUtils.check(random, query,searcher);+ QueryUtils.check(random, query,searcher, LuceneTestCase.rarely(random));}/** Tests that a Hits has an expected order of documents */diff --git a/lucene/src/test-framework/java/org/apache/lucene/search/QueryUtils.java b/lucene/src/test-framework/java/org/apache/lucene/search/QueryUtils.javaindex 187700cd6f9..5adeb33613f 100644--- a/lucene/src/test-framework/java/org/apache/lucene/search/QueryUtils.java+++ b/lucene/src/test-framework/java/org/apache/lucene/search/QueryUtils.java@@ -105,7 +105,7 @@ public class QueryUtils {public static void check(Random random, Query q1, IndexSearcher s) {check(random, q1, s, true);}- private static void check(Random random, Query q1, IndexSearcher s, boolean wrap) {+ public static void check(Random random, Query q1, IndexSearcher s, boolean wrap) {try {check(q1);if (s!=null) {diff --git a/lucene/src/test-framework/java/org/apache/lucene/store/MockDirectoryWrapper.java b/lucene/src/test-framework/java/org/apache/lucene/store/MockDirectoryWrapper.javaindex 8b77c878ef1..beff7ab3191 100644--- a/lucene/src/test-framework/java/org/apache/lucene/store/MockDirectoryWrapper.java+++ b/lucene/src/test-framework/java/org/apache/lucene/store/MockDirectoryWrapper.java@@ -156,7 +156,10 @@ public class MockDirectoryWrapper extends Directory {if (crashed)throw new IOException("cannot sync after crash");unSyncedFiles.removeAll(names);- delegate.sync(names);+ if (LuceneTestCase.rarely(randomState) || delegate instanceof NRTCachingDirectory) {+ // don't wear out our hardware so much in tests.+ delegate.sync(names);+ }}@Overridediff --git a/lucene/src/test-framework/java/org/apache/lucene/util/LuceneTestCase.java b/lucene/src/test-framework/java/org/apache/lucene/util/LuceneTestCase.javaindex e0e3ec043f2..94c5948cf65 100644--- a/lucene/src/test-framework/java/org/apache/lucene/util/LuceneTestCase.java+++ b/lucene/src/test-framework/java/org/apache/lucene/util/LuceneTestCase.java@@ -686,7 +686,7 @@ public abstract class LuceneTestCase extends Assert {}}- private final static int THREAD_STOP_GRACE_MSEC = 50;+ private final static int THREAD_STOP_GRACE_MSEC = 10;// jvm-wide list of 'rogue threads' we found, so they only get reported once.private final static IdentityHashMap<Thread,Boolean> rogueThreads = new IdentityHashMap<Thread,Boolean>();@@ -898,10 +898,10 @@ public abstract class LuceneTestCase extends Assert {if (r.nextBoolean()) {if (rarely(r)) {// crazy value- c.setMaxBufferedDocs(_TestUtil.nextInt(r, 2, 7));+ c.setMaxBufferedDocs(_TestUtil.nextInt(r, 2, 15));} else {// reasonable value- c.setMaxBufferedDocs(_TestUtil.nextInt(r, 8, 1000));+ c.setMaxBufferedDocs(_TestUtil.nextInt(r, 16, 1000));}}if (r.nextBoolean()) {@@ -914,15 +914,21 @@ public abstract class LuceneTestCase extends Assert {}}if (r.nextBoolean()) {- c.setIndexerThreadPool(new ThreadAffinityDocumentsWriterThreadPool(_TestUtil.nextInt(r, 1, 20)));+ if (rarely(r)) {+ // crazy value+ c.setIndexerThreadPool(new ThreadAffinityDocumentsWriterThreadPool(_TestUtil.nextInt(r, 5, 20)));+ } else {+ // reasonable value+ c.setIndexerThreadPool(new ThreadAffinityDocumentsWriterThreadPool(_TestUtil.nextInt(r, 1, 4)));+ }}- if (r.nextBoolean()) {- c.setMergePolicy(newTieredMergePolicy());+ if (rarely(r)) {+ c.setMergePolicy(new MockRandomMergePolicy(r));} else if (r.nextBoolean()) {- c.setMergePolicy(newLogMergePolicy());+ c.setMergePolicy(newTieredMergePolicy());} else {- c.setMergePolicy(new MockRandomMergePolicy(r));+ c.setMergePolicy(newLogMergePolicy());}c.setReaderPooling(r.nextBoolean());@@ -943,9 +949,9 @@ public abstract class LuceneTestCase extends Assert {logmp.setUseCompoundFile(r.nextBoolean());logmp.setCalibrateSizeByDeletes(r.nextBoolean());if (rarely(r)) {- logmp.setMergeFactor(_TestUtil.nextInt(r, 2, 4));+ logmp.setMergeFactor(_TestUtil.nextInt(r, 2, 9));} else {- logmp.setMergeFactor(_TestUtil.nextInt(r, 5, 50));+ logmp.setMergeFactor(_TestUtil.nextInt(r, 10, 50));}return logmp;}@@ -953,16 +959,24 @@ public abstract class LuceneTestCase extends Assert {public static TieredMergePolicy newTieredMergePolicy(Random r) {TieredMergePolicy tmp = new TieredMergePolicy();if (rarely(r)) {- tmp.setMaxMergeAtOnce(_TestUtil.nextInt(r, 2, 4));- tmp.setMaxMergeAtOnceExplicit(_TestUtil.nextInt(r, 2, 4));+ tmp.setMaxMergeAtOnce(_TestUtil.nextInt(r, 2, 9));+ tmp.setMaxMergeAtOnceExplicit(_TestUtil.nextInt(r, 2, 9));} else {- tmp.setMaxMergeAtOnce(_TestUtil.nextInt(r, 5, 50));- tmp.setMaxMergeAtOnceExplicit(_TestUtil.nextInt(r, 5, 50));+ tmp.setMaxMergeAtOnce(_TestUtil.nextInt(r, 10, 50));+ tmp.setMaxMergeAtOnceExplicit(_TestUtil.nextInt(r, 10, 50));+ }+ if (rarely(r)) {+ tmp.setMaxMergedSegmentMB(0.2 + r.nextDouble() * 2.0);+ } else {+ tmp.setMaxMergedSegmentMB(r.nextDouble() * 100);}- tmp.setMaxMergedSegmentMB(0.2 + r.nextDouble() * 2.0);tmp.setFloorSegmentMB(0.2 + r.nextDouble() * 2.0);tmp.setForceMergeDeletesPctAllowed(0.0 + r.nextDouble() * 30.0);- tmp.setSegmentsPerTier(_TestUtil.nextInt(r, 2, 20));+ if (rarely(r)) {+ tmp.setSegmentsPerTier(_TestUtil.nextInt(r, 2, 20));+ } else {+ tmp.setSegmentsPerTier(_TestUtil.nextInt(r, 10, 50));+ }tmp.setUseCompoundFile(r.nextBoolean());tmp.setNoCFSRatio(0.1 + r.nextDouble()*0.8);tmp.setReclaimDeletesWeight(r.nextDouble()*4);@@ -1216,7 +1230,7 @@ public abstract class LuceneTestCase extends Assert {* with one that returns null for getSequentialSubReaders.*/public static IndexSearcher newSearcher(IndexReader r, boolean maybeWrap) throws IOException {- if (random.nextBoolean()) {+ if (usually()) {if (maybeWrap && rarely()) {r = new SlowMultiReaderWrapper(r);}diff --git a/lucene/src/test/org/apache/lucene/codecs/lucene3x/TestSurrogates.java b/lucene/src/test/org/apache/lucene/codecs/lucene3x/TestSurrogates.javaindex 0de48c7eb28..65b28036ba1 100644--- a/lucene/src/test/org/apache/lucene/codecs/lucene3x/TestSurrogates.java+++ b/lucene/src/test/org/apache/lucene/codecs/lucene3x/TestSurrogates.java@@ -302,7 +302,7 @@ public class TestSurrogates extends LuceneTestCase {for(int f=0;f<numField;f++) {String field = "f" + f;- final int numTerms = atLeast(1000);+ final int numTerms = atLeast(200);final Set<String> uniqueTerms = new HashSet<String>();diff --git a/lucene/src/test/org/apache/lucene/codecs/lucene3x/TestTermInfosReaderIndex.java b/lucene/src/test/org/apache/lucene/codecs/lucene3x/TestTermInfosReaderIndex.javaindex 6bc1021dc70..79cdc95b686 100644--- a/lucene/src/test/org/apache/lucene/codecs/lucene3x/TestTermInfosReaderIndex.java+++ b/lucene/src/test/org/apache/lucene/codecs/lucene3x/TestTermInfosReaderIndex.java@@ -55,32 +55,43 @@ import org.apache.lucene.store.IndexInput;import org.apache.lucene.store.LockObtainFailedException;import org.apache.lucene.util.LuceneTestCase;import org.apache.lucene.util._TestUtil;+import org.junit.AfterClass;import org.junit.BeforeClass;public class TestTermInfosReaderIndex extends LuceneTestCase {- private static final int NUMBER_OF_DOCUMENTS = 1000;- private static final int NUMBER_OF_FIELDS = 100;- private TermInfosReaderIndex index;- private Directory directory;- private SegmentTermEnum termEnum;- private int indexDivisor;- private int termIndexInterval;- private IndexReader reader;- private List<Term> sampleTerms;+ private static int NUMBER_OF_DOCUMENTS;+ private static int NUMBER_OF_FIELDS;+ private static TermInfosReaderIndex index;+ private static Directory directory;+ private static SegmentTermEnum termEnum;+ private static int indexDivisor;+ private static int termIndexInterval;+ private static IndexReader reader;+ private static List<Term> sampleTerms;/** we will manually instantiate preflex-rw here */@BeforeClass- public static void beforeClass() {+ public static void beforeClass() throws Exception {LuceneTestCase.PREFLEX_IMPERSONATION_IS_ACTIVE = true;- }-- @Override- public void setUp() throws Exception {- super.setUp();+ IndexWriterConfig config = newIndexWriterConfig(TEST_VERSION_CURRENT,+ new MockAnalyzer(random, MockTokenizer.KEYWORD, false));++ termIndexInterval = config.getTermIndexInterval();indexDivisor = _TestUtil.nextInt(random, 1, 10);+ NUMBER_OF_DOCUMENTS = atLeast(100);+ NUMBER_OF_FIELDS = atLeast(Math.max(10, 3*termIndexInterval*indexDivisor/NUMBER_OF_DOCUMENTS));+directory = newDirectory();- termIndexInterval = populate(directory);++ config.setCodec(new PreFlexRWCodec());+ // turn off compound file, this test will open some index files directly.+ LogMergePolicy mp = newLogMergePolicy();+ mp.setUseCompoundFile(false);+ config.setMergePolicy(mp);+++ populate(directory, config);IndexReader r0 = IndexReader.open(directory);SegmentReader r = (SegmentReader) r0.getSequentialSubReaders()[0];@@ -102,15 +113,18 @@ public class TestTermInfosReaderIndex extends LuceneTestCase {reader = IndexReader.open(directory);sampleTerms = sample(reader,1000);-}- @Override- public void tearDown() throws Exception {+ @AfterClass+ public static void afterClass() throws Exception {termEnum.close();reader.close();directory.close();- super.tearDown();+ termEnum = null;+ reader = null;+ directory = null;+ index = null;+ sampleTerms = null;}public void testSeekEnum() throws CorruptIndexException, IOException {@@ -141,7 +155,7 @@ public class TestTermInfosReaderIndex extends LuceneTestCase {}}- private List<Term> sample(IndexReader reader, int size) throws IOException {+ private static List<Term> sample(IndexReader reader, int size) throws IOException {List<Term> sample = new ArrayList<Term>();Random random = new Random();FieldsEnum fieldsEnum = MultiFields.getFields(reader).iterator();@@ -166,22 +180,13 @@ public class TestTermInfosReaderIndex extends LuceneTestCase {private Term findTermThatWouldBeAtIndex(SegmentTermEnum termEnum, int index) throws IOException {int termPosition = index * termIndexInterval * indexDivisor;for (int i = 0; i < termPosition; i++) {- if (!termEnum.next()) {- fail("Should not have run out of terms.");- }+ // TODO: this test just uses random terms, so this is always possible+ assumeTrue("ran out of terms.", termEnum.next());}return termEnum.term();}- private int populate(Directory directory) throws CorruptIndexException, LockObtainFailedException, IOException {- IndexWriterConfig config = newIndexWriterConfig(TEST_VERSION_CURRENT,- new MockAnalyzer(random, MockTokenizer.KEYWORD, false));- config.setCodec(new PreFlexRWCodec());- // turn off compound file, this test will open some index files directly.- LogMergePolicy mp = newLogMergePolicy();- mp.setUseCompoundFile(false);- config.setMergePolicy(mp);-+ private static void populate(Directory directory, IndexWriterConfig config) throws CorruptIndexException, LockObtainFailedException, IOException {RandomIndexWriter writer = new RandomIndexWriter(random, directory, config);for (int i = 0; i < NUMBER_OF_DOCUMENTS; i++) {Document document = new Document();@@ -192,10 +197,9 @@ public class TestTermInfosReaderIndex extends LuceneTestCase {}writer.forceMerge(1);writer.close();- return config.getTermIndexInterval();}- private String getText() {+ private static String getText() {return Long.toString(random.nextLong(),Character.MAX_RADIX);}}diff --git a/lucene/src/test/org/apache/lucene/codecs/pulsing/Test10KPulsings.java b/lucene/src/test/org/apache/lucene/codecs/pulsing/Test10KPulsings.javaindex 50c2eb96383..47a1bd53e28 100644--- a/lucene/src/test/org/apache/lucene/codecs/pulsing/Test10KPulsings.java+++ b/lucene/src/test/org/apache/lucene/codecs/pulsing/Test10KPulsings.java@@ -47,6 +47,7 @@ import org.apache.lucene.util._TestUtil;** @lucene.experimental*/public class Test10KPulsings extends LuceneTestCase {public void test10kPulsed() throws Exception {// we always run this test with pulsing codec.diff --git a/lucene/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java b/lucene/src/test/org/apache/lucene/index/TestBackwardsCompatibility.javaindex 91392d927f7..9660b940a0f 100644--- a/lucene/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java+++ b/lucene/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java@@ -23,7 +23,9 @@ import java.io.IOException;import java.io.PrintStream;import java.util.ArrayList;import java.util.Arrays;+import java.util.HashMap;import java.util.List;+import java.util.Map;import java.util.Random;import org.apache.lucene.analysis.MockAnalyzer;@@ -52,6 +54,8 @@ import org.apache.lucene.util.BytesRef;import org.apache.lucene.util.Constants;import org.apache.lucene.util.LuceneTestCase;import org.apache.lucene.util._TestUtil;+import org.junit.AfterClass;+import org.junit.BeforeClass;/*Verify we can read the pre-4.0 file format, do searches@@ -94,7 +98,7 @@ public class TestBackwardsCompatibility extends LuceneTestCase {}*/- final String[] oldNames = {"30.cfs",+ final static String[] oldNames = {"30.cfs","30.nocfs","31.cfs","31.nocfs",@@ -120,10 +124,34 @@ public class TestBackwardsCompatibility extends LuceneTestCase {"29.nocfs",};- final String[] oldSingleSegmentNames = {"31.optimized.cfs",+ final static String[] oldSingleSegmentNames = {"31.optimized.cfs","31.optimized.nocfs",};+ static Map<String,Directory> oldIndexDirs;++ @BeforeClass+ public static void beforeClass() throws Exception {+ List<String> names = new ArrayList<String>(oldNames.length + oldSingleSegmentNames.length);+ names.addAll(Arrays.asList(oldNames));+ names.addAll(Arrays.asList(oldSingleSegmentNames));+ oldIndexDirs = new HashMap<String,Directory>();+ for (String name : names) {+ File dir = _TestUtil.getTempDir(name);+ File dataFile = new File(TestBackwardsCompatibility.class.getResource("index." + name + ".zip").toURI());+ _TestUtil.unzip(dataFile, dir);+ oldIndexDirs.put(name, newFSDirectory(dir));+ }+ }++ @AfterClass+ public static void afterClass() throws Exception {+ for (Directory d : oldIndexDirs.values()) {+ d.close();+ }+ oldIndexDirs = null;+ }+/** This test checks that *only* IndexFormatTooOldExceptions are thrown when you open and operate on too old indexes! */public void testUnsupportedOldIndexes() throws Exception {for(int i=0;i<unsupportedNames.length;i++) {@@ -183,48 +211,35 @@ public class TestBackwardsCompatibility extends LuceneTestCase {}public void testFullyMergeOldIndex() throws Exception {- for(int i=0;i<oldNames.length;i++) {+ for (String name : oldNames) {if (VERBOSE) {- System.out.println("\nTEST: index=" + oldNames[i]);+ System.out.println("\nTEST: index=" + name);}- File oldIndxeDir = _TestUtil.getTempDir(oldNames[i]);- _TestUtil.unzip(getDataFile("index." + oldNames[i] + ".zip"), oldIndxeDir);- Directory dir = newFSDirectory(oldIndxeDir);-+ Directory dir = newDirectory(oldIndexDirs.get(name));IndexWriter w = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)));w.forceMerge(1);w.close();dir.close();- _TestUtil.rmDir(oldIndxeDir);}}public void testAddOldIndexes() throws IOException {for (String name : oldNames) {- File oldIndxeDir = _TestUtil.getTempDir(name);- _TestUtil.unzip(getDataFile("index." + name + ".zip"), oldIndxeDir);- Directory dir = newFSDirectory(oldIndxeDir);-Directory targetDir = newDirectory();IndexWriter w = new IndexWriter(targetDir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)));- w.addIndexes(dir);+ w.addIndexes(oldIndexDirs.get(name));w.close();- dir.close();targetDir.close();- _TestUtil.rmDir(oldIndxeDir);}}public void testAddOldIndexesReader() throws IOException {for (String name : oldNames) {- File oldIndxeDir = _TestUtil.getTempDir(name);- _TestUtil.unzip(getDataFile("index." + name + ".zip"), oldIndxeDir);- Directory dir = newFSDirectory(oldIndxeDir);- IndexReader reader = IndexReader.open(dir);+ IndexReader reader = IndexReader.open(oldIndexDirs.get(name));Directory targetDir = newDirectory();IndexWriter w = new IndexWriter(targetDir, newIndexWriterConfig(@@ -233,39 +248,32 @@ public class TestBackwardsCompatibility extends LuceneTestCase {w.close();reader.close();- dir.close();targetDir.close();- _TestUtil.rmDir(oldIndxeDir);}}public void testSearchOldIndex() throws IOException {- for(int i=0;i<oldNames.length;i++) {- File oldIndxeDir = _TestUtil.getTempDir(oldNames[i]);- _TestUtil.unzip(getDataFile("index." + oldNames[i] + ".zip"), oldIndxeDir);- searchIndex(oldIndxeDir, oldNames[i]);- _TestUtil.rmDir(oldIndxeDir);+ for (String name : oldNames) {+ searchIndex(oldIndexDirs.get(name), name);}}public void testIndexOldIndexNoAdds() throws IOException {- for(int i=0;i<oldNames.length;i++) {- File oldIndxeDir = _TestUtil.getTempDir(oldNames[i]);- _TestUtil.unzip(getDataFile("index." + oldNames[i] + ".zip"), oldIndxeDir);- changeIndexNoAdds(random, oldIndxeDir);- _TestUtil.rmDir(oldIndxeDir);+ for (String name : oldNames) {+ Directory dir = newDirectory(oldIndexDirs.get(name));+ changeIndexNoAdds(random, dir);+ dir.close();}}public void testIndexOldIndex() throws IOException {- for(int i=0;i<oldNames.length;i++) {+ for (String name : oldNames) {if (VERBOSE) {- System.out.println("TEST: oldName=" + oldNames[i]);+ System.out.println("TEST: oldName=" + name);}- File oldIndxeDir = _TestUtil.getTempDir(oldNames[i]);- _TestUtil.unzip(getDataFile("index." + oldNames[i] + ".zip"), oldIndxeDir);- changeIndexWithAdds(random, oldIndxeDir, oldNames[i]);- _TestUtil.rmDir(oldIndxeDir);+ Directory dir = newDirectory(oldIndexDirs.get(name));+ changeIndexWithAdds(random, dir, name);+ dir.close();}}@@ -278,11 +286,10 @@ public class TestBackwardsCompatibility extends LuceneTestCase {}}- public void searchIndex(File indexDir, String oldName) throws IOException {+ public void searchIndex(Directory dir, String oldName) throws IOException {//QueryParser parser = new QueryParser("contents", new MockAnalyzer(random));//Query query = parser.parse("handle:1");- Directory dir = newFSDirectory(indexDir);IndexReader reader = IndexReader.open(dir);IndexSearcher searcher = new IndexSearcher(reader);@@ -314,7 +321,7 @@ public class TestBackwardsCompatibility extends LuceneTestCase {}Terms tfv = reader.getTermVectors(i).terms("utf8");- assertNotNull("docID=" + i + " index=" + indexDir.getName(), tfv);+ assertNotNull("docID=" + i + " index=" + oldName, tfv);} else// Only ID 7 is deletedassertEquals(7, i);@@ -337,7 +344,6 @@ public class TestBackwardsCompatibility extends LuceneTestCase {assertEquals(34, hits.length);reader.close();- dir.close();}private int compare(String name, String v) {@@ -346,9 +352,7 @@ public class TestBackwardsCompatibility extends LuceneTestCase {return v0 - v1;}- public void changeIndexWithAdds(Random random, File oldIndexDir, String origOldName) throws IOException {-- Directory dir = newFSDirectory(oldIndexDir);+ public void changeIndexWithAdds(Random random, Directory dir, String origOldName) throws IOException {// open writerIndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)).setOpenMode(OpenMode.APPEND));// add 10 docs@@ -388,14 +392,9 @@ public class TestBackwardsCompatibility extends LuceneTestCase {doTestHits(hits, 44, searcher.getIndexReader());assertEquals("wrong first document", "21", d.get("id"));reader.close();-- dir.close();}- public void changeIndexNoAdds(Random random, File oldIndexDir) throws IOException {-- Directory dir = newFSDirectory(oldIndexDir);-+ public void changeIndexNoAdds(Random random, Directory dir) throws IOException {// make sure searching sees right # hitsIndexReader reader = IndexReader.open(dir);IndexSearcher searcher = new IndexSearcher(reader);@@ -416,8 +415,6 @@ public class TestBackwardsCompatibility extends LuceneTestCase {assertEquals("wrong number of hits", 34, hits.length);doTestHits(hits, 34, searcher.getIndexReader());reader.close();-- dir.close();}public File createIndex(String dirName, boolean doCFS, boolean fullyMerged) throws IOException {@@ -576,10 +573,8 @@ public class TestBackwardsCompatibility extends LuceneTestCase {// flex: test basics of TermsEnum api on non-flex indexpublic void testNextIntoWrongField() throws Exception {- for(int i=0;i<oldNames.length;i++) {- File oldIndexDir = _TestUtil.getTempDir(oldNames[i]);- _TestUtil.unzip(getDataFile("index." + oldNames[i] + ".zip"), oldIndexDir);- Directory dir = newFSDirectory(oldIndexDir);+ for (String name : oldNames) {+ Directory dir = oldIndexDirs.get(name);IndexReader r = IndexReader.open(dir);TermsEnum terms = MultiFields.getFields(r).terms("content").iterator(null);BytesRef t = terms.next();@@ -615,17 +610,13 @@ public class TestBackwardsCompatibility extends LuceneTestCase {assertNull(terms.next());r.close();- dir.close();- _TestUtil.rmDir(oldIndexDir);}}public void testNumericFields() throws Exception {- for(int i=0;i<oldNames.length;i++) {+ for (String name : oldNames) {- File oldIndexDir = _TestUtil.getTempDir(oldNames[i]);- _TestUtil.unzip(getDataFile("index." + oldNames[i] + ".zip"), oldIndexDir);- Directory dir = newFSDirectory(oldIndexDir);+ Directory dir = oldIndexDirs.get(name);IndexReader reader = IndexReader.open(dir);IndexSearcher searcher = new IndexSearcher(reader);@@ -660,8 +651,6 @@ public class TestBackwardsCompatibility extends LuceneTestCase {}reader.close();- dir.close();- _TestUtil.rmDir(oldIndexDir);}}@@ -691,9 +680,7 @@ public class TestBackwardsCompatibility extends LuceneTestCase {if (VERBOSE) {System.out.println("testUpgradeOldIndex: index=" +name);}- File oldIndxeDir = _TestUtil.getTempDir(name);- _TestUtil.unzip(getDataFile("index." + name + ".zip"), oldIndxeDir);- Directory dir = newFSDirectory(oldIndxeDir);+ Directory dir = newDirectory(oldIndexDirs.get(name));new IndexUpgrader(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, null), false).upgrade();@@ -701,7 +688,6 @@ public class TestBackwardsCompatibility extends LuceneTestCase {checkAllSegmentsUpgraded(dir);dir.close();- _TestUtil.rmDir(oldIndxeDir);}}@@ -710,9 +696,7 @@ public class TestBackwardsCompatibility extends LuceneTestCase {if (VERBOSE) {System.out.println("testUpgradeOldSingleSegmentIndexWithAdditions: index=" +name);}- File oldIndxeDir = _TestUtil.getTempDir(name);- _TestUtil.unzip(getDataFile("index." + name + ".zip"), oldIndxeDir);- Directory dir = newFSDirectory(oldIndxeDir);+ Directory dir = newDirectory(oldIndexDirs.get(name));assertEquals("Original index must be single segment", 1, getNumberOfSegments(dir));@@ -752,7 +736,6 @@ public class TestBackwardsCompatibility extends LuceneTestCase {origSegCount, segCount);dir.close();- _TestUtil.rmDir(oldIndxeDir);}}diff --git a/lucene/src/test/org/apache/lucene/index/TestCompoundFile.java b/lucene/src/test/org/apache/lucene/index/TestCompoundFile.javaindex a8422ba2116..7dca18e31ac 100644--- a/lucene/src/test/org/apache/lucene/index/TestCompoundFile.java+++ b/lucene/src/test/org/apache/lucene/index/TestCompoundFile.java@@ -773,7 +773,7 @@ public class TestCompoundFile extends LuceneTestCasepublic void testManySubFiles() throws IOException {final Directory d = newFSDirectory(_TestUtil.getTempDir("CFSManySubFiles"));- final int FILE_COUNT = 10000;+ final int FILE_COUNT = atLeast(500);for(int fileIdx=0;fileIdx<FILE_COUNT;fileIdx++) {IndexOutput out = d.createOutput("file." + fileIdx, newIOContext(random));diff --git a/lucene/src/test/org/apache/lucene/index/TestDuelingCodecs.java b/lucene/src/test/org/apache/lucene/index/TestDuelingCodecs.javaindex 7e456182e17..dead4d55412 100644--- a/lucene/src/test/org/apache/lucene/index/TestDuelingCodecs.java+++ b/lucene/src/test/org/apache/lucene/index/TestDuelingCodecs.java@@ -92,7 +92,7 @@ public class TestDuelingCodecs extends LuceneTestCase {RandomIndexWriter leftWriter = new RandomIndexWriter(new Random(seed), leftDir, leftConfig);RandomIndexWriter rightWriter = new RandomIndexWriter(new Random(seed), rightDir, rightConfig);- int numdocs = atLeast(500);+ int numdocs = atLeast(100);createRandomIndex(numdocs, leftWriter, seed);createRandomIndex(numdocs, rightWriter, seed);@@ -134,7 +134,7 @@ public class TestDuelingCodecs extends LuceneTestCase {*/public void testEquals() throws Exception {assertReaderStatistics(leftReader, rightReader);- assertFields(MultiFields.getFields(leftReader), MultiFields.getFields(rightReader));+ assertFields(MultiFields.getFields(leftReader), MultiFields.getFields(rightReader), true);assertNorms(leftReader, rightReader);assertStoredFields(leftReader, rightReader);assertTermVectors(leftReader, rightReader);@@ -160,7 +160,7 @@ public class TestDuelingCodecs extends LuceneTestCase {/*** Fields api equivalency*/- public void assertFields(Fields leftFields, Fields rightFields) throws Exception {+ public void assertFields(Fields leftFields, Fields rightFields, boolean deep) throws Exception {// Fields could be null if there are no postings,// but then it must be null for bothif (leftFields == null || rightFields == null) {@@ -176,7 +176,7 @@ public class TestDuelingCodecs extends LuceneTestCase {String field;while ((field = leftEnum.next()) != null) {assertEquals(info, field, rightEnum.next());- assertTerms(leftEnum.terms(), rightEnum.terms());+ assertTerms(leftEnum.terms(), rightEnum.terms(), deep);}assertNull(rightEnum.next());}@@ -197,7 +197,7 @@ public class TestDuelingCodecs extends LuceneTestCase {/*** Terms api equivalency*/- public void assertTerms(Terms leftTerms, Terms rightTerms) throws Exception {+ public void assertTerms(Terms leftTerms, Terms rightTerms, boolean deep) throws Exception {if (leftTerms == null || rightTerms == null) {assertNull(info, leftTerms);assertNull(info, rightTerms);@@ -210,15 +210,17 @@ public class TestDuelingCodecs extends LuceneTestCase {assertTermsEnum(leftTermsEnum, rightTermsEnum, true);// TODO: test seeking too- int numIntersections = atLeast(3);- for (int i = 0; i < numIntersections; i++) {- String re = AutomatonTestUtil.randomRegexp(random);- CompiledAutomaton automaton = new CompiledAutomaton(new RegExp(re, RegExp.NONE).toAutomaton());- if (automaton.type == CompiledAutomaton.AUTOMATON_TYPE.NORMAL) {- // TODO: test start term too- TermsEnum leftIntersection = leftTerms.intersect(automaton, null);- TermsEnum rightIntersection = rightTerms.intersect(automaton, null);- assertTermsEnum(leftIntersection, rightIntersection, rarely());+ if (deep) {+ int numIntersections = atLeast(3);+ for (int i = 0; i < numIntersections; i++) {+ String re = AutomatonTestUtil.randomRegexp(random);+ CompiledAutomaton automaton = new CompiledAutomaton(new RegExp(re, RegExp.NONE).toAutomaton());+ if (automaton.type == CompiledAutomaton.AUTOMATON_TYPE.NORMAL) {+ // TODO: test start term too+ TermsEnum leftIntersection = leftTerms.intersect(automaton, null);+ TermsEnum rightIntersection = rightTerms.intersect(automaton, null);+ assertTermsEnum(leftIntersection, rightIntersection, rarely());+ }}}}@@ -511,7 +513,7 @@ public class TestDuelingCodecs extends LuceneTestCase {for (int i = 0; i < leftReader.maxDoc(); i++) {Fields leftFields = leftReader.getTermVectors(i);Fields rightFields = rightReader.getTermVectors(i);- assertFields(leftFields, rightFields);+ assertFields(leftFields, rightFields, rarely());}}diff --git a/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java b/lucene/src/test/org/apache/lucene/index/TestIndexWriter.javaindex d24fdabc12e..1ca7ee697dc 100644--- a/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java+++ b/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java@@ -416,7 +416,8 @@ public class TestIndexWriter extends LuceneTestCase {public void testDiverseDocs() throws IOException {MockDirectoryWrapper dir = newDirectory();IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random)).setRAMBufferSizeMB(0.5));- for(int i=0;i<3;i++) {+ int n = atLeast(1);+ for(int i=0;i<n;i++) {// First, docs where every term is unique (heavy on// Posting instances)for(int j=0;j<100;j++) {@@ -455,7 +456,7 @@ public class TestIndexWriter extends LuceneTestCase {IndexReader reader = IndexReader.open(dir);IndexSearcher searcher = new IndexSearcher(reader);ScoreDoc[] hits = searcher.search(new TermQuery(new Term("field", "aaa")), null, 1000).scoreDocs;- assertEquals(300, hits.length);+ assertEquals(n*100, hits.length);reader.close();dir.close();@@ -737,104 +738,6 @@ public class TestIndexWriter extends LuceneTestCase {dir.close();}- public void testNoWaitClose() throws Throwable {- Directory directory = newDirectory();-- final Document doc = new Document();- FieldType customType = new FieldType(TextField.TYPE_STORED);- customType.setTokenized(false);-- Field idField = newField("id", "", customType);- doc.add(idField);-- for(int pass=0;pass<2;pass++) {- if (VERBOSE) {- System.out.println("TEST: pass=" + pass);- }-- IndexWriterConfig conf = newIndexWriterConfig(- TEST_VERSION_CURRENT, new MockAnalyzer(random)).- setOpenMode(OpenMode.CREATE).- setMaxBufferedDocs(2).- setMergePolicy(newLogMergePolicy());- if (pass == 2) {- conf.setMergeScheduler(new SerialMergeScheduler());- }-- IndexWriter writer = new IndexWriter(directory, conf);- ((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(100);-- for(int iter=0;iter<10;iter++) {- if (VERBOSE) {- System.out.println("TEST: iter=" + iter);- }- for(int j=0;j<199;j++) {- idField.setValue(Integer.toString(iter*201+j));- writer.addDocument(doc);- }-- int delID = iter*199;- for(int j=0;j<20;j++) {- writer.deleteDocuments(new Term("id", Integer.toString(delID)));- delID += 5;- }-- // Force a bunch of merge threads to kick off so we- // stress out aborting them on close:- ((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(2);-- final IndexWriter finalWriter = writer;- final ArrayList<Throwable> failure = new ArrayList<Throwable>();- Thread t1 = new Thread() {- @Override- public void run() {- boolean done = false;- while(!done) {- for(int i=0;i<100;i++) {- try {- finalWriter.addDocument(doc);- } catch (AlreadyClosedException e) {- done = true;- break;- } catch (NullPointerException e) {- done = true;- break;- } catch (Throwable e) {- e.printStackTrace(System.out);- failure.add(e);- done = true;- break;- }- }- Thread.yield();- }-- }- };-- if (failure.size() > 0) {- throw failure.get(0);- }-- t1.start();-- writer.close(false);- t1.join();-- // Make sure reader can read- IndexReader reader = IndexReader.open(directory);- reader.close();-- // Reopen- writer = new IndexWriter(directory, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random)).setOpenMode(OpenMode.APPEND).setMergePolicy(newLogMergePolicy()));- }- writer.close();- }-- directory.close();- }--// LUCENE-1084: test unlimited field lengthpublic void testUnlimitedMaxFieldLength() throws IOException {Directory dir = newDirectory();@@ -1613,102 +1516,6 @@ public class TestIndexWriter extends LuceneTestCase {dir.close();}- public void testRandomStoredFields() throws IOException {- Directory dir = newDirectory();- Random rand = random;- RandomIndexWriter w = new RandomIndexWriter(rand, dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)).setMaxBufferedDocs(_TestUtil.nextInt(rand, 5, 20)));- //w.w.setUseCompoundFile(false);- final int docCount = atLeast(200);- final int fieldCount = _TestUtil.nextInt(rand, 1, 5);-- final List<Integer> fieldIDs = new ArrayList<Integer>();-- FieldType customType = new FieldType(TextField.TYPE_STORED);- customType.setTokenized(false);- Field idField = newField("id", "", customType);-- for(int i=0;i<fieldCount;i++) {- fieldIDs.add(i);- }-- final Map<String,Document> docs = new HashMap<String,Document>();-- if (VERBOSE) {- System.out.println("TEST: build index docCount=" + docCount);- }-- FieldType customType2 = new FieldType();- customType2.setStored(true);- for(int i=0;i<docCount;i++) {- Document doc = new Document();- doc.add(idField);- final String id = ""+i;- idField.setValue(id);- docs.put(id, doc);- if (VERBOSE) {- System.out.println("TEST: add doc id=" + id);- }-- for(int field: fieldIDs) {- final String s;- if (rand.nextInt(4) != 3) {- s = _TestUtil.randomUnicodeString(rand, 1000);- doc.add(newField("f"+field, s, customType2));- } else {- s = null;- }- }- w.addDocument(doc);- if (rand.nextInt(50) == 17) {- // mixup binding of field name -> Number every so often- Collections.shuffle(fieldIDs);- }- if (rand.nextInt(5) == 3 && i > 0) {- final String delID = ""+rand.nextInt(i);- if (VERBOSE) {- System.out.println("TEST: delete doc id=" + delID);- }- w.deleteDocuments(new Term("id", delID));- docs.remove(delID);- }- }-- if (VERBOSE) {- System.out.println("TEST: " + docs.size() + " docs in index; now load fields");- }- if (docs.size() > 0) {- String[] idsList = docs.keySet().toArray(new String[docs.size()]);-- for(int x=0;x<2;x++) {- IndexReader r = w.getReader();- IndexSearcher s = newSearcher(r);-- if (VERBOSE) {- System.out.println("TEST: cycle x=" + x + " r=" + r);- }-- int num = atLeast(1000);- for(int iter=0;iter<num;iter++) {- String testID = idsList[rand.nextInt(idsList.length)];- if (VERBOSE) {- System.out.println("TEST: test id=" + testID);- }- TopDocs hits = s.search(new TermQuery(new Term("id", testID)), 1);- assertEquals(1, hits.totalHits);- Document doc = r.document(hits.scoreDocs[0].doc);- Document docExp = docs.get(testID);- for(int i=0;i<fieldCount;i++) {- assertEquals("doc " + testID + ", field f" + fieldCount + " is wrong", docExp.get("f"+i), doc.get("f"+i));- }- }- r.close();- w.forceMerge(1);- }- }- w.close();- dir.close();- }-public void testNoUnwantedTVFiles() throws Exception {Directory dir = newDirectory();@@ -1952,7 +1759,7 @@ public class TestIndexWriter extends LuceneTestCase {RandomIndexWriter w1 = new RandomIndexWriter(random, d);w1.deleteAll();try {- new RandomIndexWriter(random, d);+ new RandomIndexWriter(random, d, newIndexWriterConfig(TEST_VERSION_CURRENT, null).setWriteLockTimeout(100));fail("should not be able to create another writer");} catch (LockObtainFailedException lofe) {// expecteddiff --git a/lucene/src/test/org/apache/lucene/index/TestIndexWriterDelete.java b/lucene/src/test/org/apache/lucene/index/TestIndexWriterDelete.javaindex b901f74ec9c..8a4c5313890 100644--- a/lucene/src/test/org/apache/lucene/index/TestIndexWriterDelete.java+++ b/lucene/src/test/org/apache/lucene/index/TestIndexWriterDelete.java@@ -945,7 +945,7 @@ public class TestIndexWriterDelete extends LuceneTestCase {// note: tiny rambuffer used, as with a 1MB buffer the test is too slow (flush @ 128,999)IndexWriter w = new IndexWriter(dir,newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random))- .setRAMBufferSizeMB(0.2f).setMaxBufferedDocs(1000).setMergePolicy(NoMergePolicy.NO_COMPOUND_FILES).setReaderPooling(false));+ .setRAMBufferSizeMB(0.1f).setMaxBufferedDocs(1000).setMergePolicy(NoMergePolicy.NO_COMPOUND_FILES).setReaderPooling(false));int count = 0;while(true) {Document doc = new Document();@@ -1020,6 +1020,7 @@ public class TestIndexWriterDelete extends LuceneTestCase {// Make sure buffered (pushed) deletes don't use up so// much RAM that it forces long tail of tiny segments:+ @Nightlypublic void testApplyDeletesOnFlush() throws Exception {Directory dir = newDirectory();// Cannot use RandomIndexWriter because we don't want todiff --git a/lucene/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java b/lucene/src/test/org/apache/lucene/index/TestIndexWriterExceptions.javaindex 9d3670deacc..04bc77a94e8 100644--- a/lucene/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java+++ b/lucene/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java@@ -936,7 +936,7 @@ public class TestIndexWriterExceptions extends LuceneTestCase {addDoc(w);w.close();- int iter = TEST_NIGHTLY ? 200 : 20;+ int iter = TEST_NIGHTLY ? 200 : 10;for(int i=0;i<iter;i++) {if (VERBOSE) {System.out.println("TEST: iter " + i);@@ -1233,7 +1233,7 @@ public class TestIndexWriterExceptions extends LuceneTestCase {FailOnTermVectors[] failures = new FailOnTermVectors[] {new FailOnTermVectors(FailOnTermVectors.AFTER_INIT_STAGE),new FailOnTermVectors(FailOnTermVectors.INIT_STAGE), };- int num = atLeast(3);+ int num = atLeast(1);for (int j = 0; j < num; j++) {for (FailOnTermVectors failure : failures) {MockDirectoryWrapper dir = newDirectory();diff --git a/lucene/src/test/org/apache/lucene/index/TestIndexWriterMerging.java b/lucene/src/test/org/apache/lucene/index/TestIndexWriterMerging.javaindex 7e331c9439f..8e9eb93f3c7 100644--- a/lucene/src/test/org/apache/lucene/index/TestIndexWriterMerging.java+++ b/lucene/src/test/org/apache/lucene/index/TestIndexWriterMerging.java@@ -15,6 +15,7 @@ package org.apache.lucene.index;* limitations under the License.*/+import org.apache.lucene.store.AlreadyClosedException;import org.apache.lucene.store.Directory;import org.apache.lucene.analysis.MockAnalyzer;import org.apache.lucene.document.Document;@@ -26,6 +27,7 @@ import org.apache.lucene.index.IndexWriterConfig.OpenMode;import org.apache.lucene.util.LuceneTestCase;import java.io.IOException;+import java.util.ArrayList;import java.util.Random;@@ -350,4 +352,101 @@ public class TestIndexWriterMerging extends LuceneTestCaseiw.close();dir.close();}++ public void testNoWaitClose() throws Throwable {+ Directory directory = newDirectory();++ final Document doc = new Document();+ FieldType customType = new FieldType(TextField.TYPE_STORED);+ customType.setTokenized(false);++ Field idField = newField("id", "", customType);+ doc.add(idField);++ for(int pass=0;pass<2;pass++) {+ if (VERBOSE) {+ System.out.println("TEST: pass=" + pass);+ }++ IndexWriterConfig conf = newIndexWriterConfig(+ TEST_VERSION_CURRENT, new MockAnalyzer(random)).+ setOpenMode(OpenMode.CREATE).+ setMaxBufferedDocs(2).+ setMergePolicy(newLogMergePolicy());+ if (pass == 2) {+ conf.setMergeScheduler(new SerialMergeScheduler());+ }++ IndexWriter writer = new IndexWriter(directory, conf);+ ((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(100);++ for(int iter=0;iter<10;iter++) {+ if (VERBOSE) {+ System.out.println("TEST: iter=" + iter);+ }+ for(int j=0;j<199;j++) {+ idField.setValue(Integer.toString(iter*201+j));+ writer.addDocument(doc);+ }++ int delID = iter*199;+ for(int j=0;j<20;j++) {+ writer.deleteDocuments(new Term("id", Integer.toString(delID)));+ delID += 5;+ }++ // Force a bunch of merge threads to kick off so we+ // stress out aborting them on close:+ ((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(2);++ final IndexWriter finalWriter = writer;+ final ArrayList<Throwable> failure = new ArrayList<Throwable>();+ Thread t1 = new Thread() {+ @Override+ public void run() {+ boolean done = false;+ while(!done) {+ for(int i=0;i<100;i++) {+ try {+ finalWriter.addDocument(doc);+ } catch (AlreadyClosedException e) {+ done = true;+ break;+ } catch (NullPointerException e) {+ done = true;+ break;+ } catch (Throwable e) {+ e.printStackTrace(System.out);+ failure.add(e);+ done = true;+ break;+ }+ }+ Thread.yield();+ }++ }+ };++ if (failure.size() > 0) {+ throw failure.get(0);+ }++ t1.start();++ writer.close(false);+ t1.join();++ // Make sure reader can read+ IndexReader reader = IndexReader.open(directory);+ reader.close();++ // Reopen+ writer = new IndexWriter(directory, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random)).setOpenMode(OpenMode.APPEND).setMergePolicy(newLogMergePolicy()));+ }+ writer.close();+ }++ directory.close();+ }}diff --git a/lucene/src/test/org/apache/lucene/index/TestRandomStoredFields.java b/lucene/src/test/org/apache/lucene/index/TestRandomStoredFields.javanew file mode 100644index 00000000000..9e92d9cf60c--- /dev/null+++ b/lucene/src/test/org/apache/lucene/index/TestRandomStoredFields.java@@ -0,0 +1,137 @@+package org.apache.lucene.index;++/**+ * Licensed to the Apache Software Foundation (ASF) under one or more+ * contributor license agreements. See the NOTICE file distributed with+ * this work for additional information regarding copyright ownership.+ * The ASF licenses this file to You under the Apache License, Version 2.0+ * (the "License"); you may not use this file except in compliance with+ * the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import java.io.IOException;+import java.util.ArrayList;+import java.util.Collections;+import java.util.HashMap;+import java.util.List;+import java.util.Map;+import java.util.Random;++import org.apache.lucene.analysis.MockAnalyzer;+import org.apache.lucene.document.Document;+import org.apache.lucene.document.Field;+import org.apache.lucene.document.FieldType;+import org.apache.lucene.document.TextField;+import org.apache.lucene.search.IndexSearcher;+import org.apache.lucene.search.TermQuery;+import org.apache.lucene.search.TopDocs;+import org.apache.lucene.store.Directory;+import org.apache.lucene.util.LuceneTestCase;+import org.apache.lucene.util._TestUtil;++public class TestRandomStoredFields extends LuceneTestCase {++ public void testRandomStoredFields() throws IOException {+ Directory dir = newDirectory();+ Random rand = random;+ RandomIndexWriter w = new RandomIndexWriter(rand, dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)).setMaxBufferedDocs(_TestUtil.nextInt(rand, 5, 20)));+ //w.w.setUseCompoundFile(false);+ final int docCount = atLeast(200);+ final int fieldCount = _TestUtil.nextInt(rand, 1, 5);++ final List<Integer> fieldIDs = new ArrayList<Integer>();++ FieldType customType = new FieldType(TextField.TYPE_STORED);+ customType.setTokenized(false);+ Field idField = newField("id", "", customType);++ for(int i=0;i<fieldCount;i++) {+ fieldIDs.add(i);+ }++ final Map<String,Document> docs = new HashMap<String,Document>();++ if (VERBOSE) {+ System.out.println("TEST: build index docCount=" + docCount);+ }++ FieldType customType2 = new FieldType();+ customType2.setStored(true);+ for(int i=0;i<docCount;i++) {+ Document doc = new Document();+ doc.add(idField);+ final String id = ""+i;+ idField.setValue(id);+ docs.put(id, doc);+ if (VERBOSE) {+ System.out.println("TEST: add doc id=" + id);+ }++ for(int field: fieldIDs) {+ final String s;+ if (rand.nextInt(4) != 3) {+ s = _TestUtil.randomUnicodeString(rand, 1000);+ doc.add(newField("f"+field, s, customType2));+ } else {+ s = null;+ }+ }+ w.addDocument(doc);+ if (rand.nextInt(50) == 17) {+ // mixup binding of field name -> Number every so often+ Collections.shuffle(fieldIDs);+ }+ if (rand.nextInt(5) == 3 && i > 0) {+ final String delID = ""+rand.nextInt(i);+ if (VERBOSE) {+ System.out.println("TEST: delete doc id=" + delID);+ }+ w.deleteDocuments(new Term("id", delID));+ docs.remove(delID);+ }+ }++ if (VERBOSE) {+ System.out.println("TEST: " + docs.size() + " docs in index; now load fields");+ }+ if (docs.size() > 0) {+ String[] idsList = docs.keySet().toArray(new String[docs.size()]);++ for(int x=0;x<2;x++) {+ IndexReader r = w.getReader();+ IndexSearcher s = newSearcher(r);++ if (VERBOSE) {+ System.out.println("TEST: cycle x=" + x + " r=" + r);+ }++ int num = atLeast(1000);+ for(int iter=0;iter<num;iter++) {+ String testID = idsList[rand.nextInt(idsList.length)];+ if (VERBOSE) {+ System.out.println("TEST: test id=" + testID);+ }+ TopDocs hits = s.search(new TermQuery(new Term("id", testID)), 1);+ assertEquals(1, hits.totalHits);+ Document doc = r.document(hits.scoreDocs[0].doc);+ Document docExp = docs.get(testID);+ for(int i=0;i<fieldCount;i++) {+ assertEquals("doc " + testID + ", field f" + fieldCount + " is wrong", docExp.get("f"+i), doc.get("f"+i));+ }+ }+ r.close();+ w.forceMerge(1);+ }+ }+ w.close();+ dir.close();+ }+}diff --git a/lucene/src/test/org/apache/lucene/index/TestStressNRT.java b/lucene/src/test/org/apache/lucene/index/TestStressNRT.javaindex 3726b98d2c7..ce4f01a7140 100644--- a/lucene/src/test/org/apache/lucene/index/TestStressNRT.java+++ b/lucene/src/test/org/apache/lucene/index/TestStressNRT.java@@ -77,7 +77,7 @@ public class TestStressNRT extends LuceneTestCase {final boolean tombstones = random.nextBoolean();// query variables- final AtomicLong operations = new AtomicLong(atLeast(50000)); // number of query operations to perform in total+ final AtomicLong operations = new AtomicLong(atLeast(10000)); // number of query operations to perform in totalfinal int nReadThreads = _TestUtil.nextInt(random, 1, TEST_NIGHTLY ? 10 : 5);initModel(ndocs);diff --git a/lucene/src/test/org/apache/lucene/search/TestFieldCache.java b/lucene/src/test/org/apache/lucene/search/TestFieldCache.javaindex 941613db49d..9f5d4c28a47 100644--- a/lucene/src/test/org/apache/lucene/search/TestFieldCache.java+++ b/lucene/src/test/org/apache/lucene/search/TestFieldCache.java@@ -37,19 +37,20 @@ import org.apache.lucene.util.Bits;import org.apache.lucene.util.BytesRef;import org.apache.lucene.util.LuceneTestCase;import org.apache.lucene.util._TestUtil;+import org.junit.AfterClass;+import org.junit.BeforeClass;public class TestFieldCache extends LuceneTestCase {- protected IndexReader reader;- private int NUM_DOCS;- private int NUM_ORDS;- private String[] unicodeStrings;- private BytesRef[][] multiValued;- private Directory directory;-- @Override- public void setUp() throws Exception {- super.setUp();- NUM_DOCS = atLeast(1000);+ private static IndexReader reader;+ private static int NUM_DOCS;+ private static int NUM_ORDS;+ private static String[] unicodeStrings;+ private static BytesRef[][] multiValued;+ private static Directory directory;++ @BeforeClass+ public static void beforeClass() throws Exception {+ NUM_DOCS = atLeast(500);NUM_ORDS = atLeast(2);directory = newDirectory();RandomIndexWriter writer= new RandomIndexWriter(random, directory, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)).setMergePolicy(newLogMergePolicy()));@@ -101,11 +102,14 @@ public class TestFieldCache extends LuceneTestCase {writer.close();}- @Override- public void tearDown() throws Exception {+ @AfterClass+ public static void afterClass() throws Exception {reader.close();+ reader = null;directory.close();- super.tearDown();+ directory = null;+ unicodeStrings = null;+ multiValued = null;}public void testInfoStream() throws Exception {@@ -296,7 +300,7 @@ public class TestFieldCache extends LuceneTestCase {dir.close();}- private String generateString(int i) {+ private static String generateString(int i) {String s = null;if (i > 0 && random.nextInt(3) == 1) {// reuse past string -- try to find one that's not nulldiff --git a/lucene/src/test/org/apache/lucene/search/TestShardSearching.java b/lucene/src/test/org/apache/lucene/search/TestShardSearching.javaindex 73bb793c67e..bcae25b4b93 100644--- a/lucene/src/test/org/apache/lucene/search/TestShardSearching.java+++ b/lucene/src/test/org/apache/lucene/search/TestShardSearching.java@@ -66,11 +66,11 @@ public class TestShardSearching extends ShardSearchingTestBase {public void testSimple() throws Exception {final int numNodes = _TestUtil.nextInt(random, 1, 10);- final double runTimeSec = atLeast(5) * RANDOM_MULTIPLIER;+ final double runTimeSec = atLeast(3);final int minDocsToMakeTerms = _TestUtil.nextInt(random, 5, 20);- final int maxSearcherAgeSeconds = _TestUtil.nextInt(random, 1, 4);+ final int maxSearcherAgeSeconds = _TestUtil.nextInt(random, 1, 3);if (VERBOSE) {System.out.println("TEST: numNodes=" + numNodes + " runTimeSec=" + runTimeSec + " maxSearcherAgeSeconds=" + maxSearcherAgeSeconds);diff --git a/lucene/src/test/org/apache/lucene/search/TestSort.java b/lucene/src/test/org/apache/lucene/search/TestSort.javaindex ce1a5d5feb5..37851037bd8 100644--- a/lucene/src/test/org/apache/lucene/search/TestSort.java+++ b/lucene/src/test/org/apache/lucene/search/TestSort.java@@ -80,7 +80,7 @@ public class TestSort extends LuceneTestCase {@BeforeClasspublic static void beforeClass() throws Exception {- NUM_STRINGS = atLeast(6000);+ NUM_STRINGS = atLeast(500);}// document data:@@ -204,8 +204,7 @@ public class TestSort extends LuceneTestCase {dirs.add(indexStore);IndexWriter writer = new IndexWriter(indexStore,- new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)).- setMaxBufferedDocs(4).+ newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)).setMergePolicy(newLogMergePolicy(97)));FieldType onlyStored = new FieldType();diff --git a/lucene/src/test/org/apache/lucene/search/TestTermVectors.java b/lucene/src/test/org/apache/lucene/search/TestTermVectors.javaindex e35e688b460..8d5a9780e3b 100644--- a/lucene/src/test/org/apache/lucene/search/TestTermVectors.java+++ b/lucene/src/test/org/apache/lucene/search/TestTermVectors.java@@ -36,15 +36,16 @@ import org.apache.lucene.util.English;import org.apache.lucene.util.IOUtils;import org.apache.lucene.util.LuceneTestCase;import org.apache.lucene.util._TestUtil;+import org.junit.AfterClass;+import org.junit.BeforeClass;public class TestTermVectors extends LuceneTestCase {- private IndexSearcher searcher;- private IndexReader reader;- private Directory directory;+ private static IndexSearcher searcher;+ private static IndexReader reader;+ private static Directory directory;- @Override- public void setUp() throws Exception {- super.setUp();+ @BeforeClass+ public static void beforeClass() throws Exception {directory = newDirectory();RandomIndexWriter writer = new RandomIndexWriter(random, directory, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random, MockTokenizer.SIMPLE, true)).setMergePolicy(newLogMergePolicy()));//writer.setUseCompoundFile(true);@@ -77,11 +78,13 @@ public class TestTermVectors extends LuceneTestCase {searcher = newSearcher(reader);}- @Override- public void tearDown() throws Exception {+ @AfterClass+ public static void afterClass() throws Exception {reader.close();directory.close();- super.tearDown();+ reader = null;+ directory = null;+ searcher = null;}public void test() {@@ -370,7 +373,7 @@ public class TestTermVectors extends LuceneTestCase {}IndexReader reader = writer.getReader();writer.close();- searcher = newSearcher(reader);+ IndexSearcher searcher = newSearcher(reader);Query query = new TermQuery(new Term("field", "hundred"));ScoreDoc[] hits = searcher.search(query, null, 1000).scoreDocs;@@ -418,7 +421,7 @@ public class TestTermVectors extends LuceneTestCase {IndexReader reader = writer.getReader();writer.close();- searcher = newSearcher(reader);+ IndexSearcher searcher = newSearcher(reader);Query query = new TermQuery(new Term("field", "one"));ScoreDoc[] hits = searcher.search(query, null, 1000).scoreDocs;diff --git a/lucene/src/test/org/apache/lucene/search/spans/TestBasics.java b/lucene/src/test/org/apache/lucene/search/spans/TestBasics.javaindex 58ff1419489..299c4d31af9 100644--- a/lucene/src/test/org/apache/lucene/search/spans/TestBasics.java+++ b/lucene/src/test/org/apache/lucene/search/spans/TestBasics.java@@ -111,7 +111,7 @@ public class TestBasics extends LuceneTestCase {directory = newDirectory();RandomIndexWriter writer = new RandomIndexWriter(random, directory,newIndexWriterConfig(TEST_VERSION_CURRENT, simplePayloadAnalyzer)- .setMaxBufferedDocs(_TestUtil.nextInt(random, 50, 1000)).setMergePolicy(newLogMergePolicy()));+ .setMaxBufferedDocs(_TestUtil.nextInt(random, 100, 1000)).setMergePolicy(newLogMergePolicy()));//writer.infoStream = System.out;for (int i = 0; i < 2000; i++) {Document doc = new Document();diff --git a/lucene/src/test/org/apache/lucene/store/TestLockFactory.java b/lucene/src/test/org/apache/lucene/store/TestLockFactory.javaindex 250aa8d5ba1..c41ca6502a4 100755--- a/lucene/src/test/org/apache/lucene/store/TestLockFactory.java+++ b/lucene/src/test/org/apache/lucene/store/TestLockFactory.java@@ -132,6 +132,7 @@ public class TestLockFactory extends LuceneTestCase {// Verify: do stress test, by opening IndexReaders and// IndexWriters over & over in 2 threads and making sure// no unexpected exceptions are raised:+ @Nightlypublic void testStressLocks() throws Exception {_testStressLocks(null, _TestUtil.getTempDir("index.TestLockFactory6"));}@@ -140,6 +141,7 @@ public class TestLockFactory extends LuceneTestCase {// IndexWriters over & over in 2 threads and making sure// no unexpected exceptions are raised, but use// NativeFSLockFactory:+ @Nightlypublic void testStressLocksNativeFSLockFactory() throws Exception {File dir = _TestUtil.getTempDir("index.TestLockFactory7");_testStressLocks(new NativeFSLockFactory(dir), dir);diff --git a/lucene/src/test/org/apache/lucene/util/fst/TestFSTs.java b/lucene/src/test/org/apache/lucene/util/fst/TestFSTs.javaindex 5f38b5256b4..44e4d3a1f07 100644--- a/lucene/src/test/org/apache/lucene/util/fst/TestFSTs.java+++ b/lucene/src/test/org/apache/lucene/util/fst/TestFSTs.java@@ -1436,7 +1436,7 @@ public class TestFSTs extends LuceneTestCase {Field idField = newField("id", "", StringField.TYPE_UNSTORED);doc.add(idField);- final int NUM_IDS = (int) (1000*RANDOM_MULTIPLIER*(1.0+random.nextDouble()));+ final int NUM_IDS = atLeast(200);//final int NUM_IDS = (int) (377 * (1.0+random.nextDouble()));if (VERBOSE) {System.out.println("TEST: NUM_IDS=" + NUM_IDS);diff --git a/modules/facet/src/test/org/apache/lucene/facet/search/TestTopKResultsHandlerRandom.java b/modules/facet/src/test/org/apache/lucene/facet/search/TestTopKResultsHandlerRandom.javaindex 0e95651d75c..d97e11153f0 100644--- a/modules/facet/src/test/org/apache/lucene/facet/search/TestTopKResultsHandlerRandom.java+++ b/modules/facet/src/test/org/apache/lucene/facet/search/TestTopKResultsHandlerRandom.java@@ -132,4 +132,9 @@ public class TestTopKResultsHandlerRandom extends BaseTestTopK {}}+ @Override+ protected int numDocsToIndex() {+ return TEST_NIGHTLY ? 20000 : 1000;+ }+}diff --git a/modules/queries/src/test/org/apache/lucene/queries/TestCustomScoreQuery.java b/modules/queries/src/test/org/apache/lucene/queries/TestCustomScoreQuery.javaindex f4585482ac2..30b73533b1a 100755--- a/modules/queries/src/test/org/apache/lucene/queries/TestCustomScoreQuery.java+++ b/modules/queries/src/test/org/apache/lucene/queries/TestCustomScoreQuery.java@@ -303,11 +303,11 @@ public class TestCustomScoreQuery extends FunctionTestSetup {assertEquals("queries should have same #hits",h1.size(),h4CustomAdd.size());assertEquals("queries should have same #hits",h1.size(),h5CustomMulAdd.size());- QueryUtils.check(random, q1,s);- QueryUtils.check(random, q2,s);- QueryUtils.check(random, q3,s);- QueryUtils.check(random, q4,s);- QueryUtils.check(random, q5,s);+ QueryUtils.check(random, q1, s, rarely());+ QueryUtils.check(random, q2, s, rarely());+ QueryUtils.check(random, q3, s, rarely());+ QueryUtils.check(random, q4, s, rarely());+ QueryUtils.check(random, q5, s, rarely());// verify scores ratiosfor (final Integer doc : h1.keySet()) {diff --git a/solr/common-build.xml b/solr/common-build.xmlindex 38e60b09371..b3b7d8309f1 100644--- a/solr/common-build.xml+++ b/solr/common-build.xml@@ -47,7 +47,6 @@<property name="example" value="${common-solr.dir}/example" /><property name="javadoc.dir" location="${build.dir}/docs/api"/><property name="tests.loggingfile" value="${common-solr.dir}/testlogging.properties"/>- <property name="tests.threadspercpu" value="2"/><property name="tests.cleanthreads.sysprop" value="perClass"/><property name="clover.db.dir" location="${dest}/tests/clover/db"/>diff --git a/solr/contrib/analysis-extras/src/test-files/analysis-extras/solr/conf/solrconfig-icucollate.xml b/solr/contrib/analysis-extras/src/test-files/analysis-extras/solr/conf/solrconfig-icucollate.xmlindex 2c9b55c1a6a..2ae6c7f3a2b 100644--- a/solr/contrib/analysis-extras/src/test-files/analysis-extras/solr/conf/solrconfig-icucollate.xml+++ b/solr/contrib/analysis-extras/src/test-files/analysis-extras/solr/conf/solrconfig-icucollate.xml@@ -20,4 +20,5 @@<config><luceneMatchVersion>${tests.luceneMatchVersion:LUCENE_CURRENT}</luceneMatchVersion><requestHandler name="standard" class="solr.StandardRequestHandler"></requestHandler>+ <directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.RAMDirectoryFactory}"/></config>diff --git a/solr/contrib/clustering/src/test-files/clustering/solr/conf/solrconfig.xml b/solr/contrib/clustering/src/test-files/clustering/solr/conf/solrconfig.xmlindex 941cdead544..c6fa8fb6148 100644--- a/solr/contrib/clustering/src/test-files/clustering/solr/conf/solrconfig.xml+++ b/solr/contrib/clustering/src/test-files/clustering/solr/conf/solrconfig.xml@@ -24,7 +24,7 @@If replication is in use, this should match the replication configuration. --><dataDir>${solr.data.dir:}</dataDir>-+ <directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.RAMDirectoryFactory}"/><indexDefaults><!-- Values here affect all index writers and act as a default unless overridden. --><useCompoundFile>false</useCompoundFile>diff --git a/solr/contrib/dataimporthandler-extras/src/test-files/dihextras/solr/conf/dataimport-solrconfig.xml b/solr/contrib/dataimporthandler-extras/src/test-files/dihextras/solr/conf/dataimport-solrconfig.xmlindex bbcf4bee3f0..a6c527d2b46 100644--- a/solr/contrib/dataimporthandler-extras/src/test-files/dihextras/solr/conf/dataimport-solrconfig.xml+++ b/solr/contrib/dataimporthandler-extras/src/test-files/dihextras/solr/conf/dataimport-solrconfig.xml@@ -24,6 +24,7 @@If replication is in use, this should match the replication configuration. --><dataDir>${solr.data.dir:}</dataDir>+ <directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.RAMDirectoryFactory}"/><indexDefaults><!-- Values here affect all index writers and act as a default unless overridden. -->diff --git a/solr/contrib/dataimporthandler/src/test-files/dih/solr/conf/contentstream-solrconfig.xml b/solr/contrib/dataimporthandler/src/test-files/dih/solr/conf/contentstream-solrconfig.xmlindex 84a50781aa1..11e77bd8fdf 100644--- a/solr/contrib/dataimporthandler/src/test-files/dih/solr/conf/contentstream-solrconfig.xml+++ b/solr/contrib/dataimporthandler/src/test-files/dih/solr/conf/contentstream-solrconfig.xml@@ -24,6 +24,7 @@If replication is in use, this should match the replication configuration. --><dataDir>${solr.data.dir:}</dataDir>+ <directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.RAMDirectoryFactory}"/><indexDefaults><!-- Values here affect all index writers and act as a default unless overridden. -->diff --git a/solr/contrib/dataimporthandler/src/test-files/dih/solr/conf/dataimport-nodatasource-solrconfig.xml b/solr/contrib/dataimporthandler/src/test-files/dih/solr/conf/dataimport-nodatasource-solrconfig.xmlindex eab5f02a6af..c3c5194c44c 100644--- a/solr/contrib/dataimporthandler/src/test-files/dih/solr/conf/dataimport-nodatasource-solrconfig.xml+++ b/solr/contrib/dataimporthandler/src/test-files/dih/solr/conf/dataimport-nodatasource-solrconfig.xml@@ -24,6 +24,7 @@If replication is in use, this should match the replication configuration. --><dataDir>${solr.data.dir:}</dataDir>+ <directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.RAMDirectoryFactory}"/><indexDefaults><!-- Values here affect all index writers and act as a default unless overridden. -->diff --git a/solr/contrib/dataimporthandler/src/test-files/dih/solr/conf/dataimport-solrconfig.xml b/solr/contrib/dataimporthandler/src/test-files/dih/solr/conf/dataimport-solrconfig.xmlindex 840e130551f..b8051017453 100644--- a/solr/contrib/dataimporthandler/src/test-files/dih/solr/conf/dataimport-solrconfig.xml+++ b/solr/contrib/dataimporthandler/src/test-files/dih/solr/conf/dataimport-solrconfig.xml@@ -24,6 +24,7 @@If replication is in use, this should match the replication configuration. --><dataDir>${solr.data.dir:}</dataDir>+ <directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.RAMDirectoryFactory}"/><indexDefaults><!-- Values here affect all index writers and act as a default unless overridden. -->diff --git a/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestDocBuilderThreaded.java b/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestDocBuilderThreaded.javaindex ca3a7ba7879..7438b9f19c4 100644--- a/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestDocBuilderThreaded.java+++ b/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestDocBuilderThreaded.java@@ -21,6 +21,7 @@ import java.util.List;import java.util.Map;import org.junit.After;+import org.junit.AfterClass;import org.junit.Before;import org.junit.BeforeClass;import org.junit.Test;@@ -31,10 +32,23 @@ import org.junit.Test;*/public class TestDocBuilderThreaded extends AbstractDataImportHandlerTestCase {+ //TODO: fix this test to not require FSDirectory.+ static String savedFactory;@BeforeClasspublic static void beforeClass() throws Exception {+ savedFactory = System.getProperty("solr.DirectoryFactory");+ System.setProperty("solr.directoryFactory", "solr.MockFSDirectoryFactory");initCore("dataimport-solrconfig.xml", "dataimport-schema.xml");}++ @AfterClass+ public static void afterClass() throws Exception {+ if (savedFactory == null) {+ System.clearProperty("solr.directoryFactory");+ } else {+ System.setProperty("solr.directoryFactory", savedFactory);+ }+ }@Before@Overridediff --git a/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestErrorHandling.java b/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestErrorHandling.javaindex d46635cd194..bbd506e9f48 100644--- a/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestErrorHandling.java+++ b/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestErrorHandling.java@@ -23,6 +23,7 @@ import java.util.List;import java.util.Map;import java.util.Properties;+import org.junit.AfterClass;import org.junit.Before;import org.junit.BeforeClass;@@ -34,12 +35,25 @@ import org.junit.BeforeClass;*/public class TestErrorHandling extends AbstractDataImportHandlerTestCase {+ //TODO: fix this test to not require FSDirectory.+ static String savedFactory;@BeforeClasspublic static void beforeClass() throws Exception {+ savedFactory = System.getProperty("solr.DirectoryFactory");+ System.setProperty("solr.directoryFactory", "solr.MockFSDirectoryFactory");initCore("dataimport-solrconfig.xml", "dataimport-schema.xml");ignoreException("Unexpected close tag");}+ @AfterClass+ public static void afterClass() throws Exception {+ if (savedFactory == null) {+ System.clearProperty("solr.directoryFactory");+ } else {+ System.setProperty("solr.directoryFactory", savedFactory);+ }+ }+@Before @Overridepublic void setUp() throws Exception {super.setUp();diff --git a/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestSolrEntityProcessorEndToEnd.java b/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestSolrEntityProcessorEndToEnd.javaindex 1dd0c9c2f01..e1c8a27c15d 100644--- a/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestSolrEntityProcessorEndToEnd.java+++ b/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestSolrEntityProcessorEndToEnd.java@@ -34,7 +34,9 @@ import org.apache.solr.client.solrj.embedded.JettySolrRunner;import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;import org.apache.solr.common.SolrInputDocument;import org.junit.After;+import org.junit.AfterClass;import org.junit.Before;+import org.junit.BeforeClass;import org.slf4j.Logger;import org.slf4j.LoggerFactory;@@ -89,6 +91,23 @@ public class TestSolrEntityProcessorEndToEnd extends AbstractDataImportHandlerTe+ "</dataConfig>\r\n";}+ //TODO: fix this test to close its directories+ static String savedFactory;+ @BeforeClass+ public static void beforeClass() throws Exception {+ savedFactory = System.getProperty("solr.DirectoryFactory");+ System.setProperty("solr.directoryFactory", "solr.StandardDirectoryFactory");+ }++ @AfterClass+ public static void afterClass() throws Exception {+ if (savedFactory == null) {+ System.clearProperty("solr.directoryFactory");+ } else {+ System.setProperty("solr.directoryFactory", savedFactory);+ }+ }+@Override@Beforepublic void setUp() throws Exception {diff --git a/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestSqlEntityProcessorDelta.java b/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestSqlEntityProcessorDelta.javaindex 43150fc2ef0..b7caea7fdca 100644--- a/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestSqlEntityProcessorDelta.java+++ b/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestSqlEntityProcessorDelta.java@@ -16,6 +16,7 @@*/package org.apache.solr.handler.dataimport;+import org.junit.AfterClass;import org.junit.Before;import org.junit.BeforeClass;import org.junit.Test;@@ -59,10 +60,23 @@ public class TestSqlEntityProcessorDelta extends AbstractDataImportHandlerTestCa" </document>\n" +"</dataConfig>\n";+ //TODO: fix this test to not require FSDirectory.+ static String savedFactory;@BeforeClasspublic static void beforeClass() throws Exception {+ savedFactory = System.getProperty("solr.DirectoryFactory");+ System.setProperty("solr.directoryFactory", "solr.MockFSDirectoryFactory");initCore("dataimport-solrconfig.xml", "dataimport-schema.xml");}++ @AfterClass+ public static void afterClass() throws Exception {+ if (savedFactory == null) {+ System.clearProperty("solr.directoryFactory");+ } else {+ System.setProperty("solr.directoryFactory", savedFactory);+ }+ }@Before @Overridepublic void setUp() throws Exception {diff --git a/solr/contrib/extraction/src/test-files/extraction/solr/conf/solrconfig.xml b/solr/contrib/extraction/src/test-files/extraction/solr/conf/solrconfig.xmlindex 773c87b8859..af2c87876d6 100644--- a/solr/contrib/extraction/src/test-files/extraction/solr/conf/solrconfig.xml+++ b/solr/contrib/extraction/src/test-files/extraction/solr/conf/solrconfig.xml@@ -30,6 +30,7 @@It defaults to "index" if not present, and should probablynot be changed if replication is in use. --><dataDir>${solr.data.dir:}</dataDir>+ <directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.RAMDirectoryFactory}"/><indexDefaults><!-- Values here affect all index writers and act as a defaultdiff --git a/solr/contrib/uima/src/test-files/uima/solr/conf/solrconfig.xml b/solr/contrib/uima/src/test-files/uima/solr/conf/solrconfig.xmlindex c4bf579e357..c05dc8af8b6 100644--- a/solr/contrib/uima/src/test-files/uima/solr/conf/solrconfig.xml+++ b/solr/contrib/uima/src/test-files/uima/solr/conf/solrconfig.xml@@ -59,6 +59,7 @@path="../a-jar-that-does-not-exist.jar" />-->+ <directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.RAMDirectoryFactory}"/><!--Used to specify an alternate directory to hold all index data otherdiff --git a/solr/core/src/test-files/solr/conf/bad_solrconfig.xml b/solr/core/src/test-files/solr/conf/bad_solrconfig.xmlindex b14aad5af2c..f3d4d67519f 100644--- a/solr/core/src/test-files/solr/conf/bad_solrconfig.xml+++ b/solr/core/src/test-files/solr/conf/bad_solrconfig.xml@@ -24,6 +24,7 @@<config><luceneMatchVersion>${tests.luceneMatchVersion:LUCENE_CURRENT}</luceneMatchVersion>+ <directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.RAMDirectoryFactory}"/><indexDefaults><useCompoundFile>${unset.sys.property}</useCompoundFile></indexDefaults>diff --git a/solr/core/src/test-files/solr/conf/solrconfig-SOLR-749.xml b/solr/core/src/test-files/solr/conf/solrconfig-SOLR-749.xmlindex cfa0b1984e3..3a0a0ccccae 100644--- a/solr/core/src/test-files/solr/conf/solrconfig-SOLR-749.xml+++ b/solr/core/src/test-files/solr/conf/solrconfig-SOLR-749.xml@@ -24,6 +24,7 @@<config><luceneMatchVersion>${tests.luceneMatchVersion:LUCENE_CURRENT}</luceneMatchVersion>+ <directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.RAMDirectoryFactory}"/><queryParser name="foo" class="FooQParserPlugin"/><!-- override the default "lucene" qparser --><queryParser name="lucene" class="org.apache.solr.search.FooQParserPlugin"/>diff --git a/solr/core/src/test-files/solr/conf/solrconfig-basic.xml b/solr/core/src/test-files/solr/conf/solrconfig-basic.xmlindex c1384a5fee2..72753119aba 100644--- a/solr/core/src/test-files/solr/conf/solrconfig-basic.xml+++ b/solr/core/src/test-files/solr/conf/solrconfig-basic.xml@@ -21,5 +21,6 @@DO NOT ADD THINGS TO THIS CONFIG! --><config><luceneMatchVersion>${tests.luceneMatchVersion:LUCENE_CURRENT}</luceneMatchVersion>+ <directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.RAMDirectoryFactory}"/><requestHandler name="standard" class="solr.StandardRequestHandler"></requestHandler></config>diff --git a/solr/core/src/test-files/solr/conf/solrconfig-delpolicy2.xml b/solr/core/src/test-files/solr/conf/solrconfig-delpolicy2.xmlindex d16a2c9325c..d72498c8f20 100644--- a/solr/core/src/test-files/solr/conf/solrconfig-delpolicy2.xml+++ b/solr/core/src/test-files/solr/conf/solrconfig-delpolicy2.xml@@ -19,6 +19,7 @@<config><luceneMatchVersion>${tests.luceneMatchVersion:LUCENE_CURRENT}</luceneMatchVersion>+ <directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.RAMDirectoryFactory}"/><mainIndex><deletionPolicy class="org.apache.solr.core.FakeDeletionPolicy"><str name="var1">value1</str>diff --git a/solr/core/src/test-files/solr/conf/solrconfig-lazywriter.xml b/solr/core/src/test-files/solr/conf/solrconfig-lazywriter.xmlindex 96e4c709b01..1e2939f6fb8 100644--- a/solr/core/src/test-files/solr/conf/solrconfig-lazywriter.xml+++ b/solr/core/src/test-files/solr/conf/solrconfig-lazywriter.xml@@ -22,6 +22,6 @@<config><luceneMatchVersion>${tests.luceneMatchVersion:LUCENE_CURRENT}</luceneMatchVersion><requestHandler name="standard" class="solr.StandardRequestHandler"></requestHandler>-+ <directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.RAMDirectoryFactory}"/><queryResponseWriter name="velocity" class="solr.VelocityResponseWriter" startup="lazy"/></config>diff --git a/solr/core/src/test-files/solr/conf/solrconfig-master.xml b/solr/core/src/test-files/solr/conf/solrconfig-master.xmlindex a3921a4f3a9..b1ce1509f66 100644--- a/solr/core/src/test-files/solr/conf/solrconfig-master.xml+++ b/solr/core/src/test-files/solr/conf/solrconfig-master.xml@@ -24,7 +24,7 @@<config><luceneMatchVersion>${tests.luceneMatchVersion:LUCENE_CURRENT}</luceneMatchVersion>-+ <directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.RAMDirectoryFactory}"/><dataDir>${solr.data.dir:}</dataDir><indexDefaults>diff --git a/solr/core/src/test-files/solr/conf/solrconfig-master1.xml b/solr/core/src/test-files/solr/conf/solrconfig-master1.xmlindex 9779a0a081e..98f9c10980a 100644--- a/solr/core/src/test-files/solr/conf/solrconfig-master1.xml+++ b/solr/core/src/test-files/solr/conf/solrconfig-master1.xml@@ -25,7 +25,7 @@<config><luceneMatchVersion>${tests.luceneMatchVersion:LUCENE_CURRENT}</luceneMatchVersion><dataDir>${solr.data.dir:}</dataDir>-+ <directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.RAMDirectoryFactory}"/><indexDefaults><useCompoundFile>false</useCompoundFile><mergeFactor>10</mergeFactor>diff --git a/solr/core/src/test-files/solr/conf/solrconfig-master2.xml b/solr/core/src/test-files/solr/conf/solrconfig-master2.xmlindex 04a8388b275..8b3fcc180e6 100644--- a/solr/core/src/test-files/solr/conf/solrconfig-master2.xml+++ b/solr/core/src/test-files/solr/conf/solrconfig-master2.xml@@ -25,7 +25,7 @@<config><luceneMatchVersion>${tests.luceneMatchVersion:LUCENE_CURRENT}</luceneMatchVersion><dataDir>${solr.data.dir:}</dataDir>-+ <directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.RAMDirectoryFactory}"/><indexDefaults><useCompoundFile>false</useCompoundFile><mergeFactor>10</mergeFactor>diff --git a/solr/core/src/test-files/solr/conf/solrconfig-master3.xml b/solr/core/src/test-files/solr/conf/solrconfig-master3.xmlindex 1f48733ce89..ae8f47a7324 100644--- a/solr/core/src/test-files/solr/conf/solrconfig-master3.xml+++ b/solr/core/src/test-files/solr/conf/solrconfig-master3.xml@@ -25,7 +25,7 @@<config><luceneMatchVersion>${tests.luceneMatchVersion:LUCENE_CURRENT}</luceneMatchVersion><dataDir>${solr.data.dir:}</dataDir>-+ <directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.RAMDirectoryFactory}"/><indexDefaults><useCompoundFile>false</useCompoundFile><mergeFactor>10</mergeFactor>diff --git a/solr/core/src/test-files/solr/conf/solrconfig-mergepolicy.xml b/solr/core/src/test-files/solr/conf/solrconfig-mergepolicy.xmlindex c125b6e2559..40d9bada24a 100644--- a/solr/core/src/test-files/solr/conf/solrconfig-mergepolicy.xml+++ b/solr/core/src/test-files/solr/conf/solrconfig-mergepolicy.xml@@ -24,7 +24,7 @@<config><luceneMatchVersion>${tests.luceneMatchVersion:LUCENE_CURRENT}</luceneMatchVersion>-+ <directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.RAMDirectoryFactory}"/><indexDefaults><ramBufferSizeMB>32</ramBufferSizeMB><termIndexInterval>256</termIndexInterval>diff --git a/solr/core/src/test-files/solr/conf/solrconfig-repeater.xml b/solr/core/src/test-files/solr/conf/solrconfig-repeater.xmlindex 909381e4e35..6b7c5773f24 100644--- a/solr/core/src/test-files/solr/conf/solrconfig-repeater.xml+++ b/solr/core/src/test-files/solr/conf/solrconfig-repeater.xml@@ -24,7 +24,7 @@<config><luceneMatchVersion>${tests.luceneMatchVersion:LUCENE_CURRENT}</luceneMatchVersion>-+ <directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.RAMDirectoryFactory}"/><dataDir>${solr.data.dir:}</dataDir><indexDefaults>diff --git a/solr/core/src/test-files/solr/conf/solrconfig-slave.xml b/solr/core/src/test-files/solr/conf/solrconfig-slave.xmlindex 69dde90ee74..1e17c3734ac 100644--- a/solr/core/src/test-files/solr/conf/solrconfig-slave.xml+++ b/solr/core/src/test-files/solr/conf/solrconfig-slave.xml@@ -24,7 +24,7 @@<config><luceneMatchVersion>${tests.luceneMatchVersion:LUCENE_CURRENT}</luceneMatchVersion>-+ <directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.RAMDirectoryFactory}"/><dataDir>${solr.data.dir:}</dataDir><indexDefaults>diff --git a/solr/core/src/test-files/solr/conf/solrconfig-slave1.xml b/solr/core/src/test-files/solr/conf/solrconfig-slave1.xmlindex 420450a978b..38320ae4c5e 100644--- a/solr/core/src/test-files/solr/conf/solrconfig-slave1.xml+++ b/solr/core/src/test-files/solr/conf/solrconfig-slave1.xml@@ -25,7 +25,7 @@<config><luceneMatchVersion>${tests.luceneMatchVersion:LUCENE_CURRENT}</luceneMatchVersion><dataDir>${solr.data.dir:}</dataDir>-+ <directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.RAMDirectoryFactory}"/><indexDefaults><useCompoundFile>false</useCompoundFile><mergeFactor>10</mergeFactor>diff --git a/solr/core/src/test-files/solr/conf/solrconfig-tlog.xml b/solr/core/src/test-files/solr/conf/solrconfig-tlog.xmlindex 2c4e923a97d..fbe439f4027 100644--- a/solr/core/src/test-files/solr/conf/solrconfig-tlog.xml+++ b/solr/core/src/test-files/solr/conf/solrconfig-tlog.xml@@ -19,7 +19,7 @@<config><luceneMatchVersion>${tests.luceneMatchVersion:LUCENE_CURRENT}</luceneMatchVersion>-+ <directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.RAMDirectoryFactory}"/><requestHandler name="standard" class="solr.StandardRequestHandler"></requestHandler>diff --git a/solr/core/src/test-files/solr/conf/solrconfig-xinclude.xml b/solr/core/src/test-files/solr/conf/solrconfig-xinclude.xmlindex 0486b696f4a..5135a7e1821 100644--- a/solr/core/src/test-files/solr/conf/solrconfig-xinclude.xml+++ b/solr/core/src/test-files/solr/conf/solrconfig-xinclude.xml@@ -19,7 +19,7 @@<config><luceneMatchVersion>${tests.luceneMatchVersion:LUCENE_CURRENT}</luceneMatchVersion>-+ <directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.RAMDirectoryFactory}"/><xi:include href="foobar-missing.xml" xmlns:xi="http://www.w3.org/2001/XInclude"><xi:fallback><xi:include href="solrconfig-reqHandler.incl" xmlns:xi="http://www.w3.org/2001/XInclude"/>diff --git a/solr/core/src/test-files/solr/conf/solrconfig_codec.xml b/solr/core/src/test-files/solr/conf/solrconfig_codec.xmlindex 1ff30e0ea2c..28b4608a170 100644--- a/solr/core/src/test-files/solr/conf/solrconfig_codec.xml+++ b/solr/core/src/test-files/solr/conf/solrconfig_codec.xml@@ -18,6 +18,6 @@<config><luceneMatchVersion>${tests.luceneMatchVersion:LUCENE_CURRENT}</luceneMatchVersion>-+ <directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.RAMDirectoryFactory}"/><requestHandler name="standard" class="solr.StandardRequestHandler"></requestHandler></config>diff --git a/solr/core/src/test/org/apache/solr/TestGroupingSearch.java b/solr/core/src/test/org/apache/solr/TestGroupingSearch.javaindex 0951e36a239..a787e6f9238 100644--- a/solr/core/src/test/org/apache/solr/TestGroupingSearch.java+++ b/solr/core/src/test/org/apache/solr/TestGroupingSearch.java@@ -537,8 +537,8 @@ public class TestGroupingSearch extends SolrTestCaseJ4 {assertJQ(req("q","id:"+doc.id), "/response/numFound==1");**/- int indexIter=50 * RANDOM_MULTIPLIER; // make >0 to enable test- int queryIter=100 * RANDOM_MULTIPLIER;+ int indexIter=atLeast(10); // make >0 to enable test+ int queryIter=atLeast(50);while (--indexIter >= 0) {diff --git a/solr/core/src/test/org/apache/solr/core/TestArbitraryIndexDir.java b/solr/core/src/test/org/apache/solr/core/TestArbitraryIndexDir.javaindex 9ac9939c686..8939c5f2fdd 100644--- a/solr/core/src/test/org/apache/solr/core/TestArbitraryIndexDir.java+++ b/solr/core/src/test/org/apache/solr/core/TestArbitraryIndexDir.java@@ -36,6 +36,8 @@ import org.apache.solr.common.SolrException;import org.apache.solr.common.params.CommonParams;import org.apache.solr.util.AbstractSolrTestCase;import org.apache.solr.util.TestHarness;+import org.junit.AfterClass;+import org.junit.BeforeClass;import org.junit.Test;import org.xml.sax.SAXException;@@ -44,6 +46,22 @@ import org.xml.sax.SAXException;*/public class TestArbitraryIndexDir extends AbstractSolrTestCase{+ // TODO: fix this test to not require FSDirectory+ static String savedFactory;+ @BeforeClass+ public static void beforeClass() throws Exception {+ savedFactory = System.getProperty("solr.DirectoryFactory");+ System.setProperty("solr.directoryFactory", "org.apache.solr.core.MockFSDirectoryFactory");+ }+ @AfterClass+ public static void afterClass() throws Exception {+ if (savedFactory == null) {+ System.clearProperty("solr.directoryFactory");+ } else {+ System.setProperty("solr.directoryFactory", savedFactory);+ }+ }+@Overridepublic void setUp() throws Exception {super.setUp();diff --git a/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java b/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.javaindex 90c9dc070f0..92c59077376 100644--- a/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java+++ b/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java@@ -35,6 +35,7 @@ import org.apache.lucene.search.MatchAllDocsQuery;import org.apache.lucene.search.TopDocs;import org.apache.lucene.store.Directory;import org.apache.lucene.store.SimpleFSDirectory;+import org.apache.lucene.util.LuceneTestCase;import org.apache.solr.SolrTestCaseJ4;import org.apache.solr.TestDistributedSearch;import org.apache.solr.client.solrj.SolrServer;@@ -59,6 +60,8 @@ import org.junit.BeforeClass;** @since 1.4*/+// TODO: can this test be sped up? it used to not be so slow...public class TestReplicationHandler extends SolrTestCaseJ4 {@@ -74,8 +77,12 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {// index from previous test methodstatic int nDocs = 500;+ // TODO: fix this test to not require FSDirectory.. doesnt even work with MockFSDirectory... wtf?+ static String savedFactory;@BeforeClasspublic static void beforeClass() throws Exception {+ savedFactory = System.getProperty("solr.DirectoryFactory");+ System.setProperty("solr.directoryFactory", "solr.StandardDirectoryFactory");master = new SolrInstance("master", null);master.setUp();masterJetty = createJetty(master);@@ -105,6 +112,11 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {slaveJetty.stop();master.tearDown();slave.tearDown();+ if (savedFactory == null) {+ System.clearProperty("solr.directoryFactory");+ } else {+ System.setProperty("solr.directoryFactory", savedFactory);+ }}private static JettySolrRunner createJetty(SolrInstance instance) throws Exception {diff --git a/solr/core/src/test/org/apache/solr/spelling/suggest/SuggesterTest.java b/solr/core/src/test/org/apache/solr/spelling/suggest/SuggesterTest.javaindex 600c598a745..30bc8016f8d 100644--- a/solr/core/src/test/org/apache/solr/spelling/suggest/SuggesterTest.java+++ b/solr/core/src/test/org/apache/solr/spelling/suggest/SuggesterTest.java@@ -22,6 +22,7 @@ import java.io.File;import org.apache.solr.SolrTestCaseJ4;import org.apache.solr.common.params.SpellingParams;import org.apache.solr.common.util.NamedList;+import org.junit.AfterClass;import org.junit.BeforeClass;import org.junit.Test;@@ -31,10 +32,23 @@ public class SuggesterTest extends SolrTestCaseJ4 {*/protected String requestUri = "/suggest";+ // TODO: fix this test to not require FSDirectory+ static String savedFactory;@BeforeClasspublic static void beforeClass() throws Exception {+ savedFactory = System.getProperty("solr.DirectoryFactory");+ System.setProperty("solr.directoryFactory", "org.apache.solr.core.MockFSDirectoryFactory");initCore("solrconfig-spellchecker.xml","schema-spellchecker.xml");}++ @AfterClass+ public static void afterClass() throws Exception {+ if (savedFactory == null) {+ System.clearProperty("solr.directoryFactory");+ } else {+ System.setProperty("solr.directoryFactory", savedFactory);+ }+ }public static void addDocs() throws Exception {assertU(adoc("id", "1",diff --git a/solr/core/src/test/org/apache/solr/update/DirectUpdateHandlerTest.java b/solr/core/src/test/org/apache/solr/update/DirectUpdateHandlerTest.javaindex 654d474d161..dfc3037288b 100644--- a/solr/core/src/test/org/apache/solr/update/DirectUpdateHandlerTest.java+++ b/solr/core/src/test/org/apache/solr/update/DirectUpdateHandlerTest.java@@ -27,6 +27,7 @@ import org.apache.solr.common.params.MapSolrParams;import org.apache.solr.core.SolrCore;import org.apache.solr.request.LocalSolrQueryRequest;import org.apache.solr.request.SolrQueryRequest;+import org.junit.AfterClass;import org.junit.Before;import org.junit.BeforeClass;import org.junit.Test;@@ -37,10 +38,23 @@ import org.junit.Test;*/public class DirectUpdateHandlerTest extends SolrTestCaseJ4 {+ // TODO: fix this test to not require FSDirectory+ static String savedFactory;@BeforeClasspublic static void beforeClass() throws Exception {+ savedFactory = System.getProperty("solr.DirectoryFactory");+ System.setProperty("solr.directoryFactory", "org.apache.solr.core.MockFSDirectoryFactory");initCore("solrconfig.xml", "schema12.xml");}++ @AfterClass+ public static void afterClass() throws Exception {+ if (savedFactory == null) {+ System.clearProperty("solr.directoryFactory");+ } else {+ System.setProperty("solr.directoryFactory", savedFactory);+ }+ }@Override@Beforediff --git a/solr/core/src/test/org/apache/solr/update/TestIndexingPerformance.java b/solr/core/src/test/org/apache/solr/update/TestIndexingPerformance.javaindex 11875db0f79..23fd6870b02 100755--- a/solr/core/src/test/org/apache/solr/update/TestIndexingPerformance.java+++ b/solr/core/src/test/org/apache/solr/update/TestIndexingPerformance.java@@ -22,6 +22,8 @@ import org.apache.solr.request.SolrQueryRequest;import org.apache.solr.schema.IndexSchema;import org.apache.solr.util.AbstractSolrTestCase;import org.apache.solr.common.util.StrUtils;+import org.junit.AfterClass;+import org.junit.BeforeClass;import org.slf4j.Logger;import org.slf4j.LoggerFactory;@@ -35,6 +37,22 @@ import java.util.Arrays;* $ ant test -Dtestcase=TestIndexingPerformance -Dargs="-server -Diter=100000"; grep throughput build/test-results/*TestIndexingPerformance.xml*/public class TestIndexingPerformance extends AbstractSolrTestCase {++ // TODO: fix this test to not require FSDirectory+ static String savedFactory;+ @BeforeClass+ public static void beforeClass() throws Exception {+ savedFactory = System.getProperty("solr.DirectoryFactory");+ System.setProperty("solr.directoryFactory", "org.apache.solr.core.MockFSDirectoryFactory");+ }+ @AfterClass+ public static void afterClass() throws Exception {+ if (savedFactory == null) {+ System.clearProperty("solr.directoryFactory");+ } else {+ System.setProperty("solr.directoryFactory", savedFactory);+ }+ }public static final Logger log= LoggerFactory.getLogger(TestIndexingPerformance.class);diff --git a/solr/solrj/src/test-files/solrj/solr/conf/solrconfig-slave1.xml b/solr/solrj/src/test-files/solrj/solr/conf/solrconfig-slave1.xmlindex 8a6bf099500..36f098d953c 100644--- a/solr/solrj/src/test-files/solrj/solr/conf/solrconfig-slave1.xml+++ b/solr/solrj/src/test-files/solrj/solr/conf/solrconfig-slave1.xml@@ -25,7 +25,7 @@<config><luceneMatchVersion>${tests.luceneMatchVersion:LUCENE_CURRENT}</luceneMatchVersion><dataDir>${solr.data.dir:}</dataDir>-+ <directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.RAMDirectoryFactory}"/><indexDefaults><useCompoundFile>false</useCompoundFile><mergeFactor>10</mergeFactor>diff --git a/solr/solrj/src/test-files/solrj/solr/shared/conf/solrconfig.xml b/solr/solrj/src/test-files/solrj/solr/shared/conf/solrconfig.xmlindex 031fbb02e5c..c3fbe589ff8 100644--- a/solr/solrj/src/test-files/solrj/solr/shared/conf/solrconfig.xml+++ b/solr/solrj/src/test-files/solrj/solr/shared/conf/solrconfig.xml@@ -23,7 +23,7 @@<config><luceneMatchVersion>${tests.luceneMatchVersion:LUCENE_CURRENT}</luceneMatchVersion><dataDir>${solr.solr.home}/data/${l10n}-${version}</dataDir>-+ <directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.RAMDirectoryFactory}"/><updateHandler class="solr.DirectUpdateHandler2" />diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java b/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.javaindex fd1af1def45..3ae62ee742d 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java@@ -280,7 +280,7 @@ abstract public class SolrExampleTests extends SolrJettyTestBase}public void testUnicode() throws Exception {- int numIterations = 100 * RANDOM_MULTIPLIER;+ int numIterations = atLeast(3);SolrServer server = getSolrServer();@@ -302,7 +302,7 @@ abstract public class SolrExampleTests extends SolrJettyTestBase}}- int numDocs = _TestUtil.nextInt(random, 1, 100);+ int numDocs = _TestUtil.nextInt(random, 1, 10*RANDOM_MULTIPLIER);// Empty the database...server.deleteByQuery("*:*");// delete everything!diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttpSolrServer.java b/solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttpSolrServer.javaindex 92b830eed33..78d213fb13a 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttpSolrServer.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttpSolrServer.java@@ -30,6 +30,8 @@ import org.apache.solr.client.solrj.response.QueryResponse;import org.apache.solr.client.solrj.response.UpdateResponse;import org.apache.solr.common.SolrInputDocument;import org.apache.solr.util.AbstractSolrTestCase;+import org.junit.AfterClass;+import org.junit.BeforeClass;import java.io.File;import java.io.IOException;@@ -48,6 +50,22 @@ public class TestLBHttpSolrServer extends LuceneTestCase {SolrInstance[] solr = new SolrInstance[3];HttpClient httpClient;+ // TODO: fix this test to not require FSDirectory+ static String savedFactory;+ @BeforeClass+ public static void beforeClass() throws Exception {+ savedFactory = System.getProperty("solr.DirectoryFactory");+ System.setProperty("solr.directoryFactory", "org.apache.solr.core.MockFSDirectoryFactory");+ }+ @AfterClass+ public static void afterClass() throws Exception {+ if (savedFactory == null) {+ System.clearProperty("solr.directoryFactory");+ } else {+ System.setProperty("solr.directoryFactory", savedFactory);+ }+ }+@Overridepublic void setUp() throws Exception {super.setUp();diff --git a/solr/solrj/src/test/org/apache/solr/common/util/ContentStreamTest.java b/solr/solrj/src/test/org/apache/solr/common/util/ContentStreamTest.javaindex 578479b73e2..a5b7b65a4b1 100755--- a/solr/solrj/src/test/org/apache/solr/common/util/ContentStreamTest.java+++ b/solr/solrj/src/test/org/apache/solr/common/util/ContentStreamTest.java@@ -71,6 +71,8 @@ public class ContentStreamTest extends LuceneTestCaseInputStream in = null;try {URLConnection conn = url.openConnection();+ conn.setConnectTimeout(1000);+ conn.setReadTimeout(1000);in = conn.getInputStream();contentType = conn.getContentType();content = IOUtils.toByteArray(in);diff --git a/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java b/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.javaindex 1ec2654a6e0..e65f044f0a8 100644--- a/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java+++ b/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java@@ -81,7 +81,7 @@ public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 {// to stress with higher thread counts and requests, make sure the junit// xml formatter is not being used (all output will be buffered before// transformation to xml and cause an OOM exception).- protected int stress = 2;+ protected int stress = TEST_NIGHTLY ? 2 : 0;protected boolean verifyStress = true;protected int nThreads = 3;diff --git a/solr/test-framework/src/java/org/apache/solr/core/MockDirectoryFactory.java b/solr/test-framework/src/java/org/apache/solr/core/MockDirectoryFactory.javaindex 92c1d242a60..ce1e523b66e 100644--- a/solr/test-framework/src/java/org/apache/solr/core/MockDirectoryFactory.java+++ b/solr/test-framework/src/java/org/apache/solr/core/MockDirectoryFactory.java@@ -25,13 +25,13 @@ import org.apache.lucene.store.MockDirectoryWrapper;import org.apache.lucene.util.LuceneTestCase;/**- * Opens a directory with {@link LuceneTestCase#newFSDirectory(File)}+ * Opens a directory with {@link LuceneTestCase#newDirectory()}*/public class MockDirectoryFactory extends CachingDirectoryFactory {@Override- public Directory create(String path) throws IOException {- MockDirectoryWrapper dir = LuceneTestCase.newFSDirectory(new File(path));+ protected Directory create(String path) throws IOException {+ MockDirectoryWrapper dir = LuceneTestCase.newDirectory();// Somehow removing unref'd files in Solr tests causes// problems... there's some interaction w/// CachingDirectoryFactory. Once we track down where Solr@@ -39,4 +39,21 @@ public class MockDirectoryFactory extends CachingDirectoryFactory {dir.setAssertNoUnrefencedFilesOnClose(false);return dir;}++ @Override+ public boolean exists(String path) {+ String fullPath = new File(path).getAbsolutePath();+ synchronized (DirectoryFactory.class) {+ CacheValue cacheValue = byPathCache.get(fullPath);+ Directory directory = null;+ if (cacheValue != null) {+ directory = cacheValue.directory;+ }+ if (directory == null) {+ return false;+ } else {+ return true;+ }+ }+ }}diff --git a/solr/test-framework/src/java/org/apache/solr/core/MockFSDirectoryFactory.java b/solr/test-framework/src/java/org/apache/solr/core/MockFSDirectoryFactory.javanew file mode 100644index 00000000000..9c95813d4e4--- /dev/null+++ b/solr/test-framework/src/java/org/apache/solr/core/MockFSDirectoryFactory.java@@ -0,0 +1,42 @@+package org.apache.solr.core;++/**+ * Licensed to the Apache Software Foundation (ASF) under one or more+ * contributor license agreements. See the NOTICE file distributed with+ * this work for additional information regarding copyright ownership.+ * The ASF licenses this file to You under the Apache License, Version 2.0+ * (the "License"); you may not use this file except in compliance with+ * the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import java.io.File;+import java.io.IOException;++import org.apache.lucene.store.Directory;+import org.apache.lucene.store.MockDirectoryWrapper;+import org.apache.lucene.util.LuceneTestCase;++/**+ * Opens a directory with {@link LuceneTestCase#newFSDirectory(File)}+ */+public class MockFSDirectoryFactory extends CachingDirectoryFactory {++ @Override+ public Directory create(String path) throws IOException {+ MockDirectoryWrapper dir = LuceneTestCase.newFSDirectory(new File(path));+ // Somehow removing unref'd files in Solr tests causes+ // problems... there's some interaction w/+ // CachingDirectoryFactory. Once we track down where Solr+ // isn't closing an IW, we can re-enable this:+ dir.setAssertNoUnrefencedFilesOnClose(false);+ return dir;+ }+}