YARN-7118. AHS REST API can return NullPointerException. (Billie Rinaldi via wangda)
Change-Id: I16ca93385ab80e3680d4d173b8d1b79929ea7174
This commit is contained in:
parent
e7199cb494
commit
179d8dc83c
|
@ -146,7 +146,11 @@ public class TestApplicationHistoryManagerOnTimelineStore {
|
||||||
} else if (i == 3) {
|
} else if (i == 3) {
|
||||||
entities.addEntity(createApplicationTimelineEntity(
|
entities.addEntity(createApplicationTimelineEntity(
|
||||||
appId, false, false, false, false, YarnApplicationState.FINISHED,
|
appId, false, false, false, false, YarnApplicationState.FINISHED,
|
||||||
true));
|
true, false));
|
||||||
|
} else if (i == SCALE + 1) {
|
||||||
|
entities.addEntity(createApplicationTimelineEntity(
|
||||||
|
appId, false, false, false, false, YarnApplicationState.FINISHED,
|
||||||
|
false, true));
|
||||||
} else {
|
} else {
|
||||||
entities.addEntity(createApplicationTimelineEntity(
|
entities.addEntity(createApplicationTimelineEntity(
|
||||||
appId, false, false, false, false, YarnApplicationState.FINISHED));
|
appId, false, false, false, false, YarnApplicationState.FINISHED));
|
||||||
|
@ -497,13 +501,14 @@ public class TestApplicationHistoryManagerOnTimelineStore {
|
||||||
boolean wrongAppId, boolean enableUpdateEvent,
|
boolean wrongAppId, boolean enableUpdateEvent,
|
||||||
YarnApplicationState state) {
|
YarnApplicationState state) {
|
||||||
return createApplicationTimelineEntity(appId, emptyACLs, noAttemptId,
|
return createApplicationTimelineEntity(appId, emptyACLs, noAttemptId,
|
||||||
wrongAppId, enableUpdateEvent, state, false);
|
wrongAppId, enableUpdateEvent, state, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static TimelineEntity createApplicationTimelineEntity(
|
private static TimelineEntity createApplicationTimelineEntity(
|
||||||
ApplicationId appId, boolean emptyACLs, boolean noAttemptId,
|
ApplicationId appId, boolean emptyACLs, boolean noAttemptId,
|
||||||
boolean wrongAppId, boolean enableUpdateEvent,
|
boolean wrongAppId, boolean enableUpdateEvent,
|
||||||
YarnApplicationState state, boolean missingPreemptMetrics) {
|
YarnApplicationState state, boolean missingPreemptMetrics,
|
||||||
|
boolean missingQueue) {
|
||||||
TimelineEntity entity = new TimelineEntity();
|
TimelineEntity entity = new TimelineEntity();
|
||||||
entity.setEntityType(ApplicationMetricsConstants.ENTITY_TYPE);
|
entity.setEntityType(ApplicationMetricsConstants.ENTITY_TYPE);
|
||||||
if (wrongAppId) {
|
if (wrongAppId) {
|
||||||
|
@ -519,7 +524,10 @@ public class TestApplicationHistoryManagerOnTimelineStore {
|
||||||
entityInfo.put(ApplicationMetricsConstants.TYPE_ENTITY_INFO,
|
entityInfo.put(ApplicationMetricsConstants.TYPE_ENTITY_INFO,
|
||||||
"test app type");
|
"test app type");
|
||||||
entityInfo.put(ApplicationMetricsConstants.USER_ENTITY_INFO, "user1");
|
entityInfo.put(ApplicationMetricsConstants.USER_ENTITY_INFO, "user1");
|
||||||
entityInfo.put(ApplicationMetricsConstants.QUEUE_ENTITY_INFO, "test queue");
|
if (!missingQueue) {
|
||||||
|
entityInfo.put(ApplicationMetricsConstants.QUEUE_ENTITY_INFO,
|
||||||
|
"test queue");
|
||||||
|
}
|
||||||
entityInfo.put(
|
entityInfo.put(
|
||||||
ApplicationMetricsConstants.UNMANAGED_APPLICATION_ENTITY_INFO, "false");
|
ApplicationMetricsConstants.UNMANAGED_APPLICATION_ENTITY_INFO, "false");
|
||||||
entityInfo.put(ApplicationMetricsConstants.APPLICATION_PRIORITY_INFO,
|
entityInfo.put(ApplicationMetricsConstants.APPLICATION_PRIORITY_INFO,
|
||||||
|
|
|
@ -98,7 +98,7 @@ public class TestAHSWebServices extends JerseyTestBase {
|
||||||
private static ApplicationHistoryClientService historyClientService;
|
private static ApplicationHistoryClientService historyClientService;
|
||||||
private static AHSWebServices ahsWebservice;
|
private static AHSWebServices ahsWebservice;
|
||||||
private static final String[] USERS = new String[] { "foo" , "bar" };
|
private static final String[] USERS = new String[] { "foo" , "bar" };
|
||||||
private static final int MAX_APPS = 5;
|
private static final int MAX_APPS = 6;
|
||||||
private static Configuration conf;
|
private static Configuration conf;
|
||||||
private static FileSystem fs;
|
private static FileSystem fs;
|
||||||
private static final String remoteLogRootDir = "target/logs/";
|
private static final String remoteLogRootDir = "target/logs/";
|
||||||
|
@ -361,7 +361,26 @@ public class TestAHSWebServices extends JerseyTestBase {
|
||||||
JSONObject apps = json.getJSONObject("apps");
|
JSONObject apps = json.getJSONObject("apps");
|
||||||
assertEquals("incorrect number of elements", 1, apps.length());
|
assertEquals("incorrect number of elements", 1, apps.length());
|
||||||
JSONArray array = apps.getJSONArray("app");
|
JSONArray array = apps.getJSONArray("app");
|
||||||
assertEquals("incorrect number of elements", 5, array.length());
|
assertEquals("incorrect number of elements", MAX_APPS, array.length());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testQueueQuery() throws Exception {
|
||||||
|
WebResource r = resource();
|
||||||
|
ClientResponse response =
|
||||||
|
r.path("ws").path("v1").path("applicationhistory").path("apps")
|
||||||
|
.queryParam("queue", "test queue")
|
||||||
|
.queryParam("user.name", USERS[round])
|
||||||
|
.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
|
||||||
|
assertEquals(Status.OK, response.getClientResponseStatus());
|
||||||
|
assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
|
||||||
|
JSONObject json = response.getEntity(JSONObject.class);
|
||||||
|
assertEquals("incorrect number of elements", 1, json.length());
|
||||||
|
JSONObject apps = json.getJSONObject("apps");
|
||||||
|
assertEquals("incorrect number of elements", 1, apps.length());
|
||||||
|
JSONArray array = apps.getJSONArray("app");
|
||||||
|
assertEquals("incorrect number of elements", MAX_APPS - 1,
|
||||||
|
array.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -410,7 +429,7 @@ public class TestAHSWebServices extends JerseyTestBase {
|
||||||
JSONObject appAttempts = json.getJSONObject("appAttempts");
|
JSONObject appAttempts = json.getJSONObject("appAttempts");
|
||||||
assertEquals("incorrect number of elements", 1, appAttempts.length());
|
assertEquals("incorrect number of elements", 1, appAttempts.length());
|
||||||
JSONArray array = appAttempts.getJSONArray("appAttempt");
|
JSONArray array = appAttempts.getJSONArray("appAttempt");
|
||||||
assertEquals("incorrect number of elements", 5, array.length());
|
assertEquals("incorrect number of elements", MAX_APPS, array.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -467,7 +486,7 @@ public class TestAHSWebServices extends JerseyTestBase {
|
||||||
JSONObject containers = json.getJSONObject("containers");
|
JSONObject containers = json.getJSONObject("containers");
|
||||||
assertEquals("incorrect number of elements", 1, containers.length());
|
assertEquals("incorrect number of elements", 1, containers.length());
|
||||||
JSONArray array = containers.getJSONArray("container");
|
JSONArray array = containers.getJSONArray("container");
|
||||||
assertEquals("incorrect number of elements", 5, array.length());
|
assertEquals("incorrect number of elements", MAX_APPS, array.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -192,7 +192,8 @@ public class WebServices {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (queueQuery != null && !queueQuery.isEmpty()) {
|
if (queueQuery != null && !queueQuery.isEmpty()) {
|
||||||
if (!appReport.getQueue().equals(queueQuery)) {
|
if (appReport.getQueue() == null || !appReport.getQueue()
|
||||||
|
.equals(queueQuery)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue