slfan1989 commented on code in PR #5565: URL: https://github.com/apache/hadoop/pull/5565#discussion_r1178658969
########## hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMHA.java: ########## @@ -742,6 +746,102 @@ public void testResourceProfilesManagerAfterRMWentStandbyThenBackToActive() rm.getRMContext().getResourceProfilesManager()); } + @Test + public void testTransitionedToActiveWithExcludeFileNotExist() throws Exception { + final String errUnforcedRequest = "User request succeeded even when " + + "automatic failover is enabled"; + + Configuration conf = new YarnConfiguration(configuration); + String nodeExcludeFilePath = "/tmp/non-existent-path-" + UUID.randomUUID(); + conf.set(YarnConfiguration.RM_NODES_EXCLUDE_FILE_PATH, nodeExcludeFilePath); + + DataOutputStream output = null; + final File confFile = + new File("target/test-classes/"+YarnConfiguration.YARN_SITE_CONFIGURATION_FILE); + final File backupConfFile = new File( + "target/test-classes/" + YarnConfiguration.YARN_SITE_CONFIGURATION_FILE + + ".backup." + UUID.randomUUID()); + boolean hasRenamed = false; + try { + if (confFile.exists()) { + hasRenamed = confFile.renameTo(backupConfFile); + if (!hasRenamed) { + Assert.fail("Can not rename " + confFile.getAbsolutePath() + " to " + + backupConfFile.getAbsolutePath()); + } + } + if (!confFile.createNewFile()) { + Assert.fail( + "Can not create " + YarnConfiguration.YARN_SITE_CONFIGURATION_FILE); + } + output = new DataOutputStream(Files.newOutputStream(confFile.toPath())); + conf.writeXml(output); + } finally { + if (output != null) { + output.close(); + } + } + + try { + rm = new MockRM(conf); Review Comment: Shouldn't `rm` be closed after the test? -- 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: common-issues-unsubscr...@hadoop.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-issues-h...@hadoop.apache.org