Search in sources :

Example 1 with ContainerizedGraylogBackend

use of org.graylog.testing.completebackend.ContainerizedGraylogBackend in project graylog2-server by Graylog2.

the class ContainerMatrixHierarchicalTestEngine method execute.

@Override
public void execute(ExecutionRequest request) {
    request.getRootTestDescriptor().getChildren().forEach(descriptor -> {
        if (descriptor instanceof ContainerMatrixTestWithRunningESMongoTestsDescriptor) {
            GraylogBackend backend = RunningGraylogBackend.createStarted();
            RequestSpecification specification = requestSpec(backend);
            this.execute(request, ((ContainerMatrixTestsDescriptor) descriptor).getChildren(), backend, specification);
        } else if (descriptor instanceof ContainerMatrixTestsDescriptor) {
            ContainerMatrixTestsDescriptor containerMatrixTestsDescriptor = (ContainerMatrixTestsDescriptor) descriptor;
            SearchVersion esVersion = containerMatrixTestsDescriptor.getEsVersion();
            MongodbServer mongoVersion = containerMatrixTestsDescriptor.getMongoVersion();
            int[] extraPorts = containerMatrixTestsDescriptor.getExtraPorts();
            List<URL> mongoDBFixtures = containerMatrixTestsDescriptor.getMongoDBFixtures();
            PluginJarsProvider pluginJarsProvider = instantiateFactory(containerMatrixTestsDescriptor.getPluginJarsProvider());
            MavenProjectDirProvider mavenProjectDirProvider = instantiateFactory(containerMatrixTestsDescriptor.getMavenProjectDirProvider());
            if (Lifecycle.VM.equals(containerMatrixTestsDescriptor.getLifecycle())) {
                try (ContainerizedGraylogBackend backend = ContainerizedGraylogBackend.createStarted(esVersion, mongoVersion, extraPorts, mongoDBFixtures, pluginJarsProvider, mavenProjectDirProvider)) {
                    RequestSpecification specification = requestSpec(backend);
                    this.execute(request, ((ContainerMatrixTestsDescriptor) descriptor).getChildren(), backend, specification);
                } catch (Exception exception) {
                    throw new JUnitException("Error executing tests for engine " + getId(), exception);
                }
            } else if (Lifecycle.CLASS.equals(containerMatrixTestsDescriptor.getLifecycle())) {
                for (TestDescriptor td : containerMatrixTestsDescriptor.getChildren()) {
                    List<URL> fixtures = mongoDBFixtures;
                    if (td instanceof ContainerMatrixTestClassDescriptor) {
                        fixtures = ((ContainerMatrixTestClassDescriptor) td).getMongoFixtures();
                    }
                    try (ContainerizedGraylogBackend backend = ContainerizedGraylogBackend.createStarted(esVersion, mongoVersion, extraPorts, fixtures, pluginJarsProvider, mavenProjectDirProvider)) {
                        RequestSpecification specification = requestSpec(backend);
                        this.execute(request, Collections.singleton(td), backend, specification);
                    } catch (Exception exception) {
                        throw new JUnitException("Error executing tests for engine " + getId(), exception);
                    }
                }
            } else {
                LOG.error("Unknown lifecycle: " + containerMatrixTestsDescriptor.getLifecycle());
            }
        } else {
            LOG.error("All children of the root should be of type 'ContainerMatrixTestsDescriptor' or 'ContainerMatrixTestWithRunningESMongoTestsDescriptor'");
        }
        request.getEngineExecutionListener().executionFinished(descriptor, TestExecutionResult.successful());
    });
}
Also used : ContainerMatrixTestsDescriptor(org.junit.jupiter.engine.descriptor.ContainerMatrixTestsDescriptor) ContainerMatrixTestClassDescriptor(org.junit.jupiter.engine.descriptor.ContainerMatrixTestClassDescriptor) RequestSpecification(io.restassured.specification.RequestSpecification) JUnitException(org.junit.platform.commons.JUnitException) MavenProjectDirProvider(org.graylog.testing.completebackend.MavenProjectDirProvider) JUnitException(org.junit.platform.commons.JUnitException) URL(java.net.URL) ContainerizedGraylogBackend(org.graylog.testing.completebackend.ContainerizedGraylogBackend) PluginJarsProvider(org.graylog.testing.completebackend.PluginJarsProvider) GraylogBackend(org.graylog.testing.completebackend.GraylogBackend) ContainerizedGraylogBackend(org.graylog.testing.completebackend.ContainerizedGraylogBackend) RunningGraylogBackend(org.graylog.testing.completebackend.RunningGraylogBackend) MongodbServer(org.graylog.testing.containermatrix.MongodbServer) List(java.util.List) SearchVersion(org.graylog2.storage.SearchVersion) TestDescriptor(org.junit.platform.engine.TestDescriptor) ContainerMatrixTestWithRunningESMongoTestsDescriptor(org.junit.jupiter.engine.descriptor.ContainerMatrixTestWithRunningESMongoTestsDescriptor)

Aggregations

RequestSpecification (io.restassured.specification.RequestSpecification)1 URL (java.net.URL)1 List (java.util.List)1 ContainerizedGraylogBackend (org.graylog.testing.completebackend.ContainerizedGraylogBackend)1 GraylogBackend (org.graylog.testing.completebackend.GraylogBackend)1 MavenProjectDirProvider (org.graylog.testing.completebackend.MavenProjectDirProvider)1 PluginJarsProvider (org.graylog.testing.completebackend.PluginJarsProvider)1 RunningGraylogBackend (org.graylog.testing.completebackend.RunningGraylogBackend)1 MongodbServer (org.graylog.testing.containermatrix.MongodbServer)1 SearchVersion (org.graylog2.storage.SearchVersion)1 ContainerMatrixTestClassDescriptor (org.junit.jupiter.engine.descriptor.ContainerMatrixTestClassDescriptor)1 ContainerMatrixTestWithRunningESMongoTestsDescriptor (org.junit.jupiter.engine.descriptor.ContainerMatrixTestWithRunningESMongoTestsDescriptor)1 ContainerMatrixTestsDescriptor (org.junit.jupiter.engine.descriptor.ContainerMatrixTestsDescriptor)1 JUnitException (org.junit.platform.commons.JUnitException)1 TestDescriptor (org.junit.platform.engine.TestDescriptor)1