You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by is...@apache.org on 2017/03/13 10:00:15 UTC
lucene-solr:branch_6x: SOLR-10079: Force in-place standalone test to
always use NoMergePolicy, also assert that it was used
Repository: lucene-solr
Updated Branches:
refs/heads/branch_6x 65526c84a -> c9204e4d0
SOLR-10079: Force in-place standalone test to always use NoMergePolicy, also assert that it was used
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/c9204e4d
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/c9204e4d
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/c9204e4d
Branch: refs/heads/branch_6x
Commit: c9204e4d0c4cfe27080795ddef28b98bb78567c4
Parents: 65526c8
Author: Ishan Chattopadhyaya <is...@apache.org>
Authored: Mon Mar 13 15:22:49 2017 +0530
Committer: Ishan Chattopadhyaya <is...@apache.org>
Committed: Mon Mar 13 15:23:42 2017 +0530
----------------------------------------------------------------------
.../update/TestInPlaceUpdatesStandalone.java | 27 ++++++++++++++++++++
1 file changed, 27 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/c9204e4d/solr/core/src/test/org/apache/solr/update/TestInPlaceUpdatesStandalone.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/update/TestInPlaceUpdatesStandalone.java b/solr/core/src/test/org/apache/solr/update/TestInPlaceUpdatesStandalone.java
index 9a5031f..877467e 100644
--- a/solr/core/src/test/org/apache/solr/update/TestInPlaceUpdatesStandalone.java
+++ b/solr/core/src/test/org/apache/solr/update/TestInPlaceUpdatesStandalone.java
@@ -32,6 +32,8 @@ import java.util.Random;
import java.util.Set;
import org.apache.lucene.index.FieldInfo;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.NoMergePolicy;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.client.solrj.SolrClient;
@@ -41,6 +43,7 @@ import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.SolrInputField;
+import org.apache.solr.index.NoMergePolicyFactory;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.update.processor.DistributedUpdateProcessor;
import org.apache.solr.schema.IndexSchema;
@@ -49,6 +52,7 @@ import org.apache.solr.search.SolrIndexSearcher;
import org.apache.solr.update.processor.AtomicUpdateDocumentMerger;
import org.apache.solr.util.RefCounted;
import org.junit.After;
+import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -67,6 +71,14 @@ public class TestInPlaceUpdatesStandalone extends SolrTestCaseJ4 {
System.setProperty("solr.tests.floatClassName", random().nextBoolean()? "TrieFloatField": "FloatPointField");
System.setProperty("solr.tests.doubleClassName", random().nextBoolean()? "TrieDoubleField": "DoublePointField");
+ // we need consistent segments that aren't re-ordered on merge because we're
+ // asserting inplace updates happen by checking the internal [docid]
+ systemSetPropertySolrTestsMergePolicyFactory(NoMergePolicyFactory.class.getName());
+
+ // HACK: Don't use a RandomMergePolicy, but only use the mergePolicyFactory that we've just set
+ System.setProperty(SYSTEM_PROPERTY_SOLR_TESTS_USEMERGEPOLICYFACTORY, "true");
+ System.setProperty(SYSTEM_PROPERTY_SOLR_TESTS_USEMERGEPOLICY, "false");
+
initCore("solrconfig-tlog.xml", "schema-inplace-updates.xml");
// sanity check that autocommits are disabled
@@ -75,6 +87,16 @@ public class TestInPlaceUpdatesStandalone extends SolrTestCaseJ4 {
assertEquals(-1, h.getCore().getSolrConfig().getUpdateHandlerInfo().autoCommmitMaxDocs);
assertEquals(-1, h.getCore().getSolrConfig().getUpdateHandlerInfo().autoSoftCommmitMaxDocs);
+ // assert that NoMergePolicy was chosen
+ RefCounted<IndexWriter> iw = h.getCore().getSolrCoreState().getIndexWriter(h.getCore());
+ try {
+ IndexWriter writer = iw.get();
+ assertTrue("Actual merge policy is: " + writer.getConfig().getMergePolicy(),
+ writer.getConfig().getMergePolicy() instanceof NoMergePolicy);
+ } finally {
+ iw.decref();
+ }
+
// validate that the schema was not changed to an unexpected state
IndexSchema schema = h.getCore().getLatestSchema();
for (String fieldName : Arrays.asList("_version_",
@@ -98,6 +120,11 @@ public class TestInPlaceUpdatesStandalone extends SolrTestCaseJ4 {
client = new EmbeddedSolrServer(h.getCoreContainer(), h.coreName);
}
+ @AfterClass
+ public static void afterClass() {
+ client = null;
+ }
+
@After
public void after() {
System.clearProperty("solr.tests.intClassName");