use of org.apache.tez.dag.records.TezDAGID in project tez by apache.
the class TestATSHistoryLoggingService method testATSEventBatching.
@Test(timeout = 20000)
public void testATSEventBatching() {
atsHistoryLoggingService.start();
TezDAGID tezDAGID = TezDAGID.getInstance(ApplicationId.newInstance(100l, 1), 1);
DAGHistoryEvent historyEvent = new DAGHistoryEvent(tezDAGID, new DAGStartedEvent(tezDAGID, 1001l, "user1", "dagName1"));
for (int i = 0; i < 100; ++i) {
atsHistoryLoggingService.handle(historyEvent);
}
try {
Thread.sleep(1000l);
} catch (InterruptedException e) {
// Do nothing
}
LOG.info("ATS entitiesSent=" + atsEntitiesCounter + ", timelineInvocations=" + atsInvokeCounter);
Assert.assertTrue(atsEntitiesCounter > atsInvokeCounter);
Assert.assertEquals(atsEntitiesCounter / 2, atsInvokeCounter);
}
use of org.apache.tez.dag.records.TezDAGID in project tez by apache.
the class TestATSHistoryLoggingService method testNonSessionDomainsAclNull.
@Test(timeout = 10000)
public void testNonSessionDomainsAclNull() throws Exception {
when(historyACLPolicyManager.setupSessionACLs((Configuration) any(), (ApplicationId) any())).thenReturn(null);
atsHistoryLoggingService.start();
verify(historyACLPolicyManager, times(1)).setupSessionACLs((Configuration) any(), (ApplicationId) any());
// Send the event and wait for completion.
TezDAGID dagId1 = TezDAGID.getInstance(appId, 0);
for (DAGHistoryEvent event : makeHistoryEvents(dagId1, atsHistoryLoggingService)) {
atsHistoryLoggingService.handle(event);
}
Thread.sleep(2500);
while (!atsHistoryLoggingService.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.
verify(historyACLPolicyManager, times(0)).updateTimelineEntityDomain(any(), eq("session-id"));
Assert.assertEquals(6, atsEntitiesCounter);
}
use of org.apache.tez.dag.records.TezDAGID in project tez by apache.
the class TestATSHistoryLoggingService method testSessionDomainsFailed.
@Test(timeout = 10000)
public void testSessionDomainsFailed() throws Exception {
when(historyACLPolicyManager.setupSessionACLs((Configuration) any(), (ApplicationId) any())).thenThrow(new IOException());
when(historyACLPolicyManager.setupSessionDAGACLs((Configuration) any(), (ApplicationId) any(), eq("0"), (DAGAccessControls) any())).thenReturn(Collections.singletonMap(TezConfiguration.YARN_ATS_ACL_DAG_DOMAIN_ID, "dag-domain"));
when(appContext.isSession()).thenReturn(true);
atsHistoryLoggingService.start();
verify(historyACLPolicyManager, times(1)).setupSessionACLs((Configuration) any(), (ApplicationId) any());
// Send the event and wait for completion.
TezDAGID dagId1 = TezDAGID.getInstance(appId, 0);
for (DAGHistoryEvent event : makeHistoryEvents(dagId1, atsHistoryLoggingService)) {
atsHistoryLoggingService.handle(event);
}
while (!atsHistoryLoggingService.eventQueue.isEmpty()) {
Thread.sleep(1000);
}
// No dag domain were created.
verify(historyACLPolicyManager, times(0)).setupSessionDAGACLs((Configuration) any(), eq(appId), eq("0"), (DAGAccessControls) any());
// No calls were made for domains.
verify(historyACLPolicyManager, times(0)).updateTimelineEntityDomain(any(), (String) any());
Assert.assertEquals(0, atsEntitiesCounter);
}
use of org.apache.tez.dag.records.TezDAGID in project tez by apache.
the class TestATSHistoryWithACLs method verifyEntityDomains.
private void verifyEntityDomains(ApplicationId applicationId, boolean sameDomain) {
assertNotNull(timelineAddress);
String appUrl = "http://" + timelineAddress + "/ws/v1/timeline/TEZ_APPLICATION/" + "tez_" + applicationId.toString();
LOG.info("Getting timeline entity for tez application: " + appUrl);
TimelineEntity appEntity = getTimelineData(appUrl, TimelineEntity.class);
TezDAGID tezDAGID = TezDAGID.getInstance(applicationId, 1);
String dagUrl = "http://" + timelineAddress + "/ws/v1/timeline/TEZ_DAG_ID/" + tezDAGID.toString();
LOG.info("Getting timeline entity for tez dag: " + dagUrl);
TimelineEntity dagEntity = getTimelineData(dagUrl, TimelineEntity.class);
// App and DAG entities should have different domains
assertEquals(ATSHistoryACLPolicyManager.DOMAIN_ID_PREFIX + applicationId.toString(), appEntity.getDomainId());
if (!sameDomain) {
assertEquals(ATSHistoryACLPolicyManager.DOMAIN_ID_PREFIX + applicationId.toString() + "_1", dagEntity.getDomainId());
} else {
assertEquals(appEntity.getDomainId(), dagEntity.getDomainId());
}
}
use of org.apache.tez.dag.records.TezDAGID in project tez by apache.
the class TestATSHistoryWithACLs method testDagLoggingDisabled.
/**
* use mini cluster to verify data do not push to ats when the daglogging flag
* in dagsubmittedevent is set off
* @throws Exception
*/
@Test(timeout = 50000)
public void testDagLoggingDisabled() throws Exception {
ATSHistoryLoggingService historyLoggingService;
historyLoggingService = ReflectionUtils.createClazzInstance(ATSHistoryLoggingService.class.getName());
AppContext appContext = mock(AppContext.class);
when(appContext.getApplicationID()).thenReturn(ApplicationId.newInstance(0, 1));
historyLoggingService.setAppContext(appContext);
TezConfiguration tezConf = new TezConfiguration(mrrTezCluster.getConfig());
String viewAcls = "nobody nobody_group";
tezConf.set(TezConfiguration.TEZ_AM_VIEW_ACLS, viewAcls);
tezConf.set(TezConfiguration.TEZ_HISTORY_LOGGING_SERVICE_CLASS, ATSHistoryLoggingService.class.getName());
Path remoteStagingDir = remoteFs.makeQualified(new Path("/tmp", String.valueOf(random.nextInt(100000))));
remoteFs.mkdirs(remoteStagingDir);
tezConf.set(TezConfiguration.TEZ_AM_STAGING_DIR, remoteStagingDir.toString());
historyLoggingService.init(tezConf);
historyLoggingService.start();
ApplicationId appId = ApplicationId.newInstance(100l, 1);
TezDAGID tezDAGID = TezDAGID.getInstance(appId, 100);
ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(appId, 1);
DAGPlan dagPlan = DAGPlan.newBuilder().setName("DAGPlanMock").build();
DAGSubmittedEvent submittedEvent = new DAGSubmittedEvent(tezDAGID, 1, dagPlan, appAttemptId, null, "usr", tezConf, null, null);
submittedEvent.setHistoryLoggingEnabled(false);
DAGHistoryEvent event = new DAGHistoryEvent(tezDAGID, submittedEvent);
historyLoggingService.handle(new DAGHistoryEvent(tezDAGID, submittedEvent));
Thread.sleep(1000l);
String url = "http://" + timelineAddress + "/ws/v1/timeline/TEZ_DAG_ID/" + event.getDagID();
Client client = new Client();
WebResource resource = client.resource(url);
ClientResponse response = resource.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
assertEquals(404, response.getStatus());
}
Aggregations