Skip to content

Commit cc69339

Browse files
committed
YARN-11511 Improve TestRMWebServices test config and data
fix by review
1 parent 362cca5 commit cc69339

13 files changed

+9607
-7640
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesCapacitySched.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ private Configuration createConfig() {
133133
conf.set("yarn.scheduler.capacity.root.a.capacity", "20");
134134
conf.set("yarn.scheduler.capacity.root.a.maximum-capacity", "50");
135135
conf.set("yarn.scheduler.capacity.root.a.max-parallel-app", "42");
136-
conf.set("yarn.scheduler.capacity.root.b.capacity", "79.5");
137-
conf.set("yarn.scheduler.capacity.root.c.capacity", "0.5");
136+
conf.set("yarn.scheduler.capacity.root.b.capacity", "70");
137+
conf.set("yarn.scheduler.capacity.root.c.capacity", "10");
138138
return conf;
139139
}
140140
}

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesCapacitySchedDynamicConfig.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,14 @@ public void testWeightModeFlexibleAQC() throws Exception {
122122
setupAQC(config, "yarn.scheduler.capacity.root.test1.");
123123
setupAQC(config, "yarn.scheduler.capacity.root.test1.test1_1.");
124124
try (MockRM rm = createMutableRM(config)) {
125+
rm.registerNode("h1:1234", 32768, 32);
126+
assertJsonResponse(sendRequest(resource()),
127+
String.format(EXPECTED_FILE_TMPL, "testWeightMode", "before-aqc"));
125128
createAQC(rm, "test1");
126129
createAQC(rm, "test1.test1_1");
127-
rm.registerNode("h1:1234", 32768, 32);
128130
reinitialize(rm, config);
129131
assertJsonResponse(sendRequest(resource()),
130-
String.format(EXPECTED_FILE_TMPL, "testWeightMode", "aqc"));
132+
String.format(EXPECTED_FILE_TMPL, "testWeightMode", "after-aqc"));
131133
}
132134
}
133135

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesCapacitySchedLegacyQueueCreation.java

Lines changed: 32 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import org.junit.After;
2828
import org.junit.Test;
2929

30-
import org.apache.hadoop.conf.Configuration;
3130
import org.apache.hadoop.yarn.exceptions.YarnException;
3231
import org.apache.hadoop.yarn.server.resourcemanager.MockRM;
3332
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler;
@@ -36,76 +35,22 @@
3635
import org.apache.hadoop.yarn.webapp.JerseyTestBase;
3736

3837
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfigGeneratorForTest.createConfiguration;
38+
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerTestUtilities.GB;
3939
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.TestWebServiceUtil.assertJsonResponse;
4040
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.TestWebServiceUtil.createMutableRM;
4141
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.TestWebServiceUtil.createWebAppDescriptor;
4242

