Class IntegrationTestingUtility


Facility for integration/system tests. This extends HBaseTestingUtil and adds-in the functionality needed by integration and system tests. This class understands distributed and pseudo-distributed/local cluster deployments, and abstracts those from the tests in this module.

IntegrationTestingUtility is constructed and used by the integration tests, but the tests themselves should not assume a particular deployment. They can rely on the methods in this class and HBaseCluster. Before the testing begins, the test should initialize the cluster by calling initializeCluster(int).

The cluster that is used defaults to a mini cluster, but it can be forced to use a distributed cluster by calling setUseDistributedCluster(Configuration). This method is invoked by test drivers (maven, IntegrationTestsDriver, etc) before initializing the cluster via initializeCluster(int). Individual tests should not directly call setUseDistributedCluster(Configuration).

  • Field Details

  • Constructor Details

  • Method Details

    • initializeCluster

      public void initializeCluster(int numSlaves) throws Exception
      Initializes the state of the cluster. It starts a new in-process mini cluster, OR if we are given an already deployed distributed cluster it initializes the state.
      Parameters:
      numSlaves - Number of slaves to start up if we are booting a mini cluster. Otherwise we check whether this many nodes are available and throw an exception if not.
      Throws:
      Exception
    • checkNodeCount

      public void checkNodeCount(int numSlaves) throws Exception
      Checks whether we have more than numSlaves nodes. Throws an exception otherwise.
      Throws:
      Exception
    • restoreCluster

      public void restoreCluster() throws IOException
      Restores the cluster to the initial state if it is a distributed cluster, otherwise, shutdowns the mini cluster.
      Throws:
      IOException
    • setUseDistributedCluster

      public static void setUseDistributedCluster(org.apache.hadoop.conf.Configuration conf)
      Sets the configuration property to use a distributed cluster for the integration tests. Test drivers should use this to enforce cluster deployment.
    • isDistributedCluster

      public boolean isDistributedCluster()
      Returns whether we are interacting with a distributed cluster as opposed to and in-process mini cluster or a local cluster.
      See Also:
    • createDistributedHBaseCluster

      Throws:
      IOException
    • createPreSplitLoadTestTable

      public static int createPreSplitLoadTestTable(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.hbase.client.TableDescriptor td, org.apache.hadoop.hbase.client.ColumnFamilyDescriptor[] cds, int numRegionsPerServer) throws IOException
      Creates a pre-split table for load testing. If the table already exists, logs a warning and continues.
      Returns:
      the number of regions the table was split into
      Throws:
      IOException