use of io.elastest.etm.model.TJobExecution in project elastest-torm by elastest.
the class TJobService method stopTJobExec.
public TJobExecution stopTJobExec(Long tJobExecId) {
TJobExecution tJobExec = tJobExecRepositoryImpl.findOne(tJobExecId);
String mapKey = getMapNameByTJobExec(tJobExec);
Future<Void> asyncExec = asyncExecs.get(mapKey);
boolean cancelExecuted = false;
try {
cancelExecuted = asyncExec.cancel(true);
// If is not cancelled, stop async Exec and stop services
if (cancelExecuted) {
logger.info("Forcing Execution Stop");
try {
tJobExec = tJobExecOrchestratorService.forceEndExecution(tJobExec);
logger.info("Execution Stopped Successfully!");
} catch (Exception e) {
logger.error("Error on forcing Execution stop");
}
} else {
// If is already finished, gets TJobExec
tJobExec = tJobExecRepositoryImpl.findOne(tJobExecId);
}
asyncExecs.remove(mapKey);
} catch (Exception e) {
logger.info("Error during forcing stop", e);
}
return tJobExec;
}
use of io.elastest.etm.model.TJobExecution in project elastest-torm by elastest.
the class TJobService method executeTJob.
public TJobExecution executeTJob(Long tJobId, List<Parameter> parameters, List<Parameter> sutParameters) throws HttpClientErrorException {
TJob tJob = tJobRepo.findOne(tJobId);
SutSpecification sut = tJob.getSut();
// activating yet
if (sut != null && sut.isInstrumentedByElastest() && sut.getEimMonitoringConfig() != null && sut.getEimMonitoringConfig().getBeatsStatus() == BeatsStatusEnum.ACTIVATING) {
throw new HttpClientErrorException(HttpStatus.ACCEPTED);
}
TJobExecution tJobExec = new TJobExecution();
tJobExec.setStartDate(new Date());
if (tJob.getSut() != null && sutParameters != null && !sutParameters.isEmpty()) {
tJob.getSut().setParameters(sutParameters);
}
tJobExec.setTjob(tJob);
if (parameters != null && !parameters.isEmpty()) {
tJobExec.setParameters(parameters);
}
tJobExec = tJobExecRepositoryImpl.save(tJobExec);
// After first save, get real Id
tJobExec.generateMonitoringIndex();
tJobExec = tJobExecRepositoryImpl.save(tJobExec);
Future<Void> asyncExec;
if (!tJob.isExternal()) {
asyncExec = tJobExecOrchestratorService.executeTJob(tJobExec, tJob.getSelectedServices());
asyncExecs.put(getMapNameByTJobExec(tJobExec), asyncExec);
} else {
tJobExecOrchestratorService.executeExternalJob(tJobExec);
}
return tJobExec;
}
use of io.elastest.etm.model.TJobExecution in project elastest-torm by elastest.
the class TjobApiController method getTJobExecResultStatus.
@Override
public ResponseEntity<Map<String, Object>> getTJobExecResultStatus(@ApiParam(value = "TJob Id.", required = true) @PathVariable("tJobId") Long tJobId, @ApiParam(value = "TJob Execution Id.", required = true) @PathVariable("tJobExecId") Long tJobExecId) {
TJobExecution tJobExec = tJobService.getTJobsExecution(tJobId, tJobExecId);
Map<String, Object> response = new HashMap<>();
response.put("result", tJobExec.getResult());
response.put("msg", tJobExec.getResultMsg());
return new ResponseEntity<Map<String, Object>>(response, HttpStatus.OK);
}
use of io.elastest.etm.model.TJobExecution in project elastest-torm by elastest.
the class DockerService2 method removeSutVolumeFolder.
public void removeSutVolumeFolder(DockerExecution dockerExec) {
TJobExecution tJobExec = dockerExec.gettJobexec();
String sutPath = filesService.buildFilesPath(tJobExec, ElastestConstants.SUT_FOLDER);
try {
filesService.removeExecFilesFolder(sutPath);
} catch (IOException e) {
}
}
use of io.elastest.etm.model.TJobExecution in project elastest-torm by elastest.
the class ExternalService method executeExternalTJob.
public ExternalJob executeExternalTJob(ExternalJob externalJob) throws Exception {
logger.info("Executing TJob from external Job.");
try {
logger.debug("Creating TJob data structure.");
TJob tJob = createElasTestEntitiesForExtJob(externalJob);
logger.debug("Creating TJobExecution.");
TJobExecution tJobExec = tJobService.executeTJob(tJob.getId(), new ArrayList<>(), new ArrayList<>());
externalJob.setExecutionUrl((etInProd ? "http://" + etPublicHost + ":" + etProxyPort : "http://localhost" + ":" + etEtmDevGuiPort) + "/#/projects/" + tJob.getProject().getId() + "/tjob/" + tJob.getId() + "/tjob-exec/" + tJobExec.getId() + "/dashboard");
externalJob.setLogAnalyzerUrl((etInProd ? "http://" + etPublicHost + ":" + etProxyPort : "http://localhost" + ":" + etEtmDevGuiPort) + "/#/logmanager?indexName=" + tJobExec.getId());
// externalJob.setEnvVars(tJobExec.getEnvVars());
externalJob.setServicesIp(etPublicHost);
externalJob.setLogstashPort(etInProd ? etProxyPort : etEtmLsHttpPort);
externalJob.settJobExecId(tJobExec.getId());
runningExternalJobs.put(externalJob.gettJobExecId(), externalJob);
} catch (Exception e) {
e.printStackTrace();
logger.error("Error message: " + e.getMessage());
throw e;
}
return externalJob;
}
Aggregations