Search in sources :

Example 11 with SutExecution

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

the class TJobExecOrchestratorService method startManagedSut.

private SutExecution startManagedSut(DockerExecution dockerExec) throws Exception {
    TJobExecution tJobExec = dockerExec.gettJobexec();
    SutSpecification sut = dockerExec.gettJobexec().getTjob().getSut();
    String resultMsg = "Executing dockerized SuT";
    updateTJobExecResultStatus(tJobExec, TJobExecution.ResultEnum.EXECUTING_SUT, resultMsg);
    logger.info(resultMsg + " " + dockerExec.getExecutionId());
    SutExecution sutExec = sutService.createSutExecutionBySut(sut);
    try {
        // By Docker Image
        if (sut.getManagedDockerType() != ManagedDockerType.COMPOSE) {
            startSutByDockerImage(dockerExec);
        } else // By Docker Compose
        {
            startSutByDockerCompose(dockerExec);
        }
        sutExec.setDeployStatus(SutExecution.DeployStatusEnum.DEPLOYED);
        String sutContainerId = dockerExec.getAppContainerId();
        String sutIP = dockerService.getContainerIpWithDockerExecution(sutContainerId, dockerExec);
        // If port is defined, wait for SuT ready
        if (sut.getPort() != null) {
            String sutPort = sut.getPort();
            resultMsg = "Waiting for SuT service ready in port " + sutPort;
            logger.info(resultMsg);
            updateTJobExecResultStatus(tJobExec, TJobExecution.ResultEnum.WAITING_SUT, resultMsg);
            // If is Sut In new Container
            if (sut.isSutInNewContainer()) {
                // 8min
                sutIP = this.waitForSutInContainer(dockerExec, 480000);
            }
            // Wait for SuT started
            dockerService.checkSut(dockerExec, sutIP, sutPort);
            endCheckSutExec(dockerExec);
        }
        // Save SuTUrl and Ip into sutexec
        String sutUrl = "http://" + sutIP + ":" + (sut.getPort() != null ? sut.getPort() : "");
        sutExec.setUrl(sutUrl);
        sutExec.setIp(sutIP);
    } catch (TJobStoppedException e) {
        throw e;
    } catch (Exception e) {
        logger.error("Exception during TJob execution", e);
        sutExec.setDeployStatus(SutExecution.DeployStatusEnum.ERROR);
        try {
            sutService.modifySutExec(dockerExec.getSutExec());
        } catch (Exception e1) {
        }
        throw e;
    }
    return sutExec;
}
Also used : TJobExecution(io.elastest.etm.model.TJobExecution) SutExecution(io.elastest.etm.model.SutExecution) SutSpecification(io.elastest.etm.model.SutSpecification) IOException(java.io.IOException)

Example 12 with SutExecution

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

the class SutService method createSutExecutionById.

public SutExecution createSutExecutionById(Long sutId) {
    SutSpecification sut = sutRepository.findOne(sutId);
    SutExecution sutExecution = new SutExecution();
    sutExecution.setSutSpecification(sut);
    return sutExecutionRepository.save(sutExecution);
}
Also used : SutExecution(io.elastest.etm.model.SutExecution) SutSpecification(io.elastest.etm.model.SutSpecification)

Example 13 with SutExecution

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

the class SutService method undeploySut.

public void undeploySut(Long sutId, Long sutExecId) {
    SutSpecification sut = sutRepository.findOne(sutId);
    SutExecution sutExec = sutExecutionRepository.findByIdAndSutSpecification(sutExecId, sut);
    sutExec.setDeployStatus(SutExecution.DeployStatusEnum.UNDEPLOYED);
    sutExecutionRepository.save(sutExec);
}
Also used : SutExecution(io.elastest.etm.model.SutExecution) SutSpecification(io.elastest.etm.model.SutSpecification)

Example 14 with SutExecution

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

the class ModelsTest method testCreateSutExecution.

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

Example 15 with SutExecution

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

the class SutServiceTest method testGetAllSutExecBySutId.

@Test
public void testGetAllSutExecBySutId() {
    List<SutExecution> sutExecutions = new ArrayList<>();
    sutExecutions.add(new SutExecution(2L, sut, null, null));
    sutExecutions.add(new SutExecution(3L, sut, null, null));
    when(sutExecutionRepository.findAll()).thenReturn(sutExecutions);
    List<SutExecution> sutExecutionsResult = sutService.getAllSutExecBySutId(1L);
    assertTrue(sutExecutionsResult.size() == 2);
}
Also used : SutExecution(io.elastest.etm.model.SutExecution) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test)

Aggregations

SutExecution (io.elastest.etm.model.SutExecution)18 SutSpecification (io.elastest.etm.model.SutSpecification)9 Test (org.junit.jupiter.api.Test)8 EimMonitoringConfig (io.elastest.etm.model.EimMonitoringConfig)2 TJobExecution (io.elastest.etm.model.TJobExecution)2 ArrayList (java.util.ArrayList)2 Parameter (io.elastest.etm.model.Parameter)1 Project (io.elastest.etm.model.Project)1 TJob (io.elastest.etm.model.TJob)1 IOException (java.io.IOException)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1