@VisibleForTesting
    static void setupAndModifyConfiguration(
            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);
    }
@Test
    public void testPreInstallKerberosKeytabConfiguration() 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");
        // Try directly resolving local path when no remote keytab path is provided.
        envs.put(YarnConfigKeys.LOCAL_KEYTAB_PATH, "src/test/resources/krb5.keytab");

        Configuration configuration = new Configuration();
        YarnTaskExecutorRunner.setupAndModifyConfiguration(configuration, resourceDirPath, envs);

        // the SecurityContext is installed on TaskManager startup
        SecurityUtils.install(new SecurityConfiguration(configuration));

        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())
                    .isEqualTo("testuser1@domain");
            // Using containString verification as the absolute path varies depending on runtime
            // environment
            assertThat(hadoopModule.getSecurityConfig().getKeytab())
                    .containsSequence("src/test/resources/krb5.keytab");
        } else {
            fail("Can not find HadoopModule!");
        }

        assertThat(configuration.get(SecurityOptions.KERBEROS_LOGIN_KEYTAB))
                .containsSequence("src/test/resources/krb5.keytab");
        assertThat(configuration.get(SecurityOptions.KERBEROS_LOGIN_PRINCIPAL))
                .isEqualTo("testuser1@domain");
    }