Class AbstractFullDistribZkTestBase

java.lang.Object
org.junit.Assert
org.apache.lucene.tests.util.LuceneTestCase

public abstract class AbstractFullDistribZkTestBase extends BaseDistributedSearchTestCase
TODO: we should still test this works as a custom update chain as well as what we test now - the default update chain
  • Field Details

  • Constructor Details

    • AbstractFullDistribZkTestBase

      public AbstractFullDistribZkTestBase()
  • Method Details

    • beforeThisClass

      public static void beforeThisClass() throws Exception
      Throws:
      Exception
    • beforeFullSolrCloudTest

      public static void beforeFullSolrCloudTest()
    • beforeTest

      public void beforeTest()
    • setErrorHook

      protected static void setErrorHook()
    • clearErrorHook

      protected static void clearErrorHook()
    • distribSetUp

      public void distribSetUp() throws Exception
      Overrides:
      distribSetUp in class BaseDistributedSearchTestCase
      Throws:
      Exception
    • getCloudSolrConfig

      protected String getCloudSolrConfig()
    • getCloudSchemaFile

      protected String getCloudSchemaFile()
    • beforeClass

      public static void beforeClass()
    • afterClass

      public static void afterClass() throws Exception
      Throws:
      Exception
    • getDataDir

      protected String getDataDir(String dataDir) throws IOException
      Throws:
      IOException
    • initCloud

      protected void initCloud() throws Exception
      Throws:
      Exception
    • useTlogReplicas

      protected boolean useTlogReplicas()
    • createCloudClient

      protected org.apache.solr.client.solrj.impl.CloudSolrClient createCloudClient(String defaultCollection)
    • createServers

      protected void createServers(int numServers) throws Exception
      Overrides:
      createServers in class BaseDistributedSearchTestCase
      Throws:
      Exception
    • waitForCollection

      public static void waitForCollection(org.apache.solr.common.cloud.ZkStateReader reader, String collection, int slices) throws Exception
      Throws:
      Exception
    • createJettys

      protected List<JettySolrRunner> createJettys(int numJettys) throws Exception
      Throws:
      Exception
    • waitForLiveNode

      protected void waitForLiveNode(JettySolrRunner j) throws InterruptedException, TimeoutException
      Throws:
      InterruptedException
      TimeoutException
    • waitForActiveReplicaCount

      protected void waitForActiveReplicaCount(org.apache.solr.client.solrj.impl.CloudSolrClient client, String collection, int expectedNumReplicas) throws TimeoutException, org.apache.solr.cloud.ZkController.NotInClusterStateException
      Throws:
      TimeoutException
      org.apache.solr.cloud.ZkController.NotInClusterStateException
    • getPullReplicaCount

      protected int getPullReplicaCount()
    • getTotalReplicas

      @Deprecated protected int getTotalReplicas(org.apache.solr.common.cloud.DocCollection c, String collection)
      Deprecated.
      This method is virtually useless as it does not consider the status of either the shard or replica, nor wether the node hosting each replica is alive.
      Total number of replicas for all shards as indicated by the cluster state, regardless of status.
    • createJetty

      public JettySolrRunner createJetty(String dataDir, String ulogDir, String shardList, String solrConfigOverride) throws Exception
      Throws:
      Exception
    • createJetty

      public final JettySolrRunner createJetty(Path solrHome, String dataDir, String shardList, String solrConfigOverride, String schemaOverride) throws Exception
      Overrides:
      createJetty in class BaseDistributedSearchTestCase
      Throws:
      Exception
    • createJetty

      public JettySolrRunner createJetty(Path solrHome, String dataDir, String shardList, String solrConfigOverride, String schemaOverride, org.apache.solr.common.cloud.Replica.Type replicaType) throws Exception
      Throws:
      Exception
    • createProxiedJetty

      public JettySolrRunner createProxiedJetty(Path solrHome, String dataDir, String shardList, String solrConfigOverride, String schemaOverride, org.apache.solr.common.cloud.Replica.Type replicaType) throws Exception
      Creates a JettySolrRunner with a socket proxy sitting in front of the Jetty server, which gives us the ability to simulate network partitions without having to fuss with IPTables.
      Throws:
      Exception
    • getReplicaPort

      protected int getReplicaPort(org.apache.solr.common.cloud.Replica replica)
    • getJettyOnPort

      protected JettySolrRunner getJettyOnPort(int port)
    • getProxyForReplica

      protected SocketProxy getProxyForReplica(org.apache.solr.common.cloud.Replica replica) throws Exception
      Throws:
      Exception
    • updateMappingsFromZk

      protected void updateMappingsFromZk(List<JettySolrRunner> jettys, List<org.apache.solr.client.solrj.SolrClient> clients) throws Exception
      Throws:
      Exception
    • updateMappingsFromZk

      protected void updateMappingsFromZk(List<JettySolrRunner> jettys, List<org.apache.solr.client.solrj.SolrClient> clients, boolean allowOverSharding) throws Exception
      Throws:
      Exception
    • setDistributedParams

      protected void setDistributedParams(org.apache.solr.common.params.ModifiableSolrParams params)
      Overrides:
      setDistributedParams in class BaseDistributedSearchTestCase
    • sendDocsWithRetry

      protected int sendDocsWithRetry(String collectionName, List<org.apache.solr.common.SolrInputDocument> batch, int minRf, int maxRetries, int waitBeforeRetry) throws Exception
      Throws:
      Exception
    • sendDocsWithRetry

      protected static int sendDocsWithRetry(org.apache.solr.client.solrj.impl.CloudSolrClient cloudClient, String collection, List<org.apache.solr.common.SolrInputDocument> batch, int minRf, int maxRetries, int waitBeforeRetry) throws Exception
      Throws:
      Exception
    • indexDoc

      protected void indexDoc(org.apache.solr.common.SolrInputDocument doc) throws IOException, org.apache.solr.client.solrj.SolrServerException
      Description copied from class: BaseDistributedSearchTestCase
      Indexes the document in both the control client, and a randomly selected client
      Overrides:
      indexDoc in class BaseDistributedSearchTestCase
      Throws:
      IOException
      org.apache.solr.client.solrj.SolrServerException
    • index_specific

      protected void index_specific(int serverNumber, Object... fields) throws Exception
      Overrides:
      index_specific in class BaseDistributedSearchTestCase
      Throws:
      Exception
    • index_specific

      protected void index_specific(org.apache.solr.client.solrj.SolrClient client, Object... fields) throws Exception
      Throws:
      Exception
    • getLeaderFromZk

      protected org.apache.solr.common.cloud.Replica getLeaderFromZk(String collection, String slice)
    • del

      protected void del(String q) throws Exception
      Overrides:
      del in class BaseDistributedSearchTestCase
      Throws:
      Exception
    • waitForRecoveriesToFinish

      protected void waitForRecoveriesToFinish(boolean verbose) throws Exception
      Throws:
      Exception
    • waitForRecoveriesToFinish

      protected void waitForRecoveriesToFinish(String collection, boolean verbose) throws Exception
      Throws:
      Exception
    • waitForRecoveriesToFinish

      protected void waitForRecoveriesToFinish(boolean verbose, long timeoutSeconds) throws Exception
      Throws:
      Exception
    • waitForRecoveriesToFinish

      protected void waitForRecoveriesToFinish(String collection, org.apache.solr.common.cloud.ZkStateReader zkStateReader, boolean verbose) throws Exception
      Throws:
      Exception
    • waitForRecoveriesToFinish

      protected void waitForRecoveriesToFinish(String collection, org.apache.solr.common.cloud.ZkStateReader zkStateReader, boolean verbose, boolean failOnTimeout) throws Exception
      Throws:
      Exception
    • waitForRecoveriesToFinish

      public static void waitForRecoveriesToFinish(String collection, org.apache.solr.common.cloud.ZkStateReader zkStateReader, boolean verbose, boolean failOnTimeout, long timeoutSeconds) throws Exception
      Throws:
      Exception
    • waitForRecoveriesToFinish

      public static void waitForRecoveriesToFinish(String collection, org.apache.solr.common.cloud.ZkStateReader zkStateReader, boolean verbose, boolean failOnTimeout, long timeout, TimeUnit unit) throws Exception
      Throws:
      Exception
    • waitForCollectionToDisappear

      public static void waitForCollectionToDisappear(String collection, org.apache.solr.common.cloud.ZkStateReader zkStateReader, boolean failOnTimeout, int timeoutSeconds) throws Exception
      Throws:
      Exception
    • verifyReplicaStatus

      public static void verifyReplicaStatus(org.apache.solr.common.cloud.ZkStateReader reader, String collection, String shard, String coreNodeName, org.apache.solr.common.cloud.Replica.State expectedState) throws InterruptedException, TimeoutException
      Throws:
      InterruptedException
      TimeoutException
    • assertAllActive

      protected static void assertAllActive(String collection, org.apache.solr.common.cloud.ZkStateReader zkStateReader) throws org.apache.zookeeper.KeeperException, InterruptedException
      Throws:
      org.apache.zookeeper.KeeperException
      InterruptedException
    • checkQueries

      protected void checkQueries() throws Exception
      Throws:
      Exception
    • indexAbunchOfDocs

      protected void indexAbunchOfDocs() throws Exception
      Throws:
      Exception
    • queryAndCompareReplicas

      public org.apache.solr.client.solrj.response.QueryResponse queryAndCompareReplicas(org.apache.solr.common.params.SolrParams params, String shard) throws Exception
      Executes a query against each live and active replica of the specified shard and aserts that the results are identical.
      Throws:
      Exception
      See Also:
    • queryAndCompareShards

      public void queryAndCompareShards(org.apache.solr.common.params.SolrParams params) throws Exception
      For each Shard, executes a query against each live and active replica of that shard and asserts that the results are identical for each replica of the same shard. Because results are not compared between replicas of different shards, this method should be safe for comparing the results of any query, even if it contains "distrib=false", because the replicas should all be identical.
      Throws:
      Exception
      See Also:
    • checkShardConsistency

      protected void checkShardConsistency(String shard) throws Exception
      Returns a non-null string if replicas within the same shard do not have a consistent number of documents.
      Throws:
      Exception
    • checkShardConsistency

      protected String checkShardConsistency(String shard, boolean expectFailure, boolean verbose) throws Exception
      Returns a non-null string if replicas within the same shard do not have a consistent number of documents. If expectFailure==false, the exact differences found will be logged since this would be an unexpected failure. verbose causes extra debugging into to be displayed, even if everything is consistent.
      Throws:
      Exception
    • showCounts

      public void showCounts()
    • randomlyEnableAutoSoftCommit

      protected void randomlyEnableAutoSoftCommit()
    • enableAutoSoftCommit

      protected void enableAutoSoftCommit(int time)
    • checkShardConsistency

      protected void checkShardConsistency() throws Exception
      Throws:
      Exception
    • checkShardConsistency

      protected void checkShardConsistency(boolean checkVsControl, boolean verbose) throws Exception
      Throws:
      Exception
    • checkShardConsistency

      protected void checkShardConsistency(boolean checkVsControl, boolean verbose, Set<String> addFails, Set<String> deleteFails) throws Exception
      Throws:
      Exception
    • getClient

      protected org.apache.solr.client.solrj.SolrClient getClient(String nodeName)
    • assertDocCounts

      protected void assertDocCounts(boolean verbose) throws Exception
      Throws:
      Exception
    • queryRandomShard

      protected org.apache.solr.client.solrj.response.QueryResponse queryRandomShard(org.apache.solr.common.params.ModifiableSolrParams params) throws org.apache.solr.client.solrj.SolrServerException, IOException
      Description copied from class: BaseDistributedSearchTestCase
      Queries a random shard; nothing more.

      WARNING: tests should generally not call this as it doesn't compare to the control client

      Overrides:
      queryRandomShard in class BaseDistributedSearchTestCase
      Throws:
      org.apache.solr.client.solrj.SolrServerException
      IOException
    • waitForThingsToLevelOut

      public void waitForThingsToLevelOut() throws Exception
      Throws:
      Exception
    • waitForThingsToLevelOut

      public void waitForThingsToLevelOut(int timeout, TimeUnit unit) throws Exception
      Throws:
      Exception
    • waitForNoShardInconsistency

      public void waitForNoShardInconsistency() throws Exception
      Throws:
      Exception
    • distribTearDown

      public void distribTearDown() throws Exception
      Overrides:
      distribTearDown in class BaseDistributedSearchTestCase
      Throws:
      Exception
    • printLayout

      protected void printLayout() throws Exception
      Throws:
      Exception
    • restartZk

      protected void restartZk(int pauseMillis) throws Exception
      Throws:
      Exception
    • copyConfigUp

      public static void copyConfigUp(Path configSetDir, String srcConfigSet, String dstConfigName, String zkAddr) throws Exception
      Throws:
      Exception
    • destroyServers

      protected void destroyServers() throws Exception
      Overrides:
      destroyServers in class BaseDistributedSearchTestCase
      Throws:
      Exception
    • commit

      protected void commit() throws Exception
      Overrides:
      commit in class BaseDistributedSearchTestCase
      Throws:
      Exception
    • createCollection

      protected org.apache.solr.client.solrj.response.CollectionAdminResponse createCollection(String collectionName, String configSetName, int numShards, int replicationFactor) throws org.apache.solr.client.solrj.SolrServerException, IOException, InterruptedException, TimeoutException
      Throws:
      org.apache.solr.client.solrj.SolrServerException
      IOException
      InterruptedException
      TimeoutException
    • createCollection

      protected org.apache.solr.client.solrj.response.CollectionAdminResponse createCollection(Map<String,List<Integer>> collectionInfos, String collectionName, Map<String,Object> collectionProps, org.apache.solr.client.solrj.SolrClient client) throws org.apache.solr.client.solrj.SolrServerException, IOException, InterruptedException, TimeoutException
      Throws:
      org.apache.solr.client.solrj.SolrServerException
      IOException
      InterruptedException
      TimeoutException
    • createCollection

      protected org.apache.solr.client.solrj.response.CollectionAdminResponse createCollection(Map<String,List<Integer>> collectionInfos, String collectionName, Map<String,Object> collectionProps, org.apache.solr.client.solrj.SolrClient client, String confSetName) throws org.apache.solr.client.solrj.SolrServerException, IOException, InterruptedException, TimeoutException
      Throws:
      org.apache.solr.client.solrj.SolrServerException
      IOException
      InterruptedException
      TimeoutException
    • createCollection

      protected org.apache.solr.client.solrj.response.CollectionAdminResponse createCollection(Map<String,List<Integer>> collectionInfos, String collectionName, String configSetName, int numShards, int replicationFactor, org.apache.solr.client.solrj.SolrClient client, String createNodeSetStr) throws org.apache.solr.client.solrj.SolrServerException, IOException, InterruptedException, TimeoutException
      Throws:
      org.apache.solr.client.solrj.SolrServerException
      IOException
      InterruptedException
      TimeoutException
    • createCollection

      protected org.apache.solr.client.solrj.response.CollectionAdminResponse createCollection(Map<String,List<Integer>> collectionInfos, String collectionName, int numShards, int replicationFactor, org.apache.solr.client.solrj.SolrClient client, String createNodeSetStr, String configName) throws org.apache.solr.client.solrj.SolrServerException, IOException, InterruptedException, TimeoutException
      Throws:
      org.apache.solr.client.solrj.SolrServerException
      IOException
      InterruptedException
      TimeoutException
    • getCloudSolrClient

      public static org.apache.solr.client.solrj.impl.CloudSolrClient getCloudSolrClient(String zkHost, String defaultCollection, boolean shardLeadersOnly, int connectionTimeoutMillis, int socketTimeoutMillis)
      This method may randomize unspecified aspects of the resulting SolrClient. Tests that do not wish to have any randomized behavior should use the CloudSolrClient.Builder class directly
    • createNewSolrClient

      protected org.apache.solr.client.solrj.SolrClient createNewSolrClient(int port)
      Overrides:
      createNewSolrClient in class BaseDistributedSearchTestCase
    • createNewSolrClient

      protected org.apache.solr.client.solrj.SolrClient createNewSolrClient(String coreName, int port)
    • createNewSolrClient

      protected org.apache.solr.client.solrj.SolrClient createNewSolrClient(String collection, String baseUrl)
    • getBaseUrl

      protected String getBaseUrl(JettySolrRunner jetty)
    • getDoc

      public static org.apache.solr.common.SolrInputDocument getDoc(Object... fields) throws Exception
      Throws:
      Exception
    • checkForCollection

      protected void checkForCollection(String collectionName, List<Integer> numShardsNumReplicaList) throws Exception
      Throws:
      Exception
    • getCommonCloudSolrClient

      protected org.apache.solr.client.solrj.impl.CloudSolrClient getCommonCloudSolrClient()
    • getSolrClient

      protected org.apache.solr.client.solrj.impl.CloudSolrClient getSolrClient(String collectionName)
    • getBaseUrlFromZk

      public static String getBaseUrlFromZk(org.apache.solr.common.cloud.ClusterState clusterState, String collection)
      Returns the base URL of a live Solr node hosting the specified collection

      Note that the returned URL does not contain the collection name itself.

      Parameters:
      clusterState - used to identify which live nodes host the collection
      collection - the name of the collection to search for
    • waitForNon403or404or503

      public static void waitForNon403or404or503(org.apache.solr.client.solrj.SolrClient collectionClient, String baseUrl) throws Exception
      Throws:
      Exception
    • createReplicaProps

      protected static Map<String,Object> createReplicaProps(int numNrtReplicas, int numTlogReplicas, int numPullReplicas, int numShards)
    • createCollection

      protected void createCollection(String collName, org.apache.solr.client.solrj.impl.CloudSolrClient client, int replicationFactor, int numShards) throws Exception
      Throws:
      Exception
    • createCollectionRetry

      protected void createCollectionRetry(String testCollectionName, String configSetName, int numShards, int replicationFactor) throws org.apache.solr.client.solrj.SolrServerException, IOException, InterruptedException, TimeoutException
      Throws:
      org.apache.solr.client.solrj.SolrServerException
      IOException
      InterruptedException
      TimeoutException
    • getShardLeader

      protected org.apache.solr.common.cloud.Replica getShardLeader(String testCollectionName, String shardId, int timeoutSecs) throws Exception
      Throws:
      Exception
    • ensureAllReplicasAreActive

      protected List<org.apache.solr.common.cloud.Replica> ensureAllReplicasAreActive(String testCollectionName, String shardId, int shards, int rf, int maxWaitSecs) throws Exception
      Throws:
      Exception
    • printClusterStateInfo

      protected String printClusterStateInfo() throws Exception
      Throws:
      Exception
    • printClusterStateInfo

      protected String printClusterStateInfo(String collection) throws Exception
      Throws:
      Exception
    • reloadCollection

      protected boolean reloadCollection(org.apache.solr.common.cloud.Replica replica, String testCollectionName) throws Exception
      Throws:
      Exception
    • logReplicaTypesReplicationInfo

      protected void logReplicaTypesReplicationInfo(String collectionName, org.apache.solr.common.cloud.ZkStateReader zkStateReader) throws org.apache.zookeeper.KeeperException, InterruptedException, IOException
      Throws:
      org.apache.zookeeper.KeeperException
      InterruptedException
      IOException
    • waitForReplicationFromReplicas

      protected void waitForReplicationFromReplicas(String collectionName, org.apache.solr.common.cloud.ZkStateReader zkStateReader, org.apache.solr.util.TimeOut timeout) throws org.apache.zookeeper.KeeperException, InterruptedException, IOException
      Throws:
      org.apache.zookeeper.KeeperException
      InterruptedException
      IOException
    • waitForAllWarmingSearchers

      protected void waitForAllWarmingSearchers() throws InterruptedException
      Throws:
      InterruptedException
    • getIndexVersion

      protected long getIndexVersion(org.apache.solr.common.cloud.Replica replica) throws IOException
      Throws:
      IOException
    • attemptCollectionDelete

      protected static boolean attemptCollectionDelete(org.apache.solr.client.solrj.impl.CloudSolrClient client, String collectionName)
      Logs a WARN if collection can't be deleted, but does not fail or throw an exception
      Returns:
      true if success, else false
    • logReplicationDetails

      protected void logReplicationDetails(org.apache.solr.common.cloud.Replica replica, StringBuilder builder) throws IOException
      Throws:
      IOException
    • getRequestStateAfterCompletion

      public static org.apache.solr.client.solrj.response.RequestStatusState getRequestStateAfterCompletion(String requestId, int waitForSeconds, org.apache.solr.client.solrj.SolrClient client) throws IOException, org.apache.solr.client.solrj.SolrServerException
      Throws:
      IOException
      org.apache.solr.client.solrj.SolrServerException
    • setupRestTestHarnesses

      protected void setupRestTestHarnesses()
    • closeRestTestHarnesses

      protected void closeRestTestHarnesses() throws IOException
      Throws:
      IOException
    • randomRestTestHarness

      protected RestTestHarness randomRestTestHarness()
    • randomRestTestHarness

      protected RestTestHarness randomRestTestHarness(Random random)
    • forAllRestTestHarnesses

      protected void forAllRestTestHarnesses(Consumer<RestTestHarness> op)