Search in sources :

Example 6 with SutSpecification

use of io.elastest.etm.model.SutSpecification in project elastest-torm by elastest.

the class ModelsTest method testEqualsSutExecution.

@Test
public void testEqualsSutExecution() {
    SutExecution sutExec1 = new SutExecution(1L, new SutSpecification(), "http://localhost:8090", DeployStatusEnum.DEPLOYING);
    SutExecution sutExec2 = new SutExecution(1L, new SutSpecification(), "http://localhost:8090", DeployStatusEnum.DEPLOYING);
    assertTrue(sutExec1.equals(sutExec2));
    assertEquals(sutExec1.hashCode(), sutExec2.hashCode());
}
Also used : SutExecution(io.elastest.etm.model.SutExecution) SutSpecification(io.elastest.etm.model.SutSpecification) Test(org.junit.jupiter.api.Test)

Example 7 with SutSpecification

use of io.elastest.etm.model.SutSpecification in project elastest-torm by elastest.

the class SutService method prepareSutToSave.

public SutSpecification prepareSutToSave(SutSpecification sut) {
    if (sut.getId() == 0) {
        // If is a new Sut, set
        if (!sut.isInstrumentedByElastest()) {
            sut.setEimMonitoringConfig(null);
        } else {
            EimMonitoringConfig savedEimMonitoringConfig = this.eimService.createEimMonitoringConfigAndChilds(sut.getEimMonitoringConfig());
            sut.setEimMonitoringConfig(savedEimMonitoringConfig);
        }
        // Save first
        sut = sutRepository.save(sut);
        SutExecution sutExec = createSutExecutionBySut(sut);
        sut.setCurrentSutExec(sutExec.getId());
        if (sut.isInstrumentalize()) {
            String[] index = { sut.getSutMonitoringIndex() };
            elasticsearchService.createMonitoringIndex(index);
            sut = this.instrumentalizeSut(sut);
        }
    } else {
        SutSpecification savedSut = sutRepository.getOne(sut.getId());
        if (sut.isInstrumentedByElastest()) {
            if (!savedSut.isInstrumentalize() && sut.isInstrumentalize()) {
                // Instrumentalize
                sut = this.instrumentalizeSut(sut);
            } else if (savedSut.isInstrumentalize() && !sut.isInstrumentalize()) {
                // Deinstrumentalize
                logger.debug("Deinstrumentalizing SuT \"" + sut.getName() + "\"");
                this.eimService.deInstrumentalizeAndUnDeployBeats(sut.getEimConfig(), sut.getEimMonitoringConfig());
            } else {
                logger.debug("SuT is already instrumentalized. No changes");
            }
        } else {
            if (savedSut.isInstrumentalize()) {
                this.eimService.deInstrumentalizeAndUnDeployBeats(sut.getEimConfig(), sut.getEimMonitoringConfig());
            }
        }
    }
    return sut;
}
Also used : SutExecution(io.elastest.etm.model.SutExecution) SutSpecification(io.elastest.etm.model.SutSpecification) EimMonitoringConfig(io.elastest.etm.model.EimMonitoringConfig)

Example 8 with SutSpecification

use of io.elastest.etm.model.SutSpecification 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 SutSpecification

use of io.elastest.etm.model.SutSpecification in project elastest-torm by elastest.

the class ExternalTJobExecution method generateMonitoringIndex.

public void generateMonitoringIndex() {
    SutSpecification sut = this.getExTJob().getSut();
    String monitoringIndex = this.getExternalTJobExecMonitoringIndex();
    if (sut != null && sut.getSutType() == SutTypeEnum.DEPLOYED) {
        monitoringIndex += ",s" + sut.getId() + "_e" + sut.getCurrentSutExec();
    }
    this.setMonitoringIndex(monitoringIndex);
}
Also used : SutSpecification(io.elastest.etm.model.SutSpecification)

Example 10 with SutSpecification

use of io.elastest.etm.model.SutSpecification in project elastest-torm by elastest.

the class DockerService2 method getSutPrefix.

public String getSutPrefix(DockerExecution dockerExec) {
    SutSpecification sut = dockerExec.gettJobexec().getTjob().getSut();
    String prefix = "sut_" + dockerExec.getExecutionId();
    if (sut.isDockerCommandsSut() && sut.isSutInNewContainer()) {
        // If is Docker compose Sut
        if (sut.getMainService() != null && !"".equals(sut.getMainService())) {
            prefix = "sut" + dockerExec.getExecutionId();
        }
    }
    return prefix;
}
Also used : SutSpecification(io.elastest.etm.model.SutSpecification)

Aggregations

SutSpecification (io.elastest.etm.model.SutSpecification)23 SutExecution (io.elastest.etm.model.SutExecution)9 Test (org.junit.jupiter.api.Test)7 TJob (io.elastest.etm.model.TJob)4 TJobExecution (io.elastest.etm.model.TJobExecution)4 ArrayList (java.util.ArrayList)4 DockerContainer (io.elastest.epm.client.json.DockerContainerInfo.DockerContainer)3 Parameter (io.elastest.etm.model.Parameter)3 IOException (java.io.IOException)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 HttpEntity (org.springframework.http.HttpEntity)3 HttpHeaders (org.springframework.http.HttpHeaders)3 Container (com.github.dockerjava.api.model.Container)2 Project (io.elastest.etm.model.Project)2 CreateContainerCmd (com.github.dockerjava.api.command.CreateContainerCmd)1 DockerClientException (com.github.dockerjava.api.exception.DockerClientException)1 InternalServerErrorException (com.github.dockerjava.api.exception.InternalServerErrorException)1 NotFoundException (com.github.dockerjava.api.exception.NotFoundException)1 NotModifiedException (com.github.dockerjava.api.exception.NotModifiedException)1 Bind (com.github.dockerjava.api.model.Bind)1