diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMRestart.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMRestart.java index 955b4b61cd6..5915bbbf5c2 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMRestart.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMRestart.java @@ -1644,7 +1644,7 @@ public void testFinishedAppRemovalAfterRMRestart() throws Exception { nm1.registerNode(); // create an app and finish the app. - RMApp app0 = rm1.submitApp(200); + final RMApp app0 = rm1.submitApp(200); MockAM am0 = launchAM(app0, rm1, nm1); finishApplicationMaster(app0, rm1, nm1, am0); @@ -1653,7 +1653,7 @@ public void testFinishedAppRemovalAfterRMRestart() throws Exception { nm1.setResourceTrackerService(rm2.getResourceTrackerService()); nm1 = rm2.registerNode("127.0.0.1:1234", 15120); - Map rmAppState = + final Map rmAppState = rmState.getApplicationState(); // app0 exits in both state store and rmContext @@ -1670,7 +1670,8 @@ public void testFinishedAppRemovalAfterRMRestart() throws Exception { // the first app0 get kicked out from both rmContext and state store Assert.assertNull(rm2.getRMContext().getRMApps() .get(app0.getApplicationId())); - Assert.assertNull(rmAppState.get(app0.getApplicationId())); + GenericTestUtils.waitFor( + () -> rmAppState.get(app0.getApplicationId()) == null, 300, 3000); } // This is to test RM does not get hang on shutdown.