Skip to content

YARN-11511. Improve TestRMWebServices test config and data. #5745

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 35 commits into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
b550082
YARN-11511 Improve TestRMWebServices test config and data
K0K0V0K Jun 14, 2023
874beee
YARN-11511 Improve TestRMWebServices test config and data
K0K0V0K Jun 14, 2023
b3fccd5
YARN-11511 Improve TestRMWebServices test config and data
K0K0V0K Jun 14, 2023
0e50850
YARN-11511 Improve TestRMWebServices test config and data
K0K0V0K Jun 14, 2023
0c8a746
YARN-11511 Improve TestRMWebServices test config and data
K0K0V0K Jun 14, 2023
e330bb4
YARN-11511 Improve TestRMWebServices test config and data
K0K0V0K Jun 14, 2023
c8fffa5
YARN-11511 Improve TestRMWebServices test config and data
K0K0V0K Jun 14, 2023
b5d8d8f
YARN-11511 Improve TestRMWebServices test config and data
K0K0V0K Jun 14, 2023
83320ee
YARN-11511 Improve TestRMWebServices test config and data
K0K0V0K Jun 15, 2023
c93b07d
YARN-11511 Improve TestRMWebServices test config and data
K0K0V0K Jun 15, 2023
c256b74
YARN-11511 Improve TestRMWebServices test config and data
K0K0V0K Jun 15, 2023
f8c72b3
YARN-11511 Improve TestRMWebServices test config and data
K0K0V0K Jun 15, 2023
e532dff
YARN-11511 Improve TestRMWebServices test config and data
K0K0V0K Jun 16, 2023
e8a213d
Merge branch 'trunk' into YARN-11511
K0K0V0K Jun 16, 2023
7d39cdd
YARN-11511 Improve TestRMWebServices test config and data
K0K0V0K Jun 16, 2023
1111835
YARN-11511 Improve TestRMWebServices test config and data
K0K0V0K Jun 16, 2023
c565c5f
YARN-11511 Improve TestRMWebServices test config and data
K0K0V0K Jun 16, 2023
4831389
YARN-11511 Improve TestRMWebServices test config and data
K0K0V0K Jun 16, 2023
6eda3f1
YARN-11511 Improve TestRMWebServices test config and data
K0K0V0K Jun 16, 2023
9116f53
YARN-11511 Improve TestRMWebServices test config and data
K0K0V0K Jun 16, 2023
1fbf9f0
YARN-11511 Improve TestRMWebServices test config and data
K0K0V0K Jun 16, 2023
2491d41
YARN-11511 Improve TestRMWebServices test config and data
K0K0V0K Jun 19, 2023
5df6603
YARN-11511 Improve TestRMWebServices test config and data
K0K0V0K Jun 19, 2023
761975e
YARN-11511 Improve TestRMWebServices test config and data
K0K0V0K Jun 19, 2023
2aedd64
YARN-11511 Improve TestRMWebServices test config and data
K0K0V0K Jun 19, 2023
362cca5
fix conflict resolution
tomicooler Jun 19, 2023
cc69339
YARN-11511 Improve TestRMWebServices test config and data
K0K0V0K Jun 19, 2023
fbad0a9
YARN-11511 Improve TestRMWebServices test config and data
K0K0V0K Jun 19, 2023
3a81d0e
YARN-11511 Improve TestRMWebServices test config and data
K0K0V0K Jun 19, 2023
e3fa6eb
YARN-11511 Improve TestRMWebServices test config and data
K0K0V0K Jun 19, 2023
35b2436
YARN-11511 Improve TestRMWebServices test config and data
K0K0V0K Jun 19, 2023
bec7ab3
YARN-11511 Improve TestRMWebServices test config and data
K0K0V0K Jun 19, 2023
d2f3fb8
YARN-11511 Improve TestRMWebServices test config and data
K0K0V0K Jun 19, 2023
b04ead4
YARN-11511 Improve TestRMWebServices test config and data
K0K0V0K Jun 20, 2023
278a117
YARN-11511 Improve TestRMWebServices test config and data
K0K0V0K Jun 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.hadoop.yarn.server.resourcemanager.webapp;

import java.util.HashMap;
import java.util.Map;
import javax.ws.rs.core.MediaType;

import com.sun.jersey.api.client.ClientResponse;
import org.junit.Test;

import org.apache.hadoop.yarn.server.resourcemanager.MockRM;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerQueueManager;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.QueuePath;
import org.apache.hadoop.yarn.webapp.JerseyTestBase;

import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfigGeneratorForTest.createConfiguration;
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerTestUtilities.GB;
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.TestWebServiceUtil.assertJsonResponse;
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.TestWebServiceUtil.createMutableRM;
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.TestWebServiceUtil.createWebAppDescriptor;

