Search in sources :

Example 1 with AdminACLsManager

use of org.apache.hadoop.yarn.security.AdminACLsManager in project hadoop by apache.

the class TestTimelineDataManager method setup.

@Before
public void setup() throws Exception {
    fsPath = new File("target", this.getClass().getSimpleName() + "-tmpDir").getAbsoluteFile();
    fsContext = FileContext.getLocalFSFileContext();
    fsContext.delete(new Path(fsPath.getAbsolutePath()), true);
    Configuration conf = new YarnConfiguration();
    conf.set(YarnConfiguration.TIMELINE_SERVICE_LEVELDB_PATH, fsPath.getAbsolutePath());
    conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_TTL_ENABLE, false);
    store = new LeveldbTimelineStore();
    store.init(conf);
    store.start();
    loadTestEntityData();
    loadVerificationEntityData();
    loadTestDomainData();
    conf.setBoolean(YarnConfiguration.YARN_ACL_ENABLE, false);
    aclsManager = new TimelineACLsManager(conf);
    aclsManager.setTimelineStore(store);
    dataManaer = new TimelineDataManager(store, aclsManager);
    conf.setBoolean(YarnConfiguration.YARN_ACL_ENABLE, true);
    conf.set(YarnConfiguration.YARN_ADMIN_ACL, "admin");
    dataManaer.init(conf);
    adminACLsManager = new AdminACLsManager(conf);
}
Also used : Path(org.apache.hadoop.fs.Path) AdminACLsManager(org.apache.hadoop.yarn.security.AdminACLsManager) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) Configuration(org.apache.hadoop.conf.Configuration) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) File(java.io.File) TimelineACLsManager(org.apache.hadoop.yarn.server.timeline.security.TimelineACLsManager) Before(org.junit.Before)

Example 2 with AdminACLsManager

use of org.apache.hadoop.yarn.security.AdminACLsManager in project hadoop by apache.

the class TestTimelineWebServices method testGetDomainsYarnACLsEnabled.

@Test
public void testGetDomainsYarnACLsEnabled() throws Exception {
    AdminACLsManager oldAdminACLsManager = timelineACLsManager.setAdminACLsManager(adminACLsManager);
    try {
        WebResource r = resource();
        ClientResponse response = r.path("ws").path("v1").path("timeline").path("domain").queryParam("user.name", "owner_1").accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
        assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, response.getType().toString());
        TimelineDomains domains = response.getEntity(TimelineDomains.class);
        Assert.assertEquals(2, domains.getDomains().size());
        for (int i = 0; i < domains.getDomains().size(); ++i) {
            verifyDomain(domains.getDomains().get(i), i == 0 ? "domain_id_4" : "domain_id_1");
        }
        response = r.path("ws").path("v1").path("timeline").path("domain").queryParam("owner", "owner_1").queryParam("user.name", "tester").accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
        assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, response.getType().toString());
        domains = response.getEntity(TimelineDomains.class);
        Assert.assertEquals(0, domains.getDomains().size());
    } finally {
        timelineACLsManager.setAdminACLsManager(oldAdminACLsManager);
    }
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) AdminACLsManager(org.apache.hadoop.yarn.security.AdminACLsManager) TimelineDomains(org.apache.hadoop.yarn.api.records.timeline.TimelineDomains) WebResource(com.sun.jersey.api.client.WebResource) Test(org.junit.Test)

Example 3 with AdminACLsManager

use of org.apache.hadoop.yarn.security.AdminACLsManager in project hadoop by apache.

the class TestTimelineWebServices method testPutDomainYarnACLsEnabled.

