|
@@ -17,8 +17,14 @@
|
|
|
*/
|
|
|
package org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair;
|
|
|
|
|
|
-import static org.junit.Assert.*;
|
|
|
-import static org.mockito.Mockito.*;
|
|
|
+import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
|
+import static org.junit.jupiter.api.Assertions.assertFalse;
|
|
|
+import static org.junit.jupiter.api.Assertions.assertNotNull;
|
|
|
+import static org.junit.jupiter.api.Assertions.assertNull;
|
|
|
+import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
|
+import static org.mockito.Mockito.doReturn;
|
|
|
+import static org.mockito.Mockito.mock;
|
|
|
+import static org.mockito.Mockito.when;
|
|
|
|
|
|
import java.util.Collections;
|
|
|
import java.util.Set;
|
|
@@ -32,9 +38,8 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ActiveUsersManage
|
|
|
import org.apache.hadoop.util.SystemClock;
|
|
|
import org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator;
|
|
|
import org.apache.hadoop.yarn.util.resource.Resources;
|
|
|
-import org.junit.Before;
|
|
|
-import org.junit.Test;
|
|
|
-import org.mockito.Mockito;
|
|
|
+import org.junit.jupiter.api.BeforeEach;
|
|
|
+import org.junit.jupiter.api.Test;
|
|
|
|
|
|
import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableSet;
|
|
|
|
|
@@ -46,7 +51,7 @@ public class TestQueueManager {
|
|
|
private QueueManager queueManager;
|
|
|
private FairScheduler scheduler;
|
|
|
|
|
|
- @Before
|
|
|
+ @BeforeEach
|
|
|
public void setUp() {
|
|
|
PlacementManager placementManager = new PlacementManager();
|
|
|
FairSchedulerConfiguration conf = new FairSchedulerConfiguration();
|
|
@@ -194,10 +199,9 @@ public class TestQueueManager {
|
|
|
public void testCreateLeafQueue() {
|
|
|
FSQueue q1 = queueManager.createQueue("root.queue1", FSQueueType.LEAF);
|
|
|
|
|
|
- assertNotNull("Leaf queue root.queue1 was not created",
|
|
|
- queueManager.getLeafQueue("root.queue1", false));
|
|
|
- assertEquals("createQueue() returned wrong queue",
|
|
|
- "root.queue1", q1.getName());
|
|
|
+ assertNotNull(queueManager.getLeafQueue("root.queue1", false),
|
|
|
+ "Leaf queue root.queue1 was not created");
|
|
|
+ assertEquals("root.queue1", q1.getName(), "createQueue() returned wrong queue");
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -208,12 +212,12 @@ public class TestQueueManager {
|
|
|
FSQueue q2 = queueManager.createQueue("root.queue1.queue2",
|
|
|
FSQueueType.LEAF);
|
|
|
|
|
|
- assertNotNull("Parent queue root.queue1 was not created",
|
|
|
- queueManager.getParentQueue("root.queue1", false));
|
|
|
- assertNotNull("Leaf queue root.queue1.queue2 was not created",
|
|
|
- queueManager.getLeafQueue("root.queue1.queue2", false));
|
|
|
- assertEquals("createQueue() returned wrong queue",
|
|
|
- "root.queue1.queue2", q2.getName());
|
|
|
+ assertNotNull(queueManager.getParentQueue("root.queue1", false),
|
|
|
+ "Parent queue root.queue1 was not created");
|
|
|
+ assertNotNull(queueManager.getLeafQueue("root.queue1.queue2", false),
|
|
|
+ "Leaf queue root.queue1.queue2 was not created");
|
|
|
+ assertEquals("root.queue1.queue2", q2.getName(),
|
|
|
+ "createQueue() returned wrong queue");
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -228,38 +232,38 @@ public class TestQueueManager {
|
|
|
new ConfigurableResource(Resources.createResource(8192, 256)));
|
|
|
|
|
|
FSQueue q1 = queueManager.createQueue("root.test.childC", FSQueueType.LEAF);
|
|
|
- assertNotNull("Leaf queue root.test.childC was not created",
|
|
|
- queueManager.getLeafQueue("root.test.childC", false));
|
|
|
- assertEquals("createQueue() returned wrong queue",
|
|
|
- "root.test.childC", q1.getName());
|
|
|
- assertEquals("Max resources for root.queue1 were not inherited from "
|
|
|
- + "parent's max child resources", Resources.createResource(8192, 256),
|
|
|
- q1.getMaxShare());
|
|
|
+ assertNotNull(queueManager.getLeafQueue("root.test.childC", false),
|
|
|
+ "Leaf queue root.test.childC was not created");
|
|
|
+ assertEquals(q1.getName(), "root.test.childC", "createQueue() returned wrong queue");
|
|
|
+ assertEquals(Resources.createResource(8192, 256),
|
|
|
+ q1.getMaxShare(), "Max resources for root.queue1 were not inherited from "
|
|
|
+ + "parent's max child resources");
|
|
|
|
|
|
FSQueue q2 = queueManager.createQueue("root.test.childD",
|
|
|
FSQueueType.PARENT);
|
|
|
|
|
|
- assertNotNull("Leaf queue root.test.childD was not created",
|
|
|
- queueManager.getParentQueue("root.test.childD", false));
|
|
|
- assertEquals("createQueue() returned wrong queue",
|
|
|
- "root.test.childD", q2.getName());
|
|
|
- assertEquals("Max resources for root.test.childD were not inherited "
|
|
|
- + "from parent's max child resources",
|
|
|
- Resources.createResource(8192, 256),
|
|
|
- q2.getMaxShare());
|
|
|
+ assertNotNull(queueManager.getParentQueue("root.test.childD", false),
|
|
|
+ "Leaf queue root.test.childD was not created");
|
|
|
+ assertEquals("root.test.childD", q2.getName(),
|
|
|
+ "createQueue() returned wrong queue");
|
|
|
+ assertEquals(Resources.createResource(8192, 256),
|
|
|
+ q2.getMaxShare(), "Max resources for root.test.childD were not inherited "
|
|
|
+ + "from parent's max child resources");
|
|
|
|
|
|
// Check that the childA and childB queues weren't impacted
|
|
|
// by the child defaults
|
|
|
- assertNotNull("Leaf queue root.test.childA was not created during setup",
|
|
|
- queueManager.getLeafQueue("root.test.childA", false));
|
|
|
- assertEquals("Max resources for root.test.childA were inherited from "
|
|
|
- + "parent's max child resources", Resources.unbounded(),
|
|
|
- queueManager.getLeafQueue("root.test.childA", false).getMaxShare());
|
|
|
- assertNotNull("Leaf queue root.test.childB was not created during setup",
|
|
|
- queueManager.getParentQueue("root.test.childB", false));
|
|
|
- assertEquals("Max resources for root.test.childB were inherited from "
|
|
|
- + "parent's max child resources", Resources.unbounded(),
|
|
|
- queueManager.getParentQueue("root.test.childB", false).getMaxShare());
|
|
|
+ assertNotNull(queueManager.getLeafQueue("root.test.childA", false),
|
|
|
+ "Leaf queue root.test.childA was not created during setup");
|
|
|
+ assertEquals(Resources.unbounded(),
|
|
|
+ queueManager.getLeafQueue("root.test.childA", false).getMaxShare(),
|
|
|
+ "Max resources for root.test.childA were inherited from "
|
|
|
+ + "parent's max child resources");
|
|
|
+ assertNotNull(queueManager.getParentQueue("root.test.childB", false),
|
|
|
+ "Leaf queue root.test.childB was not created during setup");
|
|
|
+ assertEquals(Resources.unbounded(),
|
|
|
+ queueManager.getParentQueue("root.test.childB", false).getMaxShare(),
|
|
|
+ "Max resources for root.test.childB were inherited from "
|
|
|
+ + "parent's max child resources");
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -269,19 +273,17 @@ public class TestQueueManager {
|
|
|
public void testCreateLeafQueueWithDefaults() {
|
|
|
FSQueue q1 = queueManager.createQueue("root.queue1", FSQueueType.LEAF);
|
|
|
|
|
|
- assertNotNull("Leaf queue root.queue1 was not created",
|
|
|
- queueManager.getLeafQueue("root.queue1", false));
|
|
|
- assertEquals("createQueue() returned wrong queue",
|
|
|
- "root.queue1", q1.getName());
|
|
|
+ assertNotNull(queueManager.getLeafQueue("root.queue1", false),
|
|
|
+ "Leaf queue root.queue1 was not created");
|
|
|
+ assertEquals("root.queue1", q1.getName(), "createQueue() returned wrong queue");
|
|
|
|
|
|
// Min default is 0,0
|
|
|
- assertEquals("Min resources were not set to default",
|
|
|
- Resources.createResource(0, 0),
|
|
|
- q1.getMinShare());
|
|
|
+ assertEquals(Resources.createResource(0, 0),
|
|
|
+ q1.getMinShare(), "Min resources were not set to default");
|
|
|
|
|
|
// Max default is unbounded
|
|
|
- assertEquals("Max resources were not set to default", Resources.unbounded(),
|
|
|
- q1.getMaxShare());
|
|
|
+ assertEquals(Resources.unbounded(),
|
|
|
+ q1.getMaxShare(), "Max resources were not set to default");
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -291,10 +293,10 @@ public class TestQueueManager {
|
|
|
public void testCreateParentQueue() {
|
|
|
FSQueue q1 = queueManager.createQueue("root.queue1", FSQueueType.PARENT);
|
|
|
|
|
|
- assertNotNull("Parent queue root.queue1 was not created",
|
|
|
- queueManager.getParentQueue("root.queue1", false));
|
|
|
- assertEquals("createQueue() returned wrong queue",
|
|
|
- "root.queue1", q1.getName());
|
|
|
+ assertNotNull(queueManager.getParentQueue("root.queue1", false),
|
|
|
+ "Parent queue root.queue1 was not created");
|
|
|
+ assertEquals("root.queue1", q1.getName(),
|
|
|
+ "createQueue() returned wrong queue");
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -305,12 +307,12 @@ public class TestQueueManager {
|
|
|
FSQueue q2 = queueManager.createQueue("root.queue1.queue2",
|
|
|
FSQueueType.PARENT);
|
|
|
|
|
|
- assertNotNull("Parent queue root.queue1 was not created",
|
|
|
- queueManager.getParentQueue("root.queue1", false));
|
|
|
- assertNotNull("Leaf queue root.queue1.queue2 was not created",
|
|
|
- queueManager.getParentQueue("root.queue1.queue2", false));
|
|
|
- assertEquals("createQueue() returned wrong queue",
|
|
|
- "root.queue1.queue2", q2.getName());
|
|
|
+ assertNotNull(queueManager.getParentQueue("root.queue1", false),
|
|
|
+ "Parent queue root.queue1 was not created");
|
|
|
+ assertNotNull(queueManager.getParentQueue("root.queue1.queue2", false),
|
|
|
+ "Leaf queue root.queue1.queue2 was not created");
|
|
|
+ assertEquals("root.queue1.queue2", q2.getName(),
|
|
|
+ "createQueue() returned wrong queue");
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -321,11 +323,10 @@ public class TestQueueManager {
|
|
|
FSLeafQueue q1 = queueManager.getLeafQueue("root.test.childB.dynamic1",
|
|
|
true);
|
|
|
|
|
|
- assertNotNull("Queue root.test.childB.dynamic1 was not created", q1);
|
|
|
- assertEquals("createQueue() returned wrong queue",
|
|
|
- "root.test.childB.dynamic1", q1.getName());
|
|
|
- assertTrue("root.test.childB.dynamic1 is not a dynamic queue",
|
|
|
- q1.isDynamic());
|
|
|
+ assertNotNull(q1, "Queue root.test.childB.dynamic1 was not created");
|
|
|
+ assertEquals("root.test.childB.dynamic1", q1.getName(),
|
|
|
+ "createQueue() returned wrong queue");
|
|
|
+ assertTrue(q1.isDynamic(), "root.test.childB.dynamic1 is not a dynamic queue");
|
|
|
|
|
|
// an application is submitted to root.test.childB.dynamic1
|
|
|
ApplicationId appId = ApplicationId.newInstance(0, 0);
|
|
@@ -335,7 +336,7 @@ public class TestQueueManager {
|
|
|
queueManager.removePendingIncompatibleQueues();
|
|
|
queueManager.removeEmptyDynamicQueues();
|
|
|
q1 = queueManager.getLeafQueue("root.test.childB.dynamic1", false);
|
|
|
- assertNotNull("Queue root.test.childB.dynamic1 was deleted", q1);
|
|
|
+ assertNotNull(q1, "Queue root.test.childB.dynamic1 was deleted");
|
|
|
|
|
|
// the application finishes, the next removeEmptyDynamicQueues() should
|
|
|
// clean root.test.childB.dynamic1 up, but keep its static parent
|
|
@@ -344,9 +345,9 @@ public class TestQueueManager {
|
|
|
queueManager.removePendingIncompatibleQueues();
|
|
|
queueManager.removeEmptyDynamicQueues();
|
|
|
q1 = queueManager.getLeafQueue("root.test.childB.dynamic1", false);
|
|
|
- assertNull("Queue root.test.childB.dynamic1 was not deleted", q1);
|
|
|
- assertNotNull("The static parent of root.test.childB.dynamic1 was deleted",
|
|
|
- queueManager.getParentQueue("root.test.childB", false));
|
|
|
+ assertNull(q1, "Queue root.test.childB.dynamic1 was not deleted");
|
|
|
+ assertNotNull(queueManager.getParentQueue("root.test.childB", false),
|
|
|
+ "The static parent of root.test.childB.dynamic1 was deleted");
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -356,22 +357,22 @@ public class TestQueueManager {
|
|
|
public void testRemovalOfDynamicParentQueue() {
|
|
|
FSQueue q1 = queueManager.getLeafQueue("root.parent1.dynamic1", true);
|
|
|
|
|
|
- assertNotNull("Queue root.parent1.dynamic1 was not created", q1);
|
|
|
- assertEquals("createQueue() returned wrong queue",
|
|
|
- "root.parent1.dynamic1", q1.getName());
|
|
|
- assertTrue("root.parent1.dynamic1 is not a dynamic queue", q1.isDynamic());
|
|
|
+ assertNotNull(q1, "Queue root.parent1.dynamic1 was not created");
|
|
|
+ assertEquals("root.parent1.dynamic1", q1.getName(),
|
|
|
+ "createQueue() returned wrong queue");
|
|
|
+ assertTrue(q1.isDynamic(), "root.parent1.dynamic1 is not a dynamic queue");
|
|
|
|
|
|
FSQueue p1 = queueManager.getParentQueue("root.parent1", false);
|
|
|
- assertNotNull("Queue root.parent1 was not created", p1);
|
|
|
- assertTrue("root.parent1 is not a dynamic queue", p1.isDynamic());
|
|
|
+ assertNotNull(p1, "Queue root.parent1 was not created");
|
|
|
+ assertTrue(p1.isDynamic(), "root.parent1 is not a dynamic queue");
|
|
|
|
|
|
queueManager.removePendingIncompatibleQueues();
|
|
|
queueManager.removeEmptyDynamicQueues();
|
|
|
q1 = queueManager.getLeafQueue("root.parent1.dynamic1", false);
|
|
|
p1 = queueManager.getParentQueue("root.parent1", false);
|
|
|
|
|
|
- assertNull("Queue root.parent1.dynamic1 was not deleted", q1);
|
|
|
- assertNull("Queue root.parent1 was not deleted", p1);
|
|
|
+ assertNull(q1, "Queue root.parent1.dynamic1 was not deleted");
|
|
|
+ assertNull(p1, "Queue root.parent1 was not deleted");
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -381,10 +382,10 @@ public class TestQueueManager {
|
|
|
public void testNonEmptyDynamicQueueBecomingStaticQueue() {
|
|
|
FSLeafQueue q1 = queueManager.getLeafQueue("root.leaf1", true);
|
|
|
|
|
|
- assertNotNull("Queue root.leaf1 was not created", q1);
|
|
|
- assertEquals("createQueue() returned wrong queue",
|
|
|
- "root.leaf1", q1.getName());
|
|
|
- assertTrue("root.leaf1 is not a dynamic queue", q1.isDynamic());
|
|
|
+ assertNotNull(q1, "Queue root.leaf1 was not created");
|
|
|
+ assertEquals("root.leaf1", q1.getName(),
|
|
|
+ "createQueue() returned wrong queue");
|
|
|
+ assertTrue(q1.isDynamic(), "root.leaf1 is not a dynamic queue");
|
|
|
|
|
|
// pretend that we submitted an app to the queue
|
|
|
ApplicationId appId = ApplicationId.newInstance(0, 0);
|
|
@@ -394,7 +395,7 @@ public class TestQueueManager {
|
|
|
queueManager.removePendingIncompatibleQueues();
|
|
|
queueManager.removeEmptyDynamicQueues();
|
|
|
q1 = queueManager.getLeafQueue("root.leaf1", false);
|
|
|
- assertNotNull("Queue root.leaf1 was deleted", q1);
|
|
|
+ assertNotNull(q1, "Queue root.leaf1 was deleted");
|
|
|
|
|
|
// next we add leaf1 under root in the allocation config
|
|
|
AllocationConfiguration allocConf = scheduler.getAllocationConfiguration();
|
|
@@ -402,7 +403,7 @@ public class TestQueueManager {
|
|
|
queueManager.updateAllocationConfiguration(allocConf);
|
|
|
|
|
|
// updateAllocationConfiguration() should make root.leaf1 a dynamic queue
|
|
|
- assertFalse("root.leaf1 is not a static queue", q1.isDynamic());
|
|
|
+ assertFalse(q1.isDynamic(), "root.leaf1 is not a static queue");
|
|
|
|
|
|
// application finished now and the queue is empty, but since leaf1 is a
|
|
|
// static queue at this point, hence not affected by
|
|
@@ -411,8 +412,8 @@ public class TestQueueManager {
|
|
|
queueManager.removePendingIncompatibleQueues();
|
|
|
queueManager.removeEmptyDynamicQueues();
|
|
|
q1 = queueManager.getLeafQueue("root.leaf1", false);
|
|
|
- assertNotNull("Queue root.leaf1 was deleted", q1);
|
|
|
- assertFalse("root.leaf1 is not a static queue", q1.isDynamic());
|
|
|
+ assertNotNull(q1, "Queue root.leaf1 was deleted");
|
|
|
+ assertFalse(q1.isDynamic(), "root.leaf1 is not a static queue");
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -422,10 +423,10 @@ public class TestQueueManager {
|
|
|
public void testNonEmptyStaticQueueBecomingDynamicQueue() {
|
|
|
FSLeafQueue q1 = queueManager.getLeafQueue("root.test.childA", false);
|
|
|
|
|
|
- assertNotNull("Queue root.test.childA does not exist", q1);
|
|
|
- assertEquals("createQueue() returned wrong queue",
|
|
|
- "root.test.childA", q1.getName());
|
|
|
- assertFalse("root.test.childA is not a static queue", q1.isDynamic());
|
|
|
+ assertNotNull(q1, "Queue root.test.childA does not exist");
|
|
|
+ assertEquals("root.test.childA", q1.getName(),
|
|
|
+ "createQueue() returned wrong queue");
|
|
|
+ assertFalse(q1.isDynamic(), "root.test.childA is not a static queue");
|
|
|
|
|
|
// we submitted an app to the queue
|
|
|
ApplicationId appId = ApplicationId.newInstance(0, 0);
|
|
@@ -436,8 +437,8 @@ public class TestQueueManager {
|
|
|
queueManager.removePendingIncompatibleQueues();
|
|
|
queueManager.removeEmptyDynamicQueues();
|
|
|
q1 = queueManager.getLeafQueue("root.test.childA", false);
|
|
|
- assertNotNull("Queue root.test.childA was deleted", q1);
|
|
|
- assertFalse("root.test.childA is not a dynamic queue", q1.isDynamic());
|
|
|
+ assertNotNull(q1, "Queue root.test.childA was deleted");
|
|
|
+ assertFalse(q1.isDynamic(), "root.test.childA is not a dynamic queue");
|
|
|
|
|
|
// next we remove all queues from the allocation config,
|
|
|
// this causes all queues to change to dynamic
|
|
@@ -449,8 +450,8 @@ public class TestQueueManager {
|
|
|
queueManager.updateAllocationConfiguration(allocConf);
|
|
|
|
|
|
q1 = queueManager.getLeafQueue("root.test.childA", false);
|
|
|
- assertNotNull("Queue root.test.childA was deleted", q1);
|
|
|
- assertTrue("root.test.childA is not a dynamic queue", q1.isDynamic());
|
|
|
+ assertNotNull(q1, "Queue root.test.childA was deleted");
|
|
|
+ assertTrue(q1.isDynamic(), "root.test.childA is not a dynamic queue");
|
|
|
|
|
|
// application finished - the queue does not have runnable app
|
|
|
// the next removeEmptyDynamicQueues() call should remove the queues
|
|
@@ -460,10 +461,10 @@ public class TestQueueManager {
|
|
|
queueManager.removeEmptyDynamicQueues();
|
|
|
|
|
|
q1 = queueManager.getLeafQueue("root.test.childA", false);
|
|
|
- assertNull("Queue root.test.childA was not deleted", q1);
|
|
|
+ assertNull(q1, "Queue root.test.childA was not deleted");
|
|
|
|
|
|
FSParentQueue p1 = queueManager.getParentQueue("root.test", false);
|
|
|
- assertNull("Queue root.test was not deleted", p1);
|
|
|
+ assertNull(p1, "Queue root.test was not deleted");
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -473,16 +474,16 @@ public class TestQueueManager {
|
|
|
public void testRemovalOfChildlessParentQueue() {
|
|
|
FSParentQueue q1 = queueManager.getParentQueue("root.test.childB", false);
|
|
|
|
|
|
- assertNotNull("Queue root.test.childB was not created", q1);
|
|
|
- assertEquals("createQueue() returned wrong queue",
|
|
|
- "root.test.childB", q1.getName());
|
|
|
- assertFalse("root.test.childB is a dynamic queue", q1.isDynamic());
|
|
|
+ assertNotNull(q1, "Queue root.test.childB was not created");
|
|
|
+ assertEquals("root.test.childB", q1.getName(),
|
|
|
+ "createQueue() returned wrong queue");
|
|
|
+ assertFalse(q1.isDynamic(), "root.test.childB is a dynamic queue");
|
|
|
|
|
|
// static queues should not be deleted
|
|
|
queueManager.removePendingIncompatibleQueues();
|
|
|
queueManager.removeEmptyDynamicQueues();
|
|
|
q1 = queueManager.getParentQueue("root.test.childB", false);
|
|
|
- assertNotNull("Queue root.test.childB was deleted", q1);
|
|
|
+ assertNotNull(q1, "Queue root.test.childB was deleted");
|
|
|
|
|
|
// next we remove root.test.childB from the allocation config
|
|
|
AllocationConfiguration allocConf = scheduler.getAllocationConfiguration();
|
|
@@ -496,7 +497,7 @@ public class TestQueueManager {
|
|
|
queueManager.removePendingIncompatibleQueues();
|
|
|
queueManager.removeEmptyDynamicQueues();
|
|
|
q1 = queueManager.getParentQueue("root.leaf1", false);
|
|
|
- assertNull("Queue root.leaf1 was not deleted", q1);
|
|
|
+ assertNull(q1, "Queue root.leaf1 was not deleted");
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -506,14 +507,14 @@ public class TestQueueManager {
|
|
|
@Test
|
|
|
public void testQueueTypeChange() {
|
|
|
FSQueue q1 = queueManager.getLeafQueue("root.parent1.leaf1", true);
|
|
|
- assertNotNull("Queue root.parent1.leaf1 was not created", q1);
|
|
|
- assertEquals("createQueue() returned wrong queue",
|
|
|
- "root.parent1.leaf1", q1.getName());
|
|
|
- assertTrue("root.parent1.leaf1 is not a dynamic queue", q1.isDynamic());
|
|
|
+ assertNotNull(q1, "Queue root.parent1.leaf1 was not created");
|
|
|
+ assertEquals("root.parent1.leaf1", q1.getName(),
|
|
|
+ "createQueue() returned wrong queue");
|
|
|
+ assertTrue(q1.isDynamic(), "root.parent1.leaf1 is not a dynamic queue");
|
|
|
|
|
|
FSQueue p1 = queueManager.getParentQueue("root.parent1", false);
|
|
|
- assertNotNull("Queue root.parent1 was not created", p1);
|
|
|
- assertTrue("root.parent1 is not a dynamic queue", p1.isDynamic());
|
|
|
+ assertNotNull(p1, "Queue root.parent1 was not created");
|
|
|
+ assertTrue(p1.isDynamic(), "root.parent1 is not a dynamic queue");
|
|
|
|
|
|
// adding root.parent1.leaf1 and root.parent1 to the allocation config
|
|
|
AllocationConfiguration allocConf = scheduler.getAllocationConfiguration();
|
|
@@ -524,9 +525,9 @@ public class TestQueueManager {
|
|
|
// updateAllocationConfiguration() should change both queues over to static
|
|
|
queueManager.updateAllocationConfiguration(allocConf);
|
|
|
q1 = queueManager.getLeafQueue("root.parent1.leaf1", false);
|
|
|
- assertFalse("root.parent1.leaf1 is not a static queue", q1.isDynamic());
|
|
|
+ assertFalse(q1.isDynamic(), "root.parent1.leaf1 is not a static queue");
|
|
|
p1 = queueManager.getParentQueue("root.parent1", false);
|
|
|
- assertFalse("root.parent1 is not a static queue", p1.isDynamic());
|
|
|
+ assertFalse(p1.isDynamic(), "root.parent1 is not a static queue");
|
|
|
|
|
|
// removing root.parent1.leaf1 and root.parent1 from the allocation
|
|
|
// config
|
|
@@ -540,9 +541,9 @@ public class TestQueueManager {
|
|
|
queueManager.setQueuesToDynamic(
|
|
|
ImmutableSet.of("root.parent1", "root.parent1.leaf1"));
|
|
|
q1 = queueManager.getLeafQueue("root.parent1.leaf1", false);
|
|
|
- assertTrue("root.parent1.leaf1 is not a dynamic queue", q1.isDynamic());
|
|
|
+ assertTrue(q1.isDynamic(), "root.parent1.leaf1 is not a dynamic queue");
|
|
|
p1 = queueManager.getParentQueue("root.parent1", false);
|
|
|
- assertTrue("root.parent1 is not a dynamic queue", p1.isDynamic());
|
|
|
+ assertTrue(p1.isDynamic(), "root.parent1 is not a dynamic queue");
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -551,27 +552,27 @@ public class TestQueueManager {
|
|
|
@Test
|
|
|
public void testApplicationAssignmentPreventsRemovalOfDynamicQueue() {
|
|
|
FSLeafQueue q = queueManager.getLeafQueue("root.leaf1", true);
|
|
|
- assertNotNull("root.leaf1 does not exist", q);
|
|
|
- assertTrue("root.leaf1 is not empty", q.isEmpty());
|
|
|
+ assertNotNull(q, "root.leaf1 does not exist");
|
|
|
+ assertTrue(q.isEmpty(), "root.leaf1 is not empty");
|
|
|
|
|
|
// assigning an application (without an appAttempt so far) to the queue
|
|
|
// removeEmptyDynamicQueues() should not remove the queue
|
|
|
ApplicationId applicationId = ApplicationId.newInstance(1L, 0);
|
|
|
q.addAssignedApp(applicationId);
|
|
|
q = queueManager.getLeafQueue("root.leaf1", false);
|
|
|
- assertFalse("root.leaf1 is empty", q.isEmpty());
|
|
|
+ assertFalse(q.isEmpty(), "root.leaf1 is empty");
|
|
|
|
|
|
queueManager.removePendingIncompatibleQueues();
|
|
|
queueManager.removeEmptyDynamicQueues();
|
|
|
q = queueManager.getLeafQueue("root.leaf1", false);
|
|
|
- assertNotNull("root.leaf1 has been removed", q);
|
|
|
- assertFalse("root.leaf1 is empty", q.isEmpty());
|
|
|
+ assertNotNull(q, "root.leaf1 has been removed");
|
|
|
+ assertFalse(q.isEmpty(), "root.leaf1 is empty");
|
|
|
|
|
|
ApplicationAttemptId applicationAttemptId =
|
|
|
ApplicationAttemptId.newInstance(applicationId, 0);
|
|
|
ActiveUsersManager activeUsersManager =
|
|
|
- Mockito.mock(ActiveUsersManager.class);
|
|
|
- RMContext rmContext = Mockito.mock(RMContext.class);
|
|
|
+ mock(ActiveUsersManager.class);
|
|
|
+ RMContext rmContext = mock(RMContext.class);
|
|
|
doReturn(scheduler.getConfig()).when(rmContext).getYarnConfiguration();
|
|
|
|
|
|
// the appAttempt is created
|
|
@@ -581,19 +582,19 @@ public class TestQueueManager {
|
|
|
q.addApp(appAttempt, true);
|
|
|
queueManager.removeEmptyDynamicQueues();
|
|
|
q = queueManager.getLeafQueue("root.leaf1", false);
|
|
|
- assertNotNull("root.leaf1 has been removed", q);
|
|
|
- assertFalse("root.leaf1 is empty", q.isEmpty());
|
|
|
+ assertNotNull(q, "root.leaf1 has been removed");
|
|
|
+ assertFalse(q.isEmpty(), "root.leaf1 is empty");
|
|
|
|
|
|
// the appAttempt finished, the queue should be empty
|
|
|
q.removeApp(appAttempt);
|
|
|
q = queueManager.getLeafQueue("root.leaf1", false);
|
|
|
- assertTrue("root.leaf1 is not empty", q.isEmpty());
|
|
|
+ assertTrue(q.isEmpty(), "root.leaf1 is not empty");
|
|
|
|
|
|
// removeEmptyDynamicQueues() should remove the queue
|
|
|
queueManager.removePendingIncompatibleQueues();
|
|
|
queueManager.removeEmptyDynamicQueues();
|
|
|
q = queueManager.getLeafQueue("root.leaf1", false);
|
|
|
- assertNull("root.leaf1 has not been removed", q);
|
|
|
+ assertNull(q, "root.leaf1 has not been removed");
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -608,20 +609,20 @@ public class TestQueueManager {
|
|
|
queueManager.updateAllocationConfiguration(allocConf);
|
|
|
|
|
|
FSLeafQueue q = queueManager.getLeafQueue("root.a", true);
|
|
|
- assertNotNull("root.a does not exist", q);
|
|
|
- assertTrue("root.a is not empty", q.isEmpty());
|
|
|
+ assertNotNull(q, "root.a does not exist");
|
|
|
+ assertTrue(q.isEmpty(), "root.a is not empty");
|
|
|
|
|
|
// we start to run an application on root.a
|
|
|
ApplicationId appId = ApplicationId.newInstance(0, 0);
|
|
|
q.addAssignedApp(appId);
|
|
|
- assertFalse("root.a is empty", q.isEmpty());
|
|
|
+ assertFalse(q.isEmpty(), "root.a is empty");
|
|
|
|
|
|
// root.a should not be removed by removeEmptyDynamicQueues or by
|
|
|
// removePendingIncompatibleQueues
|
|
|
queueManager.removePendingIncompatibleQueues();
|
|
|
queueManager.removeEmptyDynamicQueues();
|
|
|
q = queueManager.getLeafQueue("root.a", false);
|
|
|
- assertNotNull("root.a does not exist", q);
|
|
|
+ assertNotNull(q, "root.a does not exist");
|
|
|
|
|
|
// let's introduce queue incompatibility
|
|
|
allocConf.configuredQueues.get(FSQueueType.LEAF).remove("root.a");
|
|
@@ -631,14 +632,14 @@ public class TestQueueManager {
|
|
|
|
|
|
// since root.a has running applications, it should be still a leaf queue
|
|
|
q = queueManager.getLeafQueue("root.a", false);
|
|
|
- assertNotNull("root.a has been removed", q);
|
|
|
- assertFalse("root.a is empty", q.isEmpty());
|
|
|
+ assertNotNull(q, "root.a has been removed");
|
|
|
+ assertFalse(q.isEmpty(), "root.a is empty");
|
|
|
|
|
|
// removePendingIncompatibleQueues should still keep root.a as a leaf queue
|
|
|
queueManager.removePendingIncompatibleQueues();
|
|
|
q = queueManager.getLeafQueue("root.a", false);
|
|
|
- assertNotNull("root.a has been removed", q);
|
|
|
- assertFalse("root.a is empty", q.isEmpty());
|
|
|
+ assertNotNull(q, "root.a has been removed");
|
|
|
+ assertFalse(q.isEmpty(), "root.a is empty");
|
|
|
|
|
|
// when the application finishes, root.a will become a parent queue on next
|
|
|
// config cleanup. The leaf queue will be created below it on reload of the
|
|
@@ -647,10 +648,10 @@ public class TestQueueManager {
|
|
|
queueManager.removePendingIncompatibleQueues();
|
|
|
queueManager.removeEmptyDynamicQueues();
|
|
|
FSParentQueue p = queueManager.getParentQueue("root.a", false);
|
|
|
- assertNotNull("root.a does not exist", p);
|
|
|
+ assertNotNull(p, "root.a does not exist");
|
|
|
queueManager.updateAllocationConfiguration(allocConf);
|
|
|
q = queueManager.getLeafQueue("root.a.b", false);
|
|
|
- assertNotNull("root.a.b was not created", q);
|
|
|
+ assertNotNull(q, "root.a.b was not created");
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -660,8 +661,8 @@ public class TestQueueManager {
|
|
|
public void testRemoveDeepHierarchy() {
|
|
|
// create a deeper queue hierarchy
|
|
|
FSLeafQueue q = queueManager.getLeafQueue("root.p1.p2.p3.leaf", true);
|
|
|
- assertNotNull("root.p1.p2.p3.leaf does not exist", q);
|
|
|
- assertTrue("root.p1.p2.p3.leaf is not empty", q.isEmpty());
|
|
|
+ assertNotNull(q, "root.p1.p2.p3.leaf does not exist");
|
|
|
+ assertTrue(q.isEmpty(), "root.p1.p2.p3.leaf is not empty");
|
|
|
|
|
|
// Add an application to make the queue not empty
|
|
|
ApplicationId appId = ApplicationId.newInstance(0, 0);
|
|
@@ -671,16 +672,16 @@ public class TestQueueManager {
|
|
|
queueManager.removePendingIncompatibleQueues();
|
|
|
queueManager.removeEmptyDynamicQueues();
|
|
|
q = queueManager.getLeafQueue("root.p1.p2.p3.leaf", false);
|
|
|
- assertNotNull("root.p1.p2.p3.leaf does not exist", q);
|
|
|
+ assertNotNull(q, "root.p1.p2.p3.leaf does not exist");
|
|
|
|
|
|
// Remove the application
|
|
|
q.removeAssignedApp(appId);
|
|
|
// Cleanup should remove the whole tree
|
|
|
queueManager.removeEmptyDynamicQueues();
|
|
|
q = queueManager.getLeafQueue("root.p1.p2.p3.leaf", false);
|
|
|
- assertNull("root.p1.p2.p3.leaf does exist", q);
|
|
|
+ assertNull(q, "root.p1.p2.p3.leaf does exist");
|
|
|
FSParentQueue p = queueManager.getParentQueue("root.p1", false);
|
|
|
- assertNull("root.p1 does exist", p);
|
|
|
+ assertNull(p, "root.p1 does exist");
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -691,12 +692,12 @@ public class TestQueueManager {
|
|
|
public void testRemoveSplitHierarchy() {
|
|
|
// create a deeper queue hierarchy
|
|
|
FSLeafQueue leaf1 = queueManager.getLeafQueue("root.p1.p2-1.leaf-1", true);
|
|
|
- assertNotNull("root.p1.p2-1.leaf-1 does not exist", leaf1);
|
|
|
- assertTrue("root.p1.p2-1.leaf1 is not empty", leaf1.isEmpty());
|
|
|
+ assertNotNull(leaf1, "root.p1.p2-1.leaf-1 does not exist");
|
|
|
+ assertTrue(leaf1.isEmpty(), "root.p1.p2-1.leaf1 is not empty");
|
|
|
// Create a split below the first level
|
|
|
FSLeafQueue leaf2 = queueManager.getLeafQueue("root.p1.p2-2.leaf-2", true);
|
|
|
- assertNotNull("root.p1.p2-2.leaf2 does not exist", leaf2);
|
|
|
- assertTrue("root.p1.p2-2.leaf2 is not empty", leaf2.isEmpty());
|
|
|
+ assertNotNull(leaf2, "root.p1.p2-2.leaf2 does not exist");
|
|
|
+ assertTrue(leaf2.isEmpty(), "root.p1.p2-2.leaf2 is not empty");
|
|
|
|
|
|
// Add an application to make one of the queues not empty
|
|
|
ApplicationId appId = ApplicationId.newInstance(0, 0);
|
|
@@ -706,19 +707,19 @@ public class TestQueueManager {
|
|
|
queueManager.removePendingIncompatibleQueues();
|
|
|
queueManager.removeEmptyDynamicQueues();
|
|
|
leaf1 = queueManager.getLeafQueue("root.p1.p2-1.leaf-1", false);
|
|
|
- assertNotNull("root.p1.p2-1.leaf-1 does not exist", leaf1);
|
|
|
+ assertNotNull(leaf1, "root.p1.p2-1.leaf-1 does not exist");
|
|
|
leaf2 = queueManager.getLeafQueue("root.p1.p2-2.leaf-2", false);
|
|
|
- assertNull("root.p1.p2-2.leaf2 does exist", leaf2);
|
|
|
+ assertNull(leaf2, "root.p1.p2-2.leaf2 does exist");
|
|
|
FSParentQueue p = queueManager.getParentQueue("root.p1.p2-2", false);
|
|
|
- assertNull("root.p1.p2-2 does exist", p);
|
|
|
+ assertNull(p, "root.p1.p2-2 does exist");
|
|
|
|
|
|
// Remove the application
|
|
|
leaf1.removeAssignedApp(appId);
|
|
|
// Cleanup should remove the whole tree
|
|
|
queueManager.removeEmptyDynamicQueues();
|
|
|
leaf1 = queueManager.getLeafQueue("root.p1.p2-1.leaf-1", false);
|
|
|
- assertNull("root.p1.p2-1.leaf-1 does exist", leaf1);
|
|
|
+ assertNull(leaf1, "root.p1.p2-1.leaf-1 does exist");
|
|
|
p = queueManager.getParentQueue("root.p1", false);
|
|
|
- assertNull("root.p1 does exist", p);
|
|
|
+ assertNull(p, "root.p1 does exist");
|
|
|
}
|
|
|
}
|