@LuceneTestCase.SuppressSysoutChecks(bugUrl="Solr dumps tons of logs to console.") @LuceneTestCase.SuppressFileSystems(value="ExtrasFS") @RandomizeSSL public abstract class SolrTestCaseJ4 extends SolrTestCase
initCore(String, String, String, String)
method.Modifier and Type | Class and Description |
---|---|
static class |
SolrTestCaseJ4.BVal |
static class |
SolrTestCaseJ4.CloudHttp2SolrClientBuilder
A variant of
CloudHttp2SolrClient.Builder that will randomize
some internal settings. |
static class |
SolrTestCaseJ4.CloudSolrClientBuilder
A variant of
CloudSolrClient.Builder that will randomize
some internal settings. |
static class |
SolrTestCaseJ4.Doc |
static class |
SolrTestCaseJ4.Fld |
protected static class |
SolrTestCaseJ4.FldType |
static class |
SolrTestCaseJ4.FVal |
static class |
SolrTestCaseJ4.IRange |
static class |
SolrTestCaseJ4.IVals |
static class |
SolrTestCaseJ4.IValsPercent |
static interface |
SolrTestCaseJ4.SuppressPointFields
Annotation for test classes that want to disable PointFields.
|
static interface |
SolrTestCaseJ4.SuppressSSL
Annotation for test classes that want to disable SSL
|
static class |
SolrTestCaseJ4.SVal |
static class |
SolrTestCaseJ4.Vals |
static class |
SolrTestCaseJ4.XmlDoc
Necessary to make method signatures un-ambiguous
|
org.apache.lucene.util.LuceneTestCase.AwaitsFix, org.apache.lucene.util.LuceneTestCase.BadApple, org.apache.lucene.util.LuceneTestCase.Monster, org.apache.lucene.util.LuceneTestCase.Nightly, org.apache.lucene.util.LuceneTestCase.Slow, org.apache.lucene.util.LuceneTestCase.SuppressCodecs, org.apache.lucene.util.LuceneTestCase.SuppressFileSystems, org.apache.lucene.util.LuceneTestCase.SuppressFsync, org.apache.lucene.util.LuceneTestCase.SuppressReproduceLine, org.apache.lucene.util.LuceneTestCase.SuppressSysoutChecks, org.apache.lucene.util.LuceneTestCase.SuppressTempFileChecks, org.apache.lucene.util.LuceneTestCase.ThrowingRunnable, org.apache.lucene.util.LuceneTestCase.Weekly
Modifier and Type | Field and Description |
---|---|
protected static String |
configString |
protected static String |
CORE_PROPERTIES_FILENAME |
protected static String |
coreName |
static int |
DEFAULT_CONNECTION_TIMEOUT |
static String |
DEFAULT_TEST_COLLECTION_NAME |
static String |
DEFAULT_TEST_CORENAME |
protected static TestHarness |
h
Harness initialized by create[Default]Core[Container].
|
protected static String |
hdfsDataDir |
protected static File |
initCoreDataDir
The directory used to story the index managed by the TestHarness
|
protected static TestHarness.LocalRequestFactory |
lrf
LocalRequestFactory initialized by create[Default]Core[Container] using sensible
defaults.
|
static String |
NUMERIC_DOCVALUES_SYSPROP
The name of a sysprop that will be either
true or false indicating if
docValues should be used on a numeric field. |
static String |
NUMERIC_POINTS_SYSPROP
The name of a sysprop that will either
true or false indicating if
numeric points fields are currently in use, depending on the user specified value of
USE_NUMERIC_POINTS_SYSPROP and/or the SolrTestCaseJ4.SuppressPointFields annotation and/or
randomization. |
static SolrTestCaseJ4.IRange |
ONE_ONE |
protected static Map<Class,String> |
RANDOMIZED_NUMERIC_FIELDTYPES
A Map of "primitive" java "numeric" types and the string name of the
class used in the
corresponding schema fieldType declaration. |
protected static String |
schemaString |
static org.junit.rules.TestRule |
solrClassRules |
protected static org.apache.solr.core.SolrConfig |
solrConfig |
org.junit.rules.TestRule |
solrTestRules |
protected static SSLTestConfig |
sslConfig |
static String |
SYSTEM_PROPERTY_SOLR_DISABLE_SHARDS_WHITELIST
Deprecated.
|
static String |
SYSTEM_PROPERTY_SOLR_TESTS_MERGEPOLICYFACTORY |
protected static ExecutorService |
testExecutor |
protected static Path |
testSolrHome |
static String |
UPDATELOG_SYSPROP |
static String |
USE_NUMERIC_POINTS_SYSPROP
The name of a sysprop that can be set by users when running tests to force the types of numerics
used for test classes that do not have the
SolrTestCaseJ4.SuppressPointFields annotation:
If unset, then a random variable will be used to decide the type of numerics.
If set to true then Points based numerics will be used.
If set to false (or any other string) then Trie based numerics will be used.
|
static SolrTestCaseJ4.IRange |
ZERO_ONE |
static SolrTestCaseJ4.IRange |
ZERO_TWO |
assertsAreEnabled, classRules, DEFAULT_LINE_DOCS_FILE, INFOSTREAM, JENKINS_LARGE_LINE_DOCS_FILE, LEAVE_TEMPORARY, MAYBE_CACHE_POLICY, RANDOM_MULTIPLIER, ruleChain, suiteFailureMarker, SYSPROP_AWAITSFIX, SYSPROP_BADAPPLES, SYSPROP_FAILFAST, SYSPROP_MAXFAILURES, SYSPROP_MONSTER, SYSPROP_NIGHTLY, SYSPROP_SLOW, SYSPROP_WEEKLY, TEST_ASSERTS_ENABLED, TEST_AWAITSFIX, TEST_BADAPPLES, TEST_CODEC, TEST_DIRECTORY, TEST_DOCVALUESFORMAT, TEST_LINE_DOCS_FILE, TEST_MONSTER, TEST_NIGHTLY, TEST_POSTINGSFORMAT, TEST_SLOW, TEST_THROTTLING, TEST_WEEKLY, VERBOSE
Constructor and Description |
---|
SolrTestCaseJ4() |
Modifier and Type | Method and Description |
---|---|
static String |
add(SolrTestCaseJ4.XmlDoc doc,
String... args)
Generates an <add><doc>...
|
static Long |
addAndGetVersion(org.apache.solr.common.SolrInputDocument sdoc,
org.apache.solr.common.params.SolrParams params) |
static void |
addDoc(String doc,
String updateRequestProcessorChain) |
static String |
adoc(org.apache.solr.common.SolrInputDocument sdoc)
Generates a simple <add><doc>...
|
static String |
adoc(String... fieldsAndValues)
Generates a simple <add><doc>...
|
static void |
assertFailedU(String update)
Validates an update XML String failed
|
static void |
assertFailedU(String message,
String update)
Validates an update XML String failed
|
static void |
assertFieldValues(org.apache.solr.common.SolrDocumentList documents,
String fieldName,
Object... expectedValues)
Fails if the number of documents in the given SolrDocumentList differs
from the given number of expected values, or if any of the values in the
given field don't match the expected values in the same order.
|
static String |
assertJQ(org.apache.solr.request.SolrQueryRequest req,
double delta,
String... tests)
Validates a query matches some JSON test expressions and closes the
query.
|
static String |
assertJQ(org.apache.solr.request.SolrQueryRequest req,
String... tests)
Validates a query matches some JSON test expressions using the default double delta tolerance.
|
static void |
assertNonBlockingRandomGeneratorAvailable() |
static void |
assertQ(org.apache.solr.request.SolrQueryRequest req,
String... tests)
Validates a query matches some XPath test expressions and closes the query
|
static void |
assertQ(String message,
org.apache.solr.request.SolrQueryRequest req,
String... tests)
Validates a query matches some XPath test expressions and closes the query
|
static void |
assertQEx(String message,
org.apache.solr.request.SolrQueryRequest req,
int code)
Makes sure a query throws a SolrException with the listed response code
|
static void |
assertQEx(String message,
org.apache.solr.request.SolrQueryRequest req,
org.apache.solr.common.SolrException.ErrorCode code) |
static void |
assertQEx(String failMessage,
String exceptionMessage,
org.apache.solr.request.SolrQueryRequest req,
org.apache.solr.common.SolrException.ErrorCode code)
Makes sure a query throws a SolrException with the listed response code and expected message
|
static void |
assertResponseValues(org.apache.solr.client.solrj.response.SolrResponseBase rsp,
Object... assertions) |
boolean |
assertSolrInputFieldEquals(Object expected,
Object actual) |
static void |
assertU(String update)
Validates an update XML String is successful
|
static void |
assertU(String message,
String update)
Validates an update XML String is successful
|
static void |
assertXmlFile(File file,
String... xpath) |
static void |
assumeWorkingMockito()
Assumes that Mockito/Bytebuddy is available and can be used to mock classes (e.g., fails if Java version is too new).
|
protected static org.apache.solr.client.solrj.embedded.JettyConfig |
buildJettyConfig(String context) |
protected static String |
buildUrl(int port,
String context) |
void |
clearIndex()
Does a low level delete of all docs in the index.
|
static String |
clearObjectTrackerAndCheckEmpty(int waitSeconds) |
static String |
clearObjectTrackerAndCheckEmpty(int waitSeconds,
boolean tryClose) |
static String |
commit(String... args) |
boolean |
compareSolrDocument(Object expected,
Object actual) |
boolean |
compareSolrDocumentList(Object expected,
Object actual) |
boolean |
compareSolrInputDocument(Object expected,
Object actual) |
static Path |
configset(String name) |
static void |
copyMinConf(File dstRoot) |
static void |
copyMinConf(File dstRoot,
String propertiesContent) |
static void |
copyMinConf(File dstRoot,
String propertiesContent,
String solrconfigXmlName) |
static void |
copyMinFullSetup(File dstRoot) |
static void |
copySolrHomeToTemp(File dstRoot,
String collection) |
static void |
copyXmlToHome(File dstRoot,
String fromFile) |
static Comparator<SolrTestCaseJ4.Doc> |
createComparator(List<Comparator<SolrTestCaseJ4.Doc>> comparators) |
static Comparator<SolrTestCaseJ4.Doc> |
createComparator(String field,
boolean asc,
boolean sortMissingLast,
boolean sortMissingFirst,
boolean sortMissingAsZero) |
static void |
createCore() |
static org.apache.solr.core.CoreContainer |
createCoreContainer(org.apache.solr.core.NodeConfig config,
org.apache.solr.core.CoresLocator locator) |
static org.apache.solr.core.CoreContainer |
createCoreContainer(Path solrHome,
String solrXML) |
static org.apache.solr.core.CoreContainer |
createCoreContainer(String coreName,
String dataDir,
String solrConfig,
String schema) |
static org.apache.solr.core.CoreContainer |
createDefaultCoreContainer(Path solrHome) |
static org.apache.solr.update.processor.DistributedUpdateProcessor |
createDistributedUpdateProcessor(org.apache.solr.request.SolrQueryRequest req,
org.apache.solr.response.SolrQueryResponse rsp,
org.apache.solr.update.processor.UpdateRequestProcessor next) |
static SolrTestCaseJ4.Doc |
createDoc(List<SolrTestCaseJ4.FldType> descriptor) |
static Comparator<SolrTestCaseJ4.Doc> |
createSort(org.apache.solr.schema.IndexSchema schema,
List<SolrTestCaseJ4.FldType> fieldTypes,
String[] out) |
static Long |
deleteAndGetVersion(String id,
org.apache.solr.common.params.SolrParams params) |
static Long |
deleteByQueryAndGetVersion(String q,
org.apache.solr.common.params.SolrParams params) |
static void |
deleteCore()
Shuts down the test harness, and makes the best attempt possible
to delete dataDir, unless the system property "solr.test.leavedatadir"
is set.
|
static String |
delI(String id)
Generates a <delete>...
|
static String |
delQ(String q)
Generates a <delete>...
|
static SolrTestCaseJ4.XmlDoc |
doc(String... fieldsAndValues)
Generates a simple <doc>...
|
protected static String |
getClassName() |
static org.apache.solr.client.solrj.impl.CloudHttp2SolrClient |
getCloudHttp2SolrClient(MiniSolrCloudCluster cluster)
This method may randomize unspecified aspects of the resulting SolrClient.
|
static org.apache.solr.client.solrj.impl.CloudSolrClient |
getCloudSolrClient(MiniSolrCloudCluster cluster)
This method may randomize unspecified aspects of the resulting SolrClient.
|
static org.apache.solr.client.solrj.impl.CloudSolrClient |
getCloudSolrClient(String zkHost)
This method may randomize unspecified aspects of the resulting SolrClient.
|
static org.apache.solr.client.solrj.impl.CloudSolrClient |
getCloudSolrClient(String zkHost,
boolean shardLeadersOnly)
This method may randomize unspecified aspects of the resulting SolrClient.
|
static org.apache.solr.client.solrj.impl.CloudSolrClient |
getCloudSolrClient(String zkHost,
boolean shardLeadersOnly,
org.apache.http.client.HttpClient httpClient)
This method may randomize unspecified aspects of the resulting SolrClient.
|
static org.apache.solr.client.solrj.impl.CloudSolrClient |
getCloudSolrClient(String zkHost,
boolean shardLeadersOnly,
org.apache.http.client.HttpClient httpClient,
int connectionTimeoutMillis,
int socketTimeoutMillis)
This method may randomize unspecified aspects of the resulting SolrClient.
|
static org.apache.solr.client.solrj.impl.CloudSolrClient |
getCloudSolrClient(String zkHost,
boolean shardLeadersOnly,
int socketTimeoutMillis)
This method may randomize unspecified aspects of the resulting SolrClient.
|
static org.apache.solr.client.solrj.impl.CloudSolrClient |
getCloudSolrClient(String zkHost,
boolean shardLeadersOnly,
int connectionTimeoutMillis,
int socketTimeoutMillis)
This method may randomize unspecified aspects of the resulting SolrClient.
|
static org.apache.solr.client.solrj.impl.CloudSolrClient |
getCloudSolrClient(String zkHost,
org.apache.http.client.HttpClient httpClient)
This method may randomize unspecified aspects of the resulting SolrClient.
|
static org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrClient |
getConcurrentUpdateSolrClient(String baseSolrUrl,
org.apache.http.client.HttpClient httpClient,
int queueSize,
int threadCount)
This method may randomize unspecified aspects of the resulting SolrClient.
|
static org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrClient |
getConcurrentUpdateSolrClient(String baseSolrUrl,
int queueSize,
int threadCount)
This method may randomize unspecified aspects of the resulting SolrClient.
|
static org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrClient |
getConcurrentUpdateSolrClient(String baseSolrUrl,
int queueSize,
int threadCount,
int connectionTimeoutMillis)
This method may randomize unspecified aspects of the resulting SolrClient.
|
static File |
getFile(String name)
Gets a resource from the context classloader as
File . |
static org.apache.solr.client.solrj.impl.HttpSolrClient |
getHttpSolrClient(String url)
This method may randomize unspecified aspects of the resulting SolrClient.
|
static org.apache.solr.client.solrj.impl.HttpSolrClient |
getHttpSolrClient(String url,
org.apache.http.client.HttpClient httpClient)
This method may randomize unspecified aspects of the resulting SolrClient.
|
static org.apache.solr.client.solrj.impl.HttpSolrClient |
getHttpSolrClient(String url,
org.apache.http.client.HttpClient httpClient,
int connectionTimeoutMillis)
This method may randomize unspecified aspects of the resulting SolrClient.
|
static org.apache.solr.client.solrj.impl.HttpSolrClient |
getHttpSolrClient(String url,
org.apache.http.client.HttpClient httpClient,
org.apache.solr.client.solrj.ResponseParser responseParser)
This method may randomize unspecified aspects of the resulting SolrClient.
|
static org.apache.solr.client.solrj.impl.HttpSolrClient |
getHttpSolrClient(String url,
org.apache.http.client.HttpClient httpClient,
org.apache.solr.client.solrj.ResponseParser responseParser,
boolean compression)
This method may randomize unspecified aspects of the resulting SolrClient.
|
static org.apache.solr.client.solrj.impl.HttpSolrClient |
getHttpSolrClient(String url,
int connectionTimeoutMillis)
This method may randomize unspecified aspects of the resulting SolrClient.
|
static org.apache.solr.client.solrj.impl.HttpSolrClient |
getHttpSolrClient(String url,
int connectionTimeoutMillis,
int socketTimeoutMillis)
This method may randomize unspecified aspects of the resulting SolrClient.
|
static org.apache.solr.client.solrj.impl.LBHttpSolrClient |
getLBHttpSolrClient(org.apache.http.client.HttpClient client,
int connectionTimeoutMillis,
int socketTimeoutMillis,
String... solrUrls)
This method may randomize unspecified aspects of the resulting SolrClient.
|
static org.apache.solr.client.solrj.impl.LBHttpSolrClient |
getLBHttpSolrClient(org.apache.http.client.HttpClient client,
String... solrUrls)
This method may randomize unspecified aspects of the resulting SolrClient.
|
static org.apache.solr.client.solrj.impl.LBHttpSolrClient |
getLBHttpSolrClient(String... solrUrls)
This method may randomize unspecified aspects of the resulting SolrClient.
|
protected static int |
getNextAvailablePort()
Find next available local port.
|
static Throwable |
getRootCause(Throwable t) |
protected String |
getSaferTestName() |
static String |
getSchemaFile()
Subclasses must define this method to return the name of the
schema.xml they wish to use.
|
protected static String |
getSimpleClassName() |
static String |
getSolrConfigFile()
Subclasses must define this method to return the name of the
solrconfig.xml they wish to use.
|
static Throwable |
getWrappedException(Throwable e) |
static boolean |
hasInitException(Class<? extends Exception> exceptionType) |
static boolean |
hasInitException(String message) |
static void |
ignoreException(String pattern)
Causes an exception matching the regex pattern to not be logged.
|
Map<Comparable,SolrTestCaseJ4.Doc> |
indexDocs(List<SolrTestCaseJ4.FldType> descriptor,
Map<Comparable,SolrTestCaseJ4.Doc> model,
int nDocs) |
static void |
initClassLogLevels() |
static void |
initCore() |
static void |
initCore(String config,
String schema)
Call initCore in @BeforeClass to instantiate a solr core in your test class.
|
static void |
initCore(String config,
String schema,
String solrHome)
Call initCore in @BeforeClass to instantiate a solr core in your test class.
|
static void |
initCore(String config,
String schema,
String solrHome,
String pCoreName)
Call initCore in @BeforeClass to instantiate a solr core in your test class.
|
void |
initMethodLogLevels() |
Map<Comparable,List<Comparable>> |
invertField(Map<Comparable,SolrTestCaseJ4.Doc> model,
String field)
Return a Map from field value to a list of document ids
|
protected static boolean |
isSSLMode() |
static String |
JQ(org.apache.solr.request.SolrQueryRequest req)
Makes a query request and returns the JSON string response
|
static String |
json(org.apache.solr.common.SolrInputDocument doc)
Creates JSON from a SolrInputDocument.
|
static void |
json(org.apache.solr.common.SolrInputDocument doc,
org.noggit.CharArr out)
Appends to the
out array with JSON from the doc . |
static String |
json(String testJSON)
Converts "test JSON" strings into JSON parseable by our JSON parser.
|
static String |
jsonAdd(org.apache.solr.common.SolrInputDocument... docs)
Creates a JSON add command from a SolrInputDocument list.
|
static String |
jsonDelId(Object... ids)
Creates a JSON delete command from an id list
|
static String |
jsonDelQ(String... queries)
Creates a JSON deleteByQuery command
|
static Map |
map(Object... params) |
static SolrTestCaseJ4.CloudSolrClientBuilder |
newCloudSolrClient(String zkHost) |
static void |
newRandomConfig()
Sets system properties to allow generation of random configurations of
solrconfig.xml and schema.xml.
|
static String |
optimize(String... args) |
static org.apache.solr.common.params.ModifiableSolrParams |
params(String... params) |
protected <T> T |
pickRandom(T... options) |
void |
postSetUp()
Subclasses that override setUp can optionally call this method
to log the fact that their setUp process has ended.
|
void |
preTearDown()
Subclasses that override tearDown can optionally call this method
to log the fact that the tearDown process has started.
|
static String |
randomDate()
Returns a randomly generated Date in the appropriate Solr external (input) format
|
static void |
randomizeUpdateLogImpl()
randomizes the updateLog between different update log implementations for better test coverage
|
static String |
randomSkewedDate()
Returns a Date such that all results from this method always have the same values for
year+month+day+hour+minute but the seconds are randomized.
|
static String |
randomXmlUsableUnicodeString()
We want "realistic" unicode strings beyond simple ascii, but because our
updates use XML we need to ensure we don't get "special" code block.
|
static org.apache.solr.request.SolrQueryRequest |
req(org.apache.solr.common.params.SolrParams params,
String... moreParams)
Generates a SolrQueryRequest
|
static org.apache.solr.request.SolrQueryRequest |
req(String... q)
Generates a SolrQueryRequest using the LocalRequestFactory
|
static org.apache.solr.request.SolrQueryRequest |
req(String[] params,
String... moreParams)
Generates a SolrQueryRequest using the LocalRequestFactory
|
static void |
resetExceptionIgnores()
Clears all exception patterns, although keeps
"ignore_exception" . |
static void |
resetFactory() |
void |
restoreMethodLogLevels() |
static org.apache.solr.common.SolrInputDocument |
sdoc(Object... fieldsAndValues) |
static List<org.apache.solr.common.SolrInputDocument> |
sdocs(org.apache.solr.common.SolrInputDocument... docs) |
org.apache.solr.common.SolrInputDocument |
sdocWithChildren(Integer id,
String version,
int childCount) |
org.apache.solr.common.SolrInputDocument |
sdocWithChildren(String id,
String version) |
org.apache.solr.common.SolrInputDocument |
sdocWithChildren(String id,
String version,
int childCount) |
void |
setUp() |
static void |
setupNoCoreTest(Path solrHome,
String xmlStr)
Call this from @BeforeClass to set up the test harness and update handler with no cores.
|
static void |
setupTestCases() |
static Object |
skewed(Object likely,
Object unlikely)
Returns
likely most (1/10) of the time, otherwise unlikely |
static void |
Solr11035BandAid(org.apache.solr.client.solrj.SolrClient client,
String collection,
String idField,
long expectedDocCount,
String query,
String tag)
See SOLR-11035.
|
static void |
Solr11035BandAid(org.apache.solr.client.solrj.SolrClient client,
String collection,
String idField,
long expectedDocCount,
String query,
String tag,
boolean failAnyway) |
static void |
startTrackingSearchers() |
protected static void |
systemClearPropertySolrDisableShardsWhitelist()
Deprecated.
|
protected static void |
systemClearPropertySolrTestsMergePolicyFactory() |
protected static void |
systemSetPropertySolrDisableShardsWhitelist(String value)
Deprecated.
|
protected static void |
systemSetPropertySolrTestsMergePolicyFactory(String value) |
void |
tearDown() |
static void |
teardownTestCases() |
static String |
TEST_HOME() |
static Path |
TEST_PATH() |
static String |
toJSON(SolrTestCaseJ4.Doc doc) |
static void |
unIgnoreException(String pattern) |
static String |
updateJ(String json,
org.apache.solr.common.params.SolrParams args)
Send JSON update commands
|
static void |
useFactory(String factory)
Use a different directory factory.
|
protected void |
waitForWarming() |
protected static void |
waitForWarming(org.apache.solr.core.SolrCore core) |
protected static org.apache.lucene.analysis.MockTokenizer |
whitespaceMockTokenizer(Reader input) |
protected static org.apache.lucene.analysis.MockTokenizer |
whitespaceMockTokenizer(String input) |
static void |
writeCoreProperties(Path coreDirectory,
Properties properties,
String testname) |
protected void |
writeCoreProperties(Path coreDirectory,
String corename) |
checkSyspropForceBeforeAssumptionFailure, checkSyspropForceBeforeClassAssumptionFailure, shutdownLogger
addVirusChecker, assertDeletedDocsEquals, assertDocsAndPositionsEnumEquals, assertDocsEnumEquals, assertDocsSkippingEquals, assertDocValuesEquals, assertDocValuesEquals, assertFieldInfosEquals, assertNormsEquals, assertPointsEquals, assertPositionsSkippingEquals, assertReaderEquals, assertReaderStatisticsEquals, assertStoredFieldEquals, assertStoredFieldsEquals, assertTermsEnumEquals, assertTermsEquals, assertTermsEquals, assertTermsStatisticsEquals, assertTermStatsEquals, assertTermVectorsEquals, asSet, assumeFalse, assumeNoException, assumeTrue, assumeWorkingMMapOnWindows, atLeast, atLeast, closeAfterSuite, closeAfterTest, collate, createTempDir, createTempDir, createTempFile, createTempFile, dumpArray, dumpIterator, expectThrows, expectThrows, expectThrows, expectThrowsAnyOf, expectThrowsAnyOf, getBaseTempDirForTestClass, getDataInputStream, getDataPath, getOnlyLeafReader, getTestClass, getTestName, hasWorkingMMapOnWindows, isTestThread, localeForLanguageTag, maybeChangeLiveIndexWriterConfig, maybeWrapReader, newAlcoholicMergePolicy, newAlcoholicMergePolicy, newDirectory, newDirectory, newDirectory, newDirectory, newDirectory, newField, newField, newFSDirectory, newFSDirectory, newIndexWriterConfig, newIndexWriterConfig, newIndexWriterConfig, newIOContext, newIOContext, newLogMergePolicy, newLogMergePolicy, newLogMergePolicy, newLogMergePolicy, newLogMergePolicy, newMaybeVirusCheckingDirectory, newMaybeVirusCheckingFSDirectory, newMergePolicy, newMergePolicy, newMergePolicy, newMockDirectory, newMockDirectory, newMockDirectory, newMockFSDirectory, newMockFSDirectory, newSearcher, newSearcher, newSearcher, newStringField, newStringField, newStringField, newStringField, newTextField, newTextField, newTieredMergePolicy, newTieredMergePolicy, overrideDefaultQueryCache, overrideTestDefaultQueryCache, random, randomLocale, randomTimeZone, rarely, rarely, replaceMaxFailureRule, resetDefaultQueryCache, restoreCPUCoreCount, restoreIndexWriterMaxDocs, restoreSpins, runWithRestrictedPermissions, setIndexWriterMaxDocs, setupCPUCoreCount, setupSpins, slowFileExists, usually, usually, wrapReader
assertArrayEquals, assertArrayEquals, 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, assertEquals, assertEquals, assertFalse, assertFalse, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertThat, assertThat, assertTrue, assertTrue, fail, fail
public static final String DEFAULT_TEST_COLLECTION_NAME
public static final String DEFAULT_TEST_CORENAME
protected static final String CORE_PROPERTIES_FILENAME
public static final String SYSTEM_PROPERTY_SOLR_TESTS_MERGEPOLICYFACTORY
@Deprecated public static final String SYSTEM_PROPERTY_SOLR_DISABLE_SHARDS_WHITELIST
protected static String coreName
public static int DEFAULT_CONNECTION_TIMEOUT
protected static volatile ExecutorService testExecutor
protected static volatile SSLTestConfig sslConfig
public static org.junit.rules.TestRule solrClassRules
public org.junit.rules.TestRule solrTestRules
protected static String configString
protected static String schemaString
protected static Path testSolrHome
protected static org.apache.solr.core.SolrConfig solrConfig
protected static TestHarness h
For use in test methods as needed.
protected static TestHarness.LocalRequestFactory lrf
For use in test methods as needed.
protected static volatile File initCoreDataDir
protected static String hdfsDataDir
public static final SolrTestCaseJ4.IRange ZERO_ONE
public static final SolrTestCaseJ4.IRange ZERO_TWO
public static final SolrTestCaseJ4.IRange ONE_ONE
public static final String USE_NUMERIC_POINTS_SYSPROP
SolrTestCaseJ4.SuppressPointFields
annotation:
true
then Points based numerics will be used.false
(or any other string) then Trie based numerics will be used.NUMERIC_POINTS_SYSPROP
,
Constant Field Valuespublic static final String NUMERIC_POINTS_SYSPROP
true
or false
indicating if
numeric points fields are currently in use, depending on the user specified value of
USE_NUMERIC_POINTS_SYSPROP
and/or the SolrTestCaseJ4.SuppressPointFields
annotation and/or
randomization. Tests can use Boolean.getBoolean(NUMERIC_POINTS_SYSPROP)
.public static final String NUMERIC_DOCVALUES_SYSPROP
true
or false
indicating if
docValues should be used on a numeric field. This property string should be used in the
docValues
attribute of (most) numeric fieldTypes in schemas, and by default will be
randomized by this class in a @BeforeClass
. Subclasses that need to force specific
behavior can use System.setProperty(NUMERIC_DOCVALUES_SYSPROP,"true")
to override the default randomization.public static final String UPDATELOG_SYSPROP
protected static final Map<Class,String> RANDOMIZED_NUMERIC_FIELDTYPES
class
used in the
corresponding schema fieldType declaration.
Example: java.util.Date => "solr.DatePointField"
randomizeNumericTypesProperties()
protected void writeCoreProperties(Path coreDirectory, String corename) throws IOException
IOException
public static void writeCoreProperties(Path coreDirectory, Properties properties, String testname) throws IOException
IOException
public static void setupTestCases()
public static void assumeWorkingMockito()
public static String clearObjectTrackerAndCheckEmpty(int waitSeconds)
public static String clearObjectTrackerAndCheckEmpty(int waitSeconds, boolean tryClose)
public static void initClassLogLevels()
public void initMethodLogLevels()
public void restoreMethodLogLevels()
protected static boolean isSSLMode()
public static void useFactory(String factory) throws Exception
Exception
protected static org.apache.solr.client.solrj.embedded.JettyConfig buildJettyConfig(String context)
protected static org.apache.lucene.analysis.MockTokenizer whitespaceMockTokenizer(Reader input) throws IOException
IOException
protected static org.apache.lucene.analysis.MockTokenizer whitespaceMockTokenizer(String input) throws IOException
IOException
public static void setupNoCoreTest(Path solrHome, String xmlStr) throws Exception
solrHome
- The solr home directory.xmlStr
- - the text of an XML file to use. If null, use the what's the absolute minimal file.Exception
- Lost of file-type things can go wrong.public static void newRandomConfig()
LuceneTestCase.newIndexWriterConfig(org.apache.lucene.analysis.Analyzer)
and base schema.xml (Point Fields)public void setUp() throws Exception
setUp
in class org.apache.lucene.util.LuceneTestCase
Exception
public void tearDown() throws Exception
tearDown
in class org.apache.lucene.util.LuceneTestCase
Exception
public static void initCore(String config, String schema) throws Exception
Exception
public static void initCore(String config, String schema, String solrHome) throws Exception
Exception
public static void initCore(String config, String schema, String solrHome, String pCoreName) throws Exception
Exception
public static void startTrackingSearchers()
public static void ignoreException(String pattern)
public static void unIgnoreException(String pattern)
public static void resetExceptionIgnores()
"ignore_exception"
.
SolrTestCaseJ4
calls this in AfterClass
so usually tests don't need to call this.protected static String getClassName()
protected static String getSimpleClassName()
public static String getSchemaFile()
public static String getSolrConfigFile()
public static void createCore()
public static org.apache.solr.core.CoreContainer createCoreContainer(Path solrHome, String solrXML)
public static org.apache.solr.core.CoreContainer createCoreContainer(org.apache.solr.core.NodeConfig config, org.apache.solr.core.CoresLocator locator)
public static org.apache.solr.core.CoreContainer createCoreContainer(String coreName, String dataDir, String solrConfig, String schema)
public static org.apache.solr.core.CoreContainer createDefaultCoreContainer(Path solrHome)
public static boolean hasInitException(String message)
public void postSetUp()
public void preTearDown()
public static void deleteCore()
protected static int getNextAvailablePort() throws Exception
Exception
- on IO errorspublic static void assertU(String update)
public static void assertU(String message, String update)
public static void assertFailedU(String update)
public static void assertFailedU(String message, String update)
public static void assertQ(org.apache.solr.request.SolrQueryRequest req, String... tests)
public static void assertQ(String message, org.apache.solr.request.SolrQueryRequest req, String... tests)
public static String JQ(org.apache.solr.request.SolrQueryRequest req) throws Exception
Exception
public static String assertJQ(org.apache.solr.request.SolrQueryRequest req, String... tests) throws Exception
Exception
JSONTestUtil.DEFAULT_DELTA
,
assertJQ(SolrQueryRequest,double,String...)
public static String assertJQ(org.apache.solr.request.SolrQueryRequest req, double delta, String... tests) throws Exception
Please use this with care: this makes it easy to match complete structures, but doing so can result in fragile tests if you are matching more than what you want to test.
req
- Solr request to executedelta
- tolerance allowed in comparing float/double valuestests
- JSON path expression + '==' + expected valueException
public static void assertQEx(String message, org.apache.solr.request.SolrQueryRequest req, int code)
public static void assertQEx(String message, org.apache.solr.request.SolrQueryRequest req, org.apache.solr.common.SolrException.ErrorCode code)
public static void assertQEx(String failMessage, String exceptionMessage, org.apache.solr.request.SolrQueryRequest req, org.apache.solr.common.SolrException.ErrorCode code)
failMessage
- The assert message to show when the query doesn't throw the expected exceptionexceptionMessage
- A substring of the message expected in the exceptionreq
- Solr requestcode
- expected error code for the querypublic static String adoc(String... fieldsAndValues)
fieldsAndValues
- 0th and Even numbered args are fields names odds are field values.add(org.apache.solr.SolrTestCaseJ4.XmlDoc, java.lang.String...)
,
doc(java.lang.String...)
public static String adoc(org.apache.solr.common.SolrInputDocument sdoc)
public static void addDoc(String doc, String updateRequestProcessorChain) throws Exception
Exception
public static String add(SolrTestCaseJ4.XmlDoc doc, String... args)
doc
- the Document to addargs
- 0th and Even numbered args are param names, Odds are param values.add(org.apache.solr.SolrTestCaseJ4.XmlDoc, java.lang.String...)
,
doc(java.lang.String...)
public static SolrTestCaseJ4.XmlDoc doc(String... fieldsAndValues)
fieldsAndValues
- 0th and Even numbered args are fields names, Odds are field values.BaseTestHarness.makeSimpleDoc(java.lang.String...)
public static org.apache.solr.common.params.ModifiableSolrParams params(String... params)
public static org.apache.solr.request.SolrQueryRequest req(String... q)
lrf
public static org.apache.solr.request.SolrQueryRequest req(String[] params, String... moreParams)
lrf
public static org.apache.solr.request.SolrQueryRequest req(org.apache.solr.common.params.SolrParams params, String... moreParams)
public void clearIndex()
*:*
DBQ because it
takes advantage of internal methods to ensure all index data is wiped, regardless of optimistic
concurrency version constraints -- making it suitable for tests that create synthetic versions,
and/or require a completely pristine index w/o any field metdata.public static String updateJ(String json, org.apache.solr.common.params.SolrParams args) throws Exception
Exception
public static org.apache.solr.common.SolrInputDocument sdoc(Object... fieldsAndValues)
public org.apache.solr.common.SolrInputDocument sdocWithChildren(String id, String version)
public org.apache.solr.common.SolrInputDocument sdocWithChildren(String id, String version, int childCount)
public org.apache.solr.common.SolrInputDocument sdocWithChildren(Integer id, String version, int childCount)
public static List<org.apache.solr.common.SolrInputDocument> sdocs(org.apache.solr.common.SolrInputDocument... docs)
public static String json(String testJSON)
public static String json(org.apache.solr.common.SolrInputDocument doc)
json(SolrInputDocument,CharArr)
public static void json(org.apache.solr.common.SolrInputDocument doc, org.noggit.CharArr out)
out
array with JSON from the doc
.
Doesn't currently handle boosts, but does recursively handle child documentspublic static String jsonAdd(org.apache.solr.common.SolrInputDocument... docs)
public static String jsonDelId(Object... ids)
public static Long addAndGetVersion(org.apache.solr.common.SolrInputDocument sdoc, org.apache.solr.common.params.SolrParams params) throws Exception
Exception
public static Long deleteAndGetVersion(String id, org.apache.solr.common.params.SolrParams params) throws Exception
Exception
public static Long deleteByQueryAndGetVersion(String q, org.apache.solr.common.params.SolrParams params) throws Exception
Exception
public static void assertResponseValues(org.apache.solr.client.solrj.response.SolrResponseBase rsp, Object... assertions)
public Map<Comparable,SolrTestCaseJ4.Doc> indexDocs(List<SolrTestCaseJ4.FldType> descriptor, Map<Comparable,SolrTestCaseJ4.Doc> model, int nDocs) throws Exception
Exception
public static SolrTestCaseJ4.Doc createDoc(List<SolrTestCaseJ4.FldType> descriptor)
public static Comparator<SolrTestCaseJ4.Doc> createSort(org.apache.solr.schema.IndexSchema schema, List<SolrTestCaseJ4.FldType> fieldTypes, String[] out)
public static Comparator<SolrTestCaseJ4.Doc> createComparator(String field, boolean asc, boolean sortMissingLast, boolean sortMissingFirst, boolean sortMissingAsZero)
public static Comparator<SolrTestCaseJ4.Doc> createComparator(List<Comparator<SolrTestCaseJ4.Doc>> comparators)
public static String toJSON(SolrTestCaseJ4.Doc doc)
public Map<Comparable,List<Comparable>> invertField(Map<Comparable,SolrTestCaseJ4.Doc> model, String field)
public static File getFile(String name)
File
. This method should only be used,
if a real file is needed. To get a stream, code should prefer
Class.getResourceAsStream(java.lang.String)
using this.getClass()
.public static String TEST_HOME()
public static Path TEST_PATH()
public static void assertXmlFile(File file, String... xpath) throws IOException, SAXException
IOException
SAXException
public static void assertFieldValues(org.apache.solr.common.SolrDocumentList documents, String fieldName, Object... expectedValues)
public static void copyMinConf(File dstRoot) throws IOException
IOException
public static void copyMinConf(File dstRoot, String propertiesContent) throws IOException
IOException
public static void copyMinConf(File dstRoot, String propertiesContent, String solrconfigXmlName) throws IOException
IOException
public static void copyMinFullSetup(File dstRoot) throws IOException
IOException
public static void copyXmlToHome(File dstRoot, String fromFile) throws IOException
IOException
public static void copySolrHomeToTemp(File dstRoot, String collection) throws IOException
IOException
public boolean assertSolrInputFieldEquals(Object expected, Object actual)
public static Object skewed(Object likely, Object unlikely)
likely
most (1/10) of the time, otherwise unlikely
public static org.apache.solr.client.solrj.impl.CloudHttp2SolrClient getCloudHttp2SolrClient(MiniSolrCloudCluster cluster)
CloudHttp2SolrClient.Builder
class directlypublic static org.apache.solr.client.solrj.impl.CloudSolrClient getCloudSolrClient(String zkHost)
CloudSolrClient.Builder
class directlypublic static org.apache.solr.client.solrj.impl.CloudSolrClient getCloudSolrClient(MiniSolrCloudCluster cluster)
CloudSolrClient.Builder
class directlypublic static org.apache.solr.client.solrj.impl.CloudSolrClient getCloudSolrClient(String zkHost, org.apache.http.client.HttpClient httpClient)
CloudSolrClient.Builder
class directlypublic static org.apache.solr.client.solrj.impl.CloudSolrClient getCloudSolrClient(String zkHost, boolean shardLeadersOnly)
CloudSolrClient.Builder
class directlypublic static SolrTestCaseJ4.CloudSolrClientBuilder newCloudSolrClient(String zkHost)
public static org.apache.solr.client.solrj.impl.CloudSolrClient getCloudSolrClient(String zkHost, boolean shardLeadersOnly, int socketTimeoutMillis)
CloudSolrClient.Builder
class directlypublic static org.apache.solr.client.solrj.impl.CloudSolrClient getCloudSolrClient(String zkHost, boolean shardLeadersOnly, int connectionTimeoutMillis, int socketTimeoutMillis)
CloudSolrClient.Builder
class directlypublic static org.apache.solr.client.solrj.impl.CloudSolrClient getCloudSolrClient(String zkHost, boolean shardLeadersOnly, org.apache.http.client.HttpClient httpClient)
CloudSolrClient.Builder
class directlypublic static org.apache.solr.client.solrj.impl.CloudSolrClient getCloudSolrClient(String zkHost, boolean shardLeadersOnly, org.apache.http.client.HttpClient httpClient, int connectionTimeoutMillis, int socketTimeoutMillis)
CloudSolrClient.Builder
class directlypublic static org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrClient getConcurrentUpdateSolrClient(String baseSolrUrl, int queueSize, int threadCount)
ConcurrentUpdateSolrClient.Builder
class directlypublic static org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrClient getConcurrentUpdateSolrClient(String baseSolrUrl, int queueSize, int threadCount, int connectionTimeoutMillis)
ConcurrentUpdateSolrClient.Builder
class directlypublic static org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrClient getConcurrentUpdateSolrClient(String baseSolrUrl, org.apache.http.client.HttpClient httpClient, int queueSize, int threadCount)
ConcurrentUpdateSolrClient.Builder
class directlypublic static org.apache.solr.client.solrj.impl.LBHttpSolrClient getLBHttpSolrClient(org.apache.http.client.HttpClient client, String... solrUrls)
LBHttpSolrClient.Builder
class directlypublic static org.apache.solr.client.solrj.impl.LBHttpSolrClient getLBHttpSolrClient(org.apache.http.client.HttpClient client, int connectionTimeoutMillis, int socketTimeoutMillis, String... solrUrls)
LBHttpSolrClient.Builder
class directlypublic static org.apache.solr.client.solrj.impl.LBHttpSolrClient getLBHttpSolrClient(String... solrUrls) throws MalformedURLException
LBHttpSolrClient.Builder
class directlyMalformedURLException
public static org.apache.solr.client.solrj.impl.HttpSolrClient getHttpSolrClient(String url, org.apache.http.client.HttpClient httpClient, org.apache.solr.client.solrj.ResponseParser responseParser, boolean compression)
HttpSolrClient.Builder
class directlypublic static org.apache.solr.client.solrj.impl.HttpSolrClient getHttpSolrClient(String url, org.apache.http.client.HttpClient httpClient, org.apache.solr.client.solrj.ResponseParser responseParser)
HttpSolrClient.Builder
class directlypublic static org.apache.solr.client.solrj.impl.HttpSolrClient getHttpSolrClient(String url, org.apache.http.client.HttpClient httpClient)
HttpSolrClient.Builder
class directlypublic static org.apache.solr.client.solrj.impl.HttpSolrClient getHttpSolrClient(String url, org.apache.http.client.HttpClient httpClient, int connectionTimeoutMillis)
HttpSolrClient.Builder
class directlypublic static org.apache.solr.client.solrj.impl.HttpSolrClient getHttpSolrClient(String url)
HttpSolrClient.Builder
class directlypublic static org.apache.solr.client.solrj.impl.HttpSolrClient getHttpSolrClient(String url, int connectionTimeoutMillis)
HttpSolrClient.Builder
class directlypublic static org.apache.solr.client.solrj.impl.HttpSolrClient getHttpSolrClient(String url, int connectionTimeoutMillis, int socketTimeoutMillis)
HttpSolrClient.Builder
class directlypublic static String randomDate()
randomSkewedDate()
public static String randomSkewedDate()
randomDate()
public static String randomXmlUsableUnicodeString()
protected static void waitForWarming(org.apache.solr.core.SolrCore core) throws InterruptedException
InterruptedException
protected void waitForWarming() throws InterruptedException
InterruptedException
protected String getSaferTestName()
public static void assertNonBlockingRandomGeneratorAvailable() throws InterruptedException
InterruptedException
protected static void systemSetPropertySolrTestsMergePolicyFactory(String value)
protected static void systemClearPropertySolrTestsMergePolicyFactory()
@Deprecated protected static void systemSetPropertySolrDisableShardsWhitelist(String value)
@Deprecated protected static void systemClearPropertySolrDisableShardsWhitelist()
protected <T> T pickRandom(T... options)
public static void randomizeUpdateLogImpl()
public static org.apache.solr.update.processor.DistributedUpdateProcessor createDistributedUpdateProcessor(org.apache.solr.request.SolrQueryRequest req, org.apache.solr.response.SolrQueryResponse rsp, org.apache.solr.update.processor.UpdateRequestProcessor next)
public static void Solr11035BandAid(org.apache.solr.client.solrj.SolrClient client, String collection, String idField, long expectedDocCount, String query, String tag) throws IOException, org.apache.solr.client.solrj.SolrServerException
At least one I've seen (Erick Erickson) cannot be cured by waiting on the client side.
This is a horrible hack, but until we fix the underlying cause using it will reduce the noise from tests. Once the root cause of SOLR-11035 is found, this should be removed.
I don't mind the extra commits (why do two?) as this should be pretty rare. This test fails 10% - 15% of the time without using this method, especially if you @Ignore all the other tests in that suite. ant test -Dtestcase=DocValuesNotIndexedTest -Dtests.method=testGroupingDVOnly -Dtests.seed=54688F608E614440 -Dtests.slow=true -Dtests.locale=nl-BE -Dtests.timezone=America/North_Dakota/Beulah -Dtests.asserts=true -Dtests.file.encoding=ISO-8859-1 This only really works for adding documents. The test at the top of the method will succeed for an update of an existing doc and nothing will be done. If that becomes necessary we should probably create a new method that takes a docID, field and value.
client
- - the client that we'll use to send the requestcollection
- - the target collection we'll add and remove the doc fromidField
- - the uniqueKey for this collection. This MUST be a stringexpectedDocCount
- - numFound for the queryquery
- - The Solr query to check for expectedDocCount.tag
- - additional information to display on a failure. Often class.method is useful.IOException
org.apache.solr.client.solrj.SolrServerException
public static void Solr11035BandAid(org.apache.solr.client.solrj.SolrClient client, String collection, String idField, long expectedDocCount, String query, String tag, boolean failAnyway) throws IOException, org.apache.solr.client.solrj.SolrServerException
IOException
org.apache.solr.client.solrj.SolrServerException
Copyright © 2000-2019 Apache Software Foundation. All Rights Reserved.