Apache Lucene open-source search software
SOLR-5118: more testing of edge case and some error conditions
Chris M. Hostetter5e70c629a464
diff --git a/solr/core/src/test-files/solr/collection1/conf/bad-solrconfig-warmer-no-reopen.xml b/solr/core/src/test-files/solr/collection1/conf/bad-solrconfig-warmer-no-reopen.xmlnew file mode 100644index 00000000000..cba30ecf745--- /dev/null+++ b/solr/core/src/test-files/solr/collection1/conf/bad-solrconfig-warmer-no-reopen.xml@@ -0,0 +1,27 @@+<?xml version="1.0" ?>++<!--+ 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.+-->++<config>++ <luceneMatchVersion>${tests.luceneMatchVersion:LUCENE_CURRENT}</luceneMatchVersion>+ <indexConfig>+ <mergedSegmentWarmer class="org.apache.lucene.index.SimpleMergedSegmentWarmer"/>+ <reopenReaders>false</reopenReaders> <!-- BAD -->+ </indexConfig>+</config>diff --git a/solr/core/src/test-files/solr/collection1/conf/solrconfig-logmergepolicy.xml b/solr/core/src/test-files/solr/collection1/conf/solrconfig-logmergepolicy.xmlnew file mode 100644index 00000000000..371bfb5638d--- /dev/null+++ b/solr/core/src/test-files/solr/collection1/conf/solrconfig-logmergepolicy.xml@@ -0,0 +1,37 @@+<?xml version="1.0" ?>++<!--+ 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.+-->++<config>+ <luceneMatchVersion>${tests.luceneMatchVersion:LUCENE_CURRENT}</luceneMatchVersion>+ <directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.RAMDirectoryFactory}"/>++ <indexConfig>+ <!-- set some values to -1 to force the use of internal lucene defaults -->+ <maxBufferedDocs>-1</maxBufferedDocs>+ <ramBufferSizeMB>-1</ramBufferSizeMB>+ <maxIndexingThreads>-1</maxIndexingThreads>++ <mergeFactor>11</mergeFactor>+ <maxMergeDocs>456</maxMergeDocs>+ <mergePolicy class="${solr.test.log.merge.policy}" />+ </indexConfig>++ <requestHandler name="standard" class="solr.StandardRequestHandler"></requestHandler>++</config>diff --git a/solr/core/src/test-files/solr/collection1/conf/solrconfig-mergepolicy.xml b/solr/core/src/test-files/solr/collection1/conf/solrconfig-tieredmergepolicy.xmlsimilarity index 100%rename from solr/core/src/test-files/solr/collection1/conf/solrconfig-mergepolicy.xmlrename to solr/core/src/test-files/solr/collection1/conf/solrconfig-tieredmergepolicy.xmldiff --git a/solr/core/src/test/org/apache/solr/core/TestBadConfig.java b/solr/core/src/test/org/apache/solr/core/TestBadConfig.javaindex 621dba6e49a..42f7d629251 100644--- a/solr/core/src/test/org/apache/solr/core/TestBadConfig.java+++ b/solr/core/src/test/org/apache/solr/core/TestBadConfig.java@@ -27,6 +27,10 @@ public class TestBadConfig extends AbstractBadConfigTestBase {assertConfigs("bad_solrconfig.xml","schema.xml","unset.sys.property");}+ public void testSegmentMergerWithoutReopen() throws Exception {+ assertConfigs("bad-solrconfig-warmer-no-reopen.xml", "schema12.xml",+ "mergedSegmentWarmer");+ }public void testMultipleDirectoryFactories() throws Exception {assertConfigs("bad-solrconfig-multiple-dirfactory.xml", "schema12.xml","directoryFactory");diff --git a/solr/core/src/test/org/apache/solr/core/TestMergePolicyConfig.java b/solr/core/src/test/org/apache/solr/core/TestMergePolicyConfig.javaindex bb6525f83f4..85c93ff872f 100644--- a/solr/core/src/test/org/apache/solr/core/TestMergePolicyConfig.java+++ b/solr/core/src/test/org/apache/solr/core/TestMergePolicyConfig.java@@ -27,6 +27,9 @@ import org.apache.lucene.index.SegmentInfo;import org.apache.lucene.index.IndexWriterConfig;import org.apache.lucene.index.MergePolicy;import org.apache.lucene.index.TieredMergePolicy;+import org.apache.lucene.index.LogMergePolicy;+import org.apache.lucene.index.LogByteSizeMergePolicy;+import org.apache.lucene.index.LogDocMergePolicy;import org.apache.lucene.index.ConcurrentMergeScheduler;import org.apache.solr.core.SolrCore;import org.apache.solr.util.RefCounted;@@ -82,7 +85,7 @@ public class TestMergePolicyConfig extends SolrTestCaseJ4 {final boolean expectCFS= Boolean.parseBoolean(System.getProperty("useCompoundFile"));- initCore("solrconfig-mergepolicy.xml","schema-minimal.xml");+ initCore("solrconfig-tieredmergepolicy.xml","schema-minimal.xml");IndexWriterConfig iwc = solrConfig.indexConfig.toIndexWriterConfig(h.getCore().getLatestSchema());assertEquals(expectCFS, iwc.getUseCompoundFile());@@ -116,6 +119,37 @@ public class TestMergePolicyConfig extends SolrTestCaseJ4 {assertCompoundSegments(h.getCore(), false);}+ public void testLogMergePolicyConfig() throws Exception {++ final Class<? extends LogMergePolicy> mpClass = random().nextBoolean()+ ? LogByteSizeMergePolicy.class : LogDocMergePolicy.class;++ System.setProperty("solr.test.log.merge.policy", mpClass.getName());++ initCore("solrconfig-logmergepolicy.xml","schema-minimal.xml");+ IndexWriterConfig iwc = solrConfig.indexConfig.toIndexWriterConfig(h.getCore().getLatestSchema());++ // verify some props set to -1 get lucene internal defaults+ assertEquals(-1, solrConfig.indexConfig.maxBufferedDocs);+ assertEquals(IndexWriterConfig.DISABLE_AUTO_FLUSH,+ iwc.getMaxBufferedDocs());+ assertEquals(-1, solrConfig.indexConfig.maxIndexingThreads);+ assertEquals(IndexWriterConfig.DEFAULT_MAX_THREAD_STATES,+ iwc.getMaxThreadStates());+ assertEquals(-1, solrConfig.indexConfig.ramBufferSizeMB, 0.0D);+ assertEquals(IndexWriterConfig.DEFAULT_RAM_BUFFER_SIZE_MB,+ iwc.getRAMBufferSizeMB(), 0.0D);+++ LogMergePolicy logMP = assertAndCast(mpClass, iwc.getMergePolicy());++ // set by legacy <mergeFactor> setting+ assertEquals(11, logMP.getMergeFactor());+ // set by legacy <maxMergeDocs> setting+ assertEquals(456, logMP.getMaxMergeDocs());++ }+/*** Given a Type and an object asserts that the object is non-null and an* instance of the specified Type. The object is then cast to that type anddiff --git a/solr/core/src/test/org/apache/solr/update/SolrIndexConfigTest.java b/solr/core/src/test/org/apache/solr/update/SolrIndexConfigTest.javaindex c1729bd301d..fef45302726 100644--- a/solr/core/src/test/org/apache/solr/update/SolrIndexConfigTest.java+++ b/solr/core/src/test/org/apache/solr/update/SolrIndexConfigTest.java@@ -54,7 +54,7 @@ public class SolrIndexConfigTest extends SolrTestCaseJ4 {@Testpublic void testTieredMPSolrIndexConfigCreation() throws Exception {SolrConfig solrConfig = new SolrConfig("solr" + File.separator- + "collection1", "solrconfig-mergepolicy.xml", null);+ + "collection1", "solrconfig-tieredmergepolicy.xml", null);SolrIndexConfig solrIndexConfig = new SolrIndexConfig(solrConfig, null,null);assertNotNull(solrIndexConfig);