org.apache.solr.cloud

## Class SolrCloudTestCase

- java.lang.Object
- - org.junit.Assert
  - - org.apache.lucene.util.LuceneTestCase
    - - org.apache.solr.SolrTestCaseJ4
      - - org.apache.solr.cloud.SolrCloudTestCase

-     public class SolrCloudTestCase
      extends SolrTestCaseJ4

  Base class for SolrCloud tests Derived tests should call `configureCluster(int)` in a `BeforeClass` static method. This configures and starts a `MiniSolrCloudCluster`, available via the `cluster` variable. Cluster shutdown is handled automatically.

          @BeforeClass
         public static void setupCluster() {
           configureCluster(NUM_NODES)
              .addConfig("configname", pathToConfig)
              .configure();
         }

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected static class` | `SolrCloudTestCase.Builder` Builder class for a MiniSolrCloudCluster

    - ### Nested classes/interfaces inherited from class org.apache.solr.SolrTestCaseJ4

      `SolrTestCaseJ4.CloudSolrClientBuilder, SolrTestCaseJ4.Doc, SolrTestCaseJ4.Fld, SolrTestCaseJ4.FldType, SolrTestCaseJ4.FVal, SolrTestCaseJ4.IRange, SolrTestCaseJ4.IVals, SolrTestCaseJ4.IValsPercent, SolrTestCaseJ4.SuppressObjectReleaseTracker, SolrTestCaseJ4.SuppressSSL, 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.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`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static MiniSolrCloudCluster` | `cluster` The cluster
    `static int` | `DEFAULT_TIMEOUT`

    - ### Fields inherited from class org.apache.solr.SolrTestCaseJ4

      `configString, CORE_PROPERTIES_FILENAME, DEFAULT_CONNECTION_TIMEOUT, DEFAULT_TEST_COLLECTION_NAME, DEFAULT_TEST_CORENAME, h, hdfsDataDir, initCoreDataDir, lrf, ONE_ONE, schemaString, solrClassRules, solrConfig, solrTestRules, sslConfig, SYSTEM_PROPERTY_SOLR_TESTS_MERGEPOLICY, SYSTEM_PROPERTY_SOLR_TESTS_MERGEPOLICYFACTORY, SYSTEM_PROPERTY_SOLR_TESTS_USEMERGEPOLICY, SYSTEM_PROPERTY_SOLR_TESTS_USEMERGEPOLICYFACTORY, testSolrHome, ZERO_ONE, ZERO_TWO`

    - ### Fields inherited from class org.apache.lucene.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_BADAPPLES, SYSPROP_FAILFAST, SYSPROP_MAXFAILURES, SYSPROP_MONSTER, SYSPROP_NIGHTLY, SYSPROP_SLOW, SYSPROP_WEEKLY, TEST_ASSERTS_ENABLED, TEST_AWAITSFIX, TEST_CODEC, TEST_DIRECTORY, TEST_DOCVALUESFORMAT, TEST_LINE_DOCS_FILE, TEST_NIGHTLY, TEST_POSTINGSFORMAT, TEST_SLOW, TEST_THROTTLING, TEST_WEEKLY, VERBOSE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SolrCloudTestCase()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `checkClusterConfiguration()`
    `static org.apache.solr.common.cloud.CollectionStatePredicate` | `clusterShape(int expectedShards, int expectedReplicas)` Return a `CollectionStatePredicate` that returns true if a collection has the expected number of shards and replicas
    `protected static SolrCloudTestCase.Builder` | `configureCluster(int nodeCount)` Call this to configure a cluster of n nodes.
    `protected org.apache.solr.common.cloud.DocCollection` | `getCollectionState(String collectionName)` Get the collection state for a particular collection
    `protected static org.apache.solr.client.solrj.request.CoreStatus` | `getCoreStatus(org.apache.solr.common.cloud.Replica replica)` Get the `CoreStatus` data for a `Replica` This assumes that the replica is hosted on a live node.
    `protected static org.apache.solr.common.cloud.Replica` | `getRandomReplica(org.apache.solr.common.cloud.Slice slice)` Get a (reproducibly) random replica from a `Slice`
    `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 a `Slice` matching a predicate
    `protected static org.apache.solr.common.cloud.Slice` | `getRandomShard(org.apache.solr.common.cloud.DocCollection collection)` Get a (reproducibly) random shard from a `DocCollection`
    `static void` | `shutdownCluster()`
    `protected 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 reader This is a convenience method using the `DEFAULT_TIMEOUT`
    `protected org.apache.solr.common.cloud.SolrZkClient` | `zkClient()`

    - ### Methods inherited from class org.apache.solr.SolrTestCaseJ4

      `add, addAndGetVersion, adoc, adoc, assertFailedU, assertFailedU, assertFieldValues, assertJQ, assertJQ, assertQ, assertQ, assertQEx, assertQEx, assertQEx, assertSolrInputFieldEquals, assertU, assertU, assertXmlFile, buildJettyConfig, buildUrl, chooseMPForMP, clearIndex, commit, compareSolrDocument, compareSolrDocumentList, compareSolrInputDocument, configset, copyMinConf, copyMinConf, copyMinFullSetup, copySolrHomeToTemp, createComparator, createComparator, createCore, createCoreContainer, createCoreContainer, createCoreContainer, createDefaultCoreContainer, createDoc, createSort, deleteAndGetVersion, deleteByQueryAndGetVersion, deleteCore, delI, delQ, doc, endTrackingSearchers, getClassName, getCloudSolrClient, getCloudSolrClient, getCloudSolrClient, getCloudSolrClient, getConcurrentUpdateSolrClient, getConcurrentUpdateSolrClient, getFile, getHttpSolrClient, getHttpSolrClient, getHttpSolrClient, getHttpSolrClient, getLBHttpSolrClient, getLBHttpSolrClient, getRootCause, getSchemaFile, getSimpleClassName, getSolrConfigFile, getWrappedException, hasInitException, hasInitException, ignoreException, indexDocs, initClassLogLevels, initCore, initCore, initCore, initCore, initMethodLogLevels, invertField, isSSLMode, JQ, json, json, json, jsonAdd, jsonDelId, jsonDelQ, map, newRandomConfig, optimize, params, postSetUp, preTearDown, randomDate, randomSkewedDate, randomXmlUsableUnicodeString, req, req, req, resetExceptionIgnores, resetFactory, restoreMethodLogLevels, sdoc, sdocs, setUp, setupNoCoreTest, setupTestCases, skewed, startTrackingSearchers, systemClearPropertySolrTestsMergePolicy, systemClearPropertySolrTestsMergePolicyFactory, systemSetPropertySolrTestsMergePolicy, systemSetPropertySolrTestsMergePolicyFactory, tearDown, teardownTestCases, TEST_HOME, TEST_PATH, toJSON, unchooseMPForMP, unIgnoreException, updateJ, useFactory, waitForWarming, whitespaceMockTokenizer, whitespaceMockTokenizer, writeCoreProperties, writeCoreProperties`

    - ### Methods inherited from class org.apache.lucene.util.LuceneTestCase

      `addVirusChecker, assertDeletedDocsEquals, assertDocsAndPositionsEnumEquals, assertDocsEnumEquals, assertDocsSkippingEquals, assertDocValuesEquals, assertDocValuesEquals, assertFieldInfosEquals, assertFieldsEquals, assertFieldStatisticsEquals, assertNormsEquals, assertPointsEquals, assertPositionsSkippingEquals, assertReaderEquals, assertReaderStatisticsEquals, assertStoredFieldEquals, assertStoredFieldsEquals, assertTermsEnumEquals, assertTermsEquals, assertTermsStatisticsEquals, assertTermStatsEquals, assertTermVectorsEquals, asSet, assumeFalse, assumeNoException, assumeTrue, atLeast, atLeast, closeAfterSuite, closeAfterTest, collate, createTempDir, createTempDir, createTempFile, createTempFile, dumpArray, dumpIterator, expectThrows, getBaseTempDirForTestClass, getDataInputStream, getDataPath, getOnlyLeafReader, getTestClass, getTestName, 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, 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`

    - ### 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

    - #### DEFAULT_TIMEOUT

          public static final int DEFAULT_TIMEOUT

      See Also:
        Constant Field Values

    - #### cluster

          protected static MiniSolrCloudCluster cluster

      The cluster

  - ### Constructor Detail

    - #### SolrCloudTestCase

          public SolrCloudTestCase()

  - ### Method Detail

    - #### zkClient

          protected org.apache.solr.common.cloud.SolrZkClient zkClient()

    - #### configureCluster

          protected static SolrCloudTestCase.Builder configureCluster(int nodeCount)

      Call this to configure a cluster of n nodes. NB you must call `SolrCloudTestCase.Builder.configure()` to start the cluster
      Parameters:
        `nodeCount` - the number of nodes

    - #### shutdownCluster

          public static void shutdownCluster()
                                      throws Exception

      Throws:
        `Exception`

    - #### checkClusterConfiguration

          public void checkClusterConfiguration()

    - #### getCollectionState

          protected org.apache.solr.common.cloud.DocCollection getCollectionState(String collectionName)

      Get the collection state for a particular collection

    - #### waitForState

          protected 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 reader This is a convenience method using the `DEFAULT_TIMEOUT`
      Parameters:
        `message` - a message to report on failure
        `collection` - the collection to watch
        `predicate` - a predicate to match against the collection state

    - #### clusterShape

          public static org.apache.solr.common.cloud.CollectionStatePredicate clusterShape(int expectedShards,
                                                                                           int expectedReplicas)

      Return a `CollectionStatePredicate` that returns true if a collection has the expected number of shards and replicas

    - #### getRandomShard

          protected static org.apache.solr.common.cloud.Slice getRandomShard(org.apache.solr.common.cloud.DocCollection collection)

      Get a (reproducibly) random shard from a `DocCollection`

    - #### getRandomReplica

          protected static org.apache.solr.common.cloud.Replica getRandomReplica(org.apache.solr.common.cloud.Slice slice)

      Get a (reproducibly) random replica from a `Slice`

    - #### 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 a `Slice` matching a predicate

    - #### getCoreStatus

          protected static org.apache.solr.client.solrj.request.CoreStatus getCoreStatus(org.apache.solr.common.cloud.Replica replica)
                                                                                  throws IOException,
                                                                                         org.apache.solr.client.solrj.SolrServerException

      Get the `CoreStatus` data for a `Replica` This assumes that the replica is hosted on a live node.
      Throws:
        `IOException`
        `org.apache.solr.client.solrj.SolrServerException`

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