You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by GitBox <gi...@apache.org> on 2021/08/19 10:16:51 UTC

[GitHub] [hbase] bitterfox commented on a change in pull request #3592: HBASE-26205 Use specified cluster conf for UserProvider in TableMRUtil#initCredentialsForCluster

bitterfox commented on a change in pull request #3592:
URL: https://github.com/apache/hbase/pull/3592#discussion_r691979353



##########
File path: hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableMapReduceUtil.java
##########
@@ -104,4 +130,147 @@ public void testInitTableMapperJob4() throws Exception {
     assertNull(job.getCombinerClass());
     assertEquals("Table", job.getConfiguration().get(TableInputFormat.INPUT_TABLE));
   }
+
+  private static void startSecureMiniCluster(HBaseTestingUtil util, MiniKdc kdc, String principal)
+    throws Exception {
+    Configuration conf = util.getConfiguration();
+
+    SecureTestUtil.enableSecurity(conf);
+    VisibilityTestUtil.enableVisiblityLabels(conf);
+    SecureTestUtil.verifyConfiguration(conf);
+
+    conf.set(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY,
+      AccessController.class.getName() + ',' + TokenProvider.class.getName());
+
+    HBaseKerberosUtils.setSecuredConfiguration(conf,
+      principal + '@' + kdc.getRealm(), HTTP_PRINCIPAL + '@' + kdc.getRealm());
+
+    util.startMiniCluster();
+    util.waitUntilAllRegionsAssigned(PermissionStorage.ACL_TABLE_NAME);
+  }
+
+  @Test
+  public void testInitCredentialsForCluster1() throws Exception {
+    HBaseTestingUtil util1 = new HBaseTestingUtil();
+    HBaseTestingUtil util2 = new HBaseTestingUtil();
+
+    util1.startMiniCluster();
+    util2.startMiniCluster();
+
+    Configuration conf1 = util1.getConfiguration();
+    Job job = Job.getInstance(conf1);
+
+    TableMapReduceUtil.initCredentialsForCluster(job, util2.getConfiguration());
+
+    Credentials credentials = job.getCredentials();
+    Collection<Token<? extends TokenIdentifier>> tokens = credentials.getAllTokens();
+    assertTrue(tokens.isEmpty());
+
+    util1.shutdownMiniCluster();

Review comment:
       Thank you. Added better resource management.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@hbase.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org