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

    • IS_DISTRIBUTED_CLUSTER

      public static final String IS_DISTRIBUTED_CLUSTER
      Configuration that controls whether this utility assumes a running/deployed cluster. This is different than "hbase.cluster.distributed" since that parameter indicates whether the cluster is in an actual distributed environment, while this shows that there is a deployed (distributed or pseudo-distributed) cluster running, and we do not need to start a mini-cluster for tests.
      See Also:
    • HBASE_CLUSTER_MANAGER_CLASS

      public static final String HBASE_CLUSTER_MANAGER_CLASS
      Config for pluggable hbase cluster manager. Pass fully-qualified class name as property value. Drop the '.class' suffix.
      See Also:
    • DEFAULT_HBASE_CLUSTER_MANAGER_CLASS

      private static final Class<? extends ClusterManager> DEFAULT_HBASE_CLUSTER_MANAGER_CLASS
  • 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