@Test public void testAppSuccessPath() throws IOException { LOG.info("--- START: testAppSuccessPath ---"); final String diagMsg = "some diagnostics"; RMApp application = testCreateAppFinished(null, diagMsg); Assert.assertTrue("Finished application missing diagnostics", application.getDiagnostics().indexOf(diagMsg) != -1); verifyRMAppFieldsForFinalTransitions(application); }
@Test public void testAppFinishedFinished() throws IOException { LOG.info("--- START: testAppFinishedFinished ---"); RMApp application = testCreateAppFinished(null, ""); // FINISHED => FINISHED event RMAppEventType.KILL RMAppEvent event = new RMAppEvent(application.getApplicationId(), RMAppEventType.KILL, "Application killed by user."); application.handle(event); rmDispatcher.await(); assertTimesAtFinish(application); assertAppState(RMAppState.FINISHED, application); StringBuilder diag = application.getDiagnostics(); Assert.assertEquals("application diagnostics is not correct", "", diag.toString()); verifyApplicationFinished(RMAppState.FINISHED); verifyRMAppFieldsForFinalTransitions(application); }
@Test public void testAppNewReject() throws IOException { LOG.info("--- START: testAppNewReject ---"); RMApp application = createNewTestApp(null); // NEW => FAILED event RMAppEventType.APP_REJECTED String rejectedText = "Test Application Rejected"; RMAppEvent event = new RMAppEvent(application.getApplicationId(), RMAppEventType.APP_REJECTED, rejectedText); application.handle(event); rmDispatcher.await(); sendAppUpdateSavedEvent(application); assertFailed(application, rejectedText); assertAppFinalStateSaved(application); verifyApplicationFinished(RMAppState.FAILED); verifyRMAppFieldsForFinalTransitions(application); }
@Test (timeout = 30000) public void testAppSubmittedRejected() throws IOException { LOG.info("--- START: testAppSubmittedRejected ---"); RMApp application = testCreateAppSubmittedNoRecovery(null); // SUBMITTED => FAILED event RMAppEventType.APP_REJECTED String rejectedText = "app rejected"; RMAppEvent event = new RMAppEvent(application.getApplicationId(), RMAppEventType.APP_REJECTED, rejectedText); application.handle(event); rmDispatcher.await(); sendAppUpdateSavedEvent(application); assertFailed(application, rejectedText); assertAppFinalStateSaved(application); verifyApplicationFinished(RMAppState.FAILED); verifyRMAppFieldsForFinalTransitions(application); }
@Test (timeout = 30000) public void testAppNewSavingReject() throws IOException { LOG.info("--- START: testAppNewSavingReject ---"); RMApp application = testCreateAppNewSaving(null); // NEW_SAVING => FAILED event RMAppEventType.APP_REJECTED String rejectedText = "Test Application Rejected"; RMAppEvent event = new RMAppEvent(application.getApplicationId(), RMAppEventType.APP_REJECTED, rejectedText); application.handle(event); rmDispatcher.await(); sendAppUpdateSavedEvent(application); assertFailed(application, rejectedText); assertAppFinalStateSaved(application); verifyApplicationFinished(RMAppState.FAILED); verifyRMAppFieldsForFinalTransitions(application); }
@Test public void testUnmanagedApp() throws IOException { ApplicationSubmissionContext subContext = new ApplicationSubmissionContextPBImpl(); subContext.setUnmanagedAM(true); // test success path LOG.info("--- START: testUnmanagedAppSuccessPath ---"); final String diagMsg = "some diagnostics"; RMApp application = testCreateAppFinished(subContext, diagMsg); Assert.assertTrue("Finished app missing diagnostics", application.getDiagnostics().indexOf(diagMsg) != -1); // reset the counter of Mockito.verify reset(writer); reset(publisher); // test app fails after 1 app attempt failure LOG.info("--- START: testUnmanagedAppFailPath ---"); application = testCreateAppRunning(subContext); RMAppEvent event = new RMAppFailedAttemptEvent( application.getApplicationId(), RMAppEventType.ATTEMPT_FAILED, "", false); application.handle(event); rmDispatcher.await(); RMAppAttempt appAttempt = application.getCurrentAppAttempt(); Assert.assertEquals(1, appAttempt.getAppAttemptId().getAttemptId()); sendAppUpdateSavedEvent(application); assertFailed(application, ".*Unmanaged application.*Failing the application.*"); assertAppFinalStateSaved(application); verifyRMAppFieldsForFinalTransitions(application); }
@Test (timeout = 30000) public void testAppNewSavingKill() throws IOException { LOG.info("--- START: testAppNewSavingKill ---"); RMApp application = testCreateAppNewSaving(null); // NEW_SAVING => KILLED event RMAppEventType.KILL UserGroupInformation fooUser = UserGroupInformation.createUserForTesting( "fooTestAppNewSavingKill", new String[] {"foo_group"}); RMAppEvent event = new RMAppKillByClientEvent( application.getApplicationId(), "Application killed by user.", fooUser, Server.getRemoteIp()); application.handle(event); rmDispatcher.await(); sendAppUpdateSavedEvent(application); assertKilled(application); verifyApplicationFinished(RMAppState.KILLED); verifyAppRemovedSchedulerEvent(RMAppState.KILLED); verifyRMAppFieldsForFinalTransitions(application); }
@Test (timeout = 30000) public void testAppNewRejectAddToStore() throws IOException { LOG.info("--- START: testAppNewRejectAddToStore ---"); RMApp application = createNewTestApp(null); // NEW => FAILED event RMAppEventType.APP_REJECTED String rejectedText = "Test Application Rejected"; RMAppEvent event = new RMAppEvent(application.getApplicationId(), RMAppEventType.APP_REJECTED, rejectedText); application.handle(event); rmDispatcher.await(); sendAppUpdateSavedEvent(application); assertFailed(application, rejectedText); assertAppFinalStateSaved(application); verifyApplicationFinished(RMAppState.FAILED); verifyRMAppFieldsForFinalTransitions(application); rmContext.getStateStore().removeApplication(application); }
@Test public void testAppFinalSavingToFinished() throws IOException { LOG.info("--- START: testAppFinalSavingToFinished ---"); RMApp application = testCreateAppFinalSaving(null); final String diagMsg = "some diagnostics"; // attempt_finished event comes before attempt_saved event RMAppEvent event = new RMAppEvent(application.getApplicationId(), RMAppEventType.ATTEMPT_FINISHED, diagMsg); application.handle(event); assertAppState(RMAppState.FINAL_SAVING, application); RMAppEvent appUpdated = new RMAppEvent(application.getApplicationId(), RMAppEventType.APP_UPDATE_SAVED); application.handle(appUpdated); assertAppState(RMAppState.FINISHED, application); assertTimesAtFinish(application); // finished without a proper unregister implies failed assertFinalAppStatus(FinalApplicationStatus.FAILED, application); Assert.assertTrue("Finished app missing diagnostics", application .getDiagnostics().indexOf(diagMsg) != -1); verifyRMAppFieldsForFinalTransitions(application); }
@Test public void testAppSubmittedKill() throws IOException, InterruptedException { LOG.info("--- START: testAppSubmittedKill---"); RMApp application = testCreateAppSubmittedNoRecovery(null); UserGroupInformation fooUser = UserGroupInformation.createUserForTesting( "fooTestAppSubmittedKill", new String[] {"foo_group"}); // SUBMITTED => KILLED event RMAppEventType.KILL RMAppEvent event = new RMAppKillByClientEvent( application.getApplicationId(), "Application killed by user.", fooUser, Server.getRemoteIp()); application.handle(event); rmDispatcher.await(); sendAppUpdateSavedEvent(application); assertKilled(application); assertAppFinalStateSaved(application); verifyApplicationFinished(RMAppState.KILLED); verifyAppRemovedSchedulerEvent(RMAppState.KILLED); verifyRMAppFieldsForFinalTransitions(application); }
@Test (timeout = 30000) public void testAppNewKill() throws IOException { LOG.info("--- START: testAppNewKill ---"); UserGroupInformation fooUser = UserGroupInformation.createUserForTesting( "fooTestAppNewKill", new String[] {"foo_group"}); RMApp application = createNewTestApp(null); // NEW => KILLED event RMAppEventType.KILL RMAppEvent event = new RMAppKillByClientEvent( application.getApplicationId(), "Application killed by user.", fooUser, Server.getRemoteIp()); application.handle(event); rmDispatcher.await(); sendAppUpdateSavedEvent(application); assertKilled(application); assertAppFinalStateNotSaved(application); verifyApplicationFinished(RMAppState.KILLED); verifyAppRemovedSchedulerEvent(RMAppState.KILLED); verifyRMAppFieldsForFinalTransitions(application); }
@Test public void testAppRunningKill() throws IOException { LOG.info("--- START: testAppRunningKill ---"); RMApp application = testCreateAppRunning(null); // RUNNING => KILLED event RMAppEventType.KILL UserGroupInformation fooUser = UserGroupInformation.createUserForTesting( "fooTestAppRunningKill", new String[] {"foo_group"}); // SUBMITTED => KILLED event RMAppEventType.KILL RMAppEvent event = new RMAppKillByClientEvent( application.getApplicationId(), "Application killed by user.", fooUser, Server.getRemoteIp()); application.handle(event); rmDispatcher.await(); sendAttemptUpdateSavedEvent(application); sendAppUpdateSavedEvent(application); assertKilled(application); verifyApplicationFinished(RMAppState.KILLED); verifyAppRemovedSchedulerEvent(RMAppState.KILLED); verifyRMAppFieldsForFinalTransitions(application); }
@Test (timeout = 30000) public void testAppFailedFailed() throws IOException { LOG.info("--- START: testAppFailedFailed ---"); RMApp application = testCreateAppNewSaving(null); // NEW_SAVING => FAILED event RMAppEventType.APP_REJECTED RMAppEvent event = new RMAppEvent(application.getApplicationId(), RMAppEventType.APP_REJECTED, ""); application.handle(event); rmDispatcher.await(); sendAppUpdateSavedEvent(application); assertTimesAtFinish(application); assertAppState(RMAppState.FAILED, application); // FAILED => FAILED event RMAppEventType.KILL event = new RMAppEvent(application.getApplicationId(), RMAppEventType.KILL, "Application killed by user."); application.handle(event); rmDispatcher.await(); assertTimesAtFinish(application); assertAppState(RMAppState.FAILED, application); verifyApplicationFinished(RMAppState.FAILED); assertTimesAtFinish(application); assertAppState(RMAppState.FAILED, application); verifyRMAppFieldsForFinalTransitions(application); }
@Test public void testAppAcceptedKill() throws IOException, InterruptedException { LOG.info("--- START: testAppAcceptedKill ---"); RMApp application = testCreateAppAccepted(null); // ACCEPTED => KILLED event RMAppEventType.KILL UserGroupInformation fooUser = UserGroupInformation.createUserForTesting( "fooTestAppAcceptedKill", new String[] {"foo_group"}); RMAppEvent event = new RMAppKillByClientEvent( application.getApplicationId(), "Application killed by user.", fooUser, Server.getRemoteIp()); application.handle(event); rmDispatcher.await(); assertAppState(RMAppState.KILLING, application); RMAppEvent appAttemptKilled = new RMAppEvent(application.getApplicationId(), RMAppEventType.ATTEMPT_KILLED, "Application killed by user."); application.handle(appAttemptKilled); assertAppState(RMAppState.FINAL_SAVING, application); sendAppUpdateSavedEvent(application); assertKilled(application); assertAppFinalStateSaved(application); verifyApplicationFinished(RMAppState.KILLED); verifyAppRemovedSchedulerEvent(RMAppState.KILLED); verifyRMAppFieldsForFinalTransitions(application); }
Assert.assertEquals("Application is not in finalState.", finalState, application.getState()); verifyRMAppFieldsForFinalTransitions(application);
verifyRMAppFieldsForFinalTransitions(application);
assertAppFinalStateSaved(application); verifyApplicationFinished(RMAppState.FAILED); verifyRMAppFieldsForFinalTransitions(application);