use of org.apache.tez.dag.history.logging.ats.ATSV15HistoryLoggingService in project tez by apache.
the class TestATSHistoryV15 method testGetGroupId.
@Test
public void testGetGroupId() throws Exception {
ApplicationId appId = ApplicationId.newInstance(1000l, 1);
TezDAGID dagid = TezDAGID.getInstance(appId, 1);
for (final HistoryEventType eventType : HistoryEventType.values()) {
HistoryEvent historyEvent = new HistoryEvent() {
@Override
public HistoryEventType getEventType() {
return eventType;
}
@Override
public boolean isRecoveryEvent() {
return false;
}
@Override
public boolean isHistoryEvent() {
return false;
}
@Override
public void toProtoStream(OutputStream outputStream) throws IOException {
}
@Override
public void fromProtoStream(InputStream inputStream) throws IOException {
}
};
DAGHistoryEvent event = new DAGHistoryEvent(dagid, historyEvent);
ATSV15HistoryLoggingService service = new ATSV15HistoryLoggingService();
AppContext appContext = mock(AppContext.class);
when(appContext.getApplicationID()).thenReturn(appId);
when(appContext.getHadoopShim()).thenReturn(new HadoopShim() {
});
service.setAppContext(appContext);
TimelineEntityGroupId grpId = service.getGroupId(event);
Assert.assertNotNull(grpId);
Assert.assertEquals(appId, grpId.getApplicationId());
switch(eventType) {
case AM_LAUNCHED:
case APP_LAUNCHED:
case AM_STARTED:
case CONTAINER_LAUNCHED:
case CONTAINER_STOPPED:
Assert.assertEquals(appId.toString(), grpId.getTimelineEntityGroupId());
break;
default:
Assert.assertEquals(dagid.toString(), grpId.getTimelineEntityGroupId());
}
service.close();
}
}
Aggregations