You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by jd...@apache.org on 2012/02/15 16:52:32 UTC

svn commit: r1244553 - in /lucene/dev/trunk/solr: core/src/test/org/apache/solr/handler/component/DistributedSpellCheckComponentTest.java test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java

Author: jdyer
Date: Wed Feb 15 15:52:32 2012
New Revision: 1244553

URL: http://svn.apache.org/viewvc?rev=1244553&view=rev
Log:
SOLR-2847

Modified:
    lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/component/DistributedSpellCheckComponentTest.java
    lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java

Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/component/DistributedSpellCheckComponentTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/component/DistributedSpellCheckComponentTest.java?rev=1244553&r1=1244552&r2=1244553&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/component/DistributedSpellCheckComponentTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/component/DistributedSpellCheckComponentTest.java Wed Feb 15 15:52:32 2012
@@ -17,9 +17,13 @@ package org.apache.solr.handler.componen
  * limitations under the License.
  */
 
+import junit.framework.TestCase;
+
 import org.apache.solr.BaseDistributedSearchTestCase;
 import org.apache.solr.client.solrj.SolrServer;
+import org.apache.solr.client.solrj.response.QueryResponse;
 import org.apache.solr.common.params.ModifiableSolrParams;
+import org.apache.solr.common.util.NamedList;
 
 /**
  * Test for SpellCheckComponent's distributed querying
@@ -45,7 +49,7 @@ public class DistributedSpellCheckCompon
     // this test requires FSDir
     saveProp = System.getProperty("solr.directoryFactory");
     System.setProperty("solr.directoryFactory", "solr.StandardDirectoryFactory");    
-    requestHandlerName = random.nextBoolean() ? "spellCheckCompRH" : "spellCheckCompRH_Direct";   
+    requestHandlerName = random.nextBoolean() ? "spellCheckCompRH" : "spellCheckCompRH_Direct"; 
     super.setUp();
   }
   
@@ -75,6 +79,17 @@ public class DistributedSpellCheckCompon
   }
   
   @Override
+  public void validateControlData(QueryResponse control) throws Exception
+  {    
+    NamedList nl = control.getResponse();
+    NamedList sc = (NamedList) nl.get("spellcheck");
+    NamedList sug = (NamedList) sc.get("suggestions");
+    if(sug.size()==0) {
+      TestCase.fail("Control data did not return any suggestions.");
+    }
+  }
+  
+  @Override
   public void doTest() throws Exception {
   	del("*:*");
     index(id, "1", "lowerfilt", "toyota");
@@ -109,7 +124,7 @@ public class DistributedSpellCheckCompon
     // we care only about the spellcheck results
     handle.put("response", SKIP);
         
-    q("q", "*:*", SpellCheckComponent.SPELLCHECK_BUILD, "true", "qt", "spellCheckCompRH", "shards.qt", "spellCheckCompRH");
+    q("q", "*:*", "spellcheck", "true", SpellCheckComponent.SPELLCHECK_BUILD, "true", "qt", "spellCheckCompRH", "shards.qt", "spellCheckCompRH");
     
     query("q", "*:*", "fl", "id,lowerfilt", "spellcheck.q","toyata", "spellcheck", "true", "qt", requestHandlerName, "shards.qt", requestHandlerName);
     query("q", "*:*", "fl", "id,lowerfilt", "spellcheck.q","toyata", "spellcheck", "true", "qt", requestHandlerName, "shards.qt", requestHandlerName, SpellCheckComponent.SPELLCHECK_EXTENDED_RESULTS, "true");

Modified: lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java?rev=1244553&r1=1244552&r2=1244553&view=diff
==============================================================================
--- lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java (original)
+++ lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java Wed Feb 15 15:52:32 2012
@@ -372,6 +372,7 @@ public abstract class BaseDistributedSea
     // TODO: look into why passing true causes fails
     params.set("distrib", "false");
     final QueryResponse controlRsp = controlClient.query(params);
+    validateControlData(controlRsp);
 
     params.remove("distrib");
     setDistributedParams(params);
@@ -680,6 +681,19 @@ public abstract class BaseDistributedSea
     }
     return o;
   }
+  
+  /**
+   * Implementations can pre-test the control data for basic correctness before using it
+   * as a check for the shard data.  This is useful, for instance, if a test bug is introduced
+   * causing a spelling index not to get built:  both control & shard data would have no results
+   * but because they match the test would pass.  This method gives us a chance to ensure something
+   * exists in the control data.
+   * 
+   * @throws Exception
+   */
+  public void validateControlData(QueryResponse control) throws Exception {
+    /* no-op */
+  }
 
   public static abstract class RandVal {
     public static Random r = random;