Search in sources :

Example 6 with HistoryACLPolicyManager

use of org.apache.tez.common.security.HistoryACLPolicyManager in project tez by apache.

the class TestATSV15HistoryLoggingService method testNonSessionDomains.

@Test
public void testNonSessionDomains() throws Exception {
    ATSV15HistoryLoggingService service = createService(-1);
    HistoryACLPolicyManager historyACLPolicyManager = mock(HistoryACLPolicyManager.class);
    service.historyACLPolicyManager = historyACLPolicyManager;
    when(historyACLPolicyManager.setupSessionACLs((Configuration) any(), eq(appId))).thenReturn(Collections.singletonMap(TezConfiguration.YARN_ATS_ACL_SESSION_DOMAIN_ID, "session-id"));
    service.start();
    verify(historyACLPolicyManager, times(1)).setupSessionACLs((Configuration) any(), eq(appId));
    // Send the event and wait for completion.
    TezDAGID dagId1 = TezDAGID.getInstance(appId, 0);
    for (DAGHistoryEvent event : makeHistoryEvents(dagId1, service)) {
        service.handle(event);
    }
    while (!service.eventQueue.isEmpty()) {
        Thread.sleep(100);
    }
    // No dag domain were created.
    verify(historyACLPolicyManager, times(0)).setupSessionDAGACLs((Configuration) any(), eq(appId), eq("0"), (DAGAccessControls) any());
    // All calls made with session domain id.
    // NOTE: Expect 6 invocations for 5 history events because DAG_SUBMITTED becomes two separate timeline events.
    verify(historyACLPolicyManager, times(6)).updateTimelineEntityDomain(any(), eq("session-id"));
    assertTrue(entityLog.size() > 0);
    service.stop();
}
Also used : HistoryACLPolicyManager(org.apache.tez.common.security.HistoryACLPolicyManager) TezDAGID(org.apache.tez.dag.records.TezDAGID) DAGHistoryEvent(org.apache.tez.dag.history.DAGHistoryEvent) Test(org.junit.Test)

Example 7 with HistoryACLPolicyManager

use of org.apache.tez.common.security.HistoryACLPolicyManager in project tez by apache.

the class TestATSV15HistoryLoggingService method testNonSessionDomainsAclNull.

@Test
public void testNonSessionDomainsAclNull() throws Exception {
    ATSV15HistoryLoggingService service = createService(-1);
    HistoryACLPolicyManager historyACLPolicyManager = mock(HistoryACLPolicyManager.class);
    service.historyACLPolicyManager = historyACLPolicyManager;
    when(historyACLPolicyManager.setupSessionACLs((Configuration) any(), eq(appId))).thenReturn(null);
    service.start();
    verify(historyACLPolicyManager, times(1)).setupSessionACLs((Configuration) any(), eq(appId));
    // Send the event and wait for completion.
    TezDAGID dagId1 = TezDAGID.getInstance(appId, 0);
    for (DAGHistoryEvent event : makeHistoryEvents(dagId1, service)) {
        service.handle(event);
    }
    while (!service.eventQueue.isEmpty()) {
        Thread.sleep(100);
    }
    // No dag domain were created.
    verify(historyACLPolicyManager, times(0)).setupSessionDAGACLs((Configuration) any(), eq(appId), eq("0"), (DAGAccessControls) any());
    // No domain updates but history logging happened.
    verify(historyACLPolicyManager, times(0)).updateTimelineEntityDomain(any(), (String) any());
    assertTrue(entityLog.size() > 0);
    service.stop();
}
Also used : HistoryACLPolicyManager(org.apache.tez.common.security.HistoryACLPolicyManager) TezDAGID(org.apache.tez.dag.records.TezDAGID) DAGHistoryEvent(org.apache.tez.dag.history.DAGHistoryEvent) Test(org.junit.Test)

Aggregations

HistoryACLPolicyManager (org.apache.tez.common.security.HistoryACLPolicyManager)7 DAGHistoryEvent (org.apache.tez.dag.history.DAGHistoryEvent)6 TezDAGID (org.apache.tez.dag.records.TezDAGID)6 Test (org.junit.Test)6 IOException (java.io.IOException)3 Configuration (org.apache.hadoop.conf.Configuration)1 TimelineEntity (org.apache.hadoop.yarn.api.records.timeline.TimelineEntity)1 TimelineClient (org.apache.hadoop.yarn.client.api.TimelineClient)1 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)1 TezConfiguration (org.apache.tez.dag.api.TezConfiguration)1 AppContext (org.apache.tez.dag.app.AppContext)1 Before (org.junit.Before)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1