private void cleanup() throws Exception { rm.close(); rm.stop(); }
@Test(expected = YarnException.class) public void testModifyLabelsOnNodesWithCentralizedConfigurationDisabled() throws IOException, YarnException { // create RM and set it's ACTIVE, and set distributed node label // configuration to true MockRM rm = new MockRM(); rm.adminService.isCentralizedNodeLabelConfiguration = false; ((RMContextImpl) rm.getRMContext()) .setHAServiceState(HAServiceState.ACTIVE); RMNodeLabelsManager labelMgr = rm.rmContext.getNodeLabelManager(); // by default, distributed configuration for node label is disabled, this // should pass labelMgr.addToCluserNodeLabelsWithDefaultExclusivity(ImmutableSet.of("x", "y")); rm.adminService.replaceLabelsOnNode(ReplaceLabelsOnNodeRequest .newInstance(ImmutableMap.of(NodeId.newInstance("host", 0), (Set<String>) ImmutableSet.of("x")))); rm.close(); }
@Test public void testModifyLabelsOnNodesWithDistributedConfigurationDisabled() throws IOException, YarnException { // create RM and set it's ACTIVE MockRM rm = new MockRM(); ((RMContextImpl) rm.getRMContext()) .setHAServiceState(HAServiceState.ACTIVE); RMNodeLabelsManager labelMgr = rm.rmContext.getNodeLabelManager(); // by default, distributed configuration for node label is disabled, this // should pass labelMgr.addToCluserNodeLabelsWithDefaultExclusivity(ImmutableSet.of("x", "y")); rm.adminService.replaceLabelsOnNode(ReplaceLabelsOnNodeRequest .newInstance(ImmutableMap.of(NodeId.newInstance("host", 0), (Set<String>) ImmutableSet.of("x")))); rm.close(); }
@Test public void testRemoveClusterNodeLabelsWithCentralizedConfigurationDisabled() throws IOException, YarnException { // create RM and set it's ACTIVE MockRM rm = new MockRM(); ((RMContextImpl) rm.getRMContext()) .setHAServiceState(HAServiceState.ACTIVE); RMNodeLabelsManager labelMgr = rm.rmContext.getNodeLabelManager(); rm.adminService.isCentralizedNodeLabelConfiguration = false; // by default, distributed configuration for node label is disabled, this // should pass labelMgr.addToCluserNodeLabelsWithDefaultExclusivity(ImmutableSet.of("x", "y")); rm.adminService .removeFromClusterNodeLabels(RemoveFromClusterNodeLabelsRequest .newInstance((Set<String>) ImmutableSet.of("x"))); Set<String> clusterNodeLabels = labelMgr.getClusterNodeLabelNames(); assertEquals(1,clusterNodeLabels.size()); rm.close(); }
@Test public void testProxyUserConfiguration() throws Exception { MockRM rm = null; try { rm = new MockRM(conf); rm.start(); // wait for web server starting Thread.sleep(10000); UserGroupInformation proxyUser = UserGroupInformation.createProxyUser( BAR_USER.getShortUserName(), FOO_USER); try { ProxyUsers.getDefaultImpersonationProvider().authorize(proxyUser, ipAddress); } catch (AuthorizationException e) { // Exception is not expected Assert.fail(); } } finally { if (rm != null) { rm.stop(); rm.close(); } } }
@Test public void testProxyUserConfiguration() throws Exception { MockRM rm = null; try { rm = new MockRM(conf); rm.start(); // wait for web server starting Thread.sleep(10000); UserGroupInformation proxyUser = UserGroupInformation.createProxyUser( BAR_USER.getShortUserName(), FOO_USER); try { ProxyUsers.getDefaultImpersonationProvider().authorize(proxyUser, ipAddress); } catch (AuthorizationException e) { // Exception is not expected Assert.fail(); } } finally { if (rm != null) { rm.stop(); rm.close(); } } }
} catch (QueueInvalidException e) { } finally { rm.close();
.assertTrue(attributes.contains(NodeAttributeInfo.newInstance(docker))); rpc.stopProxy(client, conf); rm.close();
.getNumContainers()); rm1.close();
@Test(timeout = 60000) public void testAssignMultipleOffswitchContainers() throws Exception { MockRM rm1 = new MockRM(); rm1.getRMContext().setNodeLabelManager(mgr); rm1.start(); MockNM nm1 = rm1.registerNode("h1:1234", 80 * GB); // launch an app to queue, AM container should be launched in nm1 RMApp app1 = rm1.submitApp(1 * GB, "app", "user", null, "default"); MockAM am1 = MockRM.launchAndRegisterAM(app1, rm1, nm1); am1.allocate("*", 1 * GB, 5, new ArrayList<ContainerId>()); CapacityScheduler cs = (CapacityScheduler) rm1.getResourceScheduler(); RMNode rmNode1 = rm1.getRMContext().getRMNodes().get(nm1.getNodeId()); // Do node heartbeats once cs.handle(new NodeUpdateSchedulerEvent(rmNode1)); FiCaSchedulerApp schedulerApp1 = cs.getApplicationAttempt(am1.getApplicationAttemptId()); // App1 will get one container allocated (plus AM container Assert.assertEquals(2, schedulerApp1.getLiveContainers().size()); // Set assign multiple off-switch containers to 3 CapacitySchedulerConfiguration newCSConf = new CapacitySchedulerConfiguration(); newCSConf.setInt( CapacitySchedulerConfiguration.OFFSWITCH_PER_HEARTBEAT_LIMIT, 3); cs.reinitialize(newCSConf, rm1.getRMContext()); // Do node heartbeats once cs.handle(new NodeUpdateSchedulerEvent(rmNode1)); // App1 will get 3 new container allocated (plus 2 previously allocated // container) Assert.assertEquals(5, schedulerApp1.getLiveContainers().size()); rm1.close(); }
Assert.assertEquals(0, schedulerApp1.getReservedContainers().size()); rm1.close();
Assert.assertEquals(0, schedulerApp1.getReservedContainers().size()); rm1.close();
Assert.assertEquals(100, schedulerApp2.getLiveContainers().size()); rm1.close();
Assert.assertEquals(2, um.getNumActiveUsersWithOnlyPendingApps()); Assert.assertEquals(2, lq.getMetrics().getAppsPending()); rm1.close();