You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by an...@apache.org on 2014/10/02 02:58:50 UTC

svn commit: r1628872 - in /lucene/dev/trunk/solr/core/src: test-files/solr/collection1/conf/ test/org/apache/solr/core/ test/org/apache/solr/search/

Author: anshum
Date: Thu Oct  2 00:58:50 2014
New Revision: 1628872

URL: http://svn.apache.org/r1628872
Log:
SOLR-6564: Fix failing ExitableDirectoryReader tests for Solr

Added:
    lucene/dev/trunk/solr/core/src/test-files/solr/collection1/conf/solrconfig-nocache-with-delaying-searchcomponent.xml   (with props)
    lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/DelayingSearchComponent.java   (with props)
Modified:
    lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/ExitableDirectoryReaderTest.java

Added: lucene/dev/trunk/solr/core/src/test-files/solr/collection1/conf/solrconfig-nocache-with-delaying-searchcomponent.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test-files/solr/collection1/conf/solrconfig-nocache-with-delaying-searchcomponent.xml?rev=1628872&view=auto
==============================================================================
--- lucene/dev/trunk/solr/core/src/test-files/solr/collection1/conf/solrconfig-nocache-with-delaying-searchcomponent.xml (added)
+++ lucene/dev/trunk/solr/core/src/test-files/solr/collection1/conf/solrconfig-nocache-with-delaying-searchcomponent.xml Thu Oct  2 00:58:50 2014
@@ -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>

Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/ExitableDirectoryReaderTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/ExitableDirectoryReaderTest.java?rev=1628872&r1=1628871&r2=1628872&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/ExitableDirectoryReaderTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/ExitableDirectoryReaderTest.java Thu Oct  2 00:58:50 2014
@@ -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
         , 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
   
   @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

Added: lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/DelayingSearchComponent.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/DelayingSearchComponent.java?rev=1628872&view=auto
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/DelayingSearchComponent.java (added)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/DelayingSearchComponent.java Thu Oct  2 00:58:50 2014
@@ -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;
+  }
+}