SOLR-4952: fix DirectUpdateHandlerTest, it can't handle RandomMergePolicy

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1510853 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Chris M. Hostetter 2013-08-06 04:45:02 +00:00
parent 80fb94c647
commit 74549edd2f
2 changed files with 10 additions and 4 deletions

View File

@ -22,8 +22,11 @@ A solrconfig.xml snippet containing indexConfig settings for randomized testing.
--> -->
<indexConfig> <indexConfig>
<!-- allways use this randomized policy --> <!-- this sys property is not set by SolrTestCaseJ4 because we ideally want to use
<mergePolicy class="org.apache.solr.util.RandomMergePolicy" /> the RandomMergePolicy in all tests - but some tests expect very specific
Merge behavior, so those tests can set it as needed.
-->
<mergePolicy class="${solr.tests.mergePolicy:org.apache.solr.util.RandomMergePolicy}" />
<useCompoundFile>${useCompoundFile:false}</useCompoundFile> <useCompoundFile>${useCompoundFile:false}</useCompoundFile>

View File

@ -21,6 +21,7 @@ import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.apache.lucene.index.TieredMergePolicy;
import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.store.Directory; import org.apache.lucene.store.Directory;
import org.apache.solr.SolrTestCaseJ4; import org.apache.solr.SolrTestCaseJ4;
@ -46,6 +47,7 @@ public class DirectUpdateHandlerTest extends SolrTestCaseJ4 {
savedFactory = System.getProperty("solr.DirectoryFactory"); savedFactory = System.getProperty("solr.DirectoryFactory");
System.setProperty("solr.directoryFactory", "org.apache.solr.core.MockFSDirectoryFactory"); System.setProperty("solr.directoryFactory", "org.apache.solr.core.MockFSDirectoryFactory");
System.setProperty("enable.update.log", "false"); // schema12 doesn't support _version_ System.setProperty("enable.update.log", "false"); // schema12 doesn't support _version_
System.setProperty("solr.tests.mergePolicy", TieredMergePolicy.class.getName());
initCore("solrconfig.xml", "schema12.xml"); initCore("solrconfig.xml", "schema12.xml");
} }
@ -271,13 +273,14 @@ public class DirectUpdateHandlerTest extends SolrTestCaseJ4 {
assertU(commit()); assertU(commit());
assertU(adoc("id","3")); assertU(adoc("id","3"));
assertU(adoc("id","2")); assertU(adoc("id","2")); // dup, triggers delete
assertU(adoc("id","4")); assertU(adoc("id","4"));
assertU(commit()); assertU(commit());
SolrQueryRequest sr = req("q","foo"); SolrQueryRequest sr = req("q","foo");
DirectoryReader r = sr.getSearcher().getIndexReader(); DirectoryReader r = sr.getSearcher().getIndexReader();
assertTrue(r.maxDoc() > r.numDocs()); // should have deletions assertTrue("maxDoc !> numDocs ... expected some deletions",
r.maxDoc() > r.numDocs());
sr.close(); sr.close();
assertU(commit("expungeDeletes","true")); assertU(commit("expungeDeletes","true"));