Class SolrCloudTestCase

    • Constructor Detail

      • SolrCloudTestCase

        public SolrCloudTestCase()
    • Method Detail

      • zkClient

        protected static org.apache.solr.common.cloud.SolrZkClient zkClient()
      • shutdownCluster

        public static void shutdownCluster()
                                    throws Exception
        Throws:
        Exception
      • 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)
      • waitForState

        protected static void waitForState​(String message,
                                           String collection,
                                           org.apache.solr.common.cloud.CollectionStatePredicate predicate,
                                           int timeout,
                                           TimeUnit timeUnit)
        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 active replicas
      • activeClusterShape

        public static org.apache.solr.common.cloud.CollectionStatePredicate activeClusterShape​(int expectedShards,
                                                                                               int expectedReplicas)
        Return a CollectionStatePredicate that returns true if a collection has the expected number of active shards and active replicas
      • containsLiveNode

        public static org.apache.solr.common.cloud.LiveNodesPredicate containsLiveNode​(String node)
      • missingLiveNode

        public static org.apache.solr.common.cloud.LiveNodesPredicate missingLiveNode​(String node)
      • missingLiveNodes

        public static org.apache.solr.common.cloud.LiveNodesPredicate missingLiveNodes​(List<String> nodes)
      • 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
      • waitForResponse

        protected org.apache.solr.common.util.NamedList waitForResponse​(Predicate<org.apache.solr.common.util.NamedList> predicate,
                                                                        org.apache.solr.client.solrj.SolrRequest request,
                                                                        int intervalInMillis,
                                                                        int numRetries,
                                                                        String messageOnFail)
      • ensureRunningJettys

        public static void ensureRunningJettys​(int nodeCount,
                                               int timeoutSeconds)
                                        throws Exception
        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

        public static Map<String,​String> mapReplicasToReplicaType​(org.apache.solr.common.cloud.DocCollection collection)