Apache Lucene open-source search software
SOLR-5118: beef up assertions in SolrIndexConfigTest, this allows us to remove TestPropInject and TestPropInjectDefaults -- neither of which were testing property injection (tested elsewhere) but were doing some basic assertions on the parsing & init of merge policy and merge scheduler
Chris M. Hostetterc12875f84e99
diff --git a/solr/core/src/test-files/solr/collection1/conf/solrconfig-mergepolicy.xml b/solr/core/src/test-files/solr/collection1/conf/solrconfig-mergepolicy.xmlindex cd37e605acd..86a79fbf8fc 100644--- a/solr/core/src/test-files/solr/collection1/conf/solrconfig-mergepolicy.xml+++ b/solr/core/src/test-files/solr/collection1/conf/solrconfig-mergepolicy.xml@@ -36,6 +36,10 @@<bool name="useCompoundFile">${useCompoundFile:false}</bool></mergePolicy>+ <mergeScheduler class="org.apache.lucene.index.ConcurrentMergeScheduler">+ <int name="maxMergeCount">987</int>+ <int name="maxThreadCount">42</int>+ </mergeScheduler></indexConfig><requestHandler name="standard" class="solr.StandardRequestHandler"></requestHandler>diff --git a/solr/core/src/test-files/solr/collection1/conf/solrconfig-propinject-indexdefault.xml b/solr/core/src/test-files/solr/collection1/conf/solrconfig-propinject-indexdefault.xmldeleted file mode 100644index a56a71e02c1..00000000000--- a/solr/core/src/test-files/solr/collection1/conf/solrconfig-propinject-indexdefault.xml+++ /dev/null@@ -1,42 +0,0 @@-<?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>-- <!-- The DirectoryFactory to use for indexes.- solr.StandardDirectoryFactory, the default, is filesystem based.- solr.RAMDirectoryFactory is memory based and not persistent. -->- <directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.RAMDirectoryFactory}"/>-- <indexConfig>- <useCompoundFile>${useCompoundFile:false}</useCompoundFile>- <mergePolicy class="org.apache.lucene.index.LogByteSizeMergePolicy">- <double name="maxMergeMB">32.0</double>- </mergePolicy>- <mergeScheduler class="org.apache.lucene.index.ConcurrentMergeScheduler">- <int name="maxMergeCount">4</int>- <int name="maxThreadCount">4</int>- </mergeScheduler>- </indexConfig>-- <updateHandler class="solr.DirectUpdateHandler2">- </updateHandler>--</config>diff --git a/solr/core/src/test-files/solr/collection1/conf/solrconfig-propinject.xml b/solr/core/src/test-files/solr/collection1/conf/solrconfig-propinject.xmldeleted file mode 100644index 0ba21a5fdc5..00000000000--- a/solr/core/src/test-files/solr/collection1/conf/solrconfig-propinject.xml+++ /dev/null@@ -1,43 +0,0 @@-<?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>-- <!-- The DirectoryFactory to use for indexes.- solr.StandardDirectoryFactory, the default, is filesystem based.- solr.RAMDirectoryFactory is memory based and not persistent. -->- <directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.RAMDirectoryFactory}"/>--- <indexConfig>- <useCompoundFile>${useCompoundFile:false}</useCompoundFile>- <mergePolicy class="org.apache.lucene.index.LogByteSizeMergePolicy">- <double name="maxMergeMB">64.0</double>- </mergePolicy>-- <mergeScheduler class="org.apache.lucene.index.ConcurrentMergeScheduler">- <int name="maxThreadCount">2</int>- </mergeScheduler>- </indexConfig>-- <updateHandler class="solr.DirectUpdateHandler2">- </updateHandler>--</config>diff --git a/solr/core/src/test/org/apache/solr/core/TestMergePolicyConfig.java b/solr/core/src/test/org/apache/solr/core/TestMergePolicyConfig.javaindex b47eef5a474..bb6525f83f4 100644--- a/solr/core/src/test/org/apache/solr/core/TestMergePolicyConfig.java+++ b/solr/core/src/test/org/apache/solr/core/TestMergePolicyConfig.java@@ -17,6 +17,8 @@ package org.apache.solr.core;* limitations under the License.*/+import org.apache.solr.update.SolrIndexConfigTest;+import org.apache.lucene.index.IndexReader;import org.apache.lucene.index.AtomicReader;import org.apache.lucene.index.AtomicReaderContext;@@ -25,6 +27,7 @@ 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.ConcurrentMergeScheduler;import org.apache.solr.core.SolrCore;import org.apache.solr.util.RefCounted;import org.apache.solr.search.SolrIndexSearcher;@@ -32,6 +35,7 @@ import org.apache.solr.SolrTestCaseJ4;import org.junit.After;import java.util.concurrent.atomic.AtomicInteger;+/** @see SolrIndexConfigTest */public class TestMergePolicyConfig extends SolrTestCaseJ4 {private static AtomicInteger docIdCounter = new AtomicInteger(42);diff --git a/solr/core/src/test/org/apache/solr/core/TestPropInject.java b/solr/core/src/test/org/apache/solr/core/TestPropInject.javadeleted file mode 100644index 1398f90c465..00000000000--- a/solr/core/src/test/org/apache/solr/core/TestPropInject.java+++ /dev/null@@ -1,57 +0,0 @@-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 org.apache.lucene.index.ConcurrentMergeScheduler;-import org.apache.lucene.index.IndexWriter;-import org.apache.lucene.index.LogByteSizeMergePolicy;-import org.apache.solr.update.DirectUpdateHandler2;-import org.apache.solr.util.AbstractSolrTestCase;-import org.apache.solr.util.RefCounted;-import org.junit.BeforeClass;--public class TestPropInject extends AbstractSolrTestCase {-- @BeforeClass- public static void beforeClass() throws Exception {- initCore("solrconfig-propinject.xml", "schema.xml");- }-- public void testMergePolicy() throws Exception {-- RefCounted<IndexWriter> iw = ((DirectUpdateHandler2)h.getCore().getUpdateHandler()).getSolrCoreState().getIndexWriter(h.getCore());- LogByteSizeMergePolicy mp;- try {- mp = (LogByteSizeMergePolicy)iw.get().getConfig().getMergePolicy();- } finally {- iw.decref();- }- assertEquals(64.0, mp.getMaxMergeMB(), 0);- }-- public void testProps() throws Exception {- RefCounted<IndexWriter> iw = ((DirectUpdateHandler2)h.getCore().getUpdateHandler()).getSolrCoreState().getIndexWriter(h.getCore());- ConcurrentMergeScheduler cms;- try {- cms = (ConcurrentMergeScheduler)iw.get().getConfig().getMergeScheduler();- } finally {- iw.decref();- }- assertEquals(2, cms.getMaxThreadCount());- }-}diff --git a/solr/core/src/test/org/apache/solr/core/TestPropInjectDefaults.java b/solr/core/src/test/org/apache/solr/core/TestPropInjectDefaults.javadeleted file mode 100644index ee586cb95cf..00000000000--- a/solr/core/src/test/org/apache/solr/core/TestPropInjectDefaults.java+++ /dev/null@@ -1,61 +0,0 @@-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 org.apache.lucene.index.ConcurrentMergeScheduler;-import org.apache.lucene.index.IndexWriter;-import org.apache.lucene.index.LogByteSizeMergePolicy;-import org.apache.solr.SolrTestCaseJ4;-import org.apache.solr.update.DirectUpdateHandler2;-import org.apache.solr.util.RefCounted;-import org.junit.BeforeClass;-import org.junit.Test;--public class TestPropInjectDefaults extends SolrTestCaseJ4 {- @BeforeClass- public static void beforeClass() throws Exception {- initCore("solrconfig-propinject-indexdefault.xml", "schema.xml");- }-- @Test- public void testMergePolicyDefaults() throws Exception {- RefCounted<IndexWriter> iw = ((DirectUpdateHandler2) h.getCore()- .getUpdateHandler()).getSolrCoreState().getIndexWriter(h.getCore());- LogByteSizeMergePolicy mp;- try {- mp = (LogByteSizeMergePolicy) iw.get().getConfig().getMergePolicy();- } finally {- iw.decref();- }- assertEquals(32.0, mp.getMaxMergeMB(), 0);- }-- @Test- public void testPropsDefaults() throws Exception {- RefCounted<IndexWriter> iw = ((DirectUpdateHandler2) h.getCore()- .getUpdateHandler()).getSolrCoreState().getIndexWriter(h.getCore());- ConcurrentMergeScheduler cms;- try {- cms = (ConcurrentMergeScheduler) iw.get().getConfig().getMergeScheduler();- } finally {- iw.decref();- }- assertEquals(4, cms.getMaxThreadCount());- }--}diff --git a/solr/core/src/test/org/apache/solr/update/SolrIndexConfigTest.java b/solr/core/src/test/org/apache/solr/update/SolrIndexConfigTest.javaindex 247b3523917..c1729bd301d 100644--- a/solr/core/src/test/org/apache/solr/update/SolrIndexConfigTest.java+++ b/solr/core/src/test/org/apache/solr/update/SolrIndexConfigTest.java@@ -19,8 +19,12 @@ package org.apache.solr.update;import java.io.File;+import org.apache.solr.core.TestMergePolicyConfig;+import org.apache.lucene.index.IndexWriterConfig;import org.apache.lucene.index.SimpleMergedSegmentWarmer;+import org.apache.lucene.index.TieredMergePolicy;+import org.apache.lucene.index.ConcurrentMergeScheduler;import org.apache.solr.SolrTestCaseJ4;import org.apache.solr.core.SolrConfig;import org.apache.solr.schema.IndexSchema;@@ -29,6 +33,8 @@ import org.junit.Test;/*** Testcase for {@link SolrIndexConfig}+ *+ * @see TestMergePolicyConfig*/public class SolrIndexConfigTest extends SolrTestCaseJ4 {@@ -52,10 +58,22 @@ public class SolrIndexConfigTest extends SolrTestCaseJ4 {SolrIndexConfig solrIndexConfig = new SolrIndexConfig(solrConfig, null,null);assertNotNull(solrIndexConfig);- assertEquals("org.apache.lucene.index.TieredMergePolicy",- solrIndexConfig.defaultMergePolicyClassName);IndexSchema indexSchema = IndexSchemaFactory.buildIndexSchema("schema.xml", solrConfig);- solrIndexConfig.toIndexWriterConfig(indexSchema);++ IndexWriterConfig iwc = solrIndexConfig.toIndexWriterConfig(indexSchema);++ assertNotNull("null mp", iwc.getMergePolicy());+ assertTrue("mp is not TMP", iwc.getMergePolicy() instanceof TieredMergePolicy);+ TieredMergePolicy mp = (TieredMergePolicy) iwc.getMergePolicy();+ assertEquals("mp.maxMergeAtOnceExplicit", 19, mp.getMaxMergeAtOnceExplicit());+ assertEquals("mp.segmentsPerTier",9,(int)mp.getSegmentsPerTier());++ assertNotNull("null ms", iwc.getMergeScheduler());+ assertTrue("ms is not CMS", iwc.getMergeScheduler() instanceof ConcurrentMergeScheduler);+ ConcurrentMergeScheduler ms = (ConcurrentMergeScheduler) iwc.getMergeScheduler();+ assertEquals("ms.maxMergeCount", 987, ms.getMaxMergeCount());+ assertEquals("ms.maxThreadCount", 42, ms.getMaxThreadCount());+}public void testMergedSegmentWarmerIndexConfigCreation() throws Exception {