public class TestRMWebServicesCapacitySchedLegacyQueueCreation extends
JerseyTestBase {

public TestRMWebServicesCapacitySchedLegacyQueueCreation() {
super(createWebAppDescriptor());
}

@Test
public void testSchedulerResponsePercentageModeLegacyAutoCreation()
throws Exception {
Map<String, String> conf = new HashMap<>();
conf.put("yarn.scheduler.capacity.root.queues", "default, managed");
conf.put("yarn.scheduler.capacity.root.default.capacity", "20");
conf.put("yarn.scheduler.capacity.root.managed.capacity", "80");
conf.put("yarn.scheduler.capacity.root.managed." +
"auto-create-child-queue.enabled", "true");
try (MockRM rm = createMutableRM(createConfiguration(conf))) {
assertJsonResponse(sendRequest(),
"webapp/scheduler-response-PercentageModeLegacyAutoCreation.json");
}
}

@Test
public void testSchedulerResponseAbsoluteModeLegacyAutoCreation()
throws Exception {
Map<String, String> conf = new HashMap<>();
conf.put("yarn.scheduler.capacity.root.queues", "default, managed");
conf.put("yarn.scheduler.capacity.root.default.capacity", "[memory=28672,vcores=28]");
conf.put("yarn.scheduler.capacity.root.managed.capacity", "[memory=4096,vcores=4]");
conf.put("yarn.scheduler.capacity.root.managed.leaf-queue-template.capacity",
"[memory=2048,vcores=2]");
conf.put("yarn.scheduler.capacity.root.managed." +
"auto-create-child-queue.enabled", "true");
conf.put("yarn.scheduler.capacity.root.managed.leaf-queue-template.acl_submit_applications",
"user");
conf.put("yarn.scheduler.capacity.root.managed.leaf-queue-template.acl_administer_queue",
"admin");
try (MockRM rm = createMutableRM(createConfiguration(conf))) {
rm.registerNode("h1:1234", 32 * GB, 32);
CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();
CapacitySchedulerQueueManager autoQueueHandler = cs.getCapacitySchedulerQueueManager();
autoQueueHandler.createQueue(new QueuePath("root.managed.queue1"));
assertJsonResponse(sendRequest(),
"webapp/scheduler-response-AbsoluteModeLegacyAutoCreation.json");
}
}

private ClientResponse sendRequest() {
return resource().path("ws").path("v1").path("cluster")
.path("scheduler").accept(MediaType.APPLICATION_JSON)
.get(ClientResponse.class);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.test.GenericTestUtils;
import org.apache.hadoop.yarn.api.protocolrecords.AllocateRequest;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.activities.ActivityDiagnosticConstant;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.activities.ActivityState;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration;
Expand Down Expand Up @@ -88,8 +90,7 @@
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.ActivitiesTestUtils.verifyNumberOfNodes;
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.ActivitiesTestUtils.verifyQueueOrder;
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.ActivitiesTestUtils.verifyStateOfAllocations;
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.TestRMWebServicesCapacitySched.createMockRM;
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.TestRMWebServicesCapacitySched.createWebAppDescriptor;
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.TestWebServiceUtil.createWebAppDescriptor;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
Expand All @@ -110,10 +111,52 @@ public TestRMWebServicesSchedulerActivities() {
@Override
public void setUp() throws Exception {
super.setUp();
rm = createMockRM(new CapacitySchedulerConfiguration(
new Configuration(false)));
CapacitySchedulerConfiguration config =
createConfig(new CapacitySchedulerConfiguration(new Configuration(false)));
rm = createMockRM(config);
GuiceServletConfig.setInjector(
Guice.createInjector(new TestRMWebServicesCapacitySched.WebServletModule(rm)));
Guice.createInjector(new TestWebServiceUtil.WebServletModule(rm)));
}

public static MockRM createMockRM(CapacitySchedulerConfiguration csConf) {
setupQueueConfiguration(csConf);
YarnConfiguration conf = new YarnConfiguration(csConf);
conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
ResourceScheduler.class);
conf.set(YarnConfiguration.RM_PLACEMENT_CONSTRAINTS_HANDLER,
YarnConfiguration.SCHEDULER_RM_PLACEMENT_CONSTRAINTS_HANDLER);
return new MockRM(conf);
}

public static void setupQueueConfiguration(
CapacitySchedulerConfiguration config) {
config.set("yarn.scheduler.capacity.root.queues", "a, b, c");
config.set("yarn.scheduler.capacity.root.a.queues", "a1, a2");
config.set("yarn.scheduler.capacity.root.b.queues", "b1, b2, b3");
config.set("yarn.scheduler.capacity.root.a.a1.queues", "a1a, a1b, a1c");
config.set("yarn.scheduler.capacity.root.a.capacity", "10.5");
config.set("yarn.scheduler.capacity.root.a.maximum-capacity", "50");
config.set("yarn.scheduler.capacity.root.a.max-parallel-app", "42");
config.set("yarn.scheduler.capacity.root.b.capacity", "79.5");
config.set("yarn.scheduler.capacity.root.c.capacity", "10");
config.set("yarn.scheduler.capacity.root.a.a1.capacity", "30");
config.set("yarn.scheduler.capacity.root.a.a1.maximum-capacity", "50");
config.set("yarn.scheduler.capacity.root.a.a1.user-limit-factor", "100");
config.set("yarn.scheduler.capacity.root.a.a2.capacity", "70");
config.set("yarn.scheduler.capacity.root.a.a2.maximum-application-lifetime", "100");
config.set("yarn.scheduler.capacity.root.a.a2.default-application-lifetime", "50");
config.set("yarn.scheduler.capacity.root.a.a2.user-limit-factor", "100");
config.set("yarn.scheduler.capacity.root.b.b1.capacity", "60");
config.set("yarn.scheduler.capacity.root.b.b2.capacity", "39.5");
config.set("yarn.scheduler.capacity.root.b.b3.capacity", "0.5");
config.set("yarn.scheduler.capacity.root.b.b1.user-limit-factor", "100");
config.set("yarn.scheduler.capacity.root.b.b2.user-limit-factor", "100");
config.set("yarn.scheduler.capacity.root.b.b3.user-limit-factor", "100");
config.set("yarn.scheduler.capacity.root.a.a1.a1a.capacity", "65");
config.set("yarn.scheduler.capacity.root.a.a1.a1b.capacity", "15");
config.set("yarn.scheduler.capacity.root.a.a1.a1c.capacity", "20");
config.set("yarn.scheduler.capacity.root.a.a1.a1c.auto-create-child-queue.enabled", "true");
config.set("yarn.scheduler.capacity.root.a.a1.a1c.leaf-queue-template.capacity", "50");
}

@Test
Expand Down Expand Up @@ -399,7 +442,7 @@ public void testReserveNewContainer() throws Exception {
JSONObject allocations = getFirstSubNodeFromJson(json,
FN_SCHEDULER_ACT_ROOT, FN_ACT_ALLOCATIONS);
verifyQueueOrder(allocations,
"root-root.c-root.a-root.b-root.b.b3-root.b.b1");
"root-root.a-root.c-root.b-root.b.b3-root.b.b1");
verifyStateOfAllocations(allocations, FN_ACT_FINAL_ALLOCATION_STATE,
"RESERVED");

Expand Down Expand Up @@ -1705,4 +1748,35 @@ private void sendHeartbeat(RESTClient restClient, MockNM[] nms)
return restClient.isDone();
}, 10, 20000);
}

