Search in sources :

Example 1 with EimMonitoringConfig

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

the class SutService method instrumentalizeSut.

public SutSpecification instrumentalizeSut(SutSpecification sut) {
    SutExecution sutExec = createSutExecutionBySut(sut);
    sut.setCurrentSutExec(sutExec.getId());
    sutExec.setUrl(sut.getSpecification());
    // Deploy beats
    EimMonitoringConfig eimMonitoringConfig = sut.getEimMonitoringConfig();
    eimMonitoringConfig.setExec(sut.getSutMonitoringIndex());
    sut.setEimMonitoringConfig(eimMonitoringConfig);
    logger.debug("Instrumentalizing SuT \"" + sut.getName() + "\"");
    this.eimService.instrumentalizeAndDeployBeats(sut.getEimConfig(), sut.getEimMonitoringConfig());
    return sut;
}
Also used : SutExecution(io.elastest.etm.model.SutExecution) EimMonitoringConfig(io.elastest.etm.model.EimMonitoringConfig)

Example 2 with EimMonitoringConfig

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

Aggregations

EimMonitoringConfig (io.elastest.etm.model.EimMonitoringConfig)2 SutExecution (io.elastest.etm.model.SutExecution)2 SutSpecification (io.elastest.etm.model.SutSpecification)1