diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/subcluster/TestFederationSubCluster.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/subcluster/TestFederationSubCluster.java index 3481c456d33a20..71034558687c97 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/subcluster/TestFederationSubCluster.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/subcluster/TestFederationSubCluster.java @@ -246,7 +246,7 @@ public static ClientResponse performCall(final String routerAddress, final Strin builder = toRouterWR.entity(context, APPLICATION_JSON); builder = builder.accept(APPLICATION_JSON); } else { - builder = toRouter.accept(APPLICATION_JSON); + builder = toRouterWR.accept(APPLICATION_JSON); } ClientResponse response = null; diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/subcluster/capacity/TestYarnFederationWithCapacityScheduler.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/subcluster/capacity/TestYarnFederationWithCapacityScheduler.java index 4a43bf458767b7..6976d0412141f7 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/subcluster/capacity/TestYarnFederationWithCapacityScheduler.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/subcluster/capacity/TestYarnFederationWithCapacityScheduler.java @@ -52,6 +52,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NodeLabelsInfo; import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.LabelsToNodesInfo; import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NodeToLabelsInfo; +import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NodeToLabelsEntryList; import org.apache.hadoop.yarn.server.router.subcluster.TestFederationSubCluster; import org.apache.hadoop.yarn.server.router.webapp.dao.FederationClusterInfo; import org.apache.hadoop.yarn.server.router.webapp.dao.FederationClusterUserInfo; @@ -99,6 +100,7 @@ import static org.apache.hadoop.yarn.server.resourcemanager.webapp.RMWSConsts.ADD_NODE_LABELS; import static org.apache.hadoop.yarn.server.resourcemanager.webapp.RMWSConsts.GET_NODE_TO_LABELS; import static org.apache.hadoop.yarn.server.resourcemanager.webapp.RMWSConsts.REMOVE_NODE_LABELS; +import static org.apache.hadoop.yarn.server.resourcemanager.webapp.RMWSConsts.REPLACE_NODE_TO_LABELS; import static org.apache.hadoop.yarn.server.router.subcluster.TestFederationSubCluster.format; import static org.apache.hadoop.yarn.server.router.webapp.HTTPMethods.POST; import static org.apache.hadoop.yarn.server.router.webapp.HTTPMethods.PUT; @@ -595,7 +597,18 @@ public void testRemoveFromClusterNodeLabels() throws Exception { ClientResponse response = TestFederationSubCluster.performCall(ROUTER_WEB_ADDRESS, RM_WEB_SERVICE_PATH + REMOVE_NODE_LABELS, LABELS, "default", null, POST); - assertEquals(SC_BAD_REQUEST, response.getStatus()); + assertEquals(SC_OK, response.getStatus()); + String entity = response.getEntity(String.class); + assertNotNull(entity); + } + + @Test + public void testReplaceLabelsOnNodes() throws Exception { + testFederationSubCluster.addNodeLabel(ROUTER_WEB_ADDRESS); + NodeToLabelsEntryList context = new NodeToLabelsEntryList(); + ClientResponse response = TestFederationSubCluster.performCall(ROUTER_WEB_ADDRESS, + RM_WEB_SERVICE_PATH + REPLACE_NODE_TO_LABELS, + null, null, context, POST); String entity = response.getEntity(String.class); assertNotNull(entity); } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/subcluster/fair/TestYarnFederationWithFairScheduler.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/subcluster/fair/TestYarnFederationWithFairScheduler.java index 9e83a956f92c68..56ec705de95751 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/subcluster/fair/TestYarnFederationWithFairScheduler.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/subcluster/fair/TestYarnFederationWithFairScheduler.java @@ -34,11 +34,11 @@ import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.SchedulerTypeInfo; import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.FairSchedulerInfo; import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.FairSchedulerQueueInfo; +import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ResourceOptionInfo; import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NodesInfo; import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NodeInfo; import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ActivitiesInfo; import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppActivitiesInfo; -import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ResourceOptionInfo; import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ApplicationStatisticsInfo; import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.StatisticsItemInfo; import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NewApplication; @@ -56,6 +56,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NodeLabelsInfo; import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.LabelsToNodesInfo; import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NodeToLabelsInfo; +import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NodeToLabelsEntryList; import org.apache.hadoop.yarn.server.router.subcluster.TestFederationSubCluster; import org.apache.hadoop.yarn.server.router.webapp.dao.FederationClusterInfo; import org.apache.hadoop.yarn.server.router.webapp.dao.FederationClusterUserInfo; @@ -80,11 +81,12 @@ import static org.apache.hadoop.yarn.server.resourcemanager.webapp.RMWSConsts.NODES; import static org.apache.hadoop.yarn.server.resourcemanager.webapp.RMWSConsts.STATES; import static org.apache.hadoop.yarn.server.resourcemanager.webapp.RMWSConsts.NODES_NODEID; -import static org.apache.hadoop.yarn.server.resourcemanager.webapp.RMWSConsts.NODE_RESOURCE; +import static org.apache.hadoop.yarn.server.resourcemanager.webapp.RMWSConsts.NODES_NODEID_REPLACE_LABELS; import static org.apache.hadoop.yarn.server.resourcemanager.webapp.RMWSConsts.SCHEDULER_ACTIVITIES; import static org.apache.hadoop.yarn.server.resourcemanager.webapp.RMWSConsts.APPS_NEW_APPLICATION; import static org.apache.hadoop.yarn.server.resourcemanager.webapp.RMWSConsts.APP_STATISTICS; import static org.apache.hadoop.yarn.server.resourcemanager.webapp.RMWSConsts.APPS; +import static org.apache.hadoop.yarn.server.resourcemanager.webapp.RMWSConsts.APP_ID; import static org.apache.hadoop.yarn.server.resourcemanager.webapp.RMWSConsts.APPS_APPID_APPATTEMPTS; import static org.apache.hadoop.yarn.server.resourcemanager.webapp.RMWSConsts.APPS_APPID_STATE; import static org.apache.hadoop.yarn.server.resourcemanager.webapp.RMWSConsts.APPS_APPID_PRIORITY; @@ -101,8 +103,9 @@ import static org.apache.hadoop.yarn.server.resourcemanager.webapp.RMWSConsts.LABELS; import static org.apache.hadoop.yarn.server.resourcemanager.webapp.RMWSConsts.ADD_NODE_LABELS; import static org.apache.hadoop.yarn.server.resourcemanager.webapp.RMWSConsts.GET_NODE_TO_LABELS; -import static org.apache.hadoop.yarn.server.resourcemanager.webapp.RMWSConsts.APP_ID; import static org.apache.hadoop.yarn.server.resourcemanager.webapp.RMWSConsts.REMOVE_NODE_LABELS; +import static org.apache.hadoop.yarn.server.resourcemanager.webapp.RMWSConsts.REPLACE_NODE_TO_LABELS; +import static org.apache.hadoop.yarn.server.resourcemanager.webapp.RMWSConsts.NODE_RESOURCE; import static org.apache.hadoop.yarn.server.router.subcluster.TestFederationSubCluster.format; import static org.apache.hadoop.yarn.server.router.webapp.HTTPMethods.POST; import static org.apache.hadoop.yarn.server.router.webapp.HTTPMethods.PUT; @@ -605,7 +608,31 @@ public void testRemoveFromClusterNodeLabels() throws Exception { ClientResponse response = TestFederationSubCluster.performCall(ROUTER_WEB_ADDRESS, RM_WEB_SERVICE_PATH + REMOVE_NODE_LABELS, LABELS, "default", null, POST); - assertEquals(SC_BAD_REQUEST, response.getStatus()); + assertEquals(SC_OK, response.getStatus()); + String entity = response.getEntity(String.class); + assertNotNull(entity); + } + + @Test + public void testReplaceLabelsOnNodes() throws Exception { + testFederationSubCluster.addNodeLabel(ROUTER_WEB_ADDRESS); + NodeToLabelsEntryList context = new NodeToLabelsEntryList(); + ClientResponse response = TestFederationSubCluster.performCall(ROUTER_WEB_ADDRESS, + RM_WEB_SERVICE_PATH + REPLACE_NODE_TO_LABELS, + null, null, context, POST); + String entity = response.getEntity(String.class); + assertNotNull(entity); + } + + @Test + public void testReplaceLabelsOnNode() throws Exception { + String rm1NodeId = testFederationSubCluster.getNodeId(SC1_RM_WEB_ADDRESS); + String pathNode = RM_WEB_SERVICE_PATH + + format(NODES_NODEID_REPLACE_LABELS, rm1NodeId); + testFederationSubCluster.addNodeLabel(ROUTER_WEB_ADDRESS); + ClientResponse response = TestFederationSubCluster.performCall(ROUTER_WEB_ADDRESS, + pathNode, LABELS, "default", null, POST); + assertEquals(SC_OK, response.getStatus()); String entity = response.getEntity(String.class); assertNotNull(entity); }