org.apache.solr
Class BaseDistributedSearchTestCase

java.lang.Object
  extended by org.junit.Assert
      extended by org.apache.lucene.util.LuceneTestCase
          extended by org.apache.solr.SolrTestCaseJ4
              extended by org.apache.solr.BaseDistributedSearchTestCase

public abstract class BaseDistributedSearchTestCase
extends SolrTestCaseJ4

Helper base class for distributed search test cases

Since:
solr 1.5

Nested Class Summary
static class BaseDistributedSearchTestCase.RandDate
           
static class BaseDistributedSearchTestCase.RandVal
           
 
Nested classes/interfaces inherited from class org.apache.solr.SolrTestCaseJ4
SolrTestCaseJ4.Doc, SolrTestCaseJ4.Fld, SolrTestCaseJ4.FldType, SolrTestCaseJ4.FVal, SolrTestCaseJ4.IRange, SolrTestCaseJ4.IVals, SolrTestCaseJ4.SVal, SolrTestCaseJ4.Vals, SolrTestCaseJ4.XmlDoc
 
Nested classes/interfaces inherited from class org.apache.lucene.util.LuceneTestCase
org.apache.lucene.util.LuceneTestCase.AwaitsFix, org.apache.lucene.util.LuceneTestCase.Nightly, org.apache.lucene.util.LuceneTestCase.Slow, org.apache.lucene.util.LuceneTestCase.SuppressCodecs, org.apache.lucene.util.LuceneTestCase.Weekly
 
Field Summary
protected  List<org.apache.solr.client.solrj.SolrServer> clients
           
protected  String context
           
protected  org.apache.solr.client.solrj.SolrServer controlClient
           
protected  org.apache.solr.client.solrj.embedded.JettySolrRunner controlJetty
           
protected  String[] deadServers
           
static String[] fieldNames
           
protected  boolean fixShardCount
          Sub classes can set this flag in their constructor to true if they want to fix the number of shards to 'shardCount' The default is false which means that test will be executed with 1, 2, 3, ....shardCount number of shards repeatedly
protected  int flags
           
protected  Map<String,Integer> handle
           
protected  String id
           
protected  List<org.apache.solr.client.solrj.embedded.JettySolrRunner> jettys
           
static org.slf4j.Logger log
           
protected  int nThreads
           
static int ORDERED
           
static Random r
           
static BaseDistributedSearchTestCase.RandVal[] randVals
           
static BaseDistributedSearchTestCase.RandVal rdate
           
static BaseDistributedSearchTestCase.RandVal rdouble
           
static BaseDistributedSearchTestCase.RandVal rfloat
           
static BaseDistributedSearchTestCase.RandVal rint
           
static BaseDistributedSearchTestCase.RandVal rlong
           
protected  int shardCount
           
protected  String shards
           
protected  String[] shardsArr
           
static int SKIP
           
static int SKIPVAL
           
protected  int stress
           
protected  File testDir
           
static int UNORDERED
           
protected  boolean verifyStress
           
 
Fields inherited from class org.apache.solr.SolrTestCaseJ4
configString, dataDir, DEFAULT_CONNECTION_TIMEOUT, formatter, h, lrf, ONE_ONE, schemaString, solrClassRules, solrConfig, solrTestRules, ZERO_ONE, ZERO_TWO
 
Fields inherited from class org.apache.lucene.util.LuceneTestCase
classRules, DEFAULT_LINE_DOCS_FILE, INFOSTREAM, JENKINS_LARGE_LINE_DOCS_FILE, PREFLEX_IMPERSONATION_IS_ACTIVE, RANDOM_MULTIPLIER, ruleChain, suiteFailureMarker, SYSPROP_AWAITSFIX, SYSPROP_NIGHTLY, SYSPROP_SLOW, SYSPROP_WEEKLY, TEMP_DIR, TEST_AWAITSFIX, TEST_CODEC, TEST_DIRECTORY, TEST_LINE_DOCS_FILE, TEST_NIGHTLY, TEST_POSTINGSFORMAT, TEST_SLOW, TEST_THROTTLING, TEST_VERSION_CURRENT, TEST_WEEKLY, VERBOSE
 
Constructor Summary
BaseDistributedSearchTestCase()
           
 
Method Summary
protected  org.apache.solr.client.solrj.response.UpdateResponse add(org.apache.solr.client.solrj.SolrServer server, org.apache.solr.common.params.SolrParams params, org.apache.solr.common.SolrInputDocument... sdocs)
           
protected  void addFields(org.apache.solr.common.SolrInputDocument doc, Object... fields)
           
