You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by wc...@apache.org on 2020/02/28 19:41:54 UTC

[hbase] branch branch-2.2 updated: HBASE-23892 SecureTestCluster should allow its subclasses to pass their Class reference on HBaseKerberosUtils.setSSLConfiguration (#1207)

This is an automated email from the ASF dual-hosted git repository.

wchevreuil pushed a commit to branch branch-2.2
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-2.2 by this push:
     new 24fabbc  HBASE-23892 SecureTestCluster should allow its subclasses to pass their Class reference on HBaseKerberosUtils.setSSLConfiguration (#1207)
24fabbc is described below

commit 24fabbc90df236e90405ced2dd9c508719889326
Author: Wellington Ramos Chevreuil <wc...@apache.org>
AuthorDate: Fri Feb 28 18:35:15 2020 +0000

    HBASE-23892 SecureTestCluster should allow its subclasses to pass their Class reference on HBaseKerberosUtils.setSSLConfiguration (#1207)
    
    Signed-off-by: Josh Elser <el...@apache.org>
    (cherry picked from commit 00ef6c624a75b0782550df4ad9b7c6a2dabfb88c)
---
 .../hbase/security/token/SecureTestCluster.java    | 37 +++++++++++++++++-----
 1 file changed, 29 insertions(+), 8 deletions(-)

diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/token/SecureTestCluster.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/token/SecureTestCluster.java
index 2263bde..1323946 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/token/SecureTestCluster.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/token/SecureTestCluster.java
@@ -51,6 +51,23 @@ public class SecureTestCluster {
 
   private static String HTTP_PRINCIPAL;
 
+  //When extending SecureTestCluster on downstream projects that refer SecureTestCluster via
+  //hbase-server jar, we need to provide a way for the implementation to refer to its own class
+  //definition, so that KeyStoreTestUtil.getClasspathDir can resolve a valid path in the local FS
+  //to place required SSL config files.
+  private static Class testRunnerClass = SecureTestCluster.class;
+
+  /**
+   * SecureTestCluster extending classes can set their own <code>Class</code> reference type
+   * to be used as the target resource to be looked for on the class loader by
+   * <code>KeyStoreTestUtil</code>, when deciding where to place ssl related config files.
+   * @param testRunnerClass a <code>Class</code> reference from the
+   *                        <code>SecureTestCluster</code> extender.
+   */
+  protected static void setTestRunner(Class testRunnerClass){
+    SecureTestCluster.testRunnerClass = testRunnerClass;
+  }
+
   /**
    * Setup and start kerberos, hbase
    */
@@ -65,7 +82,7 @@ public class SecureTestCluster {
 
     HBaseKerberosUtils.setSecuredConfiguration(TEST_UTIL.getConfiguration(),
         PRINCIPAL + "@" + KDC.getRealm(), HTTP_PRINCIPAL + "@" + KDC.getRealm());
-    HBaseKerberosUtils.setSSLConfiguration(TEST_UTIL, SecureTestCluster.class);
+    HBaseKerberosUtils.setSSLConfiguration(TEST_UTIL, testRunnerClass);
 
     TEST_UTIL.getConfiguration().setStrings(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY,
         TokenProvider.class.getName());
@@ -78,13 +95,17 @@ public class SecureTestCluster {
 
   @AfterClass
   public static void tearDown() throws Exception {
-    if (CLUSTER != null) {
-      CLUSTER.shutdown();
-    }
-    CLUSTER.join();
-    if (KDC != null) {
-      KDC.stop();
+    try {
+      if (CLUSTER != null) {
+        CLUSTER.shutdown();
+      }
+      CLUSTER.join();
+      if (KDC != null) {
+        KDC.stop();
+      }
+      TEST_UTIL.shutdownMiniCluster();
+    } finally {
+      setTestRunner(SecureTestCluster.class);
     }
-    TEST_UTIL.shutdownMiniCluster();
   }
 }