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 18:07:04 UTC
svn commit: r1244595 - in /lucene/dev/branches/branch_3x/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 17:07:04 2012
New Revision: 1244595
URL: http://svn.apache.org/viewvc?rev=1244595&view=rev
Log:
SOLR-2847: fix bug in DistributedSpellCheckComponentTest
Modified:
lucene/dev/branches/branch_3x/solr/core/src/test/org/apache/solr/handler/component/DistributedSpellCheckComponentTest.java
lucene/dev/branches/branch_3x/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java
Modified: lucene/dev/branches/branch_3x/solr/core/src/test/org/apache/solr/handler/component/DistributedSpellCheckComponentTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/core/src/test/org/apache/solr/handler/component/DistributedSpellCheckComponentTest.java?rev=1244595&r1=1244594&r2=1244595&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/core/src/test/org/apache/solr/handler/component/DistributedSpellCheckComponentTest.java (original)
+++ lucene/dev/branches/branch_3x/solr/core/src/test/org/apache/solr/handler/component/DistributedSpellCheckComponentTest.java Wed Feb 15 17:07:04 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
@@ -71,6 +75,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");
@@ -104,7 +119,7 @@ public class DistributedSpellCheckCompon
handle.put("maxScore", SKIPVAL);
// 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", "spellCheckCompRH", "shards.qt", "spellCheckCompRH");
query("q", "*:*", "fl", "id,lowerfilt", "spellcheck.q","toyata", "spellcheck", "true", "qt", "spellCheckCompRH", "shards.qt", "spellCheckCompRH", SpellCheckComponent.SPELLCHECK_EXTENDED_RESULTS, "true");
Modified: lucene/dev/branches/branch_3x/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java?rev=1244595&r1=1244594&r2=1244595&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java (original)
+++ lucene/dev/branches/branch_3x/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java Wed Feb 15 17:07:04 2012
@@ -279,6 +279,7 @@ public abstract class BaseDistributedSea
params.add("controlClient","true"); // just to enable easier sorting through log files
final QueryResponse controlRsp = controlClient.query(params);
params.remove("controlClient");
+ validateControlData(controlRsp);
// query a random server
params.set("shards", shards);
@@ -567,6 +568,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;