protected  org.apache.solr.common.SolrInputDocument addRandFields(org.apache.solr.common.SolrInputDocument sdoc)
           
protected  void commit()
           
static String compare(Map a, Map b, int flags, Map<String,Integer> handle)
           
static String compare(org.apache.solr.common.util.NamedList a, org.apache.solr.common.util.NamedList b, int flags, Map<String,Integer> handle)
           
static String compare(Object[] a, Object[] b, int flags, Map<String,Integer> handle)
           
static String compare(Object a, Object b, int flags, Map<String,Integer> handle)
           
static String compare(org.apache.solr.common.SolrDocumentList a, org.apache.solr.common.SolrDocumentList b, int flags, Map<String,Integer> handle)
           
static String compare(org.apache.solr.common.SolrDocument a, org.apache.solr.common.SolrDocument b, int flags, Map<String,Integer> handle)
           
static String compare1(Map a, Map b, int flags, Map<String,Integer> handle)
           
protected  void compareResponses(org.apache.solr.client.solrj.response.QueryResponse a, org.apache.solr.client.solrj.response.QueryResponse b)
           
 org.apache.solr.client.solrj.embedded.JettySolrRunner createJetty(File baseDir, String dataDir)
           
 org.apache.solr.client.solrj.embedded.JettySolrRunner createJetty(File baseDir, String dataDir, String shardId)
           
 org.apache.solr.client.solrj.embedded.JettySolrRunner createJetty(File baseDir, String dataDir, String shardList, String solrConfigOverride, String schemaOverride)
           
protected  org.apache.solr.client.solrj.SolrServer createNewSolrServer(int port)
           
protected  void createServers(int numShards)
           
protected  org.apache.solr.client.solrj.response.UpdateResponse del(org.apache.solr.client.solrj.SolrServer server, org.apache.solr.common.params.SolrParams params, Object... ids)
           
protected  void del(String q)
           
protected  org.apache.solr.client.solrj.response.UpdateResponse delQ(org.apache.solr.client.solrj.SolrServer server, org.apache.solr.common.params.SolrParams params, String... queries)
           
protected  void destroyServers()
           
abstract  void doTest()
          Perform the actual tests here
static boolean eq(String a, String b)
           
static int flags(Map<String,Integer> handle, Object key)
           
protected  String[] getFieldNames()
           
static Object[] getRandFields(String[] fields, BaseDistributedSearchTestCase.RandVal[] randVals)
           
protected  BaseDistributedSearchTestCase.RandVal[] getRandValues()
           
protected  String getShardsString()
           
 String getSolrHome()
          Subclasses can override this to change a test's solr home (default is in test-files)
protected  void index_specific(int serverNumber, Object... fields)
           
protected  void index(Object... fields)
           
protected  void indexDoc(org.apache.solr.common.SolrInputDocument doc)
           
protected  void indexr(Object... fields)
           
static void initialize()
           
protected  void query(Object... q)
           
 org.apache.solr.client.solrj.response.QueryResponse queryAndCompare(org.apache.solr.common.params.SolrParams params, org.apache.solr.client.solrj.SolrServer... servers)
           
protected  org.apache.solr.client.solrj.response.QueryResponse queryServer(org.apache.solr.common.params.ModifiableSolrParams params)
           
protected  void setDistributedParams(org.apache.solr.common.params.ModifiableSolrParams params)
           
 void setUp()
           
 void tearDown()
           
 void testDistribSearch()
           
 void validateControlData(org.apache.solr.client.solrj.response.QueryResponse control)
          Implementations can pre-test the control data for basic correctness before using it as a check for the shard data.
 
Methods inherited from class org.apache.solr.SolrTestCaseJ4
add, addAndGetVersion, adoc, adoc, assertFailedU, assertFailedU, assertJQ, assertJQ, assertQ, assertQ, assertQEx, assertQEx, assertU, assertU, clearIndex, commit, createComparator, createComparator, createCore, createDoc, createSort, createTempDir, deleteAndGetVersion, deleteByQueryAndGetVersion, deleteCore, delI, delQ, doc, endTrackingSearchers, endTrackingZkClients, getClassName, getFile, getRootCause, getSchemaFile, getSimpleClassName, getSolrConfigFile, ignoreException, indexDocs, initCore, initCore, initCore, JQ, json, jsonAdd, jsonDelId, jsonDelQ, map, optimize, params, postSetUp, preTearDown, recurseDelete, req, req, req, resetExceptionIgnores, sdoc, setLoggingLevel, setupLogging, startTrackingSearchers, startTrackingZkClients, TEST_HOME, toJSON, unIgnoreException, updateJ
 
