diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/HBaseCommonTestingUtil.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/HBaseCommonTestingUtil.java index f78e9de9a38f..77502db9e17a 100644 --- a/hbase-common/src/test/java/org/apache/hadoop/hbase/HBaseCommonTestingUtil.java +++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/HBaseCommonTestingUtil.java @@ -40,7 +40,9 @@ /** * Common helpers for testing HBase that do not depend on specific server/etc. things. */ -@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.PHOENIX) +@InterfaceAudience.LimitedPrivate({HBaseInterfaceAudience.COPROC, + HBaseInterfaceAudience.REPLICATION, + HBaseInterfaceAudience.PHOENIX}) @InterfaceStability.Evolving public class HBaseCommonTestingUtil { protected static final Logger LOG = LoggerFactory.getLogger(HBaseCommonTestingUtil.class); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtil.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtil.java index 1979732861dc..e116cd7bfd09 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtil.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtil.java @@ -172,7 +172,9 @@ *
To preserve test data directories, pass the system property "hbase.testing.preserve.testdir"
* setting it to true.
*/
-@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.PHOENIX)
+@InterfaceAudience.LimitedPrivate({HBaseInterfaceAudience.COPROC,
+ HBaseInterfaceAudience.REPLICATION,
+ HBaseInterfaceAudience.PHOENIX})
@InterfaceStability.Evolving
public class HBaseTestingUtil extends HBaseZKTestingUtil {
diff --git a/hbase-testing-util/src/main/java/org/apache/hadoop/hbase/testing/ServerTestingHBaseCluster.java b/hbase-testing-util/src/main/java/org/apache/hadoop/hbase/testing/ServerTestingHBaseCluster.java
new file mode 100644
index 000000000000..49d12c9d0fa2
--- /dev/null
+++ b/hbase-testing-util/src/main/java/org/apache/hadoop/hbase/testing/ServerTestingHBaseCluster.java
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hbase.testing;
+
+import org.apache.hadoop.hbase.HBaseInterfaceAudience;
+import org.apache.hadoop.hbase.HBaseTestingUtil;
+import org.apache.yetus.audience.InterfaceAudience;
+
+/**
+ * This interface is intended for uncommon testing use cases which need to access internal state
+ * on an HBase minicluster. This may be necessary when testing code which runs within an HBase
+ * server process, such as coprocessors or replication endpoints. It provides access to the
+ * underlying {@link HBaseTestingUtil}, which its parent {@link TestingHBaseCluster} interface
+ * intentionally does not. External use cases that just need to test their code using the HBase
+ * client API should use {@link TestingHBaseCluster} instead.
+ */
+@InterfaceAudience.LimitedPrivate(
+ {HBaseInterfaceAudience.COPROC, HBaseInterfaceAudience.REPLICATION,
+ HBaseInterfaceAudience.PHOENIX})
+public interface ServerTestingHBaseCluster extends TestingHBaseCluster {
+ /**
+ *
+ * @return the utility running the minicluster
+ */
+ HBaseTestingUtil getUtil();
+
+ /**
+ * Create a {@link ServerTestingHBaseCluster}. You need to call {@link #start()} of the returned
+ * {@link ServerTestingHBaseCluster} to actually start the mini testing cluster.
+ */
+ static ServerTestingHBaseCluster create(TestingHBaseClusterOption option) {
+ return new TestingHBaseClusterImpl(option);
+ }
+}
diff --git a/hbase-testing-util/src/main/java/org/apache/hadoop/hbase/testing/TestingHBaseClusterImpl.java b/hbase-testing-util/src/main/java/org/apache/hadoop/hbase/testing/TestingHBaseClusterImpl.java
index e2c42616091b..154a961e0913 100644
--- a/hbase-testing-util/src/main/java/org/apache/hadoop/hbase/testing/TestingHBaseClusterImpl.java
+++ b/hbase-testing-util/src/main/java/org/apache/hadoop/hbase/testing/TestingHBaseClusterImpl.java
@@ -33,7 +33,7 @@
import org.apache.hbase.thirdparty.com.google.common.util.concurrent.ThreadFactoryBuilder;
@InterfaceAudience.Private
-class TestingHBaseClusterImpl implements TestingHBaseCluster {
+class TestingHBaseClusterImpl implements ServerTestingHBaseCluster {
private final HBaseTestingUtil util = new HBaseTestingUtil();
@@ -55,6 +55,10 @@ public Configuration getConf() {
return util.getConfiguration();
}
+ public HBaseTestingUtil getUtil() {
+ return util;
+ }
+
private int getRegionServerIndex(ServerName serverName) {
// we have a small number of region servers, this should be fine for now.
List