Search in sources :

Example 6 with TJobExecution

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;
}
Also used : TJobExecution(io.elastest.etm.model.TJobExecution) HTTPException(javax.xml.ws.http.HTTPException) IOException(java.io.IOException) HttpClientErrorException(org.springframework.web.client.HttpClientErrorException)

Example 7 with TJobExecution

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;
}
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 8 with TJobExecution

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);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) HashMap(java.util.HashMap) TJobExecution(io.elastest.etm.model.TJobExecution)

Example 9 with TJobExecution

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) {
    }
}
Also used : TJobExecution(io.elastest.etm.model.TJobExecution) IOException(java.io.IOException)

Example 10 with TJobExecution

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;
}
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)

Aggregations

TJobExecution (io.elastest.etm.model.TJobExecution)14 TJob (io.elastest.etm.model.TJob)6 IOException (java.io.IOException)6 SutSpecification (io.elastest.etm.model.SutSpecification)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 HTTPException (javax.xml.ws.http.HTTPException)3 HttpClientErrorException (org.springframework.web.client.HttpClientErrorException)3 DockerClientException (com.github.dockerjava.api.exception.DockerClientException)2 InternalServerErrorException (com.github.dockerjava.api.exception.InternalServerErrorException)2 NotFoundException (com.github.dockerjava.api.exception.NotFoundException)2 NotModifiedException (com.github.dockerjava.api.exception.NotModifiedException)2 Bind (com.github.dockerjava.api.model.Bind)2 Volume (com.github.dockerjava.api.model.Volume)2 Parameter (io.elastest.etm.model.Parameter)2 SutExecution (io.elastest.etm.model.SutExecution)2 ExternalTJobExecution (io.elastest.etm.model.external.ExternalTJobExecution)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)2 SAXException (org.xml.sax.SAXException)2