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
Direct Known Subclasses:
AbstractDistribZkTestBase

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.BadApple, 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 useExplicitNodeNames
           
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, testSolrHome, ZERO_ONE, ZERO_TWO
 
Fields inherited from class org.apache.lucene.util.LuceneTestCase
classRules, DEFAULT_LINE_DOCS_FILE, doesntSupportOffsets, INFOSTREAM, JENKINS_LARGE_LINE_DOCS_FILE, PREFLEX_IMPERSONATION_IS_ACTIVE, RANDOM_MULTIPLIER, ruleChain, suiteFailureMarker, SYSPROP_AWAITSFIX, SYSPROP_BADAPPLES, SYSPROP_NIGHTLY, SYSPROP_SLOW, SYSPROP_WEEKLY, TEMP_DIR, TEST_AWAITSFIX, TEST_CODEC, TEST_DIRECTORY, TEST_DOCVALUESFORMAT, TEST_LINE_DOCS_FILE, TEST_NIGHTLY, TEST_POSTINGSFORMAT, TEST_SLOW, TEST_THROTTLING, TEST_VERSION_CURRENT, TEST_WEEKLY, VERBOSE
 
Constructor Summary
protected BaseDistributedSearchTestCase()
          Constructs a test in which the jetty+solr instances as well as the solr clients all use the value of the "hostContext" system property.
protected BaseDistributedSearchTestCase(String context)
           
 
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)
           
static void clearHostContext()
          Clears the "hostContext" system property
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 solrHome, String dataDir)
           
 org.apache.solr.client.solrj.embedded.JettySolrRunner createJetty(File solrHome, String dataDir, String shardId)
           
 org.apache.solr.client.solrj.embedded.JettySolrRunner createJetty(File solrHome, String dataDir, String shardList, String solrConfigOverride, String schemaOverride)
           
 org.apache.solr.client.solrj.embedded.JettySolrRunner createJetty(File solrHome, String dataDir, String shardList, String solrConfigOverride, String schemaOverride, boolean explicitCoreNodeName)
           
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  String getSolrXml()
           
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 initHostContext()
          Set's the value of the "hostContext" system property to a random path like string (which may or may not contain sub-paths).
static void initialize()
           
protected  void query(boolean setDistribParams, Object[] q)
           
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()
           
protected  void setupJettySolrHome(File jettyHome)
           
 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, initCore, JQ, json, jsonAdd, jsonDelId, jsonDelQ, map, optimize, params, postSetUp, preTearDown, recurseDelete, req, req, req, resetExceptionIgnores, resetFactory, sdoc, setLoggingLevel, setupLogging, startTrackingSearchers, startTrackingZkClients, TEST_HOME, toJSON, unIgnoreException, updateJ, useFactory
 
Methods inherited from class org.apache.lucene.util.LuceneTestCase
assertSaneFieldCaches, asSet, assumeFalse, assumeNoException, assumeTrue, atLeast, atLeast, closeAfterSuite, closeAfterTest, defaultCodecSupportsDocValues, defaultCodecSupportsSortedSet, dumpArray, dumpIterator, getDataFile, getOnlySegmentReader, getTestClass, getTestName, isTestThread, localeForName, maybeWrapReader, newAlcoholicMergePolicy, newAlcoholicMergePolicy, newDirectory, newDirectory, newDirectory, newDirectory, newField, newField, newFSDirectory, newFSDirectory, newIndexWriterConfig, newIndexWriterConfig, newIOContext, newIOContext, newLogMergePolicy, newLogMergePolicy, newLogMergePolicy, newLogMergePolicy, newLogMergePolicy, newMockDirectory, newMockDirectory, newMockFSDirectory, 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

useExplicitNodeNames

protected boolean useExplicitNodeNames

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

deadServers

protected String[] deadServers

shards

protected String shards

shardsArr

protected String[] shardsArr

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

protected BaseDistributedSearchTestCase()
Constructs a test in which the jetty+solr instances as well as the solr clients all use the value of the "hostContext" system property.

If the system property is not set, or is set to the empty string (neither of which should normally happen unless a subclass explicitly modifies the property set by initHostContext() prior to calling this constructor) a servlet context of "/solr" is used. (this is for consistency with the default behavior of solr.xml parsing when using hostContext="${hostContext:}"

If the system property is set to a value which does not begin with a "/" (which should normally happen unless a subclass explicitly modifies the property set by initHostContext() prior to calling this constructor) a leading "/" will be prepended.

See Also:
initHostContext()

BaseDistributedSearchTestCase

protected BaseDistributedSearchTestCase(String context)
Parameters:
context - explicit servlet context path to use (eg: "/solr")
Method Detail

initialize

public static void initialize()

initHostContext

public static void initHostContext()
Set's the value of the "hostContext" system property to a random path like string (which may or may not contain sub-paths). This is used in the default constructor for this test to help ensure no code paths have hardcoded assumptions about the servlet context used to run solr.

Test configs may use the ${hostContext} variable to access this system property.

See Also:
BaseDistributedSearchTestCase(), clearHostContext()

clearHostContext

public static void clearHostContext()
                             throws Exception
Clears the "hostContext" system property

Throws:
Exception
See Also:
initHostContext()

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 solrHome,
                                                                         String dataDir)
                                                                  throws Exception
Throws:
Exception

createJetty

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

createJetty

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

createJetty

public org.apache.solr.client.solrj.embedded.JettySolrRunner createJetty(File solrHome,
                                                                         String dataDir,
                                                                         String shardList,
                                                                         String solrConfigOverride,
                                                                         String schemaOverride,
                                                                         boolean explicitCoreNodeName)
                                                                  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

query

protected void query(boolean setDistribParams,
                     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

getSolrXml

protected String getSolrXml()

setupJettySolrHome

protected void setupJettySolrHome(File jettyHome)
                           throws IOException
Throws:
IOException


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