|
@@ -18,6 +18,7 @@
|
|
|
|
|
|
package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
|
|
package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
|
|
|
|
|
|
|
|
+import static org.junit.Assert.assertEquals;
|
|
import static org.junit.Assert.assertTrue;
|
|
import static org.junit.Assert.assertTrue;
|
|
import static org.junit.Assert.fail;
|
|
import static org.junit.Assert.fail;
|
|
import static org.mockito.Mockito.mock;
|
|
import static org.mockito.Mockito.mock;
|
|
@@ -39,6 +40,7 @@ public class TestReservationQueue {
|
|
|
|
|
|
CapacitySchedulerConfiguration csConf;
|
|
CapacitySchedulerConfiguration csConf;
|
|
CapacitySchedulerContext csContext;
|
|
CapacitySchedulerContext csContext;
|
|
|
|
+ final static int DEF_MAX_APPS = 10000;
|
|
final static int GB = 1024;
|
|
final static int GB = 1024;
|
|
private final ResourceCalculator resourceCalculator =
|
|
private final ResourceCalculator resourceCalculator =
|
|
new DefaultResourceCalculator();
|
|
new DefaultResourceCalculator();
|
|
@@ -66,7 +68,13 @@ public class TestReservationQueue {
|
|
// create a queue
|
|
// create a queue
|
|
PlanQueue pq = new PlanQueue(csContext, "root", null, null);
|
|
PlanQueue pq = new PlanQueue(csContext, "root", null, null);
|
|
reservationQueue = new ReservationQueue(csContext, "a", pq);
|
|
reservationQueue = new ReservationQueue(csContext, "a", pq);
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ private void validateReservationQueue(double capacity) {
|
|
|
|
+ assertTrue(" actual capacity: " + reservationQueue.getCapacity(),
|
|
|
|
+ reservationQueue.getCapacity() - capacity < CSQueueUtils.EPSILON);
|
|
|
|
+ assertEquals(reservationQueue.maxApplications, DEF_MAX_APPS);
|
|
|
|
+ assertEquals(reservationQueue.maxApplicationsPerUser, DEF_MAX_APPS);
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
@@ -74,25 +82,20 @@ public class TestReservationQueue {
|
|
|
|
|
|
// verify that setting, adding, subtracting capacity works
|
|
// verify that setting, adding, subtracting capacity works
|
|
reservationQueue.setCapacity(1.0F);
|
|
reservationQueue.setCapacity(1.0F);
|
|
- assertTrue(" actual capacity: " + reservationQueue.getCapacity(),
|
|
|
|
- reservationQueue.getCapacity() - 1 < CSQueueUtils.EPSILON);
|
|
|
|
|
|
+ validateReservationQueue(1);
|
|
reservationQueue.setEntitlement(new QueueEntitlement(0.9f, 1f));
|
|
reservationQueue.setEntitlement(new QueueEntitlement(0.9f, 1f));
|
|
- assertTrue(" actual capacity: " + reservationQueue.getCapacity(),
|
|
|
|
- reservationQueue.getCapacity() - 0.9 < CSQueueUtils.EPSILON);
|
|
|
|
|
|
+ validateReservationQueue(0.9);
|
|
reservationQueue.setEntitlement(new QueueEntitlement(1f, 1f));
|
|
reservationQueue.setEntitlement(new QueueEntitlement(1f, 1f));
|
|
- assertTrue(" actual capacity: " + reservationQueue.getCapacity(),
|
|
|
|
- reservationQueue.getCapacity() - 1 < CSQueueUtils.EPSILON);
|
|
|
|
|
|
+ validateReservationQueue(1);
|
|
reservationQueue.setEntitlement(new QueueEntitlement(0f, 1f));
|
|
reservationQueue.setEntitlement(new QueueEntitlement(0f, 1f));
|
|
- assertTrue(" actual capacity: " + reservationQueue.getCapacity(),
|
|
|
|
- reservationQueue.getCapacity() < CSQueueUtils.EPSILON);
|
|
|
|
|
|
+ validateReservationQueue(0);
|
|
|
|
|
|
try {
|
|
try {
|
|
reservationQueue.setEntitlement(new QueueEntitlement(1.1f, 1f));
|
|
reservationQueue.setEntitlement(new QueueEntitlement(1.1f, 1f));
|
|
fail();
|
|
fail();
|
|
} catch (SchedulerDynamicEditException iae) {
|
|
} catch (SchedulerDynamicEditException iae) {
|
|
// expected
|
|
// expected
|
|
- assertTrue(" actual capacity: " + reservationQueue.getCapacity(),
|
|
|
|
- reservationQueue.getCapacity() - 1 < CSQueueUtils.EPSILON);
|
|
|
|
|
|
+ validateReservationQueue(1);
|
|
}
|
|
}
|
|
|
|
|
|
try {
|
|
try {
|
|
@@ -100,8 +103,7 @@ public class TestReservationQueue {
|
|
fail();
|
|
fail();
|
|
} catch (SchedulerDynamicEditException iae) {
|
|
} catch (SchedulerDynamicEditException iae) {
|
|
// expected
|
|
// expected
|
|
- assertTrue(" actual capacity: " + reservationQueue.getCapacity(),
|
|
|
|
- reservationQueue.getCapacity() - 1 < CSQueueUtils.EPSILON);
|
|
|
|
|
|
+ validateReservationQueue(1);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|