use of org.apache.hadoop.yarn.api.records.ReservationId in project hadoop by apache.
the class TestReservationInputValidator method testDeleteReservationInvalidPlan.
@Test
public void testDeleteReservationInvalidPlan() {
ReservationDeleteRequest request = new ReservationDeleteRequestPBImpl();
ReservationId reservationID = ReservationSystemTestUtil.getNewReservationId();
request.setReservationId(reservationID);
when(rSystem.getPlan(PLAN_NAME)).thenReturn(null);
Plan plan = null;
try {
plan = rrValidator.validateReservationDeleteRequest(rSystem, request);
Assert.fail();
} catch (YarnException e) {
Assert.assertNull(plan);
String message = e.getMessage();
Assert.assertTrue(message.endsWith(" is not associated with any valid plan. Please try again with a valid reservation."));
LOG.info(message);
}
}
use of org.apache.hadoop.yarn.api.records.ReservationId in project hadoop by apache.
the class TestReservationInputValidator method testDeleteReservationDoesnotExist.
@Test
public void testDeleteReservationDoesnotExist() {
ReservationDeleteRequest request = new ReservationDeleteRequestPBImpl();
ReservationId rId = ReservationSystemTestUtil.getNewReservationId();
request.setReservationId(rId);
when(rSystem.getQueueForReservation(rId)).thenReturn(null);
Plan plan = null;
try {
plan = rrValidator.validateReservationDeleteRequest(rSystem, request);
Assert.fail();
} catch (YarnException e) {
Assert.assertNull(plan);
String message = e.getMessage();
Assert.assertTrue(message.equals(MessageFormat.format("The specified reservation with ID: {0} is unknown. Please try again with a valid reservation.", rId)));
LOG.info(message);
}
}
use of org.apache.hadoop.yarn.api.records.ReservationId in project hadoop by apache.
the class TestRMWebServicesReservation method testInvalidStartTimeRequestListReservation.
@Test
public void testInvalidStartTimeRequestListReservation() throws Exception {
rm.start();
setupCluster(100);
long time = clock.getTime() + MINIMUM_RESOURCE_DURATION;
ReservationId id1 = getReservationIdTestHelper(1);
ReservationId id2 = getReservationIdTestHelper(2);
reservationSubmissionTestHelper("reservation/submit", MediaType.APPLICATION_JSON, time, "res_1", id1);
reservationSubmissionTestHelper("reservation/submit", MediaType.APPLICATION_JSON, time + MINIMUM_RESOURCE_DURATION, "res_2", id2);
WebResource resource = constructWebResource(LIST_RESERVATION_PATH).queryParam("start-time", "-1").queryParam("end-time", new Long((long) (time + MINIMUM_RESOURCE_DURATION * 0.9)).toString()).queryParam("include-resource-allocations", "true").queryParam("queue", DEFAULT_QUEUE);
JSONObject json = testListReservationHelper(resource);
if (!this.isAuthenticationEnabled() && json == null) {
return;
}
JSONObject reservations = json.getJSONObject("reservations");
testRDLHelper(reservations);
// only res_1 should fall into the time interval given in the request json.
String reservationName = reservations.getJSONObject("reservation-definition").getString("reservation-name");
assertEquals(reservationName, "res_1");
rm.stop();
}
use of org.apache.hadoop.yarn.api.records.ReservationId in project hadoop by apache.
the class TestRMWebServicesReservation method testIncludeResourceAllocations.
@Test
public void testIncludeResourceAllocations() throws Exception {
rm.start();
setupCluster(100);
ReservationId id1 = getReservationIdTestHelper(1);
reservationSubmissionTestHelper("reservation/submit", MediaType.APPLICATION_JSON, clock.getTime(), "res_1", id1);
WebResource resource = constructWebResource(LIST_RESERVATION_PATH).queryParam("include-resource-allocations", "true").queryParam("queue", DEFAULT_QUEUE);
if (id1 != null) {
resource = resource.queryParam("reservation-id", id1.toString());
}
JSONObject json = testListReservationHelper(resource);
if (!this.isAuthenticationEnabled() && json == null) {
return;
}
JSONObject reservations = json.getJSONObject("reservations");
testRDLHelper(reservations);
String reservationId = reservations.getString("reservation-id");
assertEquals(id1.toString(), reservationId);
assertTrue(reservations.has("resource-allocations"));
rm.stop();
}
use of org.apache.hadoop.yarn.api.records.ReservationId in project hadoop by apache.
the class TestRMWebServicesReservation method testExcludeResourceAllocations.
@Test
public void testExcludeResourceAllocations() throws Exception {
rm.start();
setupCluster(100);
ReservationId id1 = getReservationIdTestHelper(1);
reservationSubmissionTestHelper("reservation/submit", MediaType.APPLICATION_JSON, clock.getTime(), "res_1", id1);
WebResource resource = constructWebResource(LIST_RESERVATION_PATH).queryParam("include-resource-allocations", "false").queryParam("queue", DEFAULT_QUEUE);
if (id1 != null) {
resource = resource.queryParam("reservation-id", id1.toString());
}
JSONObject json = testListReservationHelper(resource);
if (!this.isAuthenticationEnabled() && json == null) {
return;
}
JSONObject reservations = json.getJSONObject("reservations");
testRDLHelper(reservations);
String reservationId = reservations.getString("reservation-id");
assertEquals(id1.toString(), reservationId);
assertTrue(!reservations.has("resource-allocations"));
rm.stop();
}
Aggregations