Package org.apache.solr.cloud
Class SolrCloudTestCase
java.lang.Object
org.junit.Assert
org.apache.lucene.tests.util.LuceneTestCase
org.apache.solr.SolrTestCase
org.apache.solr.SolrTestCaseJ4
org.apache.solr.cloud.SolrCloudTestCase
- Direct Known Subclasses:
AbstractCloudBackupRestoreTestCase,AbstractCollectionsAPIDistributedZkTestBase,AbstractIncrementalBackupTest,AbstractInstallShardTest,SolrCloudAuthTestCase
Base class for SolrCloud tests
Derived tests should call configureCluster(int) in a BeforeClass static
method or Before setUp method. This configures and starts a MiniSolrCloudCluster,
available via the cluster variable. Cluster shutdown is handled automatically if using
BeforeClass.
@BeforeClass
public static void setupCluster() {
configureCluster(NUM_NODES)
.addConfig("configname", pathToConfig)
.configure();
}
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic @interfaceA marker interface to Ignore PRS in tests.Nested classes/interfaces inherited from class org.apache.solr.SolrTestCaseJ4
SolrTestCaseJ4.BVal, SolrTestCaseJ4.Doc, SolrTestCaseJ4.Fld, SolrTestCaseJ4.FldType, SolrTestCaseJ4.FVal, SolrTestCaseJ4.IRange, SolrTestCaseJ4.IVals, SolrTestCaseJ4.IValsPercent, SolrTestCaseJ4.RandomizingCloudHttp2SolrClientBuilder, SolrTestCaseJ4.RandomizingCloudSolrClientBuilder, SolrTestCaseJ4.SuppressPointFields, SolrTestCaseJ4.SuppressSSL, SolrTestCaseJ4.SVal, SolrTestCaseJ4.Vals, SolrTestCaseJ4.XmlDocNested classes/interfaces inherited from class org.apache.lucene.tests.util.LuceneTestCase
org.apache.lucene.tests.util.LuceneTestCase.AwaitsFix, org.apache.lucene.tests.util.LuceneTestCase.Concurrency, org.apache.lucene.tests.util.LuceneTestCase.Monster, org.apache.lucene.tests.util.LuceneTestCase.Nightly, org.apache.lucene.tests.util.LuceneTestCase.SuppressCodecs, org.apache.lucene.tests.util.LuceneTestCase.SuppressFileSystems, org.apache.lucene.tests.util.LuceneTestCase.SuppressFsync, org.apache.lucene.tests.util.LuceneTestCase.SuppressReproduceLine, org.apache.lucene.tests.util.LuceneTestCase.SuppressSysoutChecks, org.apache.lucene.tests.util.LuceneTestCase.SuppressTempFileChecks, org.apache.lucene.tests.util.LuceneTestCase.ThrowingConsumer<T>, org.apache.lucene.tests.util.LuceneTestCase.ThrowingRunnable, org.apache.lucene.tests.util.LuceneTestCase.Weekly -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static MiniSolrCloudClusterThe clusterstatic final intFields inherited from class org.apache.solr.SolrTestCaseJ4
configString, CORE_PROPERTIES_FILENAME, coreName, DEAD_HOST_1, DEAD_HOST_2, DEAD_HOST_3, DEFAULT_CONNECTION_TIMEOUT, DEFAULT_TEST_COLLECTION_NAME, DEFAULT_TEST_CORENAME, h, lrf, NUMERIC_DOCVALUES_SYSPROP, NUMERIC_POINTS_SYSPROP, ONE_ONE, RANDOMIZED_NUMERIC_FIELDTYPES, schemaString, solrConfig, solrTestRules, sslConfig, SYSTEM_PROPERTY_SOLR_TESTS_MERGEPOLICYFACTORY, TEST_URL_ALLOW_LIST, testExecutor, testSolrHome, UPDATELOG_SYSPROP, USE_NUMERIC_POINTS_SYSPROP, ZERO_ONE, ZERO_TWOFields inherited from class org.apache.solr.SolrTestCase
methodRules, solrClassRulesFields inherited from class org.apache.lucene.tests.util.LuceneTestCase
assertsAreEnabled, classRules, DEFAULT_LINE_DOCS_FILE, INFOSTREAM, JENKINS_LARGE_LINE_DOCS_FILE, LEAVE_TEMPORARY, MAYBE_CACHE_POLICY, RANDOM_MULTIPLIER, ruleChain, suiteFailureMarker, SYSPROP_AWAITSFIX, SYSPROP_FAILFAST, SYSPROP_MAXFAILURES, SYSPROP_MONSTER, SYSPROP_NIGHTLY, SYSPROP_WEEKLY, TEST_ASSERTS_ENABLED, TEST_AWAITSFIX, TEST_CODEC, TEST_DIRECTORY, TEST_DOCVALUESFORMAT, TEST_LINE_DOCS_FILE, TEST_MONSTER, TEST_NIGHTLY, TEST_POSTINGSFORMAT, TEST_THROTTLING, TEST_WEEKLY, VERBOSE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.apache.solr.common.cloud.CollectionStatePredicateactiveClusterShape(int expectedShards, int expectedReplicas) Return aCollectionStatePredicatethat returns true if a collection has the expected numbers of active shards and active replicas on these shardsvoidstatic org.apache.solr.common.cloud.CollectionStatePredicateclusterShape(int expectedShards, int expectedReplicas) Return aCollectionStatePredicatethat returns true if a collection has the expected numbers of shards and active replicasprotected static MiniSolrCloudCluster.BuilderconfigureCluster(int nodeCount) Call this to configure a cluster of n nodes.static voidstatic org.apache.solr.common.cloud.LiveNodesPredicatecontainsLiveNode(String node) static voidensureRunningJettys(int nodeCount, int timeoutSeconds) Ensure that the given number of solr instances are running.protected static org.apache.solr.common.cloud.DocCollectiongetCollectionState(String collectionName) Get the collection state for a particular collectionprotected static org.apache.solr.client.api.model.CoreStatusResponse.SingleCoreDatagetCoreStatus(org.apache.solr.common.cloud.Replica replica) Get theCoreStatusResponse.SingleCoreDatadata for aReplicaprotected static org.apache.solr.common.cloud.ReplicagetRandomReplica(org.apache.solr.common.cloud.Slice slice) Get a (reproducibly) random replica from aSliceprotected static org.apache.solr.common.cloud.ReplicagetRandomReplica(org.apache.solr.common.cloud.Slice slice, Predicate<org.apache.solr.common.cloud.Replica> matchPredicate) Get a (reproducibly) random replica from aSlicematching a predicateprotected static org.apache.solr.common.cloud.SlicegetRandomShard(org.apache.solr.common.cloud.DocCollection collection) Get a (reproducibly) random shard from aDocCollectionstatic List<org.apache.solr.common.cloud.Replica> getReplicas(org.apache.solr.common.cloud.DocCollection collectionState, EnumSet<org.apache.solr.common.cloud.Replica.Type> s) static booleanisPRS()if the system property is not specified, default to false.mapReplicasToReplicaType(org.apache.solr.common.cloud.DocCollection collection) static org.apache.solr.common.cloud.LiveNodesPredicatemissingLiveNode(String node) static org.apache.solr.common.cloud.LiveNodesPredicatemissingLiveNodes(List<String> nodes) static booleanreplicasForCollectionAreFullyActive(Set<String> liveNodes, org.apache.solr.common.cloud.DocCollection collectionState, int expectedShards, int expectedReplicas) Check that all replicas in a collection are livestatic voidprotected org.apache.solr.common.util.NamedListwaitForResponse(Predicate<org.apache.solr.common.util.NamedList> predicate, org.apache.solr.client.solrj.SolrRequest request, int intervalInMillis, int numRetries, String messageOnFail) protected static voidwaitForState(String message, String collection, int timeout, TimeUnit timeUnit, Predicate<org.apache.solr.common.cloud.DocCollection> predicate) Wait for a particular collection state to appear in the cluster client's state readerprotected static voidwaitForState(String message, String collection, int timeout, TimeUnit timeUnit, org.apache.solr.common.cloud.CollectionStatePredicate predicate) Wait for a particular collection state to appear in the cluster client's state readerprotected static voidwaitForState(String message, String collection, Predicate<org.apache.solr.common.cloud.DocCollection> predicate) Wait for a particular collection state to appear in the cluster client's state reader.protected static voidwaitForState(String message, String collection, org.apache.solr.common.cloud.CollectionStatePredicate predicate) Wait for a particular collection state to appear in the cluster client's state readerprotected static org.apache.solr.common.cloud.SolrZkClientzkClient()Methods inherited from class org.apache.solr.SolrTestCaseJ4
add, addAndGetVersion, addDoc, adoc, adoc, assertExceptionThrownWithMessageContaining, assertFailedU, assertFailedU, assertFieldValues, assertJQ, assertJQ, assertNonBlockingRandomGeneratorAvailable, assertQ, assertQ, assertQEx, assertQEx, assertQEx, assertResponseValues, assertSolrInputFieldEquals, assertThatJQ, assertThatJQ, assertU, assertU, assertXmlFile, assumeWorkingMockito, buildUrl, clearIndex, commit, compareSolrDocument, compareSolrDocumentList, compareSolrInputDocument, configset, copyMinConf, copyMinConf, copyMinConf, copyMinFullSetup, copySolrHomeToTemp, copyXmlToHome, createComparator, createComparator, createCore, createCoreContainer, createCoreContainer, createCoreContainer, createDefaultCoreContainer, createDistributedUpdateProcessor, createDoc, createSort, deleteAndGetVersion, deleteByQueryAndGetVersion, deleteCore, delI, delQ, doc, getClassName, getFile, getHttpClient, getHttpSolrClient, getHttpSolrClient, getHttpSolrClient, getRootCause, getSaferTestName, getSchemaFile, getSimpleClassName, getSolrConfigFile, getWrappedException, hasInitException, hasInitException, ignoreException, indexDocs, initAndGetDataDir, initCore, initCore, initCore, initCore, invertField, isSSLMode, JQ, json, json, json, jsonAdd, jsonDelId, jsonDelQ, legacyExampleCollection1SolrHome, map, map, newRandomConfig, optimize, params, pickRandom, postSetUp, preTearDown, randomDate, randomSkewedDate, randomXmlUsableUnicodeString, req, req, req, resetExceptionIgnores, resetFactory, sdoc, sdocs, sdocWithChildren, sdocWithChildren, sdocWithChildren, setUp, setupNoCoreTest, setupTestCases, skewed, startTrackingSearchers, systemClearPropertySolrEnableUrlAllowList, systemClearPropertySolrTestsMergePolicyFactory, systemSetPropertyEnableUrlAllowList, systemSetPropertySolrTestsMergePolicyFactory, tearDown, teardownTestCases, TEST_COLL1_CONF, TEST_HOME, TEST_PATH, toJSON, unIgnoreException, updateJ, useFactory, waitForWarming, waitForWarming, whitespaceMockTokenizer, whitespaceMockTokenizer, writeCoreProperties, writeCorePropertiesMethods inherited from class org.apache.solr.SolrTestCase
afterClassShutdownLogging, assertJSONEquals, assertThat, assertThat, beforeSolrTestCase, checkSyspropForceBeforeAssumptionFailure, checkSyspropForceBeforeClassAssumptionFailureMethods inherited from class org.apache.lucene.tests.util.LuceneTestCase
addVirusChecker, assertDeletedDocsEquals, assertDocsAndPositionsEnumEquals, assertDocsEnumEquals, assertDocsSkippingEquals, assertDocValuesEquals, assertDocValuesEquals, assertDoubleUlpEquals, assertFieldInfosEquals, assertFloatUlpEquals, assertNormsEquals, assertPointsEquals, assertPositionsSkippingEquals, assertReaderEquals, assertReaderStatisticsEquals, assertStoredFieldEquals, assertStoredFieldsEquals, assertTermsEnumEquals, assertTermsEquals, assertTermsEquals, assertTermsStatisticsEquals, assertTermStatsEquals, assertTermVectorsEquals, asSet, assumeFalse, assumeNoException, assumeTrue, atLeast, atLeast, callStackContains, callStackContains, callStackContainsAnyOf, closeAfterSuite, closeAfterTest, collate, createTempDir, createTempDir, createTempFile, createTempFile, dumpArray, dumpIterator, ensureSaneIWCOnNightly, expectThrows, expectThrows, expectThrows, expectThrowsAnyOf, expectThrowsAnyOf, getDataInputStream, getDataPath, getJvmForkArguments, getOnlyLeafReader, getTestClass, getTestName, isTestThread, localeForLanguageTag, maybeChangeLiveIndexWriterConfig, maybeWrapReader, newAlcoholicMergePolicy, newAlcoholicMergePolicy, newBytesRef, newBytesRef, newBytesRef, newBytesRef, newBytesRef, newBytesRef, 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, newSearcher, newSearcher, newSnapshotIndexWriterConfig, newStringField, newStringField, newStringField, newStringField, newTextField, newTextField, newTieredMergePolicy, newTieredMergePolicy, overrideDefaultQueryCache, overrideTestDefaultQueryCache, random, randomLocale, randomTimeZone, randomVectorFormat, rarely, rarely, replaceMaxFailureRule, resetDefaultQueryCache, restoreCPUCoreCount, restoreIndexWriterMaxDocs, runWithRestrictedPermissions, setIndexWriterMaxDocs, setupCPUCoreCount, setUpExecutorService, shutdownExecutorService, slowFileExists, usually, usually, wrapReaderMethods inherited from class org.junit.Assert
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, assertThrows, assertThrows, assertTrue, assertTrue, fail, fail
-
Field Details
-
DEFAULT_TIMEOUT
public static final int DEFAULT_TIMEOUT- See Also:
-
cluster
The cluster
-
-
Constructor Details
-
SolrCloudTestCase
public SolrCloudTestCase()
-
-
Method Details
-
zkClient
protected static org.apache.solr.common.cloud.SolrZkClient zkClient() -
isPRS
public static boolean isPRS()if the system property is not specified, default to false. The SystemProperty will be set in a beforeClass method. -
configureCluster
Call this to configure a cluster of n nodes. It will be shut down automatically after the tests.NB you must call
MiniSolrCloudCluster.Builder.configure()to start the cluster- Parameters:
nodeCount- the number of nodes
-
configurePrsDefault
public static void configurePrsDefault() -
shutdownCluster
- Throws:
Exception
-
replicasForCollectionAreFullyActive
public static boolean replicasForCollectionAreFullyActive(Set<String> liveNodes, org.apache.solr.common.cloud.DocCollection collectionState, int expectedShards, int expectedReplicas) Check that all replicas in a collection are live- See Also:
-
getReplicas
-
checkClusterConfiguration
public void checkClusterConfiguration() -
getCollectionState
protected static org.apache.solr.common.cloud.DocCollection getCollectionState(String collectionName) Get the collection state for a particular collection -
waitForState
protected static void waitForState(String message, String collection, org.apache.solr.common.cloud.CollectionStatePredicate predicate) Wait for a particular collection state to appear in the cluster client's state readerThis is a convenience method using the
DEFAULT_TIMEOUT. -
waitForState
protected static void waitForState(String message, String collection, int timeout, TimeUnit timeUnit, org.apache.solr.common.cloud.CollectionStatePredicate predicate) Wait for a particular collection state to appear in the cluster client's state reader- Parameters:
message- a message to report on failurecollection- the collection to watchpredicate- a predicate to match against the collection state
-
waitForState
protected static void waitForState(String message, String collection, Predicate<org.apache.solr.common.cloud.DocCollection> predicate) Wait for a particular collection state to appear in the cluster client's state reader.This is a convenience method using the
DEFAULT_TIMEOUT. -
waitForState
protected static void waitForState(String message, String collection, int timeout, TimeUnit timeUnit, Predicate<org.apache.solr.common.cloud.DocCollection> predicate) Wait for a particular collection state to appear in the cluster client's state reader- Parameters:
message- a message to report on failurecollection- the collection to watchpredicate- a predicate to match against the collection state
-
clusterShape
public static org.apache.solr.common.cloud.CollectionStatePredicate clusterShape(int expectedShards, int expectedReplicas) Return aCollectionStatePredicatethat returns true if a collection has the expected numbers of shards and active replicas -
activeClusterShape
public static org.apache.solr.common.cloud.CollectionStatePredicate activeClusterShape(int expectedShards, int expectedReplicas) Return aCollectionStatePredicatethat returns true if a collection has the expected numbers of active shards and active replicas on these shards -
containsLiveNode
-
missingLiveNode
-
missingLiveNodes
-
getRandomShard
protected static org.apache.solr.common.cloud.Slice getRandomShard(org.apache.solr.common.cloud.DocCollection collection) Get a (reproducibly) random shard from aDocCollection -
getRandomReplica
protected static org.apache.solr.common.cloud.Replica getRandomReplica(org.apache.solr.common.cloud.Slice slice) Get a (reproducibly) random replica from aSlice -
getRandomReplica
protected static org.apache.solr.common.cloud.Replica getRandomReplica(org.apache.solr.common.cloud.Slice slice, Predicate<org.apache.solr.common.cloud.Replica> matchPredicate) Get a (reproducibly) random replica from aSlicematching a predicate -
getCoreStatus
protected static org.apache.solr.client.api.model.CoreStatusResponse.SingleCoreData getCoreStatus(org.apache.solr.common.cloud.Replica replica) throws IOException, org.apache.solr.client.solrj.SolrServerException Get theCoreStatusResponse.SingleCoreDatadata for aReplicaThis assumes that the replica is hosted on a live node.
- Throws:
IOExceptionorg.apache.solr.client.solrj.SolrServerException
-
waitForResponse
-
ensureRunningJettys
Ensure that the given number of solr instances are running. If less instances are found then new instances are started. If extra instances are found then they are stopped.- Parameters:
nodeCount- the number of Solr instances that should be running at the end of this method- Throws:
Exception- on error
-
mapReplicasToReplicaType
-