|
@@ -133,7 +133,7 @@ public class TestCapacitySchedulerQueueMappingFactory {
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
- public void testNestedUserQueueWithDynamicParentQueue() throws Exception {
|
|
|
+ public void testNestedUserQueueWithStaticParentQueue() throws Exception {
|
|
|
|
|
|
CapacitySchedulerConfiguration conf = new CapacitySchedulerConfiguration();
|
|
|
setupQueueConfiguration(conf);
|
|
@@ -153,12 +153,18 @@ public class TestCapacitySchedulerQueueMappingFactory {
|
|
|
List<UserGroupMappingPlacementRule.QueueMapping> queueMappingsForUG =
|
|
|
new ArrayList<>();
|
|
|
|
|
|
- // u:%user:%primary_group.%user
|
|
|
- UserGroupMappingPlacementRule.QueueMapping userQueueMapping =
|
|
|
+ // u:user1:b1
|
|
|
+ UserGroupMappingPlacementRule.QueueMapping userQueueMapping1 =
|
|
|
new UserGroupMappingPlacementRule.QueueMapping(
|
|
|
- UserGroupMappingPlacementRule.QueueMapping.MappingType.USER,
|
|
|
- "%user", getQueueMapping("%primary_group", "%user"));
|
|
|
- queueMappingsForUG.add(userQueueMapping);
|
|
|
+ UserGroupMappingPlacementRule.QueueMapping.MappingType.USER, "user1",
|
|
|
+ "b1");
|
|
|
+ // u:%user:parentqueue.%user
|
|
|
+ UserGroupMappingPlacementRule.QueueMapping userQueueMapping2 =
|
|
|
+ new UserGroupMappingPlacementRule.QueueMapping(
|
|
|
+ UserGroupMappingPlacementRule.QueueMapping.MappingType.USER, "%user",
|
|
|
+ getQueueMapping("c", "%user"));
|
|
|
+ queueMappingsForUG.add(userQueueMapping1);
|
|
|
+ queueMappingsForUG.add(userQueueMapping2);
|
|
|
|
|
|
existingMappingsForUG.addAll(queueMappingsForUG);
|
|
|
conf.setQueueMappings(existingMappingsForUG);
|
|
@@ -175,21 +181,91 @@ public class TestCapacitySchedulerQueueMappingFactory {
|
|
|
ApplicationSubmissionContext asc =
|
|
|
Records.newRecord(ApplicationSubmissionContext.class);
|
|
|
asc.setQueue("default");
|
|
|
- String inputUser = "a";
|
|
|
|
|
|
List<PlacementRule> rules =
|
|
|
cs.getRMContext().getQueuePlacementManager().getPlacementRules();
|
|
|
|
|
|
UserGroupMappingPlacementRule r =
|
|
|
(UserGroupMappingPlacementRule) rules.get(0);
|
|
|
- ApplicationPlacementContext ctx = r.getPlacementForApp(asc, inputUser);
|
|
|
- assertEquals("Queue", "a", ctx.getQueue());
|
|
|
- assertEquals("Group", "agroup", ctx.getParentQueue());
|
|
|
+
|
|
|
+ ApplicationPlacementContext ctx = r.getPlacementForApp(asc, "user1");
|
|
|
+ assertEquals("Queue", "b1", ctx.getQueue());
|
|
|
+
|
|
|
+ ApplicationPlacementContext ctx2 = r.getPlacementForApp(asc, "user2");
|
|
|
+ assertEquals("Queue", "user2", ctx2.getQueue());
|
|
|
+ assertEquals("Queue", "c", ctx2.getParentQueue());
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
- public void testNestedUserQueueWithStaticParentQueue() throws Exception {
|
|
|
+ public void testNestedUserQueueWithPrimaryGroupAsDynamicParentQueue()
|
|
|
+ throws Exception {
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Mapping order: 1. u:%user:%primary_group.%user 2.
|
|
|
+ * u:%user:%secondary_group.%user
|
|
|
+ *
|
|
|
+ * Expected parent queue is primary group of the user
|
|
|
+ */
|
|
|
+
|
|
|
+ // set queue mapping
|
|
|
+ List<UserGroupMappingPlacementRule.QueueMapping> queueMappingsForUG =
|
|
|
+ new ArrayList<>();
|
|
|
+
|
|
|
+ // u:%user:%primary_group.%user
|
|
|
+ UserGroupMappingPlacementRule.QueueMapping userQueueMapping1 =
|
|
|
+ new UserGroupMappingPlacementRule.QueueMapping(
|
|
|
+ UserGroupMappingPlacementRule.QueueMapping.MappingType.USER,
|
|
|
+ "%user", getQueueMapping("%primary_group", "%user"));
|
|
|
+
|
|
|
+ // u:%user:%secondary_group.%user
|
|
|
+ UserGroupMappingPlacementRule.QueueMapping userQueueMapping2 =
|
|
|
+ new UserGroupMappingPlacementRule.QueueMapping(
|
|
|
+ UserGroupMappingPlacementRule.QueueMapping.MappingType.USER,
|
|
|
+ "%user", getQueueMapping("%secondary_group", "%user"));
|
|
|
+
|
|
|
+ queueMappingsForUG.add(userQueueMapping1);
|
|
|
+ queueMappingsForUG.add(userQueueMapping2);
|
|
|
+
|
|
|
+ testNestedUserQueueWithDynamicParentQueue(queueMappingsForUG, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void testNestedUserQueueWithSecondaryGroupAsDynamicParentQueue()
|
|
|
+ throws Exception {
|
|
|
|
|
|
+ /**
|
|
|
+ * Mapping order: 1. u:%user:%secondary_group.%user 2.
|
|
|
+ * u:%user:%primary_group.%user
|
|
|
+ *
|
|
|
+ * Expected parent queue is secondary group of the user
|
|
|
+ */
|
|
|
+
|
|
|
+ // set queue mapping
|
|
|
+ List<UserGroupMappingPlacementRule.QueueMapping> queueMappingsForUG =
|
|
|
+ new ArrayList<>();
|
|
|
+
|
|
|
+ // u:%user:%primary_group.%user
|
|
|
+ UserGroupMappingPlacementRule.QueueMapping userQueueMapping1 =
|
|
|
+ new UserGroupMappingPlacementRule.QueueMapping(
|
|
|
+ UserGroupMappingPlacementRule.QueueMapping.MappingType.USER,
|
|
|
+ "%user", getQueueMapping("%primary_group", "%user"));
|
|
|
+
|
|
|
+ // u:%user:%secondary_group.%user
|
|
|
+ UserGroupMappingPlacementRule.QueueMapping userQueueMapping2 =
|
|
|
+ new UserGroupMappingPlacementRule.QueueMapping(
|
|
|
+ UserGroupMappingPlacementRule.QueueMapping.MappingType.USER,
|
|
|
+ "%user", getQueueMapping("%secondary_group", "%user"));
|
|
|
+
|
|
|
+ queueMappingsForUG.add(userQueueMapping2);
|
|
|
+ queueMappingsForUG.add(userQueueMapping1);
|
|
|
+
|
|
|
+ testNestedUserQueueWithDynamicParentQueue(queueMappingsForUG, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void testNestedUserQueueWithDynamicParentQueue(
|
|
|
+ List<UserGroupMappingPlacementRule.QueueMapping> mapping,
|
|
|
+ boolean primary)
|
|
|
+ throws Exception {
|
|
|
CapacitySchedulerConfiguration conf = new CapacitySchedulerConfiguration();
|
|
|
setupQueueConfiguration(conf);
|
|
|
conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
|
|
@@ -204,24 +280,7 @@ public class TestCapacitySchedulerQueueMappingFactory {
|
|
|
List<UserGroupMappingPlacementRule.QueueMapping> existingMappingsForUG =
|
|
|
conf.getQueueMappings();
|
|
|
|
|
|
- // set queue mapping
|
|
|
- List<UserGroupMappingPlacementRule.QueueMapping> queueMappingsForUG =
|
|
|
- new ArrayList<>();
|
|
|
-
|
|
|
- // u:user1:b1
|
|
|
- UserGroupMappingPlacementRule.QueueMapping userQueueMapping1 =
|
|
|
- new UserGroupMappingPlacementRule.QueueMapping(
|
|
|
- UserGroupMappingPlacementRule.QueueMapping.MappingType.USER, "user1",
|
|
|
- "b1");
|
|
|
- // u:%user:parentqueue.%user
|
|
|
- UserGroupMappingPlacementRule.QueueMapping userQueueMapping2 =
|
|
|
- new UserGroupMappingPlacementRule.QueueMapping(
|
|
|
- UserGroupMappingPlacementRule.QueueMapping.MappingType.USER, "%user",
|
|
|
- getQueueMapping("c", "%user"));
|
|
|
- queueMappingsForUG.add(userQueueMapping1);
|
|
|
- queueMappingsForUG.add(userQueueMapping2);
|
|
|
-
|
|
|
- existingMappingsForUG.addAll(queueMappingsForUG);
|
|
|
+ existingMappingsForUG.addAll(mapping);
|
|
|
conf.setQueueMappings(existingMappingsForUG);
|
|
|
|
|
|
// override with queue mappings
|
|
@@ -242,12 +301,14 @@ public class TestCapacitySchedulerQueueMappingFactory {
|
|
|
|
|
|
UserGroupMappingPlacementRule r =
|
|
|
(UserGroupMappingPlacementRule) rules.get(0);
|
|
|
+ ApplicationPlacementContext ctx = r.getPlacementForApp(asc, "a");
|
|
|
+ assertEquals("Queue", "a", ctx.getQueue());
|
|
|
|
|
|
- ApplicationPlacementContext ctx = r.getPlacementForApp(asc, "user1");
|
|
|
- assertEquals("Queue", "b1", ctx.getQueue());
|
|
|
-
|
|
|
- ApplicationPlacementContext ctx2 = r.getPlacementForApp(asc, "user2");
|
|
|
- assertEquals("Queue", "user2", ctx2.getQueue());
|
|
|
- assertEquals("Queue", "c", ctx2.getParentQueue());
|
|
|
+ if (primary) {
|
|
|
+ assertEquals("Primary Group", "agroup", ctx.getParentQueue());
|
|
|
+ } else {
|
|
|
+ assertEquals("Secondary Group", "asubgroup1", ctx.getParentQueue());
|
|
|
+ }
|
|
|
+ mockRM.close();
|
|
|
}
|
|
|
-}
|
|
|
+}
|