SOLR-1840, SOLR-1839: DistributedSpellCheckComponentTest fails under stress test

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@932963 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Robert Miller 2010-04-11 18:04:21 +00:00
parent e525dbd83f
commit f9ca627756
3 changed files with 30 additions and 15 deletions

View File

@ -13,6 +13,7 @@ import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.schema.TrieDateField;
import org.apache.solr.util.AbstractSolrTestCase;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -25,7 +26,7 @@ import java.util.*;
*
* @since solr 1.5
*/
public abstract class BaseDistributedSearchTestCase extends TestCase {
public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 {
public static Random r = new Random(0);
protected int shardCount = 4;
@ -493,6 +494,7 @@ public abstract class BaseDistributedSearchTestCase extends TestCase {
}
}
@Test
public void testDistribSearch() throws Exception {
if (fixShardCount) {
createServers(shardCount);

View File

@ -17,6 +17,8 @@
package org.apache.solr;
import junit.framework.TestCase;
import org.apache.solr.client.solrj.SolrServerException;
/**
@ -28,13 +30,6 @@ import org.apache.solr.client.solrj.SolrServerException;
* @since solr 1.3
*/
public class TestDistributedSearch extends BaseDistributedSearchTestCase {
public String getSchemaFile() {
return null;
}
public String getSolrConfigFile() {
return null;
}
String t1="a_t";
String i1="a_si";
@ -183,7 +178,7 @@ public class TestDistributedSearch extends BaseDistributedSearchTestCase {
try {
// test error produced for field that is invalid for schema
query("q","*:*", "rows",100, "facet","true", "facet.field",invalidField, "facet.mincount",2);
fail("SolrServerException expected for invalid field that is not in schema");
TestCase.fail("SolrServerException expected for invalid field that is not in schema");
} catch (SolrServerException ex) {
// expected
}

View File

@ -1,7 +1,8 @@
package org.apache.solr.handler.component;
import org.apache.solr.BaseDistributedSearchTestCase;
import org.apache.solr.util.AbstractSolrTestCase;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.common.params.ModifiableSolrParams;
/**
* Test for SpellCheckComponent's distributed querying
@ -30,6 +31,22 @@ public class DistributedSpellCheckComponentTest extends BaseDistributedSearchTes
System.setProperty("solr.directoryFactory", saveProp);
}
private void q(Object... q) throws Exception {
final ModifiableSolrParams params = new ModifiableSolrParams();
for (int i = 0; i < q.length; i += 2) {
params.add(q[i].toString(), q[i + 1].toString());
}
controlClient.query(params);
// query a random server
params.set("shards", shards);
int which = r.nextInt(clients.size());
SolrServer client = clients.get(which);
client.query(params);
}
@Override
public void doTest() throws Exception {
index(id, "1", "lowerfilt", "toyota");
@ -51,10 +68,11 @@ public class DistributedSpellCheckComponentTest extends BaseDistributedSearchTes
handle.put("maxScore", SKIPVAL);
// we care only about the spellcheck results
handle.put("response", SKIP);
query("q", "*:*", "fl", "id,lowerfilt", "spellcheck.q","toyata", "spellcheck", "true", SpellCheckComponent.SPELLCHECK_BUILD, "true", "qt", "spellCheckCompRH", "shards.qt", "spellCheckCompRH");
query("q", "*:*", "fl", "id,lowerfilt", "spellcheck.q","toyata", "spellcheck", "true", SpellCheckComponent.SPELLCHECK_BUILD, "true", "qt", "spellCheckCompRH", "shards.qt", "spellCheckCompRH", SpellCheckComponent.SPELLCHECK_EXTENDED_RESULTS, "true");
query("q", "*:*", "fl", "id,lowerfilt", "spellcheck.q","bluo", "spellcheck", "true", SpellCheckComponent.SPELLCHECK_BUILD, "true", "qt", "spellCheckCompRH", "shards.qt", "spellCheckCompRH", SpellCheckComponent.SPELLCHECK_EXTENDED_RESULTS, "true", SpellCheckComponent.SPELLCHECK_COUNT, "4");
query("q", "The quick reb fox jumped over the lazy brown dogs", "fl", "id,lowerfilt", "spellcheck", "true", SpellCheckComponent.SPELLCHECK_BUILD, "true", "qt", "spellCheckCompRH", "shards.qt", "spellCheckCompRH", SpellCheckComponent.SPELLCHECK_EXTENDED_RESULTS, "true", SpellCheckComponent.SPELLCHECK_COUNT, "4", SpellCheckComponent.SPELLCHECK_COLLATE, "true");
q("q", "*:*", 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");
query("q", "*:*", "fl", "id,lowerfilt", "spellcheck.q","bluo", "spellcheck", "true", "qt", "spellCheckCompRH", "shards.qt", "spellCheckCompRH", SpellCheckComponent.SPELLCHECK_EXTENDED_RESULTS, "true", SpellCheckComponent.SPELLCHECK_COUNT, "4");
query("q", "The quick reb fox jumped over the lazy brown dogs", "fl", "id,lowerfilt", "spellcheck", "true", "qt", "spellCheckCompRH", "shards.qt", "spellCheckCompRH", SpellCheckComponent.SPELLCHECK_EXTENDED_RESULTS, "true", SpellCheckComponent.SPELLCHECK_COUNT, "4", SpellCheckComponent.SPELLCHECK_COLLATE, "true");
}
}