Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-6564: Fix failing ExitableDirectoryReader tests for Solr

Anshum Gupta359ab18b75a7
diff --git a/solr/core/src/test-files/solr/collection1/conf/solrconfig-nocache-with-delaying-searchcomponent.xml b/solr/core/src/test-files/solr/collection1/conf/solrconfig-nocache-with-delaying-searchcomponent.xml
new file mode 100644
index 00000000000..898aac0c5da
--- /dev/null
+++ b/solr/core/src/test-files/solr/collection1/conf/solrconfig-nocache-with-delaying-searchcomponent.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" ?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<config>
+ <luceneMatchVersion>${tests.luceneMatchVersion:LATEST}</luceneMatchVersion>
+ <dataDir>${solr.data.dir:}</dataDir>
+ <xi:include href="solrconfig.snippet.randomindexconfig.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
+ <directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.RAMDirectoryFactory}"/>
+
+ <searchComponent name="delayingSearchComponent"
+ class="org.apache.solr.search.DelayingSearchComponent"/>
+
+ <requestHandler name="/select" class="solr.SearchHandler">
+ <arr name="first-components">
+ <str>delayingSearchComponent</str>
+ </arr>
+ </requestHandler>
+
+ <requestHandler name="/update" class="solr.UpdateRequestHandler" />
+
+ <requestDispatcher handleSelect="true" >
+ <requestParsers enableRemoteStreaming="true" multipartUploadLimitInKB="2048" />
+ <httpCaching never304="true" />
+ </requestDispatcher>
+
+</config>
diff --git a/solr/core/src/test/org/apache/solr/core/ExitableDirectoryReaderTest.java b/solr/core/src/test/org/apache/solr/core/ExitableDirectoryReaderTest.java
index 2615574b6a0..697cd87e06d 100644
--- a/solr/core/src/test/org/apache/solr/core/ExitableDirectoryReaderTest.java
+++ b/solr/core/src/test/org/apache/solr/core/ExitableDirectoryReaderTest.java
@@ -29,13 +29,13 @@ import org.junit.Test;
*/
public class ExitableDirectoryReaderTest extends SolrTestCaseJ4 {
- static int NUM_DOCS_PER_TYPE = 2000;
+ static int NUM_DOCS_PER_TYPE = 100;
static final String assertionString = "//result[@numFound='"+ (NUM_DOCS_PER_TYPE - 1) + "']";
@BeforeClass
public static void beforeClass() throws Exception {
System.setProperty("enable.update.log", "false"); // schema12 doesn't support _version_
- initCore("solrconfig-nocache.xml", "schema12.xml");
+ initCore("solrconfig-nocache-with-delaying-searchcomponent.xml", "schema12.xml");
createIndex();
}
@@ -62,13 +62,13 @@ public class ExitableDirectoryReaderTest extends SolrTestCaseJ4 {
, SolrException.ErrorCode.BAD_REQUEST
);
- assertQ(req("q","name:a*", "indent","true", "timeAllowed","1000"), assertionString);
+ assertQ(req("q","name:a*", "indent","true", "timeAllowed","10000"), assertionString);
assertQEx("", req("q","name:a*", "indent","true", "timeAllowed","1")
, SolrException.ErrorCode.BAD_REQUEST
);
- assertQ(req("q","name:b*", "indent","true", "timeAllowed","1000"), assertionString);
+ assertQ(req("q","name:b*", "indent","true", "timeAllowed","10000"), assertionString);
assertQ(req("q","name:b*", "indent","true", "timeAllowed",Long.toString(Long.MAX_VALUE)), assertionString);
@@ -79,11 +79,11 @@ public class ExitableDirectoryReaderTest extends SolrTestCaseJ4 {
@Test
public void testQueriesOnDocsWithMultipleTerms() {
- assertQ(req("q","name:dummy", "indent","true", "timeAllowed","1000"), assertionString);
+ assertQ(req("q","name:dummy", "indent","true", "timeAllowed","10000"), assertionString);
// This should pass even though this may take more than the 'timeAllowed' time, it doesn't take long
// to iterate over 1 term (dummy).
- assertQ(req("q","name:dummy", "indent","true", "timeAllowed","1000"), assertionString);
+ assertQ(req("q","name:dummy", "indent","true", "timeAllowed","10000"), assertionString);
assertQEx("", req("q","name:doc*", "indent","true", "timeAllowed","1")
, SolrException.ErrorCode.BAD_REQUEST
diff --git a/solr/core/src/test/org/apache/solr/search/DelayingSearchComponent.java b/solr/core/src/test/org/apache/solr/search/DelayingSearchComponent.java
new file mode 100644
index 00000000000..ba387bbff43
--- /dev/null
+++ b/solr/core/src/test/org/apache/solr/search/DelayingSearchComponent.java
@@ -0,0 +1,48 @@
+package org.apache.solr.search;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.solr.handler.component.ResponseBuilder;
+import org.apache.solr.handler.component.SearchComponent;
+
+import java.io.IOException;
+
+/**
+ * Search component used to add delay to each request.
+ */
+public class DelayingSearchComponent extends SearchComponent{
+
+ @Override
+ public void prepare(ResponseBuilder rb) throws IOException {
+ rb.rsp.addHttpHeader("Warning", "This is a test warning");
+ }
+
+ @Override
+ public void process(ResponseBuilder rb) throws IOException {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ // Do nothing?
+ }
+ }
+
+ @Override
+ public String getDescription() {
+ return null;
+ }
+}