use of org.apache.hadoop.yarn.conf.YarnConfiguration in project hadoop by apache.
the class TestTimelineACLsManager method testYarnACLsEnabledForDomain.
@Test
public void testYarnACLsEnabledForDomain() throws Exception {
Configuration conf = new YarnConfiguration();
conf.setBoolean(YarnConfiguration.YARN_ACL_ENABLE, true);
conf.set(YarnConfiguration.YARN_ADMIN_ACL, "admin");
TimelineACLsManager timelineACLsManager = new TimelineACLsManager(conf);
TimelineDomain domain = new TimelineDomain();
domain.setOwner("owner");
Assert.assertTrue("Owner should be allowed to access", timelineACLsManager.checkAccess(UserGroupInformation.createRemoteUser("owner"), domain));
Assert.assertFalse("Other shouldn't be allowed to access", timelineACLsManager.checkAccess(UserGroupInformation.createRemoteUser("other"), domain));
Assert.assertTrue("Admin should be allowed to access", timelineACLsManager.checkAccess(UserGroupInformation.createRemoteUser("admin"), domain));
}
use of org.apache.hadoop.yarn.conf.YarnConfiguration in project hadoop by apache.
the class TestTimelineACLsManager method testYarnACLsNotEnabledForDomain.
@Test
public void testYarnACLsNotEnabledForDomain() throws Exception {
Configuration conf = new YarnConfiguration();
conf.setBoolean(YarnConfiguration.YARN_ACL_ENABLE, false);
TimelineACLsManager timelineACLsManager = new TimelineACLsManager(conf);
TimelineDomain domain = new TimelineDomain();
domain.setOwner("owner");
Assert.assertTrue("Always true when ACLs are not enabled", timelineACLsManager.checkAccess(UserGroupInformation.createRemoteUser("user"), domain));
}
use of org.apache.hadoop.yarn.conf.YarnConfiguration in project hadoop by apache.
the class TestTimelineACLsManager method testCorruptedOwnerInfoForEntity.
@Test
public void testCorruptedOwnerInfoForEntity() throws Exception {
Configuration conf = new YarnConfiguration();
conf.setBoolean(YarnConfiguration.YARN_ACL_ENABLE, true);
conf.set(YarnConfiguration.YARN_ADMIN_ACL, "owner");
TimelineACLsManager timelineACLsManager = new TimelineACLsManager(conf);
timelineACLsManager.setTimelineStore(new TestTimelineStore());
TimelineEntity entity = new TimelineEntity();
try {
timelineACLsManager.checkAccess(UserGroupInformation.createRemoteUser("owner"), ApplicationAccessType.VIEW_APP, entity);
Assert.fail("Exception is expected");
} catch (YarnException e) {
Assert.assertTrue("It's not the exact expected exception", e.getMessage().contains("doesn't exist."));
}
}
use of org.apache.hadoop.yarn.conf.YarnConfiguration in project hadoop by apache.
the class TestTimelineAuthenticationFilterInitializer method testProxyUserConfiguration.
@Test
public void testProxyUserConfiguration() {
FilterContainer container = Mockito.mock(FilterContainer.class);
for (int i = 0; i < 3; ++i) {
Configuration conf = new YarnConfiguration();
switch(i) {
case 0:
// hadoop.proxyuser prefix
conf.set("hadoop.proxyuser.foo.hosts", "*");
conf.set("hadoop.proxyuser.foo.users", "*");
conf.set("hadoop.proxyuser.foo.groups", "*");
break;
case 1:
// yarn.timeline-service.http-authentication.proxyuser prefix
conf.set(PREFIX + "proxyuser.foo.hosts", "*");
conf.set(PREFIX + "proxyuser.foo.users", "*");
conf.set(PREFIX + "proxyuser.foo.groups", "*");
break;
case 2:
// hadoop.proxyuser prefix has been overwritten by
// yarn.timeline-service.http-authentication.proxyuser prefix
conf.set("hadoop.proxyuser.foo.hosts", "bar");
conf.set("hadoop.proxyuser.foo.users", "bar");
conf.set("hadoop.proxyuser.foo.groups", "bar");
conf.set(PREFIX + "proxyuser.foo.hosts", "*");
conf.set(PREFIX + "proxyuser.foo.users", "*");
conf.set(PREFIX + "proxyuser.foo.groups", "*");
break;
default:
break;
}
TimelineAuthenticationFilterInitializer initializer = new TimelineAuthenticationFilterInitializer();
initializer.initFilter(container, conf);
Assert.assertEquals("*", initializer.filterConfig.get("proxyuser.foo.hosts"));
Assert.assertEquals("*", initializer.filterConfig.get("proxyuser.foo.users"));
Assert.assertEquals("*", initializer.filterConfig.get("proxyuser.foo.groups"));
}
}
use of org.apache.hadoop.yarn.conf.YarnConfiguration in project hadoop by apache.
the class TestNodeManagerResync method testBlockNewContainerRequestsOnStartAndResync.
// This test tests new container requests are blocked when NM starts from
// scratch until it register with RM AND while NM is resyncing with RM
@SuppressWarnings("unchecked")
@Test(timeout = 60000)
public void testBlockNewContainerRequestsOnStartAndResync() throws IOException, InterruptedException, YarnException {
NodeManager nm = new TestNodeManager2();
int port = ServerSocketUtil.getPort(49154, 10);
YarnConfiguration conf = createNMConfig(port);
conf.setBoolean(YarnConfiguration.RM_WORK_PRESERVING_RECOVERY_ENABLED, false);
nm.init(conf);
nm.start();
// Start the container in running state
ContainerId cId = TestNodeManagerShutdown.createContainerId();
TestNodeManagerShutdown.startContainer(nm, cId, localFS, tmpDir, processStartFile, port);
nm.getNMDispatcher().getEventHandler().handle(new NodeManagerEvent(NodeManagerEventType.RESYNC));
try {
syncBarrier.await();
} catch (BrokenBarrierException e) {
}
Assert.assertFalse(assertionFailedInThread.get());
nm.stop();
}
Aggregations