diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/monitor/capacity/TestProportionalCapacityPreemptionPolicyForNodePartitions.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/monitor/capacity/TestProportionalCapacityPreemptionPolicyForNodePartitions.java index 67c09cd7e5d..80cd0b62688 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/monitor/capacity/TestProportionalCapacityPreemptionPolicyForNodePartitions.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/monitor/capacity/TestProportionalCapacityPreemptionPolicyForNodePartitions.java @@ -689,4 +689,43 @@ public void testNormalizeGuaranteeWithMultipleResource() throws IOException { riMap.remove(RESOURCE_1); ResourceUtils.initializeResourcesFromResourceInformationMap(riMap); } + + @Test + public void testInterQueuePreemptionWithMultipleResource() + throws Exception { + /** + * Queue structure is: + * + *
+     *           root
+     *           /  \
+     *          a    b
+     * 
+ * + */ + + String labelsConfig = "=100:200,true"; // default partition + String nodesConfig = "n1="; // only one node + String queuesConfig = + // guaranteed,max,used,pending + "root(=[100:200 100:200 100:200 100:200]);" + //root + "-a(=[50:100 100:200 40:80 30:70]);" + // a + "-b(=[50:100 100:200 60:120 40:50])"; // b + + String appsConfig = + //queueName\t(priority,resource,host,expression,#repeat,reserved) + "a\t(1,2:4,n1,,20,false);" + // app1 in a + "b\t(1,2:4,n1,,30,false)"; // app2 in b + + buildEnv(labelsConfig, nodesConfig, queuesConfig, appsConfig, true); + policy.editSchedule(); + + // Preemption should happen in Queue b, preempt <10,20> to Queue a + verify(mDisp, never()).handle(argThat( + new TestProportionalCapacityPreemptionPolicy.IsPreemptionRequestFor( + getAppAttemptId(1)))); + verify(mDisp, times(5)).handle(argThat( + new TestProportionalCapacityPreemptionPolicy.IsPreemptionRequestFor( + getAppAttemptId(2)))); + } }