Search in sources :

Example 6 with TJob

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());
}
Also used : Project(io.elastest.etm.model.Project) TJobExecution(io.elastest.etm.model.TJobExecution) SutExecution(io.elastest.etm.model.SutExecution) ArrayList(java.util.ArrayList) Parameter(io.elastest.etm.model.Parameter) SutSpecification(io.elastest.etm.model.SutSpecification) TJob(io.elastest.etm.model.TJob) Test(org.junit.jupiter.api.Test)

Example 7 with TJob

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);
}
Also used : TJob(io.elastest.etm.model.TJob)

Example 8 with 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;
}
Also used : HttpClientErrorException(org.springframework.web.client.HttpClientErrorException) TJobExecution(io.elastest.etm.model.TJobExecution) SutSpecification(io.elastest.etm.model.SutSpecification) TJob(io.elastest.etm.model.TJob) Date(java.util.Date)

Example 9 with TJob

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;
}
Also used : ExternalTJobExecution(io.elastest.etm.model.external.ExternalTJobExecution) TJobExecution(io.elastest.etm.model.TJobExecution) TJob(io.elastest.etm.model.TJob) ExternalTJob(io.elastest.etm.model.external.ExternalTJob) HTTPException(javax.xml.ws.http.HTTPException)

Example 10 with TJob

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);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) BasicAttTJob(io.elastest.etm.model.TJob.BasicAttTJob) TJob(io.elastest.etm.model.TJob) JsonView(com.fasterxml.jackson.annotation.JsonView)

Aggregations

TJob (io.elastest.etm.model.TJob)17 TJobExecution (io.elastest.etm.model.TJobExecution)6 Test (org.junit.jupiter.api.Test)6 Project (io.elastest.etm.model.Project)5 SutSpecification (io.elastest.etm.model.SutSpecification)4 ArrayList (java.util.ArrayList)4 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)4 HttpEntity (org.springframework.http.HttpEntity)4 HttpHeaders (org.springframework.http.HttpHeaders)4 Bind (com.github.dockerjava.api.model.Bind)2 Volume (com.github.dockerjava.api.model.Volume)2 Parameter (io.elastest.etm.model.Parameter)2 ExternalTJob (io.elastest.etm.model.external.ExternalTJob)2 HashMap (java.util.HashMap)2 HTTPException (javax.xml.ws.http.HTTPException)2 JsonView (com.fasterxml.jackson.annotation.JsonView)1 CreateContainerCmd (com.github.dockerjava.api.command.CreateContainerCmd)1 CreateContainerResponse (com.github.dockerjava.api.command.CreateContainerResponse)1 DockerClientException (com.github.dockerjava.api.exception.DockerClientException)1 InternalServerErrorException (com.github.dockerjava.api.exception.InternalServerErrorException)1