@Test public void testFetchReportAHSDisabled() throws YarnException, IOException { try { testHelper(false); } catch (ApplicationNotFoundException e) { Assert.assertTrue(e.getMessage() == appNotFoundExceptionMsg); /* RM will not know of the app and Application History Service is disabled * So we will not try to get the report from AHS and RM will throw * ApplicationNotFoundException */ } Mockito.verify(appManager, Mockito.times(1)) .getApplicationReport(Mockito.any(GetApplicationReportRequest.class)); if (historyManager != null) { Assert.fail("HistoryManager should be null as AHS is disabled"); } }
@Test public void testFetchReportAHSDisabled() throws YarnException, IOException { try { testHelper(false); } catch (ApplicationNotFoundException e) { Assert.assertTrue(e.getMessage() == appNotFoundExceptionMsg); /* RM will not know of the app and Application History Service is disabled * So we will not try to get the report from AHS and RM will throw * ApplicationNotFoundException */ } Mockito.verify(appManager, Mockito.times(1)) .getApplicationReport(Mockito.any(GetApplicationReportRequest.class)); if (historyManager != null) { Assert.fail("HistoryManager should be null as AHS is disabled"); } }
@Test public void testForceKillNonExistingApplication() throws YarnException { RMContext rmContext = mock(RMContext.class); when(rmContext.getRMApps()).thenReturn( new ConcurrentHashMap<ApplicationId, RMApp>()); ClientRMService rmService = new ClientRMService(rmContext, null, null, null, null, null); ApplicationId applicationId = BuilderUtils.newApplicationId(System.currentTimeMillis(), 0); KillApplicationRequest request = KillApplicationRequest.newInstance(applicationId); try { rmService.forceKillApplication(request); Assert.fail(); } catch (ApplicationNotFoundException ex) { Assert.assertEquals(ex.getMessage(), "Trying to kill an absent " + "application " + request.getApplicationId()); } }
@Test public void testForceKillNonExistingApplication() throws YarnException { RMContext rmContext = mock(RMContext.class); when(rmContext.getRMApps()).thenReturn( new ConcurrentHashMap<ApplicationId, RMApp>()); ClientRMService rmService = new ClientRMService(rmContext, null, null, null, null, null); ApplicationId applicationId = BuilderUtils.newApplicationId(System.currentTimeMillis(), 0); KillApplicationRequest request = KillApplicationRequest.newInstance(applicationId); try { rmService.forceKillApplication(request); Assert.fail(); } catch (ApplicationNotFoundException ex) { Assert.assertEquals(ex.getMessage(), "Trying to kill an absent " + "application " + request.getApplicationId()); } }
@Test public void testNonExistingApplicationReport() throws YarnException { RMContext rmContext = mock(RMContext.class); when(rmContext.getRMApps()).thenReturn( new ConcurrentHashMap<ApplicationId, RMApp>()); ClientRMService rmService = new ClientRMService(rmContext, null, null, null, null, null); RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null); GetApplicationReportRequest request = recordFactory .newRecordInstance(GetApplicationReportRequest.class); request.setApplicationId(ApplicationId.newInstance(0, 0)); try { rmService.getApplicationReport(request); Assert.fail(); } catch (ApplicationNotFoundException ex) { Assert.assertEquals(ex.getMessage(), "Application with id '" + request.getApplicationId() + "' doesn't exist in RM. Please check that the " + "job submission was successful."); } }
@Test public void testNonExistingApplicationReport() throws YarnException { RMContext rmContext = mock(RMContext.class); when(rmContext.getRMApps()).thenReturn( new ConcurrentHashMap<ApplicationId, RMApp>()); ClientRMService rmService = new ClientRMService(rmContext, null, null, null, null, null); RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null); GetApplicationReportRequest request = recordFactory .newRecordInstance(GetApplicationReportRequest.class); request.setApplicationId(ApplicationId.newInstance(0, 0)); try { rmService.getApplicationReport(request); Assert.fail(); } catch (ApplicationNotFoundException ex) { Assert.assertEquals(ex.getMessage(), "Application with id '" + request.getApplicationId() + "' doesn't exist in RM."); } }
@Test public void testApplicationNotFound() throws IOException, YarnException { ApplicationId appId = null; appId = ApplicationId.newInstance(0, MAX_APPS + 1); GetApplicationReportRequest request = GetApplicationReportRequest.newInstance(appId); try { @SuppressWarnings("unused") GetApplicationReportResponse response = clientService.getApplicationReport(request); Assert.fail("Exception should have been thrown before we reach here."); } catch (ApplicationNotFoundException e) { //This exception is expected. Assert.assertTrue(e.getMessage().contains( "doesn't exist in the timeline store")); } catch (Exception e) { Assert.fail("Undesired exception caught"); } }
fail("Should get an exception here"); } catch (ApplicationNotFoundException ex) { Assert.assertTrue(ex.getMessage().contains( "Trying to kill an absent application " + app0.getApplicationId()));
fail("Should get an exception here"); } catch (ApplicationNotFoundException ex) { Assert.assertTrue(ex.getMessage().contains( "Trying to kill an absent application " + app0.getApplicationId()));
@Test public void testGetApplicationAttempts() throws YarnException, IOException { ClientRMService rmService = createRMService(); RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null); GetApplicationAttemptsRequest request = recordFactory .newRecordInstance(GetApplicationAttemptsRequest.class); ApplicationAttemptId attemptId = ApplicationAttemptId.newInstance( ApplicationId.newInstance(123456, 1), 1); request.setApplicationId(ApplicationId.newInstance(123456, 1)); try { GetApplicationAttemptsResponse response = rmService .getApplicationAttempts(request); Assert.assertEquals(1, response.getApplicationAttemptList().size()); Assert.assertEquals(attemptId, response.getApplicationAttemptList() .get(0).getApplicationAttemptId()); } catch (ApplicationNotFoundException ex) { Assert.fail(ex.getMessage()); } }
@Test public void testGetApplicationAttempts() throws YarnException, IOException { ClientRMService rmService = createRMService(); RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null); GetApplicationAttemptsRequest request = recordFactory .newRecordInstance(GetApplicationAttemptsRequest.class); ApplicationAttemptId attemptId = ApplicationAttemptId.newInstance( ApplicationId.newInstance(123456, 1), 1); request.setApplicationId(ApplicationId.newInstance(123456, 1)); try { GetApplicationAttemptsResponse response = rmService .getApplicationAttempts(request); Assert.assertEquals(1, response.getApplicationAttemptList().size()); Assert.assertEquals(attemptId, response.getApplicationAttemptList() .get(0).getApplicationAttemptId()); } catch (ApplicationNotFoundException ex) { Assert.fail(ex.getMessage()); } }
@Test public void testGetContainers() throws YarnException, IOException { ClientRMService rmService = createRMService(); RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null); GetContainersRequest request = recordFactory .newRecordInstance(GetContainersRequest.class); ApplicationAttemptId attemptId = ApplicationAttemptId.newInstance( ApplicationId.newInstance(123456, 1), 1); ContainerId containerId = ContainerId.newContainerId(attemptId, 1); request.setApplicationAttemptId(attemptId); try { GetContainersResponse response = rmService.getContainers(request); Assert.assertEquals(containerId, response.getContainerList().get(0) .getContainerId()); } catch (ApplicationNotFoundException ex) { Assert.fail(ex.getMessage()); } }
@Test public void testGetContainers() throws YarnException, IOException { ClientRMService rmService = createRMService(); RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null); GetContainersRequest request = recordFactory .newRecordInstance(GetContainersRequest.class); ApplicationAttemptId attemptId = ApplicationAttemptId.newInstance( ApplicationId.newInstance(123456, 1), 1); ContainerId containerId = ContainerId.newContainerId(attemptId, 1); request.setApplicationAttemptId(attemptId); try { GetContainersResponse response = rmService.getContainers(request); Assert.assertEquals(containerId, response.getContainerList().get(0) .getContainerId()); } catch (ApplicationNotFoundException ex) { Assert.fail(ex.getMessage()); } }
@Test public void testGetApplicationAttemptReport() throws YarnException, IOException { ClientRMService rmService = createRMService(); RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null); GetApplicationAttemptReportRequest request = recordFactory .newRecordInstance(GetApplicationAttemptReportRequest.class); ApplicationAttemptId attemptId = ApplicationAttemptId.newInstance( ApplicationId.newInstance(123456, 1), 1); request.setApplicationAttemptId(attemptId); try { GetApplicationAttemptReportResponse response = rmService .getApplicationAttemptReport(request); Assert.assertEquals(attemptId, response.getApplicationAttemptReport() .getApplicationAttemptId()); } catch (ApplicationNotFoundException ex) { Assert.fail(ex.getMessage()); } }
@Test public void testGetApplicationAttemptReport() throws YarnException, IOException { ClientRMService rmService = createRMService(); RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null); GetApplicationAttemptReportRequest request = recordFactory .newRecordInstance(GetApplicationAttemptReportRequest.class); ApplicationAttemptId attemptId = ApplicationAttemptId.newInstance( ApplicationId.newInstance(123456, 1), 1); request.setApplicationAttemptId(attemptId); try { GetApplicationAttemptReportResponse response = rmService .getApplicationAttemptReport(request); Assert.assertEquals(attemptId, response.getApplicationAttemptReport() .getApplicationAttemptId()); } catch (ApplicationNotFoundException ex) { Assert.fail(ex.getMessage()); } }
@Test public void testGetContainerReport() throws YarnException, IOException { ClientRMService rmService = createRMService(); RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null); GetContainerReportRequest request = recordFactory .newRecordInstance(GetContainerReportRequest.class); ApplicationAttemptId attemptId = ApplicationAttemptId.newInstance( ApplicationId.newInstance(123456, 1), 1); ContainerId containerId = ContainerId.newContainerId(attemptId, 1); request.setContainerId(containerId); try { GetContainerReportResponse response = rmService .getContainerReport(request); Assert.assertEquals(containerId, response.getContainerReport() .getContainerId()); } catch (ApplicationNotFoundException ex) { Assert.fail(ex.getMessage()); } }
@Test public void testGetContainerReport() throws YarnException, IOException { ClientRMService rmService = createRMService(); RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null); GetContainerReportRequest request = recordFactory .newRecordInstance(GetContainerReportRequest.class); ApplicationAttemptId attemptId = ApplicationAttemptId.newInstance( ApplicationId.newInstance(123456, 1), 1); ContainerId containerId = ContainerId.newContainerId(attemptId, 1); request.setContainerId(containerId); try { GetContainerReportResponse response = rmService .getContainerReport(request); Assert.assertEquals(containerId, response.getContainerReport() .getContainerId()); } catch (ApplicationNotFoundException ex) { Assert.fail(ex.getMessage()); } }