[ https://issues.apache.org/jira/browse/FLINK-10516?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16647203#comment-16647203 ]
ASF GitHub Bot commented on FLINK-10516: ---------------------------------------- suez1224 commented on a change in pull request #6828: [FLINK-10516] [yarn] fix YarnApplicationMasterRunner fail to initialize FileSystem with correct Flink Configuration during setup URL: https://github.com/apache/flink/pull/6828#discussion_r224639273 ########## File path: flink-yarn/src/test/java/org/apache/flink/yarn/YarnApplicationMasterRunnerTest.java ########## @@ -109,4 +120,37 @@ public Object answer(InvocationOnMock invocationOnMock) throws Throwable { taskManagerConf, workingDirectory, taskManagerMainClass, LOG); assertEquals("file", ctx.getLocalResources().get("flink.jar").getResource().getScheme()); } + + @Test + public void testRunAndInitializeFileSystem() throws Exception { + // Mock necessary system variables + Map<String, String> map = new HashMap<String, String>(System.getenv()); + map.put(YarnConfigKeys.ENV_HADOOP_USER_NAME, "foo"); + // Create dynamic properties to be used in the Flink configuration + map.put(YarnConfigKeys.ENV_DYNAMIC_PROPERTIES, "myKey=myValue"); + CommonTestUtils.setEnv(map); + + // Create a temporary flink-conf.yaml and to be deleted on JVM exits + File currDir = new File(System.getenv().get(ApplicationConstants.Environment.PWD.key())); + String path = String.format("%s/%s.%s", currDir, "flink-conf", "yaml"); + File f = new File(path); + f.createNewFile(); + f.deleteOnExit(); + + // Mock FileSystem.initialize() + PowerMockito.mockStatic(FileSystem.class); + PowerMockito.doNothing().when(FileSystem.class); + FileSystem.initialize(any(Configuration.class)); + + String[] args = new String[5]; + YarnApplicationMasterRunner yarnApplicationMasterRunner = new YarnApplicationMasterRunner(); + yarnApplicationMasterRunner.run(args); Review comment: I think we should refactor the code like YarnTaskManagerRunnerFactoryTest. Running the entire appMaster code in unittest is too much. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > YarnApplicationMasterRunner fail to initialize FileSystem with correct Flink > Configuration during setup > ------------------------------------------------------------------------------------------------------- > > Key: FLINK-10516 > URL: https://issues.apache.org/jira/browse/FLINK-10516 > Project: Flink > Issue Type: Bug > Components: YARN > Affects Versions: 1.4.0, 1.5.0, 1.6.0, 1.7.0 > Reporter: Shuyi Chen > Assignee: Shuyi Chen > Priority: Major > Labels: pull-request-available > Fix For: 1.7.0, 1.6.2, 1.5.5 > > > Will add a fix, and refactor YarnApplicationMasterRunner to add a unittest to > prevent future regression. -- This message was sent by Atlassian JIRA (v7.6.3#76005)