Search in sources :

Example 96 with YarnConfiguration

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));
}
Also used : YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) Configuration(org.apache.hadoop.conf.Configuration) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) TimelineDomain(org.apache.hadoop.yarn.api.records.timeline.TimelineDomain) Test(org.junit.Test)

Example 97 with YarnConfiguration

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));
}
Also used : YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) Configuration(org.apache.hadoop.conf.Configuration) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) TimelineDomain(org.apache.hadoop.yarn.api.records.timeline.TimelineDomain) Test(org.junit.Test)

Example 98 with YarnConfiguration

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."));
    }
}
Also used : YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) Configuration(org.apache.hadoop.conf.Configuration) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) TimelineEntity(org.apache.hadoop.yarn.api.records.timeline.TimelineEntity) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) Test(org.junit.Test)

Example 99 with YarnConfiguration

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"));
    }
}
Also used : YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) Configuration(org.apache.hadoop.conf.Configuration) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) FilterContainer(org.apache.hadoop.http.FilterContainer) Test(org.junit.Test)

Example 100 with YarnConfiguration

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();
}
Also used : BrokenBarrierException(java.util.concurrent.BrokenBarrierException) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) ContainerId(org.apache.hadoop.yarn.api.records.ContainerId) BaseContainerManagerTest(org.apache.hadoop.yarn.server.nodemanager.containermanager.BaseContainerManagerTest) Test(org.junit.Test)

Aggregations

YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)477 Test (org.junit.Test)300 Configuration (org.apache.hadoop.conf.Configuration)179 Before (org.junit.Before)65 IOException (java.io.IOException)63 RMApp (org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp)51 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)48 ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)47 ApplicationAttemptId (org.apache.hadoop.yarn.api.records.ApplicationAttemptId)41 Path (org.apache.hadoop.fs.Path)39 MockRM (org.apache.hadoop.yarn.server.resourcemanager.MockRM)38 File (java.io.File)37 ArrayList (java.util.ArrayList)28 HashMap (java.util.HashMap)27 RMContainerTokenSecretManager (org.apache.hadoop.yarn.server.resourcemanager.security.RMContainerTokenSecretManager)27 MockNM (org.apache.hadoop.yarn.server.resourcemanager.MockNM)26 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)25 YarnClient (org.apache.hadoop.yarn.client.api.YarnClient)24 YarnRuntimeException (org.apache.hadoop.yarn.exceptions.YarnRuntimeException)24 RMContextImpl (org.apache.hadoop.yarn.server.resourcemanager.RMContextImpl)24