mirror of https://github.com/apache/lucene.git
SOLR-2570: randomize more indexConfig settings in tests
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1510637 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
acaa4eab02
commit
26a914558b
|
@ -22,6 +22,18 @@ A solrconfig.xml snippet containing indexConfig settings for randomized testing.
|
||||||
|
|
||||||
-->
|
-->
|
||||||
<indexConfig>
|
<indexConfig>
|
||||||
<useCompoundFile>${useCompoundFile:false}</useCompoundFile>
|
<!-- allways use this randomized policy -->
|
||||||
<mergePolicy class="org.apache.solr.util.RandomMergePolicy" />
|
<mergePolicy class="org.apache.solr.util.RandomMergePolicy" />
|
||||||
|
|
||||||
|
<useCompoundFile>${useCompoundFile:false}</useCompoundFile>
|
||||||
|
|
||||||
|
<maxBufferedDocs>${solr.tests.maxBufferedDocs}</maxBufferedDocs>
|
||||||
|
<maxIndexingThreads>${solr.tests.maxIndexingThreads}</maxIndexingThreads>
|
||||||
|
<ramBufferSizeMB>${solr.tests.ramBufferSizeMB}</ramBufferSizeMB>
|
||||||
|
|
||||||
|
<mergeScheduler class="${solr.tests.mergeScheduler}" />
|
||||||
|
|
||||||
|
<writeLockTimeout>1000</writeLockTimeout>
|
||||||
|
<commitLockTimeout>10000</commitLockTimeout>
|
||||||
|
<lockType>single</lockType>
|
||||||
</indexConfig>
|
</indexConfig>
|
||||||
|
|
|
@ -129,14 +129,15 @@ public class TestConfig extends SolrTestCaseJ4 {
|
||||||
|
|
||||||
// sanity check that sys propertis are working as expected
|
// sanity check that sys propertis are working as expected
|
||||||
public void testSanityCheckTestSysPropsAreUsed() throws Exception {
|
public void testSanityCheckTestSysPropsAreUsed() throws Exception {
|
||||||
final boolean expectCFS
|
|
||||||
= Boolean.parseBoolean(System.getProperty("useCompoundFile"));
|
|
||||||
|
|
||||||
SolrConfig sc = new SolrConfig(new SolrResourceLoader("solr/collection1"), "solrconfig-basic.xml", null);
|
SolrConfig sc = new SolrConfig(new SolrResourceLoader("solr/collection1"), "solrconfig-basic.xml", null);
|
||||||
SolrIndexConfig sic = sc.indexConfig;
|
SolrIndexConfig sic = sc.indexConfig;
|
||||||
assertEquals("default ramBufferSizeMB", 100.0D, sic.ramBufferSizeMB, 0.0D);
|
|
||||||
assertEquals("default LockType", SolrIndexConfig.LOCK_TYPE_NATIVE, sic.lockType);
|
assertEquals("ramBufferSizeMB sysprop",
|
||||||
assertEquals("useCompoundFile sysprop", expectCFS, sic.useCompoundFile);
|
Double.parseDouble(System.getProperty("solr.tests.ramBufferSizeMB")),
|
||||||
|
sic.ramBufferSizeMB, 0.0D);
|
||||||
|
assertEquals("useCompoundFile sysprop",
|
||||||
|
Boolean.parseBoolean(System.getProperty("useCompoundFile")), sic.useCompoundFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,8 +21,11 @@ import com.carrotsearch.randomizedtesting.RandomizedContext;
|
||||||
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
|
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
|
||||||
import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule;
|
import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
|
import org.apache.lucene.analysis.MockAnalyzer;
|
||||||
|
import org.apache.lucene.index.IndexWriterConfig;
|
||||||
import org.apache.lucene.util.IOUtils;
|
import org.apache.lucene.util.IOUtils;
|
||||||
import org.apache.lucene.util.LuceneTestCase;
|
import org.apache.lucene.util.LuceneTestCase;
|
||||||
|
import org.apache.lucene.util._TestUtil;
|
||||||
import org.apache.lucene.util.QuickPatchThreadsFilter;
|
import org.apache.lucene.util.QuickPatchThreadsFilter;
|
||||||
import org.apache.solr.client.solrj.util.ClientUtils;
|
import org.apache.solr.client.solrj.util.ClientUtils;
|
||||||
import org.apache.solr.common.SolrException;
|
import org.apache.solr.common.SolrException;
|
||||||
|
@ -112,13 +115,13 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {
|
||||||
private static void beforeClass() {
|
private static void beforeClass() {
|
||||||
System.setProperty("jetty.testMode", "true");
|
System.setProperty("jetty.testMode", "true");
|
||||||
|
|
||||||
System.setProperty("useCompoundFile", Boolean.toString(random().nextBoolean()));
|
|
||||||
System.setProperty("enable.update.log", usually() ? "true" : "false");
|
System.setProperty("enable.update.log", usually() ? "true" : "false");
|
||||||
System.setProperty("tests.shardhandler.randomSeed", Long.toString(random().nextLong()));
|
System.setProperty("tests.shardhandler.randomSeed", Long.toString(random().nextLong()));
|
||||||
setupLogging();
|
setupLogging();
|
||||||
startTrackingSearchers();
|
startTrackingSearchers();
|
||||||
startTrackingZkClients();
|
startTrackingZkClients();
|
||||||
ignoreException("ignore_exception");
|
ignoreException("ignore_exception");
|
||||||
|
newRandomConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
|
@ -181,6 +184,28 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {
|
||||||
h = new TestHarness(loader, ConfigSolr.fromFile(loader, new File(solrHome, "solr.xml")));
|
h = new TestHarness(loader, ConfigSolr.fromFile(loader, new File(solrHome, "solr.xml")));
|
||||||
lrf = h.getRequestFactory("standard", 0, 20, CommonParams.VERSION, "2.2");
|
lrf = h.getRequestFactory("standard", 0, 20, CommonParams.VERSION, "2.2");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** sets system properties based on
|
||||||
|
* {@link #newIndexWriterConfig(org.apache.lucene.util.Version, org.apache.lucene.analysis.Analyzer)}
|
||||||
|
*
|
||||||
|
* configs can use these system properties to vary the indexwriter settings
|
||||||
|
*/
|
||||||
|
public static void newRandomConfig() {
|
||||||
|
IndexWriterConfig iwc = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
|
||||||
|
|
||||||
|
System.setProperty("useCompoundFile", String.valueOf(iwc.getUseCompoundFile()));
|
||||||
|
|
||||||
|
System.setProperty("solr.tests.maxBufferedDocs", String.valueOf(iwc.getMaxBufferedDocs()));
|
||||||
|
System.setProperty("solr.tests.ramBufferSizeMB", String.valueOf(iwc.getRAMBufferSizeMB()));
|
||||||
|
System.setProperty("solr.tests.mergeScheduler", iwc.getMergeScheduler().getClass().getName());
|
||||||
|
|
||||||
|
// don't ask iwc.getMaxThreadStates(), sometimes newIWC uses
|
||||||
|
// RandomDocumentsWriterPerThreadPool and all hell breaks loose
|
||||||
|
int maxIndexingThreads = rarely(random())
|
||||||
|
? _TestUtil.nextInt(random(), 5, 20) // crazy value
|
||||||
|
: _TestUtil.nextInt(random(), 1, 4); // reasonable value
|
||||||
|
System.setProperty("solr.tests.maxIndexingThreads", String.valueOf(maxIndexingThreads));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
|
|
Loading…
Reference in New Issue