You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ho...@apache.org on 2017/01/06 01:44:57 UTC
lucene-solr:jira/solr-5944: SOLR-5944: beef up
TestInPlaceUpdatesStandalone in light of SOLR-9934
Repository: lucene-solr
Updated Branches:
refs/heads/jira/solr-5944 aeb114ffd -> 7c0ec19e6
SOLR-5944: beef up TestInPlaceUpdatesStandalone in light of SOLR-9934
in a previous commit, ishan changed TestInPlaceUpdatesStandalone to use some unique field names in order to work around SOLR-9934, but since the reasoning behind those unique fields wasn't entirely obvious i've updated deleteAllAndCommit to work around the underlying problem instead, and updated the test to show it works with a variety of fields
this commit also includes some field renaming in schema-inplace-updates.xml so updatable fields with defaults include their type in the name, and use non-0 defaults (so we can better assert that the default is being used properly if/when tests use these fields)
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/7c0ec19e
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/7c0ec19e
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/7c0ec19e
Branch: refs/heads/jira/solr-5944
Commit: 7c0ec19e6a0902d003a901052ca40fea69497d3c
Parents: aeb114f
Author: Chris Hostetter <ho...@apache.org>
Authored: Thu Jan 5 18:44:50 2017 -0700
Committer: Chris Hostetter <ho...@apache.org>
Committed: Thu Jan 5 18:44:50 2017 -0700
----------------------------------------------------------------------
.../collection1/conf/schema-inplace-updates.xml | 21 +++--
.../update/TestInPlaceUpdatesStandalone.java | 87 +++++++++++++-------
2 files changed, 73 insertions(+), 35 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7c0ec19e/solr/core/src/test-files/solr/collection1/conf/schema-inplace-updates.xml
----------------------------------------------------------------------
diff --git a/solr/core/src/test-files/solr/collection1/conf/schema-inplace-updates.xml b/solr/core/src/test-files/solr/collection1/conf/schema-inplace-updates.xml
index d3e86c4..b4084ea 100644
--- a/solr/core/src/test-files/solr/collection1/conf/schema-inplace-updates.xml
+++ b/solr/core/src/test-files/solr/collection1/conf/schema-inplace-updates.xml
@@ -16,21 +16,28 @@
limitations under the License.
-->
<schema name="inplace-updates" version="1.6">
+ <!-- nocommit: the entire code base (configs & java) needs to be searched for "updatEable"
+ nocommit: and all usages need to be replaced with the correct spelling: "updatable"
+ nocommit: (this isn't a schema specific concern, just needed a file to track it so i don't forget)
+ -->
+
<uniqueKey>id</uniqueKey>
<field name="id" type="string" indexed="true" stored="true" docValues="true"/>
<field name="_version_" type="long" indexed="false" stored="false" docValues="true" />
-
+
<!-- specific schema fields for dv in-place updates -->
- <!-- nocommit: most tests should be able to pass w/o these fields having default="0" -->
- <!-- nocommit: if any tests that actaully depend/use the the default field value,
- nocommit: then they should be changed to use a new field, with a non-0 default,
+ <!-- nocommit: tests should be able to pass w/o these fields having default="0" -->
+ <!-- nocommit: if any tests that actually depend/use the the default field value,
+ nocommit: then they should be changed to use inplace_updatable_float_with_def
+ nocommit: (or inplace_updatable_int_with_def) and assume the non-0 default value
nocommit: so we don't risk confusion with an *implicit* (in code) default of 0 -->
<field name="inplace_updatable_float" type="float" indexed="false" stored="false" docValues="true" default="0"/>
<field name="inplace_updatable_int" type="int" indexed="false" stored="false" docValues="true" default="0"/>
- <!-- To be used only in a single test, TestInPlaceUpdatesStandalone#testComputeInPlaceUpdateableFields() -->
- <field name="inplace_updateable_without_default" type="float" indexed="false" stored="false" docValues="true"/>
- <field name="inplace_updateable_with_default" type="float" indexed="false" stored="false" docValues="true" default="0"/>
+ <field name="inplace_updatable_float_with_default"
+ type="float" indexed="false" stored="false" docValues="true" default="42.0"/>
+ <field name="inplace_updatable_int_with_default"
+ type="int" indexed="false" stored="false" docValues="true" default="666"/>
<!-- dynamic fields which *ONLY* use docValues so they can be updated in place -->
<dynamicField name="*_i_dvo" multiValued="false" type="int" docValues="true" indexed="false" stored="false"/>
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7c0ec19e/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 465ffe0..cfadc6f 100644
--- a/solr/core/src/test/org/apache/solr/update/TestInPlaceUpdatesStandalone.java
+++ b/solr/core/src/test/org/apache/solr/update/TestInPlaceUpdatesStandalone.java
@@ -22,9 +22,11 @@ import static org.junit.internal.matchers.StringContains.containsString;
import static org.apache.solr.update.UpdateLogTest.buildAddUpdateCommand;
import java.util.Arrays;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
@@ -41,6 +43,7 @@ import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.SolrInputField;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.update.processor.DistributedUpdateProcessor;
+import org.apache.solr.update.processor.DistributedUpdateProcessor.DistribPhase;
import org.apache.solr.schema.IndexSchema;
import org.apache.solr.schema.SchemaField;
import org.apache.solr.search.SolrIndexSearcher;
@@ -50,6 +53,8 @@ import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
+import static org.apache.solr.update.processor.DistributingUpdateProcessorFactory.DISTRIB_UPDATE_PARAM;
+
/**
* Tests the in-place updates (docValues updates) for a standalone Solr instance.
@@ -70,8 +75,12 @@ public class TestInPlaceUpdatesStandalone extends SolrTestCaseJ4 {
// validate that the schema was not changed to an unexpected state
IndexSchema schema = h.getCore().getLatestSchema();
- for (String fieldName : Arrays.asList("_version_", "inplace_updatable_float", "inplace_l_dvo",
- "inplace_updateable_with_default", "inplace_updateable_without_default")) {
+ for (String fieldName : Arrays.asList("_version_",
+ "inplace_l_dvo",
+ "inplace_updatable_float",
+ "inplace_updatable_int",
+ "inplace_updatable_float_with_default",
+ "inplace_updatable_int_with_default")) {
// these fields must only be using docValues to support inplace updates
SchemaField field = schema.getField(fieldName);
assertTrue(field.toString(),
@@ -87,9 +96,18 @@ public class TestInPlaceUpdatesStandalone extends SolrTestCaseJ4 {
client = new EmbeddedSolrServer(h.getCoreContainer(), h.coreName);
}
+ @Override
+ public void clearIndex() {
+
+ }
+
@Before
public void deleteAllAndCommit() throws Exception {
- clearIndex();
+ // workaround for SOLR-9934
+ // we need to ensure that all low level IndexWriter metadata (about docvalue fields) is also deleted
+ deleteByQueryAndGetVersion("*:*", params("_version_", Long.toString(-Long.MAX_VALUE), DISTRIB_UPDATE_PARAM, DistribPhase.FROMLEADER.toString()));
+ // nocommit: if SOLR-9934 is committed before this branch is merged, replace above line with simple call to clearIndex();
+
assertU(commit("softCommit", "false"));
}
@@ -982,40 +1000,53 @@ public class TestInPlaceUpdatesStandalone extends SolrTestCaseJ4 {
public void testComputeInPlaceUpdateableFields() throws Exception {
Set<String> inPlaceUpdatedFields = new HashSet<String>();
- // In-place updateable field updated before it exists SHOULD NOT BE in-place updated:
- inPlaceUpdatedFields = callComputeInPlaceUpdateableFields(sdoc("id", "1", "_version_", 42L,
- "inplace_updateable_without_default", map("set", 10)));
- assertFalse(inPlaceUpdatedFields.contains("inplace_updateable_without_default"));
-
- // In-place updateable field updated after it exists SHOULD BE in-place updated:
- addAndGetVersion(sdoc("id", "1", "inplace_updateable_without_default", "0"), params()); // setting up the dv
- inPlaceUpdatedFields = callComputeInPlaceUpdateableFields(sdoc("id", "1", "_version_", 42L,
- "inplace_updateable_without_default", map("set", 10)));
- assertTrue(inPlaceUpdatedFields.contains("inplace_updateable_without_default"));
-
- inPlaceUpdatedFields = callComputeInPlaceUpdateableFields(sdoc("id", "1", "_version_", 42L,
- "inplace_updateable_without_default", map("inc", 10)));
- assertTrue(inPlaceUpdatedFields.contains("inplace_updateable_without_default"));
-
- // Updating an in-place updateable field (with a default) for the first time.
- // DV for it should have been already created when first document was indexed,
- // since it has a default value
- inPlaceUpdatedFields = callComputeInPlaceUpdateableFields(sdoc("id", "1", "_version_", 42L,
- "inplace_updateable_with_default", map("set", 10)));
- assertTrue(inPlaceUpdatedFields.contains("inplace_updateable_with_default"));
-
+ // these asserts should hold true regardless of type, or wether the field has a default
+ List<String> fieldsToCheck = Arrays.asList("inplace_updatable_float",
+ "inplace_updatable_int",
+ "inplace_updatable_float_with_default",
+ "inplace_updatable_int_with_default");
+ Collections.shuffle(fieldsToCheck, random()); // ... and regardless of order checked
+ for (String field : fieldsToCheck) {
+ // In-place updateable field updated before it exists SHOULD NOT BE in-place updated:
+ inPlaceUpdatedFields = callComputeInPlaceUpdateableFields(sdoc("id", "1", "_version_", 42L,
+ field, map("set", 10)));
+ assertFalse(field, inPlaceUpdatedFields.contains(field));
+
+ // In-place updateable field updated after it exists SHOULD BE in-place updated:
+ addAndGetVersion(sdoc("id", "1", field, "0"), params()); // setting up the dv
+ inPlaceUpdatedFields = callComputeInPlaceUpdateableFields(sdoc("id", "1", "_version_", 42L,
+ field, map("set", 10)));
+ assertTrue(field, inPlaceUpdatedFields.contains(field));
+
+ inPlaceUpdatedFields = callComputeInPlaceUpdateableFields(sdoc("id", "1", "_version_", 42L,
+ field, map("inc", 10)));
+ assertTrue(field, inPlaceUpdatedFields.contains(field));
+
+ final String altFieldWithDefault = field.contains("float") ?
+ "inplace_updatable_int_with_default" : "inplace_updatable_int_with_default";
+
+ // Updating an in-place updatable field (with a default) for the first time.
+ // DV for it should have been already created when first document was indexed (above),
+ // since it has a default value
+ inPlaceUpdatedFields = callComputeInPlaceUpdateableFields(sdoc("id", "1", "_version_", 42L,
+ altFieldWithDefault, map("set", 10)));
+ assertTrue(field + " -> " + altFieldWithDefault, inPlaceUpdatedFields.contains(altFieldWithDefault));
+
+ deleteAllAndCommit();
+ }
+
// Non in-place updates
addAndGetVersion(sdoc("id", "1", "stored_i", "0"), params()); // setting up the dv
assertTrue("stored field updated",
callComputeInPlaceUpdateableFields(sdoc("id", "1", "_version_", 42L, "stored_i", map("inc", 1))).isEmpty());
- assertTrue("No map means full document update",
+ assertTrue("full document update",
callComputeInPlaceUpdateableFields(sdoc("id", "1", "_version_", 42L,
- "inplace_updateable_with_default", "100")).isEmpty());
+ "inplace_updatable_int_with_default", "100")).isEmpty());
assertTrue("non existent dynamic dv field updated first time",
callComputeInPlaceUpdateableFields(sdoc("id", "1", "_version_", 42L,
- "new_updateable_int_i_dvo", map("set", 10))).isEmpty());
+ "new_updatable_int_i_dvo", map("set", 10))).isEmpty());
// After adding a full document with the dynamic dv field, in-place update should work
addAndGetVersion(sdoc("id", "2", "new_updateable_int_i_dvo", "0"), params()); // setting up the dv