|
@@ -21,6 +21,7 @@ package org.apache.hadoop.yarn.server.resourcemanager.webapp;
|
|
|
import static org.junit.Assert.assertEquals;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.Comparator;
|
|
|
import java.util.HashMap;
|
|
@@ -40,6 +41,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.MockNM;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.MockRM;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
|
|
|
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.AutoCreatedQueueTemplate;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSQueueUtils;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration;
|
|
@@ -93,6 +95,7 @@ public class TestRMWebServicesCapacitySchedDynamicConfig extends
|
|
|
private String queueType;
|
|
|
private String creationMethod;
|
|
|
private String autoCreationEligibility;
|
|
|
+ private List<String[]> autoQueueTemplateProperties;
|
|
|
|
|
|
public ExpectedQueueWithProperties(String path, float weight,
|
|
|
float normalizedWeight, String queueType, String creationMethod,
|
|
@@ -103,6 +106,20 @@ public class TestRMWebServicesCapacitySchedDynamicConfig extends
|
|
|
this.queueType = queueType;
|
|
|
this.creationMethod = creationMethod;
|
|
|
this.autoCreationEligibility = autoCreationEligibility;
|
|
|
+ this.autoQueueTemplateProperties = new ArrayList<>();
|
|
|
+ }
|
|
|
+
|
|
|
+ ExpectedQueueWithProperties(
|
|
|
+ String path, float weight, float normalizedWeight, String queueType,
|
|
|
+ String creationMethod, String autoCreationEligibility,
|
|
|
+ List<String[]> autoQueueTemplateProperties) {
|
|
|
+ this.path = path;
|
|
|
+ this.weight = weight;
|
|
|
+ this.normalizedWeight = normalizedWeight;
|
|
|
+ this.queueType = queueType;
|
|
|
+ this.creationMethod = creationMethod;
|
|
|
+ this.autoCreationEligibility = autoCreationEligibility;
|
|
|
+ this.autoQueueTemplateProperties = autoQueueTemplateProperties;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -260,6 +277,10 @@ public class TestRMWebServicesCapacitySchedDynamicConfig extends
|
|
|
.createWeightConfigWithAutoQueueCreationEnabled();
|
|
|
config.set(YarnConfiguration.SCHEDULER_CONFIGURATION_STORE_CLASS,
|
|
|
YarnConfiguration.MEMORY_CONFIGURATION_STORE);
|
|
|
+ config.setInt(CapacitySchedulerConfiguration
|
|
|
+ .getQueuePrefix("root.autoParent1") +
|
|
|
+ AutoCreatedQueueTemplate.AUTO_QUEUE_TEMPLATE_PREFIX +
|
|
|
+ "maximum-applications", 300);
|
|
|
|
|
|
initResourceManager(config);
|
|
|
initAutoQueueHandler();
|
|
@@ -290,6 +311,9 @@ public class TestRMWebServicesCapacitySchedDynamicConfig extends
|
|
|
new ExpectedQueueWithProperties("root",
|
|
|
EXP_ROOT_WEIGHT_IN_WEIGHT_MODE, EXP_ROOT_WEIGHT_IN_WEIGHT_MODE,
|
|
|
PARENT_QUEUE, STATIC_QUEUE, AUTO_CREATION_OFF);
|
|
|
+ List<String[]> templateProperties = new ArrayList<>();
|
|
|
+ templateProperties.add(new String[] {"maximum-applications", "300"});
|
|
|
+
|
|
|
validateSchedulerInfo(json, "weight",
|
|
|
expectedRootQ,
|
|
|
new ExpectedQueueWithProperties("root.auto1",
|
|
@@ -307,7 +331,8 @@ public class TestRMWebServicesCapacitySchedDynamicConfig extends
|
|
|
new ExpectedQueueWithProperties("root.autoParent1",
|
|
|
EXP_DEFAULT_WEIGHT_IN_WEIGHT_MODE,
|
|
|
EXP_DEFAULT_WEIGHT_IN_WEIGHT_MODE / sumOfWeights,
|
|
|
- PARENT_QUEUE, FLEXIBLE_DYNAMIC_QUEUE, AUTO_CREATION_FLEXIBLE),
|
|
|
+ PARENT_QUEUE, FLEXIBLE_DYNAMIC_QUEUE, AUTO_CREATION_FLEXIBLE,
|
|
|
+ templateProperties),
|
|
|
new ExpectedQueueWithProperties("root.default", 10.0f,
|
|
|
10.0f / sumOfWeights,
|
|
|
LEAF_QUEUE, STATIC_QUEUE, AUTO_CREATION_OFF),
|
|
@@ -474,6 +499,22 @@ public class TestRMWebServicesCapacitySchedDynamicConfig extends
|
|
|
queuePath,
|
|
|
expectedQueue.creationMethod, obj.getString("creationMethod"));
|
|
|
|
|
|
+ if (!expectedQueue.autoQueueTemplateProperties.isEmpty()) {
|
|
|
+ JSONArray templates = obj.getJSONObject("autoQueueTemplateProperties")
|
|
|
+ .getJSONArray("property");
|
|
|
+ for (int j = 0; j < templates.length(); j++) {
|
|
|
+ JSONObject prop = templates.getJSONObject(j);
|
|
|
+ Assert.assertEquals("Auto creation eligible queue " +
|
|
|
+ "template key do not match for queue" + queuePath,
|
|
|
+ expectedQueue.autoQueueTemplateProperties.get(j)[0],
|
|
|
+ prop.getString("name"));
|
|
|
+ Assert.assertEquals("Auto creation eligible queue " +
|
|
|
+ "template value do not match for queue" + queuePath,
|
|
|
+ expectedQueue.autoQueueTemplateProperties.get(j)[1],
|
|
|
+ prop.getString("value"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
Assert.assertEquals("Queue auto creation eligibility does not " +
|
|
|
"match for queue " + queuePath,
|
|
|
expectedQueue.autoCreationEligibility,
|