diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/TestRMAppTransitions.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/TestRMAppTransitions.java index d9f452a..10d4ee3 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/TestRMAppTransitions.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/TestRMAppTransitions.java @@ -272,11 +272,11 @@ protected RMApp createNewTestApp(ApplicationSubmissionContext submissionContext) } // Test expected newly created app state - private static void testAppStartState(ApplicationId applicationId, + private static void testAppStartState(ApplicationId applicationId, String user, String name, String queue, RMApp application) { - Assert.assertTrue("application start time is not greater then 0", + Assert.assertTrue("application start time is not greater than 0", application.getStartTime() > 0); - Assert.assertTrue("application start time is before currentTime", + Assert.assertTrue("application start time is before currentTime", application.getStartTime() <= System.currentTimeMillis()); Assert.assertEquals("application user is not correct", user, application.getUser()); @@ -299,28 +299,28 @@ private static void testAppStartState(ApplicationId applicationId, // test to make sure times are set when app finishes private static void assertStartTimeSet(RMApp application) { - Assert.assertTrue("application start time is not greater then 0", + Assert.assertTrue("application start time is not greater than 0", application.getStartTime() > 0); - Assert.assertTrue("application start time is before currentTime", + Assert.assertTrue("application start time is before currentTime", application.getStartTime() <= System.currentTimeMillis()); } private static void assertAppState(RMAppState state, RMApp application) { - Assert.assertEquals("application state should have been " + state, + Assert.assertEquals("application state should have been " + state, state, application.getState()); } private static void assertFinalAppStatus(FinalApplicationStatus status, RMApp application) { - Assert.assertEquals("Final application status should have been " + status, + Assert.assertEquals("Final application status should have been " + status, status, application.getFinalApplicationStatus()); } // test to make sure times are set when app finishes private void assertTimesAtFinish(RMApp application) { assertStartTimeSet(application); - Assert.assertTrue("application finish time is not greater then 0", + Assert.assertTrue("application finish time is not greater than 0", (application.getFinishTime() > 0)); - Assert.assertTrue("application finish time is not >= then start time", + Assert.assertTrue("application finish time is not >= than start time", (application.getFinishTime() >= application.getStartTime())); } @@ -363,6 +363,7 @@ private void sendAttemptUpdateSavedEvent(RMApp application) { application.getCurrentAppAttempt().handle( new RMAppAttemptEvent(application.getCurrentAppAttempt().getAppAttemptId(), RMAppAttemptEventType.ATTEMPT_UPDATE_SAVED)); + rmDispatcher.await(); } protected RMApp testCreateAppNewSaving( @@ -411,8 +412,8 @@ protected RMApp testCreateAppAccepted( ApplicationSubmissionContext submissionContext) throws IOException { RMApp application = testCreateAppSubmittedNoRecovery(submissionContext); // SUBMITTED => ACCEPTED event RMAppEventType.APP_ACCEPTED - RMAppEvent event = - new RMAppEvent(application.getApplicationId(), + RMAppEvent event = + new RMAppEvent(application.getApplicationId(), RMAppEventType.APP_ACCEPTED); application.handle(event); assertStartTimeSet(application); @@ -424,8 +425,8 @@ protected RMApp testCreateAppRunning( ApplicationSubmissionContext submissionContext) throws IOException { RMApp application = testCreateAppAccepted(submissionContext); // ACCEPTED => RUNNING event RMAppEventType.ATTEMPT_REGISTERED - RMAppEvent event = - new RMAppEvent(application.getApplicationId(), + RMAppEvent event = + new RMAppEvent(application.getApplicationId(), RMAppEventType.ATTEMPT_REGISTERED); application.handle(event); assertStartTimeSet(application); @@ -669,24 +670,24 @@ public void testAppAcceptedFailed() throws IOException { // ACCEPTED => ACCEPTED event RMAppEventType.RMAppEventType.ATTEMPT_FAILED Assert.assertTrue(maxAppAttempts > 1); for (int i=1; i < maxAppAttempts; i++) { - RMAppEvent event = - new RMAppFailedAttemptEvent(application.getApplicationId(), + RMAppEvent event = + new RMAppFailedAttemptEvent(application.getApplicationId(), RMAppEventType.ATTEMPT_FAILED, "", false); application.handle(event); assertAppState(RMAppState.ACCEPTED, application); - event = - new RMAppEvent(application.getApplicationId(), + event = + new RMAppEvent(application.getApplicationId(), RMAppEventType.APP_ACCEPTED); application.handle(event); rmDispatcher.await(); assertAppState(RMAppState.ACCEPTED, application); } - // ACCEPTED => FAILED event RMAppEventType.RMAppEventType.ATTEMPT_FAILED + // ACCEPTED => FAILED event RMAppEventType.RMAppEventType.ATTEMPT_FAILED // after max application attempts String message = "Test fail"; - RMAppEvent event = - new RMAppFailedAttemptEvent(application.getApplicationId(), + RMAppEvent event = + new RMAppFailedAttemptEvent(application.getApplicationId(), RMAppEventType.ATTEMPT_FAILED, message, false); application.handle(event); rmDispatcher.await(); @@ -769,13 +770,13 @@ public void testAppRunningFailed() throws IOException { RMApp application = testCreateAppRunning(null); RMAppAttempt appAttempt = application.getCurrentAppAttempt(); int expectedAttemptId = 1; - Assert.assertEquals(expectedAttemptId, + Assert.assertEquals(expectedAttemptId, appAttempt.getAppAttemptId().getAttemptId()); // RUNNING => FAILED/RESTARTING event RMAppEventType.ATTEMPT_FAILED Assert.assertTrue(maxAppAttempts > 1); for (int i=1; i FAILED/RESTARTING event RMAppEventType.ATTEMPT_FAILED + // RUNNING => FAILED/RESTARTING event RMAppEventType.ATTEMPT_FAILED // after max application attempts - RMAppEvent event = - new RMAppFailedAttemptEvent(application.getApplicationId(), + RMAppEvent event = + new RMAppFailedAttemptEvent(application.getApplicationId(), RMAppEventType.ATTEMPT_FAILED, "", false); application.handle(event); rmDispatcher.await(); @@ -934,8 +935,8 @@ public void testAppKilledKilled() throws IOException { assertAppState(RMAppState.KILLED, application); // KILLED => KILLED event RMAppEventType.ATTEMPT_FAILED - event = - new RMAppFailedAttemptEvent(application.getApplicationId(), + event = + new RMAppFailedAttemptEvent(application.getApplicationId(), RMAppEventType.ATTEMPT_FAILED, "", false); application.handle(event); rmDispatcher.await();