public static MiniHS2 getMiniHS2WithKerb(MiniHiveKdc miniHiveKdc, HiveConf hiveConf,
     String authType) throws Exception {
    String hivePrincipal =
            miniHiveKdc.getFullyQualifiedServicePrincipal(MiniHiveKdc.HIVE_SERVICE_PRINCIPAL);
    String hiveKeytab = miniHiveKdc.getKeyTabFile(
            miniHiveKdc.getServicePrincipalForUser(MiniHiveKdc.HIVE_SERVICE_PRINCIPAL));

    MiniHS2.Builder miniHS2Builder = new MiniHS2.Builder()
                                              .withConf(hiveConf)
                                              .withMiniKdc(hivePrincipal, hiveKeytab)
                                              .withAuthenticationType(authType);
    if (HiveServer2.isHttpTransportMode(hiveConf)) {
      miniHS2Builder.withHTTPTransport();
    }
    return miniHS2Builder.build();
 }
Create a MiniHS2 with the hive service principal and keytab in MiniHiveKdc
@param miniHiveKdc
@param hiveConf
@param authType
@return new MiniHS2 instance
@throws Exception
itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/MiniHiveKdc.java