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