Methods inherited from class org.apache.lucene.util.LuceneTestCase
assertSaneFieldCaches, asSet, assumeFalse, assumeNoException, assumeTrue, atLeast, atLeast, closeAfterSuite, closeAfterTest, defaultCodecSupportsDocValues, dumpArray, dumpIterator, getDataFile, getOnlySegmentReader, getTestClass, getTestName, isTestThread, localeForName, maybeWrapReader, newAlcoholicMergePolicy, newAlcoholicMergePolicy, newDirectory, newDirectory, newDirectory, newDirectory, newField, newField, newFSDirectory, newFSDirectory, newIndexWriterConfig, newIndexWriterConfig, newIOContext, newLogMergePolicy, newLogMergePolicy, newLogMergePolicy, newLogMergePolicy, newLogMergePolicy, newSearcher, newSearcher, newStringField, newStringField, newTextField, newTextField, newTieredMergePolicy, newTieredMergePolicy, random, randomLocale, randomTimeZone, rarely, rarely, usually, usually
 
Methods inherited from class org.junit.Assert
assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertThat, assertThat, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

r

public static Random r

shardCount

protected int shardCount

fixShardCount

protected boolean fixShardCount
Sub classes can set this flag in their constructor to true if they want to fix the number of shards to 'shardCount' The default is false which means that test will be executed with 1, 2, 3, ....shardCount number of shards repeatedly


controlJetty

protected org.apache.solr.client.solrj.embedded.JettySolrRunner controlJetty

clients

protected List<org.apache.solr.client.solrj.SolrServer> clients

jettys

protected List<org.apache.solr.client.solrj.embedded.JettySolrRunner> jettys

context

protected String context

shards

protected String shards

shardsArr

protected String[] shardsArr

deadServers

protected String[] deadServers

testDir

protected File testDir

controlClient

protected org.apache.solr.client.solrj.SolrServer controlClient

stress

protected int stress

verifyStress

protected boolean verifyStress

nThreads

protected int nThreads

ORDERED

public static int ORDERED

SKIP

public static int SKIP

SKIPVAL

public static int SKIPVAL

UNORDERED

public static int UNORDERED

flags

protected int flags

handle

protected Map<String,Integer> handle

id

protected String id

log

public static org.slf4j.Logger log

rint

public static BaseDistributedSearchTestCase.RandVal rint

rlong

public static BaseDistributedSearchTestCase.RandVal rlong

rfloat

public static BaseDistributedSearchTestCase.RandVal rfloat

rdouble

public static BaseDistributedSearchTestCase.RandVal rdouble

rdate

public static BaseDistributedSearchTestCase.RandVal rdate

fieldNames

public static String[] fieldNames

randVals

public static BaseDistributedSearchTestCase.RandVal[] randVals
Constructor Detail

BaseDistributedSearchTestCase

public BaseDistributedSearchTestCase()
Method Detail

initialize

public static void initialize()

doTest

public abstract void doTest()
                     throws Exception
Perform the actual tests here

Throws:
Exception - on error

getFieldNames

protected String[] getFieldNames()

getRandValues

protected BaseDistributedSearchTestCase.RandVal[] getRandValues()

getSolrHome

public String getSolrHome()
Subclasses can override this to change a test's solr home (default is in test-files)


setUp

public void setUp()
           throws Exception
Overrides:
setUp in class SolrTestCaseJ4
Throws:
Exception

tearDown

public void tearDown()
              throws Exception
Overrides:
tearDown in class SolrTestCaseJ4
Throws:
Exception

createServers

protected void createServers(int numShards)
                      throws Exception
Throws:
Exception

setDistributedParams

protected void setDistributedParams(org.apache.solr.common.params.ModifiableSolrParams params)

getShardsString

protected String getShardsString()

destroyServers

protected void destroyServers()
                       throws Exception
Throws:
Exception

createJetty

public org.apache.solr.client.solrj.embedded.JettySolrRunner createJetty(File baseDir,
                                                                         String dataDir)
                                                                  throws Exception
Throws:
Exception

createJetty

public org.apache.solr.client.solrj.embedded.JettySolrRunner createJetty(File baseDir,
                                                                         String dataDir,
                                                                         String shardId)
                                                                  throws Exception
Throws:
Exception

createJetty

public org.apache.solr.client.solrj.embedded.JettySolrRunner createJetty(File baseDir,
                                                                         String dataDir,
                                                                         String shardList,
                                                                         String solrConfigOverride,
                                                                         String schemaOverride)
                                                                  throws Exception
Throws:
Exception

createNewSolrServer

