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