|
@@ -157,12 +157,9 @@ public class TestYarnClient {
|
|
|
|
|
|
YarnApplicationState[] exitStates = new YarnApplicationState[]
|
|
|
{
|
|
|
- YarnApplicationState.SUBMITTED,
|
|
|
YarnApplicationState.ACCEPTED,
|
|
|
YarnApplicationState.RUNNING,
|
|
|
- YarnApplicationState.FINISHED,
|
|
|
- YarnApplicationState.FAILED,
|
|
|
- YarnApplicationState.KILLED
|
|
|
+ YarnApplicationState.FINISHED
|
|
|
};
|
|
|
|
|
|
// Submit an application without ApplicationId provided
|
|
@@ -203,6 +200,54 @@ public class TestYarnClient {
|
|
|
client.stop();
|
|
|
}
|
|
|
|
|
|
+ @Test (timeout = 30000)
|
|
|
+ public void testSubmitIncorrectQueue() throws IOException {
|
|
|
+ MiniYARNCluster cluster = new MiniYARNCluster("testMRAMTokens", 1, 1, 1);
|
|
|
+ YarnClient rmClient = null;
|
|
|
+ try {
|
|
|
+ cluster.init(new YarnConfiguration());
|
|
|
+ cluster.start();
|
|
|
+ final Configuration yarnConf = cluster.getConfig();
|
|
|
+ rmClient = YarnClient.createYarnClient();
|
|
|
+ rmClient.init(yarnConf);
|
|
|
+ rmClient.start();
|
|
|
+ YarnClientApplication newApp = rmClient.createApplication();
|
|
|
+
|
|
|
+ ApplicationId appId = newApp.getNewApplicationResponse().getApplicationId();
|
|
|
+
|
|
|
+ // Create launch context for app master
|
|
|
+ ApplicationSubmissionContext appContext
|
|
|
+ = Records.newRecord(ApplicationSubmissionContext.class);
|
|
|
+
|
|
|
+ // set the application id
|
|
|
+ appContext.setApplicationId(appId);
|
|
|
+
|
|
|
+ // set the application name
|
|
|
+ appContext.setApplicationName("test");
|
|
|
+
|
|
|
+ // Set the queue to which this application is to be submitted in the RM
|
|
|
+ appContext.setQueue("nonexist");
|
|
|
+
|
|
|
+ // Set up the container launch context for the application master
|
|
|
+ ContainerLaunchContext amContainer
|
|
|
+ = Records.newRecord(ContainerLaunchContext.class);
|
|
|
+ appContext.setAMContainerSpec(amContainer);
|
|
|
+ appContext.setResource(Resource.newInstance(1024, 1));
|
|
|
+ // appContext.setUnmanagedAM(unmanaged);
|
|
|
+
|
|
|
+ // Submit the application to the applications manager
|
|
|
+ rmClient.submitApplication(appContext);
|
|
|
+ Assert.fail("Job submission should have thrown an exception");
|
|
|
+ } catch (YarnException e) {
|
|
|
+ Assert.assertTrue(e.getMessage().contains("Failed to submit"));
|
|
|
+ } finally {
|
|
|
+ if (rmClient != null) {
|
|
|
+ rmClient.stop();
|
|
|
+ }
|
|
|
+ cluster.stop();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Test
|
|
|
public void testKillApplication() throws Exception {
|
|
|
MockRM rm = new MockRM();
|
|
@@ -998,7 +1043,7 @@ public class TestYarnClient {
|
|
|
public ApplicationReport getApplicationReport(ApplicationId appId) {
|
|
|
ApplicationReport report = mock(ApplicationReport.class);
|
|
|
when(report.getYarnApplicationState())
|
|
|
- .thenReturn(YarnApplicationState.SUBMITTED);
|
|
|
+ .thenReturn(YarnApplicationState.RUNNING);
|
|
|
return report;
|
|
|
}
|
|
|
|