|
@@ -1413,6 +1413,37 @@ public class TestFairScheduler {
|
|
|
assertEquals(1, app2.getLiveContainers().size());
|
|
|
}
|
|
|
|
|
|
+ @Test(timeout = 3000)
|
|
|
+ public void testMaxAssign() throws AllocationConfigurationException {
|
|
|
+ // set required scheduler configs
|
|
|
+ scheduler.assignMultiple = true;
|
|
|
+ scheduler.getQueueManager().getLeafQueue("root.default")
|
|
|
+ .setPolicy(SchedulingPolicy.getDefault());
|
|
|
+
|
|
|
+ RMNode node = MockNodes.newNodeInfo(1, Resources.createResource(16384));
|
|
|
+ NodeAddedSchedulerEvent nodeEvent = new NodeAddedSchedulerEvent(node);
|
|
|
+ NodeUpdateSchedulerEvent updateEvent = new NodeUpdateSchedulerEvent(node);
|
|
|
+ scheduler.handle(nodeEvent);
|
|
|
+
|
|
|
+ ApplicationAttemptId attId =
|
|
|
+ createSchedulingRequest(1024, "root.default", "user", 8);
|
|
|
+ FSSchedulerApp app = scheduler.applications.get(attId);
|
|
|
+
|
|
|
+ // set maxAssign to 2: only 2 containers should be allocated
|
|
|
+ scheduler.maxAssign = 2;
|
|
|
+ scheduler.update();
|
|
|
+ scheduler.handle(updateEvent);
|
|
|
+ assertEquals("Incorrect number of containers allocated", 2, app
|
|
|
+ .getLiveContainers().size());
|
|
|
+
|
|
|
+ // set maxAssign to -1: all remaining containers should be allocated
|
|
|
+ scheduler.maxAssign = -1;
|
|
|
+ scheduler.update();
|
|
|
+ scheduler.handle(updateEvent);
|
|
|
+ assertEquals("Incorrect number of containers allocated", 8, app
|
|
|
+ .getLiveContainers().size());
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Test to verify the behavior of
|
|
|
* {@link FSQueue#assignContainer(FSSchedulerNode)})
|