YARN-5114. Add additional tests in TestRMWebServicesApps and rectify testInvalidAppAttempts failure in 2.8. Contributed by Bibin A Chundatt

(cherry picked from commit edd716e99c)
This commit is contained in:
Naganarasimha 2016-05-25 06:11:38 +08:00
parent 56745a0cf4
commit 02323603e2
1 changed files with 41 additions and 3 deletions

View File

@ -1499,7 +1499,46 @@ public class TestRMWebServicesApps extends JerseyTestBase {
}
@Test
public void testInvalidAppAttempts() throws JSONException, Exception {
public void testInvalidAppIdGetAttempts() throws JSONException, Exception {
rm.start();
MockNM amNodeManager = rm.registerNode("127.0.0.1:1234", 2048);
RMApp app = rm.submitApp(CONTAINER_MB);
amNodeManager.nodeHeartbeat(true);
WebResource r = resource();
try {
r.path("ws").path("v1").path("cluster").path("apps")
.path("application_invalid_12").path("appattempts")
.accept(MediaType.APPLICATION_JSON)
.get(JSONObject.class);
fail("should have thrown exception on invalid appAttempt");
} catch (UniformInterfaceException ue) {
ClientResponse response = ue.getResponse();
assertEquals(Status.BAD_REQUEST, response.getClientResponseStatus());
assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
JSONObject msg = response.getEntity(JSONObject.class);
JSONObject exception = msg.getJSONObject("RemoteException");
assertEquals("incorrect number of elements", 3, exception.length());
String message = exception.getString("message");
String type = exception.getString("exception");
String classname = exception.getString("javaClassName");
WebServicesTestUtils.checkStringMatch("exception message",
"java.lang.IllegalArgumentException: Invalid ApplicationId:"
+ " application_invalid_12",
message);
WebServicesTestUtils.checkStringMatch("exception type",
"BadRequestException", type);
WebServicesTestUtils.checkStringMatch("exception classname",
"org.apache.hadoop.yarn.webapp.BadRequestException", classname);
} finally {
rm.stop();
}
}
@Test
public void testInvalidAppAttemptId() throws JSONException, Exception {
rm.start();
MockNM amNodeManager = rm.registerNode("127.0.0.1:1234", 2048);
RMApp app = rm.submitApp(CONTAINER_MB);
@ -1510,8 +1549,7 @@ public class TestRMWebServicesApps extends JerseyTestBase {
r.path("ws").path("v1").path("cluster").path("apps")
.path(app.getApplicationId().toString()).path("appattempts")
.path("appattempt_invalid_12_000001")
.accept(MediaType.APPLICATION_JSON)
.get(JSONObject.class);
.accept(MediaType.APPLICATION_JSON).get(JSONObject.class);
fail("should have thrown exception on invalid appAttempt");
} catch (UniformInterfaceException ue) {
ClientResponse response = ue.getResponse();