@Test
public void testPutDomainYarnACLsEnabled() throws Exception {
    AdminACLsManager oldAdminACLsManager = timelineACLsManager.setAdminACLsManager(adminACLsManager);
    try {
        TimelineDomain domain = new TimelineDomain();
        domain.setId("test_domain_id_acl");
        WebResource r = resource();
        ClientResponse response = r.path("ws").path("v1").path("timeline").path("domain").queryParam("user.name", "tester").accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON).put(ClientResponse.class, domain);
        assertResponseStatusCode(Status.OK, response.getStatusInfo());
        // Update the domain by another user
        response = r.path("ws").path("v1").path("timeline").path("domain").queryParam("user.name", "other").accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON).put(ClientResponse.class, domain);
        assertResponseStatusCode(Status.FORBIDDEN, response.getStatusInfo());
    } finally {
        timelineACLsManager.setAdminACLsManager(oldAdminACLsManager);
    }
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) AdminACLsManager(org.apache.hadoop.yarn.security.AdminACLsManager) WebResource(com.sun.jersey.api.client.WebResource) TimelineDomain(org.apache.hadoop.yarn.api.records.timeline.TimelineDomain) Test(org.junit.Test)

Example 4 with AdminACLsManager

use of org.apache.hadoop.yarn.security.AdminACLsManager in project hadoop by apache.

the class TimelineACLsManager method setAdminACLsManager.

@Private
@VisibleForTesting
public AdminACLsManager setAdminACLsManager(AdminACLsManager adminAclsManager) {
    AdminACLsManager oldAdminACLsManager = this.adminAclsManager;
    this.adminAclsManager = adminAclsManager;
    return oldAdminACLsManager;
}
Also used : AdminACLsManager(org.apache.hadoop.yarn.security.AdminACLsManager) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Private(org.apache.hadoop.classification.InterfaceAudience.Private)

Example 5 with AdminACLsManager

use of org.apache.hadoop.yarn.security.AdminACLsManager in project hadoop by apache.

the class TestTimelineDataManager method testGetEntitiesAclEnabled.

@Test
public void testGetEntitiesAclEnabled() throws Exception {
    AdminACLsManager oldAdminACLsManager = aclsManager.setAdminACLsManager(adminACLsManager);
    try {
        TimelineEntities entities = dataManaer.getEntities("ACL_ENTITY_TYPE_1", null, null, null, null, null, null, 1l, null, UserGroupInformation.createUserForTesting("owner_1", new String[] { "group1" }));
        Assert.assertEquals(1, entities.getEntities().size());
        Assert.assertEquals("ACL_ENTITY_ID_11", entities.getEntities().get(0).getEntityId());
    } finally {
        aclsManager.setAdminACLsManager(oldAdminACLsManager);
    }
}
Also used : AdminACLsManager(org.apache.hadoop.yarn.security.AdminACLsManager) TimelineEntities(org.apache.hadoop.yarn.api.records.timeline.TimelineEntities) Test(org.junit.Test)

Aggregations

AdminACLsManager (org.apache.hadoop.yarn.security.AdminACLsManager)11 Test (org.junit.Test)9 ClientResponse (com.sun.jersey.api.client.ClientResponse)8 WebResource (com.sun.jersey.api.client.WebResource)8 TimelineEntities (org.apache.hadoop.yarn.api.records.timeline.TimelineEntities)6 TimelineEntity (org.apache.hadoop.yarn.api.records.timeline.TimelineEntity)5 TimelinePutResponse (org.apache.hadoop.yarn.api.records.timeline.TimelinePutResponse)5 TimelineDomain (org.apache.hadoop.yarn.api.records.timeline.TimelineDomain)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 File (java.io.File)1 Private (org.apache.hadoop.classification.InterfaceAudience.Private)1 Configuration (org.apache.hadoop.conf.Configuration)1 Path (org.apache.hadoop.fs.Path)1 TimelineDomains (org.apache.hadoop.yarn.api.records.timeline.TimelineDomains)1 TimelineEvent (org.apache.hadoop.yarn.api.records.timeline.TimelineEvent)1 TimelineEvents (org.apache.hadoop.yarn.api.records.timeline.TimelineEvents)1 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)1 TimelineACLsManager (org.apache.hadoop.yarn.server.timeline.security.TimelineACLsManager)1 Before (org.junit.Before)1