use of io.elastest.etm.model.TJob in project elastest-torm by elastest.
the class ModelsTest method executionTest.
@Test
public void executionTest() {
Project project = new Project(3l, "name", new ArrayList<TJob>(), new ArrayList<SutSpecification>());
SutSpecification sut = new SutSpecification(34l, "name", "specification", "description", project, new ArrayList<>(), SutTypeEnum.REPOSITORY, false, null, InstrumentedByEnum.WITHOUT, null, ManagedDockerType.IMAGE, CommandsOptionEnum.DEFAULT);
TJob tjob = new TJob(34l, "name", "imageName", sut, project, false, "execDashboardConfig", null);
List<Parameter> params = new ArrayList<>();
params.add(new Parameter(45l, "param1", "value1", tjob, null));
tjob.setParameters(params);
TJobExecution exec = new TJobExecution(45l, 34543534l, ResultEnum.SUCCESS);
List<Parameter> paramsExec = new ArrayList<>();
paramsExec.add(new Parameter(45l, "param1", "value1", tjob, exec));
exec.setParameters(paramsExec);
TJobExecution exec2 = new TJobExecution(45l, 34543534l, ResultEnum.SUCCESS);
List<Parameter> paramsExec2 = new ArrayList<>();
paramsExec2.add(new Parameter(45l, "param1", "value1", tjob, exec2));
exec2.setParameters(paramsExec2);
exec.setTjob(tjob);
exec2.setTjob(tjob);
SutExecution sutExec = new SutExecution(45l, sut, "ssss", DeployStatusEnum.DEPLOYED);
SutExecution sutExec2 = new SutExecution(45l, sut, "ssss", DeployStatusEnum.DEPLOYED);
exec.setSutExecution(sutExec);
exec2.setSutExecution(sutExec2);
assertEquals(exec, exec2);
assertEquals(exec.hashCode(), exec2.hashCode());
}
use of io.elastest.etm.model.TJob in project elastest-torm by elastest.
the class TJobService method deleteTJob.
public void deleteTJob(Long tJobId) {
TJob tJob = tJobRepo.findOne(tJobId);
tJobRepo.delete(tJob);
}
use of io.elastest.etm.model.TJob 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.TJob 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;
}
use of io.elastest.etm.model.TJob in project elastest-torm by elastest.
the class TjobApiController method createTJob.
/**
**************
*/
/**
*** TJobs ****
*/
/**
**************
*/
@JsonView(BasicAttTJob.class)
public ResponseEntity<TJob> createTJob(@ApiParam(value = "TJob object that needs to create", required = true) @Valid @RequestBody TJob body) {
logger.info("Services:" + body.getSelectedServices());
logger.info("Services:" + body.getName());
TJob tJob = tJobService.createTJob(body);
return new ResponseEntity<TJob>(tJob, HttpStatus.OK);
}
Aggregations