|
@@ -18,7 +18,10 @@
|
|
|
|
|
|
package org.apache.hadoop.yarn.server.resourcemanager.nodelabels;
|
|
|
|
|
|
+import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.Collection;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -31,6 +34,7 @@ import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
|
|
import org.apache.hadoop.yarn.nodelabels.CommonNodeLabelsManager;
|
|
|
import org.apache.hadoop.yarn.nodelabels.RMNodeLabel;
|
|
|
import org.apache.hadoop.yarn.nodelabels.NodeLabelTestBase;
|
|
|
+import org.apache.hadoop.yarn.server.resourcemanager.MockRM;
|
|
|
import org.apache.hadoop.yarn.util.resource.Resources;
|
|
|
import org.junit.After;
|
|
|
import org.junit.Assert;
|
|
@@ -46,7 +50,8 @@ public class TestRMNodeLabelsManager extends NodeLabelTestBase {
|
|
|
private final Resource LARGE_NODE = Resource.newInstance(1000, 0);
|
|
|
|
|
|
NullRMNodeLabelsManager mgr = null;
|
|
|
-
|
|
|
+ RMNodeLabelsManager lmgr = null;
|
|
|
+ boolean checkQueueCall = false;
|
|
|
@Before
|
|
|
public void before() {
|
|
|
mgr = new NullRMNodeLabelsManager();
|
|
@@ -506,7 +511,46 @@ public class TestRMNodeLabelsManager extends NodeLabelTestBase {
|
|
|
checkNodeLabelInfo(infos, "y", 1, 10);
|
|
|
checkNodeLabelInfo(infos, "z", 0, 0);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ @Test(timeout = 60000)
|
|
|
+ public void testcheckRemoveFromClusterNodeLabelsOfQueue() throws Exception {
|
|
|
+ class TestRMLabelManger extends RMNodeLabelsManager {
|
|
|
+ @Override
|
|
|
+ protected void checkRemoveFromClusterNodeLabelsOfQueue(
|
|
|
+ Collection<String> labelsToRemove) throws IOException {
|
|
|
+ checkQueueCall = true;
|
|
|
+ // Do nothing
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ lmgr = new TestRMLabelManger();
|
|
|
+ Configuration conf = new Configuration();
|
|
|
+ File tempDir = File.createTempFile("nlb", ".tmp");
|
|
|
+ tempDir.delete();
|
|
|
+ tempDir.mkdirs();
|
|
|
+ tempDir.deleteOnExit();
|
|
|
+ conf.set(YarnConfiguration.FS_NODE_LABELS_STORE_ROOT_DIR,
|
|
|
+ tempDir.getAbsolutePath());
|
|
|
+ conf.setBoolean(YarnConfiguration.NODE_LABELS_ENABLED, true);
|
|
|
+ MockRM rm = new MockRM(conf) {
|
|
|
+ @Override
|
|
|
+ public RMNodeLabelsManager createNodeLabelManager() {
|
|
|
+ return lmgr;
|
|
|
+ }
|
|
|
+ };
|
|
|
+ lmgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet("a"));
|
|
|
+ lmgr.removeFromClusterNodeLabels(Arrays.asList(new String[] { "a" }));
|
|
|
+ rm.getRMContext().setNodeLabelManager(lmgr);
|
|
|
+ rm.start();
|
|
|
+ lmgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet("a"));
|
|
|
+ Assert.assertEquals(false, checkQueueCall);
|
|
|
+ lmgr.removeFromClusterNodeLabels(Arrays.asList(new String[] { "a" }));
|
|
|
+ Assert.assertEquals(true, checkQueueCall);
|
|
|
+ lmgr.stop();
|
|
|
+ lmgr.close();
|
|
|
+ rm.stop();
|
|
|
+ }
|
|
|
+
|
|
|
@Test(timeout = 5000)
|
|
|
public void testLabelsToNodesOnNodeActiveDeactive() throws Exception {
|
|
|
// Activate a node without assigning any labels
|