|
@@ -5525,4 +5525,128 @@ public class TestFairScheduler extends FairSchedulerTestBase {
|
|
|
|
|
|
createSchedulingRequest(memory, vCores, "queueA", "user1", 1, 2);
|
|
createSchedulingRequest(memory, vCores, "queueA", "user1", 1, 2);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Test
|
|
|
|
+ public void testRestoreToExistingQueue() throws IOException {
|
|
|
|
+ conf.set(FairSchedulerConfiguration.ALLOCATION_FILE, ALLOC_FILE);
|
|
|
|
+ generateAllocationFilePercentageResource();
|
|
|
|
+
|
|
|
|
+ scheduler.init(conf);
|
|
|
|
+ scheduler.start();
|
|
|
|
+ scheduler.reinitialize(conf, resourceManager.getRMContext());
|
|
|
|
+
|
|
|
|
+ // no nodes so the resource total should be zero for all queues
|
|
|
|
+ // AM is using resources
|
|
|
|
+ Resource amResource = Resources.createResource(1024, 1);
|
|
|
|
+ // Add the app and the attempt
|
|
|
|
+ ApplicationAttemptId appAttemptId = null;
|
|
|
|
+ String queueId = "root.parent.queueA";
|
|
|
|
+ try {
|
|
|
|
+ appAttemptId = createRecoveringApplication(amResource, queueId, "user1");
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ fail("The exception is not expected. Exception message: "
|
|
|
|
+ + e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ scheduler.addApplicationAttempt(appAttemptId, false, true);
|
|
|
|
+
|
|
|
|
+ List<ApplicationAttemptId> appsInQueue =
|
|
|
|
+ scheduler.getAppsInQueue(queueId);
|
|
|
|
+ assertEquals("Number of apps in queue 'root.parent.queueA' should be one!",
|
|
|
|
+ 1, appsInQueue.size());
|
|
|
|
+
|
|
|
|
+ appAttemptId = scheduler.getAppsInQueue(queueId).get(0);
|
|
|
|
+ assertNotNull("Scheduler app for appAttemptId " + appAttemptId
|
|
|
|
+ + " should not be null!", scheduler.getSchedulerApp(appAttemptId));
|
|
|
|
+
|
|
|
|
+ FSAppAttempt schedulerApp = scheduler.getSchedulerApp(appAttemptId);
|
|
|
|
+ assertNotNull("Scheduler app queueInfo for appAttemptId " + appAttemptId
|
|
|
|
+ + " should not be null!", schedulerApp.getAppSchedulingInfo());
|
|
|
|
+
|
|
|
|
+ assertTrue("There should be no requests accepted", schedulerApp
|
|
|
|
+ .getAppSchedulingInfo().getAllResourceRequests().isEmpty());
|
|
|
|
+
|
|
|
|
+ // Restore an applications with a user that has no access to the queue
|
|
|
|
+ try {
|
|
|
|
+ appAttemptId = createRecoveringApplication(amResource, queueId,
|
|
|
|
+ "usernotinacl");
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ fail("The exception is not expected. Exception message: "
|
|
|
|
+ + e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ scheduler.addApplicationAttempt(appAttemptId, false, true);
|
|
|
|
+
|
|
|
|
+ appsInQueue = scheduler.getAppsInQueue(queueId);
|
|
|
|
+ assertEquals("Number of apps in queue 'root.parent.queueA' should be two!",
|
|
|
|
+ 2, appsInQueue.size());
|
|
|
|
+
|
|
|
|
+ appAttemptId = scheduler.getAppsInQueue(queueId).get(1);
|
|
|
|
+ assertNotNull("Scheduler app for appAttemptId " + appAttemptId
|
|
|
|
+ + " should not be null!", scheduler.getSchedulerApp(appAttemptId));
|
|
|
|
+
|
|
|
|
+ schedulerApp = scheduler.getSchedulerApp(appAttemptId);
|
|
|
|
+ assertNotNull("Scheduler app queueInfo for appAttemptId " + appAttemptId
|
|
|
|
+ + " should not be null!", schedulerApp.getAppSchedulingInfo());
|
|
|
|
+
|
|
|
|
+ assertTrue("There should be no requests accepted", schedulerApp
|
|
|
|
+ .getAppSchedulingInfo().getAllResourceRequests().isEmpty());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Test
|
|
|
|
+ public void testRestoreToParentQueue() throws IOException {
|
|
|
|
+ conf.set(FairSchedulerConfiguration.ALLOCATION_FILE, ALLOC_FILE);
|
|
|
|
+ generateAllocationFilePercentageResource();
|
|
|
|
+
|
|
|
|
+ scheduler.init(conf);
|
|
|
|
+ scheduler.start();
|
|
|
|
+ scheduler.reinitialize(conf, resourceManager.getRMContext());
|
|
|
|
+
|
|
|
|
+ // no nodes so the resource total should be zero for all queues
|
|
|
|
+ // AM is using resources
|
|
|
|
+ Resource amResource = Resources.createResource(1024, 1);
|
|
|
|
+ // Add the app and the attempt, use a queue that is now a parent
|
|
|
|
+ ApplicationAttemptId appAttemptId = null;
|
|
|
|
+ String queueId = "root.parent";
|
|
|
|
+ try {
|
|
|
|
+ appAttemptId = createRecoveringApplication(amResource, queueId, "user1");
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ fail("The exception is not expected. Exception message: "
|
|
|
|
+ + e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ scheduler.addApplicationAttempt(appAttemptId, false, true);
|
|
|
|
+
|
|
|
|
+ String recoveredQueue = "root.recovery";
|
|
|
|
+ List<ApplicationAttemptId> appsInQueue =
|
|
|
|
+ scheduler.getAppsInQueue(recoveredQueue);
|
|
|
|
+ assertEquals("Number of apps in queue 'root.recovery' should be one!",
|
|
|
|
+ 1, appsInQueue.size());
|
|
|
|
+
|
|
|
|
+ appAttemptId =
|
|
|
|
+ scheduler.getAppsInQueue(recoveredQueue).get(0);
|
|
|
|
+ assertNotNull("Scheduler app for appAttemptId " + appAttemptId
|
|
|
|
+ + " should not be null!", scheduler.getSchedulerApp(appAttemptId));
|
|
|
|
+
|
|
|
|
+ FSAppAttempt schedulerApp = scheduler.getSchedulerApp(appAttemptId);
|
|
|
|
+ assertNotNull("Scheduler app queueInfo for appAttemptId " + appAttemptId
|
|
|
|
+ + " should not be null!", schedulerApp.getAppSchedulingInfo());
|
|
|
|
+
|
|
|
|
+ assertTrue("There should be no requests accepted", schedulerApp
|
|
|
|
+ .getAppSchedulingInfo().getAllResourceRequests().isEmpty());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void generateAllocationFilePercentageResource() {
|
|
|
|
+ AllocationFileWriter.create()
|
|
|
|
+ .addQueue(new AllocationFileQueue.Builder("root")
|
|
|
|
+ .parent(true)
|
|
|
|
+ .aclSubmitApps(" ")
|
|
|
|
+ .aclAdministerApps(" ")
|
|
|
|
+ .subQueue(new AllocationFileQueue.Builder("parent")
|
|
|
|
+ .parent(true)
|
|
|
|
+ .maxChildResources("memory-mb=15.0%, vcores=15.0%")
|
|
|
|
+ .subQueue(new AllocationFileQueue.Builder("queueA")
|
|
|
|
+ .aclSubmitApps("user1")
|
|
|
|
+ .build())
|
|
|
|
+ .build())
|
|
|
|
+ .build())
|
|
|
|
+ .writeToFile(ALLOC_FILE);
|
|
|
|
+ }
|
|
}
|
|
}
|