4343
public class TestRMWebServicesCapacitySchedLegacyQueueCreation extends
4444
JerseyTestBase {
45-
private MockRM rm;
46-
4745
private CapacitySchedulerQueueManager autoQueueHandler;
4846

4947
public TestRMWebServicesCapacitySchedLegacyQueueCreation() {
5048
super(createWebAppDescriptor());
5149
}
5250

53-
@After
54-
public void shutDown(){
55-
if (rm != null) {
56-
rm.stop();
57-
rm = null;
58-
}
59-
}
60-
6151
@Test
6252
public void testSchedulerResponsePercentageModeLegacyAutoCreation()
6353
throws Exception {
64-
Configuration config = createPercentageConfigLegacyAutoCreation();
65-
66-
rm = createMutableRM(config);
67-
/*
68-
* mode: percentage
69-
* managedtest2.autoCreationEligibility: legacy, others.autoCreationEligibility: off
70-
* weight: -1, normalizedWeight: 0
71-
* root.queueType: parent, others.queueType: leaf
72-
*/
73-
assertJsonResponse(sendRequest(),
74-
"webapp/scheduler-response-PercentageModeLegacyAutoCreation.json");
75-
}
76-
77-
@Test
78-
public void testSchedulerResponseAbsoluteModeLegacyAutoCreation()
79-
throws Exception {
80-
Configuration config = createAbsoluteConfigLegacyAutoCreation();
81-
82-
rm = createMutableRM(config);
83-
84-
initAutoQueueHandler(8192);
85-
createQueue("root.managed.queue1");
86-
87-
assertJsonResponse(sendRequest(),
88-
"webapp/scheduler-response-AbsoluteModeLegacyAutoCreation.json");
89-
}
90-
91-
private void initAutoQueueHandler(int nodeMemory) throws Exception {
92-
CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();
93-
autoQueueHandler = cs.getCapacitySchedulerQueueManager();
94-
rm.registerNode("h1:1234", nodeMemory, 32); // label = x
95-
}
96-
97-
private void createQueue(String queuePath) throws YarnException,
98-
IOException {
99-
autoQueueHandler.createQueue(new QueuePath(queuePath));
100-
}
101-
102-
private ClientResponse sendRequest() {
103-
return resource().path("ws").path("v1").path("cluster")
104-
.path("scheduler").accept(MediaType.APPLICATION_JSON)
105-
.get(ClientResponse.class);
106-
}
107-
108-
private Configuration createPercentageConfigLegacyAutoCreation() {
10954
Map<String, String> conf = new HashMap<>();
11055
conf.put("yarn.scheduler.capacity.root.queues", "default, test1, " +
11156
"managedtest2");
@@ -116,10 +61,15 @@ private Configuration createPercentageConfigLegacyAutoCreation() {
11661
conf.put("yarn.scheduler.capacity.root.managedtest2.state", "RUNNING");
11762
conf.put("yarn.scheduler.capacity.root.managedtest2." +
11863
"auto-create-child-queue.enabled", "true");
119-
return createConfiguration(conf);
64+
try(MockRM rm = createMutableRM(createConfiguration(conf))) {
65+
assertJsonResponse(sendRequest(),
66+
"webapp/scheduler-response-PercentageModeLegacyAutoCreation.json");
67+
}
12068
}
12169

122-
private Configuration createAbsoluteConfigLegacyAutoCreation() {
70+
@Test
71+
public void testSchedulerResponseAbsoluteModeLegacyAutoCreation()
72+
throws Exception {
12373
Map<String, String> conf = new HashMap<>();
12474
conf.put("yarn.scheduler.capacity.root.queues", "default, managed");
12575
conf.put("yarn.scheduler.capacity.root.default.state", "STOPPED");
@@ -134,6 +84,29 @@ private Configuration createAbsoluteConfigLegacyAutoCreation() {
13484
"user");
13585
conf.put("yarn.scheduler.capacity.root.managed.leaf-queue-template.acl_administer_queue",
13686
"admin");
137-
return createConfiguration(conf);
87+
try (MockRM rm = createMutableRM(createConfiguration(conf))) {
88+
initAutoQueueHandler(rm);
89+
createQueue("root.managed.queue1");
90+
assertJsonResponse(sendRequest(),
91+
"webapp/scheduler-response-AbsoluteModeLegacyAutoCreation.json");
92+
}
93+
}
94+
95+
private void initAutoQueueHandler(MockRM rm) throws Exception {
96+
CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();
97+
autoQueueHandler = cs.getCapacitySchedulerQueueManager();
98+
rm.registerNode("h1:1234", 32 * GB, 32); // label = x
13899
}
100+
101+
private void createQueue(String queuePath) throws YarnException,
102+
IOException {
103+
autoQueueHandler.createQueue(new QueuePath(queuePath));
104+
}
105+
106+
private ClientResponse sendRequest() {
107+
return resource().path("ws").path("v1").path("cluster")
108+
.path("scheduler").accept(MediaType.APPLICATION_JSON)
109+
.get(ClientResponse.class);
110+
}
111+
139112
}

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesSchedulerActivities.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1748,4 +1748,35 @@ private void sendHeartbeat(RESTClient restClient, MockNM[] nms)
17481748
return restClient.isDone();
17491749
}, 10, 20000);
17501750
}
1751+
1752+
private CapacitySchedulerConfiguration createConfig(CapacitySchedulerConfiguration config) {
1753+
config.set("yarn.scheduler.capacity.root.queues", "a, b, c");
1754+
config.set("yarn.scheduler.capacity.root.a.queues", "a1, a2");
1755+
config.set("yarn.scheduler.capacity.root.b.queues", "b1, b2, b3");
1756+
config.set("yarn.scheduler.capacity.root.a.a1.queues", "a1a, a1b, a1c");
1757+
config.set("yarn.scheduler.capacity.root.a.capacity", "10.5");
1758+
config.set("yarn.scheduler.capacity.root.a.maximum-capacity", "50");
1759+
config.set("yarn.scheduler.capacity.root.a.max-parallel-app", "42");
1760+
config.set("yarn.scheduler.capacity.root.b.capacity", "79.5");
1761+
config.set("yarn.scheduler.capacity.root.c.capacity", "10");
1762+
config.set("yarn.scheduler.capacity.root.a.a1.capacity", "30");
1763+
config.set("yarn.scheduler.capacity.root.a.a1.maximum-capacity", "50");
1764+
config.set("yarn.scheduler.capacity.root.a.a1.user-limit-factor", "100");
1765+
config.set("yarn.scheduler.capacity.root.a.a2.capacity", "70");
1766+
config.set("yarn.scheduler.capacity.root.a.a2.maximum-application-lifetime", "100");
1767+
config.set("yarn.scheduler.capacity.root.a.a2.default-application-lifetime", "50");
1768+
config.set("yarn.scheduler.capacity.root.a.a2.user-limit-factor", "100");
1769+
config.set("yarn.scheduler.capacity.root.b.b1.capacity", "60");
1770+
config.set("yarn.scheduler.capacity.root.b.b2.capacity", "39.5");
1771+
config.set("yarn.scheduler.capacity.root.b.b3.capacity", "0.5");
1772+
config.set("yarn.scheduler.capacity.root.b.b1.user-limit-factor", "100");
1773+
config.set("yarn.scheduler.capacity.root.b.b2.user-limit-factor", "100");
1774+
config.set("yarn.scheduler.capacity.root.b.b3.user-limit-factor", "100");
1775+
config.set("yarn.scheduler.capacity.root.a.a1.a1a.capacity", "65");
1776+
config.set("yarn.scheduler.capacity.root.a.a1.a1b.capacity", "15");
1777+
config.set("yarn.scheduler.capacity.root.a.a1.a1c.capacity", "20");
1778+
config.set("yarn.scheduler.capacity.root.a.a1.a1c.auto-create-child-queue.enabled", "true");
1779+
config.set("yarn.scheduler.capacity.root.a.a1.a1c.leaf-queue-template.capacity", "50");
1780+
return config;
1781+
}
17511782
}

0 commit comments

Comments
 (0)