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