You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rj...@apache.org on 2015/03/31 07:22:50 UTC
svn commit: r1670257 [30/39] - in /lucene/dev/branches/lucene6271: ./
dev-tools/ dev-tools/idea/.idea/libraries/ dev-tools/scripts/ lucene/
lucene/analysis/ lucene/analysis/common/
lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneou...
Modified: lucene/dev/branches/lucene6271/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java (original)
+++ lucene/dev/branches/lucene6271/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java Tue Mar 31 05:22:40 2015
@@ -58,6 +58,8 @@ import org.apache.solr.handler.component
import org.apache.solr.highlight.SolrHighlighter;
import org.apache.solr.parser.QueryParser;
import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.request.SolrRequestHandler;
+import org.apache.solr.request.json.RequestUtil;
import org.apache.solr.response.SolrQueryResponse;
import org.apache.solr.schema.IndexSchema;
import org.apache.solr.schema.SchemaField;
@@ -88,7 +90,7 @@ import org.apache.solr.search.SyntaxErro
* default parameter settings.
*/
public class SolrPluginUtils {
-
+
/**
* Map containing all the possible purposes codes of a request as key and
@@ -130,12 +132,16 @@ public class SolrPluginUtils {
* @param appends values to be appended to those from the request (or defaults) when dealing with multi-val params, or treated as another layer of defaults for singl-val params.
* @param invariants values which will be used instead of any request, or default values, regardless of context.
*/
- public static void setDefaults(SolrQueryRequest req, SolrParams defaults,
+ public static void setDefaults(SolrQueryRequest req, SolrParams defaults, SolrParams appends, SolrParams invariants) {
+ setDefaults(null, req, defaults, appends, invariants);
+ }
+
+ public static void setDefaults(SolrRequestHandler handler, SolrQueryRequest req, SolrParams defaults,
SolrParams appends, SolrParams invariants) {
- List<String> paramNames =null;
+ List<String> paramNames = null;
String useParams = req.getParams().get(RequestParams.USEPARAM);
- if(useParams!=null && !useParams.isEmpty()){
+ if (useParams != null && !useParams.isEmpty()) {
// now that we have expanded the request macro useParams with the actual values
// it makes no sense to keep it visible now on.
// distrib request sends all params to the nodes down the line and
@@ -143,25 +149,20 @@ public class SolrPluginUtils {
// which is not desirable. At the same time, because we send the useParams
// value as an empty string to other nodes we get the desired benefit of
// overriding the useParams specified in the requestHandler directly
- req.setParams(SolrParams.wrapDefaults(maskUseParams,req.getParams()));
+ req.setParams(SolrParams.wrapDefaults(maskUseParams, req.getParams()));
}
- if(useParams == null) useParams = (String) req.getContext().get(RequestParams.USEPARAM);
- if(useParams !=null && !useParams.isEmpty()) paramNames = StrUtils.splitSmart(useParams, ',');
- if(paramNames != null){
- for (String name : paramNames) {
- SolrParams requestParams = req.getCore().getSolrConfig().getRequestParams().getParams(name);
- if(requestParams !=null){
- defaults = SolrParams.wrapDefaults(requestParams , defaults);
- }
+ if (useParams == null) useParams = (String) req.getContext().get(RequestParams.USEPARAM);
+ if (useParams != null && !useParams.isEmpty()) paramNames = StrUtils.splitSmart(useParams, ',');
+ if (paramNames != null) {
+ for (String name : paramNames) {
+ SolrParams requestParams = req.getCore().getSolrConfig().getRequestParams().getParams(name);
+ if (requestParams != null) {
+ defaults = SolrParams.wrapDefaults(requestParams, defaults);
}
}
+ }
- SolrParams p = req.getParams();
- p = SolrParams.wrapDefaults(p, defaults);
- p = SolrParams.wrapAppended(p, appends);
- p = SolrParams.wrapDefaults(invariants, p);
-
- req.setParams(p);
+ RequestUtil.processParams(handler, req, defaults, appends, invariants);
}
Modified: lucene/dev/branches/lucene6271/solr/core/src/test-files/log4j.properties
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/core/src/test-files/log4j.properties?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/core/src/test-files/log4j.properties (original)
+++ lucene/dev/branches/lucene6271/solr/core/src/test-files/log4j.properties Tue Mar 31 05:22:40 2015
@@ -25,7 +25,7 @@ log4j.logger.org.apache.solr.hadoop=INFO
#log4j.logger.org.apache.solr.cloud.ChaosMonkey=DEBUG
#log4j.logger.org.apache.solr.update.TransactionLog=DEBUG
#log4j.logger.org.apache.solr.handler.ReplicationHandler=DEBUG
-#log4j.logger.org.apache.solr.handler.SnapPuller=DEBUG
+#log4j.logger.org.apache.solr.handler.IndexFetcher=DEBUG
#log4j.logger.org.apache.solr.common.cloud.ClusterStateUtil=DEBUG
#log4j.logger.org.apache.solr.cloud.OverseerAutoReplicaFailoverThread=DEBUG
\ No newline at end of file
Modified: lucene/dev/branches/lucene6271/solr/core/src/test-files/solr/collection1/conf/schema-enums.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/core/src/test-files/solr/collection1/conf/schema-enums.xml?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/core/src/test-files/solr/collection1/conf/schema-enums.xml (original)
+++ lucene/dev/branches/lucene6271/solr/core/src/test-files/solr/collection1/conf/schema-enums.xml Tue Mar 31 05:22:40 2015
@@ -21,6 +21,7 @@
<field name="_version_" type="long" indexed="true" stored="true" multiValued="false"/>
<!-- Test EnumField -->
<field name="severity" type="severityType" indexed="true" stored="true" multiValued="false"/>
+ <field name="severity_dv" type="severityType" indexed="true" stored="true" multiValued="false" docValues="true"/>
<field name="text" type="text" indexed="true" stored="true" multiValued="true"/>
</fields>
<uniqueKey>id</uniqueKey>
Modified: lucene/dev/branches/lucene6271/solr/core/src/test-files/solr/collection1/conf/schema-spatial.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/core/src/test-files/solr/collection1/conf/schema-spatial.xml?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/core/src/test-files/solr/collection1/conf/schema-spatial.xml (original)
+++ lucene/dev/branches/lucene6271/solr/core/src/test-files/solr/collection1/conf/schema-spatial.xml Tue Mar 31 05:22:40 2015
@@ -48,7 +48,7 @@
numberType="tdouble" distanceUnits="degrees"/>
<fieldType name="bbox" class="solr.BBoxField"
- numberType="tdoubleDV" distanceUnits="degrees"/>
+ numberType="tdoubleDV" distanceUnits="degrees" storeSubFields="false"/>
</types>
Modified: lucene/dev/branches/lucene6271/solr/core/src/test-files/solr/collection1/conf/schema.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/core/src/test-files/solr/collection1/conf/schema.xml?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/core/src/test-files/solr/collection1/conf/schema.xml (original)
+++ lucene/dev/branches/lucene6271/solr/core/src/test-files/solr/collection1/conf/schema.xml Tue Mar 31 05:22:40 2015
@@ -86,6 +86,8 @@
<fieldType name="tdatedv" class="solr.TrieDateField" precisionStep="6" docValues="true" multiValued="true"/>
<fieldType name="dateRange" class="solr.DateRangeField" />
+ <fieldType name="location_rpt" class="solr.SpatialRecursivePrefixTreeFieldType"
+ geo="true" distErrPct="0.025" maxDistErr="0.001" distanceUnits="kilometers" />
<!-- solr.TextField allows the specification of custom
text analyzers specified as a tokenizer and a list
@@ -101,6 +103,16 @@
</analyzer>
</fieldType>
+ <fieldtype name="text_payload_tv" class="solr.TextField">
+ <analyzer>
+ <tokenizer class="solr.StandardTokenizerFactory"/>
+ <filter class="solr.StandardFilterFactory"/>
+ <filter class="solr.LowerCaseFilterFactory"/>
+ <filter class="solr.StopFilterFactory"/>
+ <filter class="solr.PorterStemFilterFactory"/>
+ <filter class="org.apache.lucene.analysis.payloads.TokenOffsetPayloadTokenFilterFactory"/>
+ </analyzer>
+ </fieldtype>
<fieldType name="nametext" class="solr.TextField">
<analyzer class="org.apache.lucene.analysis.core.WhitespaceAnalyzer"/>
@@ -410,6 +422,7 @@
<tokenizer class="solr.WhitespaceTokenizerFactory" />
</analyzer>
</fieldType>
+ <fieldType name="severityType" class="solr.EnumField" enumsConfig="enumsConfig.xml" enumName="severity"/>
</types>
@@ -475,6 +488,8 @@
<field name="test_offtv" type="text" termVectors="true" termOffsets="true"/>
<field name="test_posofftv" type="text" termVectors="true"
termPositions="true" termOffsets="true"/>
+ <field name="test_posoffpaytv" type="text_payload_tv" termVectors="true"
+ termPositions="true" termOffsets="true" termPayloads="true"/>
<!-- test highlit field settings -->
<field name="test_hlt" type="highlittext" indexed="true"/>
@@ -548,6 +563,10 @@
<field name="payloadDelimited" type="payloadDelimited" />
+ <!-- EnumType -->
+ <field name="severity" type="severityType" indexed="true" stored="true" multiValued="false"/>
+
+
<!-- Dynamic field definitions. If a field name is not found, dynamicFields
will be used if the name matches any of the patterns.
RESTRICTION: the glob-like pattern in the name attribute must have
@@ -620,6 +639,7 @@
<dynamicField name="*_path" type="path" indexed="true" stored="true" omitNorms="true" multiValued="true" />
<dynamicField name="*_ancestor" type="ancestor_path" indexed="true" stored="true" omitNorms="true" multiValued="true" />
+ <dynamicField name="*_sev_enum" type="severityType" indexed="true" stored="true" docValues="true" multiValued="true" />
</fields>
<defaultSearchField>text</defaultSearchField>
Modified: lucene/dev/branches/lucene6271/solr/core/src/test-files/solr/collection1/conf/schema11.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/core/src/test-files/solr/collection1/conf/schema11.xml?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/core/src/test-files/solr/collection1/conf/schema11.xml (original)
+++ lucene/dev/branches/lucene6271/solr/core/src/test-files/solr/collection1/conf/schema11.xml Tue Mar 31 05:22:40 2015
@@ -283,6 +283,9 @@ valued. -->
</fieldType>
+ <!-- EnumType -->
+ <fieldType name="severityType" class="solr.EnumField" enumsConfig="enumsConfig.xml" enumName="severity"/>
+
<!-- Valid attributes for fields:
name: mandatory - the name for the field
type: mandatory - the name of a previously defined type from the <types> section
@@ -322,6 +325,10 @@ valued. -->
<field name="cat_floatDocValues" type="float" indexed="true" stored="true" docValues="true" multiValued="true" />
<field name="cat_length" type="text_length" indexed="true" stored="true" multiValued="true"/>
+
+ <!-- EnumType -->
+ <field name="severity" type="severityType" indexed="true" stored="true" multiValued="false"/>
+
<!-- Dynamic field definitions. If a field name is not found, dynamicFields
will be used if the name matches any of the patterns.
RESTRICTION: the glob-like pattern in the name attribute must have
Modified: lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/AnalysisAfterCoreReloadTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/AnalysisAfterCoreReloadTest.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/AnalysisAfterCoreReloadTest.java (original)
+++ lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/AnalysisAfterCoreReloadTest.java Tue Mar 31 05:22:40 2015
@@ -17,12 +17,9 @@ package org.apache.solr;
* limitations under the License.
*/
-import java.io.File;
-import java.io.IOException;
-
import org.apache.commons.io.FileUtils;
-import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrClient;
+import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
import org.apache.solr.client.solrj.request.AbstractUpdateRequest.ACTION;
import org.apache.solr.client.solrj.request.QueryRequest;
@@ -32,6 +29,9 @@ import org.apache.solr.core.SolrCore;
import org.junit.AfterClass;
import org.junit.BeforeClass;
+import java.io.File;
+import java.io.IOException;
+
public class AnalysisAfterCoreReloadTest extends SolrTestCaseJ4 {
private static String tmpSolrHome;
@@ -138,7 +138,7 @@ public class AnalysisAfterCoreReloadTest
}
protected SolrClient getSolrCore() {
- return new EmbeddedSolrServer(h.getCore());
+ return new EmbeddedSolrServer(h.getCoreContainer(), collection);
}
}
Modified: lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/BasicFunctionalityTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/BasicFunctionalityTest.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/BasicFunctionalityTest.java (original)
+++ lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/BasicFunctionalityTest.java Tue Mar 31 05:22:40 2015
@@ -17,6 +17,8 @@
package org.apache.solr;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.StringWriter;
@@ -26,18 +28,10 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
import org.apache.lucene.document.Field;
import org.apache.lucene.document.LazyDocument;
-import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.StorableField;
import org.apache.lucene.index.StoredDocument;
-import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.IOContext.Context;
-import org.apache.lucene.store.MockDirectoryWrapper;
-import org.apache.lucene.util.English;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.MapSolrParams;
@@ -56,10 +50,7 @@ import org.apache.solr.schema.IndexSchem
import org.apache.solr.schema.SchemaField;
import org.apache.solr.search.DocIterator;
import org.apache.solr.search.DocList;
-import org.apache.solr.update.DirectUpdateHandler2;
-import org.apache.solr.util.RefCounted;
import org.junit.BeforeClass;
-import org.junit.Ignore;
import org.junit.Test;
/**
@@ -540,6 +531,11 @@ public class BasicFunctionalityTest exte
assertTrue(f.storeTermVector() && f.storeTermPositions() && f.storeTermOffsets());
assertTrue(luf.fieldType().storeTermVectorOffsets() && luf.fieldType().storeTermVectorPositions());
+ f = ischema.getField("test_posoffpaytv");
+ luf = f.createField("test", 0f);
+ assertTrue(f.storeTermVector() && f.storeTermPositions() && f.storeTermOffsets() && f.storeTermPayloads());
+ assertTrue(luf.fieldType().storeTermVectorOffsets() && luf.fieldType().storeTermVectorPositions() && luf.fieldType().storeTermVectorPayloads());
+
}
@Test
Modified: lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/OutputWriterTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/OutputWriterTest.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/OutputWriterTest.java (original)
+++ lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/OutputWriterTest.java Tue Mar 31 05:22:40 2015
@@ -19,16 +19,13 @@ package org.apache.solr;
import java.io.IOException;
import java.io.Writer;
-import java.util.List;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.util.NamedList;
-import org.apache.solr.core.PluginInfo;
-import org.apache.solr.core.SolrCore;
+import org.apache.solr.core.PluginBag;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.response.QueryResponseWriter;
import org.apache.solr.response.SolrQueryResponse;
-import org.apache.solr.response.XMLResponseWriter;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -94,11 +91,12 @@ public class OutputWriterTest extends So
}
public void testLazy() {
- QueryResponseWriter qrw = h.getCore().getQueryResponseWriter("useless");
- assertTrue("Should be a lazy class", qrw instanceof SolrCore.LazyQueryResponseWriterWrapper);
+ PluginBag.PluginHolder<QueryResponseWriter> qrw = h.getCore().getResponseWriters().getRegistry().get("useless");
+ assertTrue("Should be a lazy class", qrw instanceof PluginBag.LazyPluginHolder);
- qrw = h.getCore().getQueryResponseWriter("xml");
- assertTrue("Should not be a lazy class", qrw instanceof XMLResponseWriter);
+ qrw = h.getCore().getResponseWriters().getRegistry().get("xml");
+ assertTrue("Should not be a lazy class", qrw.isLoaded());
+ assertTrue("Should not be a lazy class", qrw.getClass() == PluginBag.PluginHolder.class);
}
Modified: lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/TestDistributedGrouping.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/TestDistributedGrouping.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/TestDistributedGrouping.java (original)
+++ lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/TestDistributedGrouping.java Tue Mar 31 05:22:40 2015
@@ -26,6 +26,8 @@ import org.apache.solr.common.params.Mod
import org.apache.solr.common.util.NamedList;
import org.junit.Test;
+import java.io.IOException;
+
/**
* TODO? perhaps use:
* http://docs.codehaus.org/display/JETTY/ServletTester
@@ -266,7 +268,7 @@ public class TestDistributedGrouping ext
simpleQuery("q", "*:*", "rows", 10, "fl", "id," + i1, "group", "true", "group.field", i1, "debug", "true");
}
- private void simpleQuery(Object... queryParams) throws SolrServerException {
+ private void simpleQuery(Object... queryParams) throws SolrServerException, IOException {
ModifiableSolrParams params = new ModifiableSolrParams();
for (int i = 0; i < queryParams.length; i += 2) {
params.add(queryParams[i].toString(), queryParams[i + 1].toString());
Modified: lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/TestDistributedSearch.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/TestDistributedSearch.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/TestDistributedSearch.java (original)
+++ lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/TestDistributedSearch.java Tue Mar 31 05:22:40 2015
@@ -17,28 +17,46 @@
package org.apache.solr;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-
import org.apache.commons.lang.StringUtils;
import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.solr.client.solrj.SolrClient;
+import org.apache.solr.client.solrj.SolrQuery;
+import org.apache.solr.client.solrj.SolrResponse;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.response.FacetField;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.client.solrj.response.RangeFacet;
+import org.apache.solr.client.solrj.response.FieldStatsInfo;
import org.apache.solr.cloud.ChaosMonkey;
+import org.apache.solr.common.EnumFieldValue;
import org.apache.solr.common.SolrException;
+import org.apache.solr.common.SolrException.ErrorCode;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.params.ShardParams;
+import org.apache.solr.common.params.SolrParams;
+import org.apache.solr.common.params.StatsParams;
import org.apache.solr.common.util.NamedList;
+import org.apache.solr.handler.component.ShardResponse;
+import org.apache.solr.handler.component.ShardRequest;
+import org.apache.solr.handler.component.StatsField.Stat;
+import org.apache.solr.handler.component.TrackingShardHandlerFactory;
+import org.apache.solr.handler.component.TrackingShardHandlerFactory.ShardRequestAndParams;
+import org.apache.solr.handler.component.TrackingShardHandlerFactory.RequestTrackingQueue;
+import org.apache.solr.handler.component.StatsComponentTest.StatSetCombinations;
import org.junit.Test;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.EnumSet;
+
/**
* TODO? perhaps use:
* http://docs.codehaus.org/display/JETTY/ServletTester
@@ -62,18 +80,25 @@ public class TestDistributedSearch exten
String missingField="ignore_exception__missing_but_valid_field_t";
String invalidField="ignore_exception__invalid_field_not_in_schema";
+ @Override
+ protected String getSolrXml() {
+ return "solr-trackingshardhandler.xml";
+ }
+
@Test
public void test() throws Exception {
QueryResponse rsp = null;
int backupStress = stress; // make a copy so we can restore
-
del("*:*");
indexr(id,1, i1, 100, tlong, 100,t1,"now is the time for all good men",
+ "foo_sev_enum", "Medium",
tdate_a, "2010-04-20T11:00:00Z",
tdate_b, "2009-08-20T11:00:00Z",
"foo_f", 1.414f, "foo_b", "true", "foo_d", 1.414d);
indexr(id,2, i1, 50 , tlong, 50,t1,"to come to the aid of their country.",
+ "foo_sev_enum", "Medium",
+ "foo_sev_enum", "High",
tdate_a, "2010-05-02T11:00:00Z",
tdate_b, "2009-11-02T11:00:00Z");
indexr(id,3, i1, 2, tlong, 2,t1,"how now brown cow",
@@ -89,6 +114,7 @@ public class TestDistributedSearch exten
indexr(id,7, i1, 123, tlong, 123 ,t1,"humpty dumpy had a great fall");
indexr(id,8, i1, 876, tlong, 876,
tdate_b, "2010-01-05T11:00:00Z",
+ "foo_sev_enum", "High",
t1,"all the kings horses and all the kings men");
indexr(id,9, i1, 7, tlong, 7,t1,"couldn't put humpty together again");
@@ -96,6 +122,7 @@ public class TestDistributedSearch exten
indexr(id,10, i1, 4321, tlong, 4321,t1,"this too shall pass");
indexr(id,11, i1, -987, tlong, 987,
+ "foo_sev_enum", "Medium",
t1,"An eye for eye only ends up making the whole world blind.");
indexr(id,12, i1, 379, tlong, 379,
t1,"Great works are performed, not by strength, but by perseverance.");
@@ -126,6 +153,9 @@ public class TestDistributedSearch exten
handle.put("timestamp", SKIPVAL);
handle.put("_version_", SKIPVAL); // not a cloud test, but may use updateLog
+ //Test common query parameters.
+ validateCommonQueryParameters();
+
// random value sort
for (String f : fieldNames) {
query("q","*:*", "sort",f+" desc");
@@ -362,11 +392,53 @@ public class TestDistributedSearch exten
query("q","*:*", "rows",100, "facet","true", "facet.field",missingField, "facet.mincount",2);
// test field that is valid in schema and missing in some shards
query("q","*:*", "rows",100, "facet","true", "facet.field",oddField, "facet.mincount",2);
-
+
query("q","*:*", "sort",i1+" desc", "stats", "true", "stats.field", "stats_dt");
query("q","*:*", "sort",i1+" desc", "stats", "true", "stats.field", i1);
query("q","*:*", "sort",i1+" desc", "stats", "true", "stats.field", tdate_a);
query("q","*:*", "sort",i1+" desc", "stats", "true", "stats.field", tdate_b);
+
+ query("q", "*:*", "sort", i1 + " desc", "stats", "true", "stats.field",
+ "{!percentiles='1,2,3,4,5'}" + i1);
+
+ query("q", "*:*", "sort", i1 + " desc", "stats", "true", "stats.field",
+ "{!percentiles='1,20,30,40,98,99,99.9'}" + i1);
+
+ rsp = query("q", "*:*", "sort", i1 + " desc", "stats", "true", "stats.field",
+ "{!percentiles='1.0,99.999,0.001'}" + tlong);
+ { // don't leak variabls
+ Double[] expectedKeys = new Double[] { 1.0D, 99.999D, 0.001D };
+ Double[] expectedVals = new Double[] { 2.0D, 4320.0D, 2.0D };
+ FieldStatsInfo s = rsp.getFieldStatsInfo().get(tlong);
+ assertNotNull("no stats for " + tlong, s);
+
+ Map<Double,Double> p = s.getPercentiles();
+ assertNotNull("no percentils", p);
+ assertEquals("insufficient percentiles", expectedKeys.length, p.size());
+ Iterator<Double> actualKeys = p.keySet().iterator();
+ for (int i = 0; i < expectedKeys.length; i++) {
+ Double expectedKey = expectedKeys[i];
+ assertTrue("Ran out of actual keys as of : "+ i + "->" +expectedKey,
+ actualKeys.hasNext());
+ assertEquals(expectedKey, actualKeys.next());
+ assertEquals("percentiles are off: " + p.toString(),
+ expectedVals[i], p.get(expectedKey), 1.0D);
+ }
+
+ //
+ assertNull("expected null for count", s.getMin());
+ assertNull("expected null for count", s.getMean());
+ assertNull("expected null for count", s.getCount());
+ assertNull("expected null for calcDistinct", s.getCountDistinct());
+ assertNull("expected null for distinct vals", s.getDistinctValues());
+ assertNull("expected null for max", s.getMax());
+ assertNull("expected null for missing", s.getMissing());
+ assertNull("expected null for stddev", s.getStddev());
+ assertNull("expected null for sum", s.getSum());
+ }
+
+ query("q", "*:*", "sort", i1 + " desc", "stats", "true", "stats.field",
+ "{!percentiles='1,20,50,80,99'}" + tdate_a);
query("q","*:*", "sort",i1+" desc", "stats", "true",
"fq", "{!tag=nothing}-*:*",
@@ -391,6 +463,313 @@ public class TestDistributedSearch exten
"stats.field", i1,
"stats.field", tdate_a,
"stats.field", tdate_b);
+
+ // only ask for "min" and "mean", explicitly exclude deps of mean, whitebox check shard responses
+ try {
+ RequestTrackingQueue trackingQueue = new RequestTrackingQueue();
+ TrackingShardHandlerFactory.setTrackingQueue(jettys, trackingQueue);
+
+ rsp = query("q","*:*", "sort",i1+" desc", "stats", "true",
+ "stats.field", "{!min=true sum=false mean=true count=false}" + i1);
+ FieldStatsInfo s = rsp.getFieldStatsInfo().get(i1);
+ assertNotNull("no stats for " + i1, s);
+ //
+ assertEquals("wrong min", -987.0D, (Double)s.getMin(), 0.0001D );
+ assertEquals("wrong mean", 377.153846D, (Double)s.getMean(), 0.0001D );
+ //
+ assertNull("expected null for count", s.getCount());
+ assertNull("expected null for calcDistinct", s.getCountDistinct());
+ assertNull("expected null for distinct vals", s.getDistinctValues());
+ assertNull("expected null for max", s.getMax());
+ assertNull("expected null for missing", s.getMissing());
+ assertNull("expected null for stddev", s.getStddev());
+ assertNull("expected null for sum", s.getSum());
+ assertNull("expected null for percentiles", s.getPercentiles());
+
+ // sanity check deps relationship
+ for (Stat dep : EnumSet.of(Stat.sum, Stat.count)) {
+ assertTrue("Purpose of this test is to ensure that asking for some stats works even when the deps " +
+ "of those stats are explicitly excluded -- but the expected dep relationshp is no longer valid. " +
+ "ie: who changed the code and didn't change this test?, expected: " + dep,
+ Stat.mean.getDistribDeps().contains(dep));
+ }
+
+ // check our shard requests & responses - ensure we didn't get unneccessary stats from every shard
+ int numStatsShardRequests = 0;
+ EnumSet<Stat> shardStatsExpected = EnumSet.of(Stat.min, Stat.sum, Stat.count);
+ for (List<ShardRequestAndParams> shard : trackingQueue.getAllRequests().values()) {
+ for (ShardRequestAndParams shardReq : shard) {
+ if (shardReq.params.getBool(StatsParams.STATS, false)) {
+ numStatsShardRequests++;
+ for (ShardResponse shardRsp : shardReq.sreq.responses) {
+ NamedList<Object> shardStats =
+ ((NamedList<NamedList<NamedList<Object>>>)
+ shardRsp.getSolrResponse().getResponse().get("stats")).get("stats_fields").get(i1);
+
+ assertNotNull("no stard stats for " + i1, shardStats);
+ //
+ for (Map.Entry<String,Object> entry : shardStats) {
+ Stat found = Stat.forName(entry.getKey());
+ assertNotNull("found shardRsp stat key we were not expecting: " + entry, found);
+ assertTrue("found stat we were not expecting: " + entry, shardStatsExpected.contains(found));
+
+ }
+ }
+ }
+ }
+ }
+ assertTrue("did't see any stats=true shard requests", 0 < numStatsShardRequests);
+ } finally {
+ TrackingShardHandlerFactory.setTrackingQueue(jettys, null);
+ }
+
+ // only ask for "min", "mean" and "stddev",
+ rsp = query("q","*:*", "sort",i1+" desc", "stats", "true",
+ "stats.field", "{!min=true mean=true stddev=true}" + i1);
+ { // don't leak variables
+ FieldStatsInfo s = rsp.getFieldStatsInfo().get(i1);
+ assertNotNull("no stats for " + i1, s);
+ //
+ assertEquals("wrong min", -987.0D, (Double)s.getMin(), 0.0001D );
+ assertEquals("wrong mean", 377.153846D, (Double)s.getMean(), 0.0001D );
+ assertEquals("wrong stddev", 1271.76215D, (Double)s.getStddev(), 0.0001D );
+ //
+ assertNull("expected null for count", s.getCount());
+ assertNull("expected null for calcDistinct", s.getCountDistinct());
+ assertNull("expected null for distinct vals", s.getDistinctValues());
+ assertNull("expected null for max", s.getMax());
+ assertNull("expected null for missing", s.getMissing());
+ assertNull("expected null for sum", s.getSum());
+ assertNull("expected null for percentiles", s.getPercentiles());
+ }
+
+ // request stats, but disable them all via param refs
+ rsp = query("q","*:*", "sort",i1+" desc", "stats", "true", "doMin", "false",
+ "stats.field", "{!min=$doMin}" + i1);
+ { // don't leak variables
+ FieldStatsInfo s = rsp.getFieldStatsInfo().get(i1);
+ // stats section should exist, even though stats should be null
+ assertNotNull("no stats for " + i1, s);
+ //
+ assertNull("expected null for min", s.getMin() );
+ assertNull("expected null for mean", s.getMean() );
+ assertNull("expected null for stddev", s.getStddev() );
+ //
+ assertNull("expected null for count", s.getCount());
+ assertNull("expected null for calcDistinct", s.getCountDistinct());
+ assertNull("expected null for distinct vals", s.getDistinctValues());
+ assertNull("expected null for max", s.getMax());
+ assertNull("expected null for missing", s.getMissing());
+ assertNull("expected null for sum", s.getSum());
+ assertNull("expected null for percentiles", s.getPercentiles());
+ }
+
+ final String[] stats = new String[] {
+ "min", "max", "sum", "sumOfSquares", "stddev", "mean", "missing", "count"
+ };
+
+ // ask for arbitrary pairs of stats
+ for (String stat1 : stats) {
+ for (String stat2 : stats) {
+ // NOTE: stat1 might equal stat2 - good edge case to test for
+
+ rsp = query("q","*:*", "sort",i1+" desc", "stats", "true",
+ "stats.field", "{!" + stat1 + "=true " + stat2 + "=true}" + i1);
+
+ final List<String> statsExpected = new ArrayList<String>(2);
+ statsExpected.add(stat1);
+ if ( ! stat1.equals(stat2) ) {
+ statsExpected.add(stat2);
+ }
+
+ // ignore the FieldStatsInfo convinience class, and look directly at the NamedList
+ // so we don't need any sort of crazy reflection
+ NamedList<Object> svals =
+ ((NamedList<NamedList<NamedList<Object>>>)
+ rsp.getResponse().get("stats")).get("stats_fields").get(i1);
+
+ assertNotNull("no stats for field " + i1, svals);
+ assertEquals("wrong quantity of stats", statsExpected.size(), svals.size());
+
+
+ for (String s : statsExpected) {
+ assertNotNull("stat shouldn't be null: " + s, svals.get(s));
+ assertTrue("stat should be a Number: " + s + " -> " + svals.get(s).getClass(),
+ svals.get(s) instanceof Number);
+ // some loose assertions since we're iterating over various stats
+ if (svals.get(s) instanceof Double) {
+ Double val = (Double) svals.get(s);
+ assertFalse("stat shouldn't be NaN: " + s, val.isNaN());
+ assertFalse("stat shouldn't be Inf: " + s, val.isInfinite());
+ assertFalse("stat shouldn't be 0: " + s, val.equals(0.0D));
+ } else {
+ // count or missing
+ assertTrue("stat should be count of missing: " + s,
+ ("count".equals(s) || "missing".equals(s)));
+ assertTrue("stat should be a Long: " + s + " -> " + svals.get(s).getClass(),
+ svals.get(s) instanceof Long);
+ Long val = (Long) svals.get(s);
+ assertFalse("stat shouldn't be 0: " + s, val.equals(0L));
+ }
+ }
+ }
+ }
+
+ // all of these diff ways of asking for min & calcdistinct should have the same result
+ for (SolrParams p : new SolrParams[] {
+ params("stats.field", "{!min=true calcdistinct=true}" + i1),
+ params("stats.calcdistinct", "true",
+ "stats.field", "{!min=true}" + i1),
+ params("f."+i1+".stats.calcdistinct", "true",
+ "stats.field", "{!min=true}" + i1),
+ params("stats.calcdistinct", "false",
+ "f."+i1+".stats.calcdistinct", "true",
+ "stats.field", "{!min=true}" + i1),
+ params("stats.calcdistinct", "false",
+ "f."+i1+".stats.calcdistinct", "false",
+ "stats.field", "{!min=true calcdistinct=true}" + i1),
+ }) {
+
+ rsp = query(SolrParams.wrapDefaults
+ (p, params("q","*:*", "sort",i1+" desc", "stats", "true")));
+ FieldStatsInfo s = rsp.getFieldStatsInfo().get(i1);
+ assertNotNull(p+" no stats for " + i1, s);
+ //
+ assertEquals(p+" wrong min", -987.0D, (Double)s.getMin(), 0.0001D );
+ assertEquals(p+" wrong calcDistinct", new Long(13), s.getCountDistinct());
+ assertNotNull(p+" expected non-null list for distinct vals", s.getDistinctValues());
+ assertEquals(p+" expected list for distinct vals", 13, s.getDistinctValues().size());
+ //
+ assertNull(p+" expected null for mean", s.getMean() );
+ assertNull(p+" expected null for count", s.getCount());
+ assertNull(p+" expected null for max", s.getMax());
+ assertNull(p+" expected null for missing", s.getMissing());
+ assertNull(p+" expected null for stddev", s.getStddev());
+ assertNull(p+" expected null for sum", s.getSum());
+ assertNull(p+" expected null for percentiles", s.getPercentiles());
+
+ }
+
+ // all of these diff ways of excluding calcdistinct should have the same result
+ for (SolrParams p : new SolrParams[] {
+ params("stats.field", "{!min=true calcdistinct=false}" + i1),
+ params("stats.calcdistinct", "false",
+ "stats.field", "{!min=true}" + i1),
+ params("f."+i1+".stats.calcdistinct", "false",
+ "stats.field", "{!min=true}" + i1),
+ params("stats.calcdistinct", "true",
+ "f."+i1+".stats.calcdistinct", "false",
+ "stats.field", "{!min=true}" + i1),
+ params("stats.calcdistinct", "true",
+ "f."+i1+".stats.calcdistinct", "true",
+ "stats.field", "{!min=true calcdistinct=false}" + i1),
+ }) {
+
+ rsp = query(SolrParams.wrapDefaults
+ (p, params("q","*:*", "sort",i1+" desc", "stats", "true")));
+ FieldStatsInfo s = rsp.getFieldStatsInfo().get(i1);
+ assertNotNull(p+" no stats for " + i1, s);
+ //
+ assertEquals(p+" wrong min", -987.0D, (Double)s.getMin(), 0.0001D );
+ //
+ assertNull(p+" expected null for calcDistinct", s.getCountDistinct());
+ assertNull(p+" expected null for distinct vals", s.getDistinctValues());
+ //
+ assertNull(p+" expected null for mean", s.getMean() );
+ assertNull(p+" expected null for count", s.getCount());
+ assertNull(p+" expected null for max", s.getMax());
+ assertNull(p+" expected null for missing", s.getMissing());
+ assertNull(p+" expected null for stddev", s.getStddev());
+ assertNull(p+" expected null for sum", s.getSum());
+ assertNull(p+"expected null for percentiles", s.getPercentiles());
+
+ }
+
+ // this field doesn't exist in any doc in the result set.
+ // ensure we get expected values for the stats we ask for, but null for the stats
+ rsp = query("q","*:*", "sort",i1+" desc", "stats", "true",
+ "stats.field", "{!min=true mean=true stddev=true}does_not_exist_i");
+ { // don't leak variables
+ FieldStatsInfo s = rsp.getFieldStatsInfo().get("does_not_exist_i");
+ assertNotNull("no stats for bogus field", s);
+
+ // things we explicit expect because we asked for them
+ // NOTE: min is expected to be null even though requested because of no values
+ assertEquals("wrong min", null, s.getMin());
+ assertTrue("mean should be NaN", ((Double)s.getMean()).isNaN());
+ assertEquals("wrong stddev", 0.0D, (Double)s.getStddev(), 0.0D );
+
+ // things that we didn't ask for, so they better be null
+ assertNull("expected null for count", s.getCount());
+ assertNull("expected null for calcDistinct", s.getCountDistinct());
+ assertNull("expected null for distinct vals", s.getDistinctValues());
+ assertNull("expected null for max", s.getMax());
+ assertNull("expected null for missing", s.getMissing());
+ assertNull("expected null for sum", s.getSum());
+ assertNull("expected null for percentiles", s.getPercentiles());
+ }
+
+ // look at stats on non numeric fields
+ //
+ // not all stats are supported on every field type, so some of these permutations will
+ // result in no stats being computed but this at least lets us sanity check that for each
+ // of these field+stats(s) combinations we get consistent results between the distribted
+ // request and the single node situation.
+ //
+ // NOTE: percentiles excluded because it doesn't support simple 'true/false' syntax
+ // (and since it doesn't work for non-numerics anyway, we aren't missing any coverage here)
+ EnumSet<Stat> allStats = EnumSet.complementOf(EnumSet.of(Stat.percentiles));
+
+ int numTotalStatQueries = 0;
+ // don't go overboard, just do all permutations of 1 or 2 stat params, for each field & query
+ final int numStatParamsAtOnce = 2;
+ for (int numParams = 1; numParams <= numStatParamsAtOnce; numParams++) {
+ for (EnumSet<Stat> set : new StatSetCombinations(numParams, allStats)) {
+
+ for (String field : new String[] {
+ "foo_f", i1, tlong, tdate_a, oddField, "foo_sev_enum",
+ // fields that no doc has any value in
+ "bogus___s", "bogus___f", "bogus___i", "bogus___tdt", "bogus___sev_enum"
+ }) {
+
+ for ( String q : new String[] {
+ "*:*", // all docs
+ "bogus___s:bogus", // no docs
+ "id:" + random().nextInt(50 ), // 0 or 1 doc...
+ "id:" + random().nextInt(50 ),
+ "id:" + random().nextInt(100),
+ "id:" + random().nextInt(100),
+ "id:" + random().nextInt(200)
+ }) {
+
+ // EnumSets use natural ordering, we want to randomize the order of the params
+ List<Stat> combo = new ArrayList<Stat>(set);
+ Collections.shuffle(combo, random());
+
+ StringBuilder paras = new StringBuilder("{!key=k ");
+
+ for (Stat stat : combo) {
+ paras.append(stat + "=true ");
+ }
+
+ paras.append("}").append(field);
+ numTotalStatQueries++;
+ rsp = query("q","*:*", "rows", "0", "stats", "true",
+ "stats.field", paras.toString());
+ // simple assert, mostly relying on comparison with single shard
+ FieldStatsInfo s = rsp.getFieldStatsInfo().get("k");
+ assertNotNull(s);
+
+ // TODO: if we had a programatic way to determine what stats are supported
+ // by what field types, we could make more confident asserts here.
+ }
+ }
+ }
+ }
+ assertEquals("Sanity check failed: either test broke, or test changed, or you adjusted Stat enum" +
+ " (adjust constant accordingly if intentional)",
+ 3465, numTotalStatQueries);
+
/*** TODO: the failure may come back in "exception"
try {
@@ -566,6 +945,27 @@ public class TestDistributedSearch exten
throw e;
}
}
+
+ String fieldName = "severity";
+ indexr("id", "1", fieldName, "Not Available");
+ indexr("id", "2", fieldName, "Low");
+ indexr("id", "3", fieldName, "Medium");
+ indexr("id", "4", fieldName, "High");
+ indexr("id", "5", fieldName, "Critical");
+
+ commit();
+
+ rsp = query("q", "*:*", "stats", "true", "stats.field", fieldName);
+ assertEquals(new EnumFieldValue(0, "Not Available"),
+ rsp.getFieldStatsInfo().get(fieldName).getMin());
+ query("q", "*:*", "stats", "true", "stats.field", fieldName,
+ StatsParams.STATS_CALC_DISTINCT, "true");
+ assertEquals(new EnumFieldValue(4, "Critical"),
+ rsp.getFieldStatsInfo().get(fieldName).getMax());
+
+ handle.put("severity", UNORDERED); // this is stupid, but stats.facet doesn't garuntee order
+ query("q", "*:*", "stats", "true", "stats.field", fieldName,
+ "stats.facet", fieldName);
}
protected void checkMinCountsField(List<FacetField.Count> counts, Object[] pairs) {
@@ -633,7 +1033,7 @@ public class TestDistributedSearch exten
if (verifyStress) {
comparePartialResponses(rsp, controlRsp, upShards);
}
- } catch (SolrServerException e) {
+ } catch (SolrServerException | IOException e) {
throw new RuntimeException(e);
}
}
@@ -648,7 +1048,7 @@ public class TestDistributedSearch exten
}
}
- protected QueryResponse queryRandomUpServer(ModifiableSolrParams params, List<SolrClient> upClients) throws SolrServerException {
+ protected QueryResponse queryRandomUpServer(ModifiableSolrParams params, List<SolrClient> upClients) throws SolrServerException, IOException {
// query a random "up" server
int which = r.nextInt(upClients.size());
SolrClient client = upClients.get(which);
@@ -691,4 +1091,24 @@ public class TestDistributedSearch exten
super.validateControlData(control);
assertNull("Expected the partialResults header to be null", control.getHeader().get("partialResults"));
}
+
+ private void validateCommonQueryParameters() throws Exception {
+ try {
+ SolrQuery query = new SolrQuery();
+ query.setStart(-1).setQuery("*");
+ QueryResponse resp = query(query);
+ fail("Expected the last query to fail, but got response: " + resp);
+ } catch (SolrException e) {
+ assertEquals(ErrorCode.BAD_REQUEST.code, e.code());
+ }
+
+ try {
+ SolrQuery query = new SolrQuery();
+ query.setRows(-1).setStart(0).setQuery("*");
+ QueryResponse resp = query(query);
+ fail("Expected the last query to fail, but got response: " + resp);
+ } catch (SolrException e) {
+ assertEquals(ErrorCode.BAD_REQUEST.code, e.code());
+ }
+ }
}
Modified: lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/TestSolrCoreProperties.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/TestSolrCoreProperties.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/TestSolrCoreProperties.java (original)
+++ lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/TestSolrCoreProperties.java Tue Mar 31 05:22:40 2015
@@ -73,7 +73,7 @@ public class TestSolrCoreProperties exte
Files.createFile(collDir.toPath().resolve("core.properties"));
- jetty = new JettySolrRunner(homeDir.getAbsolutePath(), "/solr", 0, null, null, true, null, sslConfig);
+ jetty = new JettySolrRunner(homeDir.getAbsolutePath(), buildJettyConfig("/solr"));
// this sets the property for jetty starting SolrDispatchFilter
if (System.getProperty("solr.data.dir") == null && System.getProperty("solr.hdfs.home") == null) {
Modified: lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/TestTolerantSearch.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/TestTolerantSearch.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/TestTolerantSearch.java (original)
+++ lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/TestTolerantSearch.java Tue Mar 31 05:22:40 2015
@@ -58,7 +58,7 @@ public class TestTolerantSearch extends
@BeforeClass
public static void createThings() throws Exception {
solrHome = createSolrHome();
- createJetty(solrHome.getAbsolutePath(), null, null);
+ createJetty(solrHome.getAbsolutePath());
String url = jetty.getBaseUrl().toString();
collection1 = new HttpSolrClient(url + "/collection1");
collection2 = new HttpSolrClient(url + "/collection2");
@@ -109,7 +109,7 @@ public class TestTolerantSearch extends
}
@SuppressWarnings("unchecked")
- public void testGetFieldsPhaseError() throws SolrServerException {
+ public void testGetFieldsPhaseError() throws SolrServerException, IOException {
BadResponseWriter.failOnGetFields = true;
BadResponseWriter.failOnGetTopIds = false;
SolrQuery query = new SolrQuery();
@@ -157,7 +157,7 @@ public class TestTolerantSearch extends
}
@SuppressWarnings("unchecked")
- public void testGetTopIdsPhaseError() throws SolrServerException {
+ public void testGetTopIdsPhaseError() throws SolrServerException, IOException {
BadResponseWriter.failOnGetTopIds = true;
BadResponseWriter.failOnGetFields = false;
SolrQuery query = new SolrQuery();
Modified: lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/ActionThrottleTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/ActionThrottleTest.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/ActionThrottleTest.java (original)
+++ lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/ActionThrottleTest.java Tue Mar 31 05:22:40 2015
@@ -17,9 +17,12 @@ package org.apache.solr.cloud;
* limitations under the License.
*/
+import java.util.Arrays;
+import java.util.List;
import java.util.concurrent.TimeUnit;
import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.cloud.ActionThrottle.NanoTimeSource;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -27,6 +30,21 @@ import org.slf4j.LoggerFactory;
public class ActionThrottleTest extends SolrTestCaseJ4 {
protected static Logger log = LoggerFactory.getLogger(ActionThrottleTest.class);
+ static class TestNanoTimeSource implements NanoTimeSource {
+
+ private List<Long> returnValues;
+ private int index = 0;
+
+ public TestNanoTimeSource(List<Long> returnValues) {
+ this.returnValues = returnValues;
+ }
+
+ @Override
+ public long getTime() {
+ return returnValues.get(index++);
+ }
+
+ }
@Test
public void testBasics() throws Exception {
@@ -59,5 +77,21 @@ public class ActionThrottleTest extends
assertTrue(elaspsedTime + "ms", elaspsedTime >= 995);
}
+
+ @Test
+ public void testAZeroNanoTimeReturnInWait() throws Exception {
+
+ ActionThrottle at = new ActionThrottle("test", 1000, new TestNanoTimeSource(Arrays.asList(new Long[]{0L, 10L})));
+ long start = System.nanoTime();
+
+ at.markAttemptingAction();
+
+ at.minimumWaitBetweenActions();
+
+ long elaspsedTime = TimeUnit.MILLISECONDS.convert(System.nanoTime() - start, TimeUnit.NANOSECONDS);
+
+ assertTrue(elaspsedTime + "ms", elaspsedTime >= 995);
+
+ }
}
Modified: lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZk2Test.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZk2Test.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZk2Test.java (original)
+++ lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZk2Test.java Tue Mar 31 05:22:40 2015
@@ -18,12 +18,14 @@ package org.apache.solr.cloud;
*/
import java.io.IOException;
+import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import com.google.common.collect.Lists;
+
import org.apache.lucene.mockfile.FilterPath;
import org.apache.solr.SolrTestCaseJ4.SuppressSSL;
import org.apache.solr.client.solrj.SolrClient;
@@ -417,9 +419,10 @@ public class BasicDistributedZk2Test ext
checkBackupStatus.fetchStatus();
Thread.sleep(1000);
}
- ArrayList<Path> files = Lists.newArrayList(Files.newDirectoryStream(location, "snapshot*").iterator());
-
- assertEquals(Arrays.asList(files).toString(), 1, files.size());
+ try (DirectoryStream<Path> stream = Files.newDirectoryStream(location, "snapshot*")) {
+ ArrayList<Path> files = Lists.newArrayList(stream.iterator());
+ assertEquals(Arrays.asList(files).toString(), 1, files.size());
+ }
}
Modified: lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java (original)
+++ lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java Tue Mar 31 05:22:40 2015
@@ -1127,7 +1127,7 @@ public class BasicDistributedZkTest exte
}
@Override
- protected QueryResponse queryServer(ModifiableSolrParams params) throws SolrServerException {
+ protected QueryResponse queryServer(ModifiableSolrParams params) throws SolrServerException, IOException {
if (r.nextBoolean())
return super.queryServer(params);
Modified: lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/BasicZkTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/BasicZkTest.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/BasicZkTest.java (original)
+++ lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/BasicZkTest.java Tue Mar 31 05:22:40 2015
@@ -25,7 +25,6 @@ import org.apache.solr.common.util.Named
import org.apache.solr.core.SolrCore;
import org.apache.solr.request.LocalSolrQueryRequest;
import org.apache.solr.request.SolrQueryRequest;
-import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -106,7 +105,10 @@ public class BasicZkTest extends Abstrac
int zkPort = zkServer.getPort();
zkServer.shutdown();
-
+
+ // document indexing shouldn't stop immediately after a ZK disconnect
+ assertU(adoc("id", "201"));
+
Thread.sleep(300);
// try a reconnect from disconnect
@@ -174,9 +176,4 @@ public class BasicZkTest extends Abstrac
req.setParams(params);
return req;
}
-
- @AfterClass
- public static void afterClass() {
-
- }
}
Modified: lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java (original)
+++ lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java Tue Mar 31 05:22:40 2015
@@ -115,11 +115,15 @@ public class ChaosMonkeyNothingIsSafeTes
numShards = sliceCount + random().nextInt(TEST_NIGHTLY ? 12 : 2) + 1;
}
fixShardCount(numShards);
+
+ // None of the operations used here are particularly costly, so this should work.
+ // Using this low timeout will also help us catch index stalling.
+ clientSoTimeout = 5000;
}
@Test
public void test() throws Exception {
- boolean testsSuccesful = false;
+ boolean testSuccessful = false;
try {
handle.clear();
handle.put("timestamp", SKIPVAL);
@@ -133,14 +137,14 @@ public class ChaosMonkeyNothingIsSafeTes
// we cannot do delete by query
// as it's not supported for recovery
- del("*:*");
+ del("*:*");
- List<StopableThread> threads = new ArrayList<>();
- List<StopableIndexingThread> indexTreads = new ArrayList<>();
+ List<StoppableThread> threads = new ArrayList<>();
+ List<StoppableIndexingThread> indexTreads = new ArrayList<>();
int threadCount = TEST_NIGHTLY ? 3 : 1;
int i = 0;
for (i = 0; i < threadCount; i++) {
- StopableIndexingThread indexThread = new StopableIndexingThread(controlClient, cloudClient, Integer.toString(i), true);
+ StoppableIndexingThread indexThread = new StoppableIndexingThread(controlClient, cloudClient, Integer.toString(i), true);
threads.add(indexThread);
indexTreads.add(indexThread);
indexThread.start();
@@ -149,7 +153,7 @@ public class ChaosMonkeyNothingIsSafeTes
threadCount = 1;
i = 0;
for (i = 0; i < threadCount; i++) {
- StopableSearchThread searchThread = new StopableSearchThread();
+ StoppableSearchThread searchThread = new StoppableSearchThread(cloudClient);
threads.add(searchThread);
searchThread.start();
}
@@ -158,7 +162,7 @@ public class ChaosMonkeyNothingIsSafeTes
// it's currently hard to know what requests failed when using ConcurrentSolrUpdateServer
boolean runFullThrottle = random().nextBoolean();
if (runFullThrottle) {
- FullThrottleStopableIndexingThread ftIndexThread = new FullThrottleStopableIndexingThread(
+ FullThrottleStoppableIndexingThread ftIndexThread = new FullThrottleStoppableIndexingThread(
clients, "ft1", true);
threads.add(ftIndexThread);
ftIndexThread.start();
@@ -184,15 +188,18 @@ public class ChaosMonkeyNothingIsSafeTes
} finally {
chaosMonkey.stopTheMonkey();
}
-
- for (StopableThread indexThread : threads) {
+
+ // ideally this should go into chaosMonkey
+ restartZk(1000 * (5 + random().nextInt(4)));
+
+ for (StoppableThread indexThread : threads) {
indexThread.safeStop();
}
// start any downed jetties to be sure we still will end up with a leader per shard...
// wait for stop...
- for (StopableThread indexThread : threads) {
+ for (StoppableThread indexThread : threads) {
indexThread.join();
}
@@ -217,9 +224,11 @@ public class ChaosMonkeyNothingIsSafeTes
// we expect full throttle fails, but cloud client should not easily fail
- for (StopableThread indexThread : threads) {
- if (indexThread instanceof StopableIndexingThread && !(indexThread instanceof FullThrottleStopableIndexingThread)) {
- assertFalse("There were too many update fails - we expect it can happen, but shouldn't easily", ((StopableIndexingThread) indexThread).getFailCount() > FAIL_TOLERANCE);
+ for (StoppableThread indexThread : threads) {
+ if (indexThread instanceof StoppableIndexingThread && !(indexThread instanceof FullThrottleStoppableIndexingThread)) {
+ int failCount = ((StoppableIndexingThread) indexThread).getFailCount();
+ assertFalse("There were too many update fails (" + failCount + " > " + FAIL_TOLERANCE
+ + ") - we expect it can happen, but shouldn't easily", failCount > FAIL_TOLERANCE);
}
}
@@ -247,11 +256,8 @@ public class ChaosMonkeyNothingIsSafeTes
// sometimes we restart zookeeper as well
if (random().nextBoolean()) {
- zkServer.shutdown();
- zkServer = new ZkTestServer(zkServer.getZkDir(), zkServer.getPort());
- zkServer.run();
+ restartZk(1000 * (5 + random().nextInt(4)));
}
-
try (CloudSolrClient client = createCloudClient("collection1")) {
createCollection(null, "testcollection",
@@ -263,31 +269,31 @@ public class ChaosMonkeyNothingIsSafeTes
numShardsNumReplicas.add(1);
checkForCollection("testcollection", numShardsNumReplicas, null);
- testsSuccesful = true;
+ testSuccessful = true;
} finally {
- if (!testsSuccesful) {
+ if (!testSuccessful) {
printLayout();
}
}
}
- private Set<String> getAddFails(List<StopableIndexingThread> threads) {
+ private Set<String> getAddFails(List<StoppableIndexingThread> threads) {
Set<String> addFails = new HashSet<String>();
- for (StopableIndexingThread thread : threads) {
+ for (StoppableIndexingThread thread : threads) {
addFails.addAll(thread.getAddFails());
}
return addFails;
}
- private Set<String> getDeleteFails(List<StopableIndexingThread> threads) {
+ private Set<String> getDeleteFails(List<StoppableIndexingThread> threads) {
Set<String> deleteFails = new HashSet<String>();
- for (StopableIndexingThread thread : threads) {
+ for (StoppableIndexingThread thread : threads) {
deleteFails.addAll(thread.getDeleteFails());
}
return deleteFails;
}
- class FullThrottleStopableIndexingThread extends StopableIndexingThread {
+ class FullThrottleStoppableIndexingThread extends StoppableIndexingThread {
private CloseableHttpClient httpClient = HttpClientUtil.createClient(null);
private volatile boolean stop = false;
int clientIndex = 0;
@@ -295,14 +301,14 @@ public class ChaosMonkeyNothingIsSafeTes
private List<SolrClient> clients;
private AtomicInteger fails = new AtomicInteger();
- public FullThrottleStopableIndexingThread(List<SolrClient> clients,
- String id, boolean doDeletes) {
+ public FullThrottleStoppableIndexingThread(List<SolrClient> clients,
+ String id, boolean doDeletes) {
super(controlClient, cloudClient, id, doDeletes);
setName("FullThrottleStopableIndexingThread");
setDaemon(true);
this.clients = clients;
- HttpClientUtil.setConnectionTimeout(httpClient, 15000);
- HttpClientUtil.setSoTimeout(httpClient, 15000);
+ HttpClientUtil.setConnectionTimeout(httpClient, clientConnectionTimeout);
+ HttpClientUtil.setSoTimeout(httpClient, clientSoTimeout);
cusc = new ConcurrentUpdateSolrClient(
((HttpSolrClient) clients.get(0)).getBaseURL(), httpClient, 8,
2) {
Modified: lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderTest.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderTest.java (original)
+++ lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderTest.java Tue Mar 31 05:22:40 2015
@@ -110,10 +110,23 @@ public class ChaosMonkeySafeLeaderTest e
tryDelete();
- List<StopableIndexingThread> threads = new ArrayList<>();
+ List<StoppableIndexingThread> threads = new ArrayList<>();
int threadCount = 2;
+ int batchSize = 1;
+ if (random().nextBoolean()) {
+ batchSize = random().nextInt(98) + 2;
+ }
+
+ boolean pauseBetweenUpdates = TEST_NIGHTLY ? random().nextBoolean() : true;
+ int maxUpdates = -1;
+ if (!pauseBetweenUpdates) {
+ maxUpdates = 1000 + random().nextInt(1000);
+ } else {
+ maxUpdates = 15000;
+ }
+
for (int i = 0; i < threadCount; i++) {
- StopableIndexingThread indexThread = new StopableIndexingThread(controlClient, cloudClient, Integer.toString(i), true);
+ StoppableIndexingThread indexThread = new StoppableIndexingThread(controlClient, cloudClient, Integer.toString(i), true, maxUpdates, batchSize, pauseBetweenUpdates); // random().nextInt(999) + 1
threads.add(indexThread);
indexThread.start();
}
@@ -139,16 +152,16 @@ public class ChaosMonkeySafeLeaderTest e
chaosMonkey.stopTheMonkey();
}
- for (StopableIndexingThread indexThread : threads) {
+ for (StoppableIndexingThread indexThread : threads) {
indexThread.safeStop();
}
// wait for stop...
- for (StopableIndexingThread indexThread : threads) {
+ for (StoppableIndexingThread indexThread : threads) {
indexThread.join();
}
- for (StopableIndexingThread indexThread : threads) {
+ for (StoppableIndexingThread indexThread : threads) {
assertEquals(0, indexThread.getFailCount());
}
@@ -158,7 +171,7 @@ public class ChaosMonkeySafeLeaderTest e
waitForThingsToLevelOut(180000);
- checkShardConsistency(true, true);
+ checkShardConsistency(batchSize == 1, true);
if (VERBOSE) System.out.println("control docs:" + controlClient.query(new SolrQuery("*:*")).getResults().getNumFound() + "\n\n");
Modified: lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyShardSplitTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyShardSplitTest.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyShardSplitTest.java (original)
+++ lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyShardSplitTest.java Tue Mar 31 05:22:40 2015
@@ -27,9 +27,10 @@ import org.apache.solr.common.cloud.Repl
import org.apache.solr.common.cloud.Slice;
import org.apache.solr.common.cloud.SolrZkClient;
import org.apache.solr.common.cloud.ZkStateReader;
+import org.apache.solr.core.CloudConfig;
import org.apache.solr.handler.component.HttpShardHandlerFactory;
import org.apache.solr.update.UpdateShardHandler;
-import org.apache.solr.util.MockConfigSolr;
+import org.apache.solr.update.UpdateShardHandlerConfig;
import org.apache.zookeeper.KeeperException;
import org.junit.Ignore;
import org.junit.Test;
@@ -242,10 +243,10 @@ public class ChaosMonkeyShardSplitTest e
SolrZkClient zkClient = new SolrZkClient(address, TIMEOUT);
ZkStateReader reader = new ZkStateReader(zkClient);
LeaderElector overseerElector = new LeaderElector(zkClient);
- UpdateShardHandler updateShardHandler = new UpdateShardHandler(null);
+ UpdateShardHandler updateShardHandler = new UpdateShardHandler(UpdateShardHandlerConfig.DEFAULT);
// TODO: close Overseer
- Overseer overseer = new Overseer(
- new HttpShardHandlerFactory().getShardHandler(), updateShardHandler, "/admin/cores", reader, null, new MockConfigSolr());
+ Overseer overseer = new Overseer(new HttpShardHandlerFactory().getShardHandler(), updateShardHandler, "/admin/cores",
+ reader, null, new CloudConfig.CloudConfigBuilder("127.0.0.1", 8983, "solr").build());
overseer.close();
ElectionContext ec = new OverseerElectionContext(zkClient, overseer,
address.replaceAll("/", "_"));
Modified: lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java (original)
+++ lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java Tue Mar 31 05:22:40 2015
@@ -100,7 +100,7 @@ import static org.apache.solr.common.clo
*/
@Slow
public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBase {
-
+
private static final String DEFAULT_COLLECTION = "collection1";
private static final boolean DEBUG = false;
@@ -139,7 +139,8 @@ public class CollectionsAPIDistributedZk
// for now, always upload the config and schema to the canonical names
AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, getCloudSolrConfig(), "solrconfig.xml");
AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "schema.xml", "schema.xml");
-
+ AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "enumsConfig.xml", "enumsConfig.xml");
+
AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "solrconfig.snippet.randomindexconfig.xml");
AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "stopwords.txt");
AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "protwords.txt");
@@ -646,6 +647,7 @@ public class CollectionsAPIDistributedZk
if (random().nextBoolean()) {
JettySolrRunner jetty = jettys.get(random().nextInt(jettys.size()));
ChaosMonkey.stop(jetty);
+ log.info("============ Restarting jetty");
ChaosMonkey.start(jetty);
for (Entry<String,List<Integer>> entry : collectionInfosEntrySet) {
@@ -665,6 +667,7 @@ public class CollectionsAPIDistributedZk
// sometimes we restart zookeeper
if (random().nextBoolean()) {
zkServer.shutdown();
+ log.info("============ Restarting zookeeper");
zkServer = new ZkTestServer(zkServer.getZkDir(), zkServer.getPort());
zkServer.run();
}
@@ -1144,7 +1147,7 @@ public class CollectionsAPIDistributedZk
}
@Override
- protected QueryResponse queryServer(ModifiableSolrParams params) throws SolrServerException {
+ protected QueryResponse queryServer(ModifiableSolrParams params) throws SolrServerException, IOException {
if (r.nextBoolean())
return super.queryServer(params);
Modified: lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/CustomCollectionTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/CustomCollectionTest.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/CustomCollectionTest.java (original)
+++ lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/CustomCollectionTest.java Tue Mar 31 05:22:40 2015
@@ -42,6 +42,7 @@ import org.apache.solr.util.DefaultSolrT
import org.junit.BeforeClass;
import org.junit.Test;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -57,8 +58,8 @@ import java.util.concurrent.ThreadPoolEx
import java.util.concurrent.TimeUnit;
import static org.apache.solr.cloud.OverseerCollectionProcessor.NUM_SLICES;
-import static org.apache.solr.cloud.OverseerCollectionProcessor.ROUTER;
import static org.apache.solr.cloud.OverseerCollectionProcessor.SHARDS_PROP;
+import static org.apache.solr.common.cloud.DocCollection.DOC_ROUTER;
import static org.apache.solr.common.cloud.ZkStateReader.MAX_SHARDS_PER_NODE;
import static org.apache.solr.common.cloud.ZkStateReader.REPLICATION_FACTOR;
import static org.apache.solr.common.params.ShardParams._ROUTE_;
@@ -208,7 +209,7 @@ public class CustomCollectionTest extend
ClusterState clusterState = zkStateReader.getClusterState();
DocCollection coll = clusterState.getCollection(COLL_PREFIX + 0);
- assertEquals("implicit", ((Map)coll.get(ROUTER)).get("name") );
+ assertEquals("implicit", ((Map)coll.get(DOC_ROUTER)).get("name") );
assertNotNull(coll.getStr(REPLICATION_FACTOR));
assertNotNull(coll.getStr(MAX_SHARDS_PER_NODE));
assertNull("A shard of a Collection configured with implicit router must have null range",
@@ -447,7 +448,7 @@ public class CustomCollectionTest extend
@Override
- protected QueryResponse queryServer(ModifiableSolrParams params) throws SolrServerException {
+ protected QueryResponse queryServer(ModifiableSolrParams params) throws SolrServerException, IOException {
if (r.nextBoolean())
return super.queryServer(params);
Modified: lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/DistribDocExpirationUpdateProcessorTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/DistribDocExpirationUpdateProcessorTest.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/DistribDocExpirationUpdateProcessorTest.java (original)
+++ lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/DistribDocExpirationUpdateProcessorTest.java Tue Mar 31 05:22:40 2015
@@ -168,8 +168,8 @@ public class DistribDocExpirationUpdateP
* Query is garunteed to be executed at least once.
*/
private void waitForNoResults(int maxTimeLimitSeconds,
- SolrParams params)
- throws SolrServerException, InterruptedException {
+ SolrParams params)
+ throws SolrServerException, InterruptedException, IOException {
final long giveUpAfter = System.currentTimeMillis() + (1000L * maxTimeLimitSeconds);
long numFound = cloudClient.query(params).getResults().getNumFound();
Modified: lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java (original)
+++ lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java Tue Mar 31 05:22:40 2015
@@ -751,7 +751,7 @@ public class FullSolrCloudDistribCmdsTes
assertEquals(1, res.getResults().getNumFound());
}
- private QueryResponse query(SolrClient client) throws SolrServerException {
+ private QueryResponse query(SolrClient client) throws SolrServerException, IOException {
SolrQuery query = new SolrQuery("*:*");
return client.query(query);
}
Modified: lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java (original)
+++ lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java Tue Mar 31 05:22:40 2015
@@ -17,7 +17,6 @@ package org.apache.solr.cloud;
* limitations under the License.
*/
-import org.apache.http.NoHttpResponseException;
import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.solr.JSONTestUtil;
import org.apache.solr.SolrTestCaseJ4.SuppressSSL;
@@ -26,7 +25,6 @@ import org.apache.solr.client.solrj.embe
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.request.QueryRequest;
-import org.apache.solr.client.solrj.request.UpdateRequest;
import org.apache.solr.client.solrj.response.CollectionAdminResponse;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrInputDocument;
@@ -48,6 +46,7 @@ import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -145,7 +144,7 @@ public class HttpPartitionTest extends A
String replicaUrl = replicaCoreNodeProps.getCoreUrl();
assertTrue(!zkController.isReplicaInRecoveryHandling(replicaUrl));
- assertTrue(zkController.ensureReplicaInLeaderInitiatedRecovery(testCollectionName, shardId, replicaUrl, replicaCoreNodeProps, false));
+ assertTrue(zkController.ensureReplicaInLeaderInitiatedRecovery(testCollectionName, shardId, replicaCoreNodeProps, leader.getName(), false, true));
assertTrue(zkController.isReplicaInRecoveryHandling(replicaUrl));
Map<String,Object> lirStateMap = zkController.getLeaderInitiatedRecoveryStateObject(testCollectionName, shardId, notLeader.getName());
assertNotNull(lirStateMap);
@@ -473,38 +472,15 @@ public class HttpPartitionTest extends A
String url = zkProps.getBaseUrl() + "/" + coll;
return new HttpSolrClient(url);
}
-
- protected void doSendDoc(int docid) throws Exception {
- UpdateRequest up = new UpdateRequest();
- up.setParam(UpdateRequest.MIN_REPFACT, String.valueOf(2));
- SolrInputDocument doc = new SolrInputDocument();
- doc.addField(id, String.valueOf(docid));
- doc.addField("a_t", "hello" + docid);
- up.add(doc);
- int minAchievedRf =
- cloudClient.getMinAchievedReplicationFactor(cloudClient.getDefaultCollection(), cloudClient.request(up));
- }
-
+
protected void sendDoc(int docId) throws Exception {
- try {
- doSendDoc(docId);
- } catch (SolrServerException e) {
- if (e.getRootCause() instanceof NoHttpResponseException) {
- // we don't know if the doc was accepted or not, we send again
- Thread.sleep(100);
- try {
- doSendDoc(docId);
- } catch (SolrServerException e2) {
- if (e2.getRootCause() instanceof NoHttpResponseException) {
- // we don't know if the doc was accepted or not, we send again
- Thread.sleep(3000);
- doSendDoc(docId);
- }
- }
- }
- }
+ SolrInputDocument doc = new SolrInputDocument();
+ doc.addField(id, String.valueOf(docId));
+ doc.addField("a_t", "hello" + docId);
+
+ sendDocsWithRetry(Collections.singletonList(doc), 2, 3, 100);
}
-
+
/**
* Query the real-time get handler for a specific doc by ID to verify it
* exists in the provided server, using distrib=false so it doesn't route to another replica.
Modified: lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/MigrateRouteKeyTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/MigrateRouteKeyTest.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/MigrateRouteKeyTest.java (original)
+++ lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/MigrateRouteKeyTest.java Tue Mar 31 05:22:40 2015
@@ -50,25 +50,6 @@ public class MigrateRouteKeyTest extends
schemaString = "schema15.xml"; // we need a string id
}
- @Override
- public void distribSetUp() throws Exception {
- super.distribSetUp();
- System.setProperty("numShards", Integer.toString(sliceCount));
- System.setProperty("solr.xml.persist", "true");
- }
-
- @Override
- public void distribTearDown() throws Exception {
- super.distribTearDown();
-
- System.clearProperty("zkHost");
- System.clearProperty("numShards");
- System.clearProperty("solr.xml.persist");
-
- // insurance
- DirectUpdateHandler2.commitOnClose = true;
- }
-
@Test
public void test() throws Exception {
waitForThingsToLevelOut(15);
Modified: lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java?rev=1670257&r1=1670256&r2=1670257&view=diff
==============================================================================
--- lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java (original)
+++ lucene/dev/branches/lucene6271/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java Tue Mar 31 05:22:40 2015
@@ -17,23 +17,6 @@ package org.apache.solr.cloud;
* limitations under the License.
*/
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import javax.xml.parsers.ParserConfigurationException;
-
import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.cloud.overseer.OverseerAction;
@@ -45,10 +28,11 @@ import org.apache.solr.common.cloud.Solr
import org.apache.solr.common.cloud.ZkNodeProps;
import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.common.params.CollectionParams;
+import org.apache.solr.core.CloudConfig;
import org.apache.solr.handler.component.HttpShardHandlerFactory;
import org.apache.solr.update.UpdateShardHandler;
+import org.apache.solr.update.UpdateShardHandlerConfig;
import org.apache.solr.util.DefaultSolrThreadFactory;
-import org.apache.solr.util.MockConfigSolr;
import org.apache.solr.util.stats.Snapshot;
import org.apache.solr.util.stats.Timer;
import org.apache.solr.util.stats.TimerContext;
@@ -63,6 +47,22 @@ import org.junit.Ignore;
import org.junit.Test;
import org.xml.sax.SAXException;
+import javax.xml.parsers.ParserConfigurationException;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.concurrent.atomic.AtomicInteger;
+
@Slow
public class OverseerTest extends SolrTestCaseJ4 {
@@ -86,6 +86,9 @@ public class OverseerTest extends SolrTe
public MockZKController(String zkAddress, String nodeName) throws InterruptedException, TimeoutException, IOException, KeeperException {
this.nodeName = nodeName;
zkClient = new SolrZkClient(zkAddress, TIMEOUT);
+
+ ZkController.createClusterZkNodes(zkClient);
+
zkStateReader = new ZkStateReader(zkClient);
zkStateReader.createClusterStateWatchersAndUpdate();
@@ -235,7 +238,7 @@ public class OverseerTest extends SolrTe
AbstractZkTestCase.makeSolrZkNode(server.getZkHost());
zkClient = new SolrZkClient(server.getZkAddress(), TIMEOUT);
- zkClient.makePath(ZkStateReader.LIVE_NODES_ZKNODE, true);
+ ZkController.createClusterZkNodes(zkClient);
overseerClient = electNewOverseer(server.getZkAddress());
@@ -290,7 +293,7 @@ public class OverseerTest extends SolrTe
AbstractZkTestCase.makeSolrZkNode(server.getZkHost());
zkClient = new SolrZkClient(server.getZkAddress(), TIMEOUT);
- zkClient.makePath(ZkStateReader.LIVE_NODES_ZKNODE, true);
+ ZkController.createClusterZkNodes(zkClient);
overseerClient = electNewOverseer(server.getZkAddress());
@@ -370,7 +373,7 @@ public class OverseerTest extends SolrTe
AbstractZkTestCase.makeSolrZkNode(server.getZkHost());
zkClient = new SolrZkClient(server.getZkAddress(), TIMEOUT);
- zkClient.makePath(ZkStateReader.LIVE_NODES_ZKNODE, true);
+ ZkController.createClusterZkNodes(zkClient);
overseerClient = electNewOverseer(server.getZkAddress());
@@ -534,7 +537,7 @@ public class OverseerTest extends SolrTe
AbstractZkTestCase.tryCleanSolrZkNode(server.getZkHost());
AbstractZkTestCase.makeSolrZkNode(server.getZkHost());
- zkClient.makePath("/live_nodes", true);
+ ZkController.createClusterZkNodes(zkClient);
reader = new ZkStateReader(zkClient);
reader.createClusterStateWatchersAndUpdate();
@@ -632,8 +635,8 @@ public class OverseerTest extends SolrTe
AbstractZkTestCase.makeSolrZkNode(server.getZkHost());
zkClient = new SolrZkClient(server.getZkAddress(), TIMEOUT);
-
- zkClient.makePath(ZkStateReader.LIVE_NODES_ZKNODE, true);
+
+ ZkController.createClusterZkNodes(zkClient);
reader = new ZkStateReader(zkClient);
reader.createClusterStateWatchersAndUpdate();
@@ -751,7 +754,7 @@ public class OverseerTest extends SolrTe
controllerClient = new SolrZkClient(server.getZkAddress(), TIMEOUT);
AbstractZkTestCase.tryCleanSolrZkNode(server.getZkHost());
AbstractZkTestCase.makeSolrZkNode(server.getZkHost());
- controllerClient.makePath(ZkStateReader.LIVE_NODES_ZKNODE, true);
+ ZkController.createClusterZkNodes(controllerClient);
killer = new OverseerRestarter(server.getZkAddress());
killerThread = new Thread(killer);
@@ -808,7 +811,7 @@ public class OverseerTest extends SolrTe
AbstractZkTestCase.tryCleanSolrZkNode(server.getZkHost());
AbstractZkTestCase.makeSolrZkNode(server.getZkHost());
- controllerClient.makePath(ZkStateReader.LIVE_NODES_ZKNODE, true);
+ ZkController.createClusterZkNodes(controllerClient);
reader = new ZkStateReader(controllerClient);
reader.createClusterStateWatchersAndUpdate();
@@ -872,8 +875,8 @@ public class OverseerTest extends SolrTe
AbstractZkTestCase.tryCleanSolrZkNode(server.getZkHost());
AbstractZkTestCase.makeSolrZkNode(server.getZkHost());
- controllerClient.makePath(ZkStateReader.LIVE_NODES_ZKNODE, true);
-
+ ZkController.createClusterZkNodes(controllerClient);
+
reader = new ZkStateReader(controllerClient);
reader.createClusterStateWatchersAndUpdate();
@@ -914,7 +917,7 @@ public class OverseerTest extends SolrTe
AbstractZkTestCase.tryCleanSolrZkNode(server.getZkHost());
AbstractZkTestCase.makeSolrZkNode(server.getZkHost());
- controllerClient.makePath(ZkStateReader.LIVE_NODES_ZKNODE, true);
+ ZkController.createClusterZkNodes(controllerClient);
reader = new ZkStateReader(controllerClient);
reader.createClusterStateWatchersAndUpdate();
@@ -1046,7 +1049,7 @@ public class OverseerTest extends SolrTe
zkClient = new SolrZkClient(server.getZkAddress(), TIMEOUT);
AbstractZkTestCase.tryCleanSolrZkNode(server.getZkHost());
AbstractZkTestCase.makeSolrZkNode(server.getZkHost());
- zkClient.makePath(ZkStateReader.LIVE_NODES_ZKNODE, true);
+ ZkController.createClusterZkNodes(zkClient);
reader = new ZkStateReader(zkClient);
reader.createClusterStateWatchersAndUpdate();
@@ -1129,12 +1132,12 @@ public class OverseerTest extends SolrTe
overseers.get(overseers.size() -1).close();
overseers.get(overseers.size() -1).getZkStateReader().getZkClient().close();
}
- UpdateShardHandler updateShardHandler = new UpdateShardHandler(null);
+ UpdateShardHandler updateShardHandler = new UpdateShardHandler(UpdateShardHandlerConfig.DEFAULT);
updateShardHandlers.add(updateShardHandler);
HttpShardHandlerFactory httpShardHandlerFactory = new HttpShardHandlerFactory();
httpShardHandlerFactorys.add(httpShardHandlerFactory);
- Overseer overseer = new Overseer(
- httpShardHandlerFactory.getShardHandler(), updateShardHandler, "/admin/cores", reader, null, new MockConfigSolr());
+ Overseer overseer = new Overseer(httpShardHandlerFactory.getShardHandler(), updateShardHandler, "/admin/cores", reader, null,
+ new CloudConfig.CloudConfigBuilder("127.0.0.1", 8983, "").build());
overseers.add(overseer);
ElectionContext ec = new OverseerElectionContext(zkClient, overseer,
address.replaceAll("/", "_"));