private CapacitySchedulerConfiguration createConfig(CapacitySchedulerConfiguration config) {
config.set("yarn.scheduler.capacity.root.queues", "a, b, c");
config.set("yarn.scheduler.capacity.root.a.queues", "a1, a2");
config.set("yarn.scheduler.capacity.root.b.queues", "b1, b2, b3");
config.set("yarn.scheduler.capacity.root.a.a1.queues", "a1a, a1b, a1c");
config.set("yarn.scheduler.capacity.root.a.capacity", "10.5");
config.set("yarn.scheduler.capacity.root.a.maximum-capacity", "50");
config.set("yarn.scheduler.capacity.root.a.max-parallel-app", "42");
config.set("yarn.scheduler.capacity.root.b.capacity", "79.5");
config.set("yarn.scheduler.capacity.root.c.capacity", "10");
config.set("yarn.scheduler.capacity.root.a.a1.capacity", "30");
config.set("yarn.scheduler.capacity.root.a.a1.maximum-capacity", "50");
config.set("yarn.scheduler.capacity.root.a.a1.user-limit-factor", "100");
config.set("yarn.scheduler.capacity.root.a.a2.capacity", "70");
config.set("yarn.scheduler.capacity.root.a.a2.maximum-application-lifetime", "100");
config.set("yarn.scheduler.capacity.root.a.a2.default-application-lifetime", "50");
config.set("yarn.scheduler.capacity.root.a.a2.user-limit-factor", "100");
config.set("yarn.scheduler.capacity.root.b.b1.capacity", "60");
config.set("yarn.scheduler.capacity.root.b.b2.capacity", "39.5");
config.set("yarn.scheduler.capacity.root.b.b3.capacity", "0.5");
config.set("yarn.scheduler.capacity.root.b.b1.user-limit-factor", "100");
config.set("yarn.scheduler.capacity.root.b.b2.user-limit-factor", "100");
config.set("yarn.scheduler.capacity.root.b.b3.user-limit-factor", "100");
config.set("yarn.scheduler.capacity.root.a.a1.a1a.capacity", "65");
config.set("yarn.scheduler.capacity.root.a.a1.a1b.capacity", "15");
config.set("yarn.scheduler.capacity.root.a.a1.a1c.capacity", "20");
config.set("yarn.scheduler.capacity.root.a.a1.a1c.auto-create-child-queue.enabled", "true");
config.set("yarn.scheduler.capacity.root.a.a1.a1c.leaf-queue-template.capacity", "50");
return config;
}
}
Loading