@Test public void testKerberosKeytabConfiguration() throws Exception { final String resourceDirPath = Paths.get("src", "test", "resources").toAbsolutePath().toString(); final Map<String, String> envs = new HashMap<>(2); envs.put(YarnConfigKeys.KEYTAB_PRINCIPAL, "testuser1@domain"); envs.put(YarnConfigKeys.KEYTAB_PATH, resourceDirPath); Configuration configuration = new Configuration(); YarnTaskExecutorRunner.setupConfigurationAndInstallSecurityContext(configuration, resourceDirPath, envs); final List<SecurityModule> modules = SecurityUtils.getInstalledModules(); Optional<SecurityModule> moduleOpt = modules.stream().filter(module -> module instanceof HadoopModule).findFirst(); if (moduleOpt.isPresent()) { HadoopModule hadoopModule = (HadoopModule) moduleOpt.get(); assertThat(hadoopModule.getSecurityConfig().getPrincipal(), is("testuser1@domain")); assertThat(hadoopModule.getSecurityConfig().getKeytab(), is(new File(resourceDirPath, Utils.KEYTAB_FILE_NAME).getAbsolutePath())); } else { fail("Can not find HadoopModule!"); } assertThat(configuration.getString(SecurityOptions.KERBEROS_LOGIN_KEYTAB), is(new File(resourceDirPath, Utils.KEYTAB_FILE_NAME).getAbsolutePath())); assertThat(configuration.getString(SecurityOptions.KERBEROS_LOGIN_PRINCIPAL), is("testuser1@domain")); }
@VisibleForTesting static void setupConfigurationAndInstallSecurityContext(Configuration configuration, String currDir, Map<String, String> variables) throws Exception { final String localDirs = variables.get(Environment.LOCAL_DIRS.key()); LOG.info("Current working/local Directory: {}", localDirs); BootstrapTools.updateTmpDirectoriesInConfiguration(configuration, localDirs); setupConfigurationFromVariables(configuration, currDir, variables); installSecurityContext(configuration); }
YarnTaskExecutorRunner { @VisibleForTesting static void setupConfigurationAndInstallSecurityContext(Configuration configuration, String currDir, Map<String, String> variables) throws Exception { final String localDirs = variables.get(Environment.LOCAL_DIRS.key()); LOG.info("Current working/local Directory: {}", localDirs); BootstrapTools.updateTmpDirectoriesInConfiguration(configuration, localDirs); setupConfigurationFromVariables(configuration, currDir, variables); installSecurityContext(configuration); } }
YarnTaskExecutorRunner { @VisibleForTesting static void setupConfigurationAndInstallSecurityContext(Configuration configuration, String currDir, Map<String, String> variables) throws Exception { final String localDirs = variables.get(Environment.LOCAL_DIRS.key()); LOG.info("Current working/local Directory: {}", localDirs); BootstrapTools.updateTmpDirectoriesInConfiguration(configuration, localDirs); setupConfigurationFromVariables(configuration, currDir, variables); installSecurityContext(configuration); }  }
YarnTaskExecutorRunner { @VisibleForTesting static void setupConfigurationAndInstallSecurityContext(Configuration configuration, String currDir, Map<String, String> variables) throws Exception { final String localDirs = variables.get(Environment.LOCAL_DIRS.key()); LOG.info("Current working/local Directory: {}", localDirs); BootstrapTools.updateTmpDirectoriesInConfiguration(configuration, localDirs); setupConfigurationFromVariables(configuration, currDir, variables); installSecurityContext(configuration); }  static void main(String[] args); }
YarnTaskExecutorRunner { @VisibleForTesting static void setupConfigurationAndInstallSecurityContext(Configuration configuration, String currDir, Map<String, String> variables) throws Exception { final String localDirs = variables.get(Environment.LOCAL_DIRS.key()); LOG.info("Current working/local Directory: {}", localDirs); BootstrapTools.updateTmpDirectoriesInConfiguration(configuration, localDirs); setupConfigurationFromVariables(configuration, currDir, variables); installSecurityContext(configuration); }  static void main(String[] args);  }