protected org.apache.solr.client.solrj.SolrServer createNewSolrServer(int port)

addFields

protected void addFields(org.apache.solr.common.SolrInputDocument doc,
                         Object... fields)

indexr

protected void indexr(Object... fields)
               throws Exception
Throws:
Exception

addRandFields

protected org.apache.solr.common.SolrInputDocument addRandFields(org.apache.solr.common.SolrInputDocument sdoc)

index

protected void index(Object... fields)
              throws Exception
Throws:
Exception

indexDoc

protected void indexDoc(org.apache.solr.common.SolrInputDocument doc)
                 throws IOException,
                        org.apache.solr.client.solrj.SolrServerException
Throws:
IOException
org.apache.solr.client.solrj.SolrServerException

add

protected org.apache.solr.client.solrj.response.UpdateResponse add(org.apache.solr.client.solrj.SolrServer server,
                                                                   org.apache.solr.common.params.SolrParams params,
                                                                   org.apache.solr.common.SolrInputDocument... sdocs)
                                                            throws IOException,
                                                                   org.apache.solr.client.solrj.SolrServerException
Throws:
IOException
org.apache.solr.client.solrj.SolrServerException

del

protected org.apache.solr.client.solrj.response.UpdateResponse del(org.apache.solr.client.solrj.SolrServer server,
                                                                   org.apache.solr.common.params.SolrParams params,
                                                                   Object... ids)
                                                            throws IOException,
                                                                   org.apache.solr.client.solrj.SolrServerException
Throws:
IOException
org.apache.solr.client.solrj.SolrServerException

delQ

protected org.apache.solr.client.solrj.response.UpdateResponse delQ(org.apache.solr.client.solrj.SolrServer server,
                                                                    org.apache.solr.common.params.SolrParams params,
                                                                    String... queries)
                                                             throws IOException,
                                                                    org.apache.solr.client.solrj.SolrServerException
Throws:
IOException
org.apache.solr.client.solrj.SolrServerException

index_specific

protected void index_specific(int serverNumber,
                              Object... fields)
                       throws Exception
Throws:
Exception

del

protected void del(String q)
            throws Exception
Throws:
Exception

commit

protected void commit()
               throws Exception
Throws:
Exception

queryServer

protected org.apache.solr.client.solrj.response.QueryResponse queryServer(org.apache.solr.common.params.ModifiableSolrParams params)
                                                                   throws org.apache.solr.client.solrj.SolrServerException
Throws:
org.apache.solr.client.solrj.SolrServerException

query

protected void query(Object... q)
              throws Exception
Throws:
Exception

queryAndCompare

public org.apache.solr.client.solrj.response.QueryResponse queryAndCompare(org.apache.solr.common.params.SolrParams params,
                                                                           org.apache.solr.client.solrj.SolrServer... servers)
                                                                    throws org.apache.solr.client.solrj.SolrServerException
Throws:
org.apache.solr.client.solrj.SolrServerException

eq

public static boolean eq(String a,
                         String b)

flags

public static int flags(Map<String,Integer> handle,
                        Object key)

compare

public static String compare(org.apache.solr.common.util.NamedList a,
                             org.apache.solr.common.util.NamedList b,
                             int flags,
                             Map<String,Integer> handle)

compare1

public static String compare1(Map a,
                              Map b,
                              int flags,
                              Map<String,Integer> handle)

compare

public static String compare(Map a,
                             Map b,
                             int flags,
                             Map<String,Integer> handle)

compare

public static String compare(org.apache.solr.common.SolrDocument a,
                             org.apache.solr.common.SolrDocument b,
                             int flags,
                             Map<String,Integer> handle)

compare

public static String compare(org.apache.solr.common.SolrDocumentList a,
                             org.apache.solr.common.SolrDocumentList b,
                             int flags,
                             Map<String,Integer> handle)

compare

public static String compare(Object[] a,
                             Object[] b,
                             int flags,
                             Map<String,Integer> handle)

compare

public static String compare(Object a,
                             Object b,
                             int flags,
                             Map<String,Integer> handle)

compareResponses

protected void compareResponses(org.apache.solr.client.solrj.response.QueryResponse a,
                                org.apache.solr.client.solrj.response.QueryResponse b)

testDistribSearch

public void testDistribSearch()
                       throws Exception
Throws:
Exception

getRandFields

public static Object[] getRandFields(String[] fields,
                                     BaseDistributedSearchTestCase.RandVal[] randVals)

validateControlData

public void validateControlData(org.apache.solr.client.solrj.response.QueryResponse control)
                         throws Exception
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


Copyright © 2000-2012 Apache Software Foundation. All Rights Reserved.