use of com.tencent.angel.protobuf.generated.ClientMasterServiceProtos.GetJobReportRequest in project angel by Tencent.
the class AppTest method testGetJobReport.
@SuppressWarnings("unchecked")
@Test
public void testGetJobReport() throws Exception {
try {
AngelApplicationMaster angelAppMaster = LocalClusterContext.get().getMaster().getAppMaster();
Location masterLoc = LocalClusterContext.get().getMaster().getAppMaster().getAppContext().getMasterService().getLocation();
TConnection connection = TConnectionManager.getConnection(angelAppMaster.getConfig());
MasterProtocol master = connection.getMasterService(masterLoc.getIp(), masterLoc.getPort());
int task0Iteration = 2;
int task1Iteration = 1;
int jobIteration = (task0Iteration < task1Iteration) ? task0Iteration : task1Iteration;
master.taskIteration(null, TaskIterationRequest.newBuilder().setIteration(task0Iteration).setTaskId(ProtobufUtil.convertToIdProto(task0Id)).build());
master.taskIteration(null, TaskIterationRequest.newBuilder().setIteration(task1Iteration).setTaskId(ProtobufUtil.convertToIdProto(task1Id)).build());
Thread.sleep(1000);
GetJobReportRequest request = GetJobReportRequest.newBuilder().setAppId(LocalClusterContext.get().getAppId().toString()).build();
GetJobReportResponse response = master.getJobReport(null, request);
assertEquals(response.getJobReport().getJobState(), JobStateProto.J_RUNNING);
assertEquals(response.getJobReport().getCurIteration(), jobIteration);
angelAppMaster.getAppContext().getEventHandler().handle(new InternalErrorEvent(angelAppMaster.getAppContext().getApplicationId(), "failed"));
Thread.sleep(5000);
response = master.getJobReport(null, request);
assertEquals(response.getJobReport().getJobState(), JobStateProto.J_FAILED);
assertEquals(response.getJobReport().getCurIteration(), jobIteration);
assertEquals(response.getJobReport().getDiagnostics(), "failed");
// Thread.sleep(5000);
// response = master.getJobReport(null, request);
// assertEquals(response.getJobReport().getJobState(), JobStateProto.J_FAILED);
// assertEquals(response.getJobReport().getCurIteration(), jobIteration);
// assertEquals(response.getJobReport().getDiagnostics(), "failed");
Thread.sleep(10000);
try {
response = master.getJobReport(null, request);
} catch (Exception x) {
response = tryGetResponseFromFile(true);
}
assertEquals(response.getJobReport().getJobState(), JobStateProto.J_FAILED);
assertEquals(response.getJobReport().getCurIteration(), jobIteration);
assertEquals(response.getJobReport().getDiagnostics(), "failed");
} catch (Exception x) {
LOG.error("run testGetJobReport failed ", x);
throw x;
}
}
Aggregations