use of org.graylog.testing.completebackend.PluginJarsProvider 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());
});
}
use of org.graylog.testing.completebackend.PluginJarsProvider in project graylog2-server by Graylog2.
the class ContainerMatrixTestEngine method discover.
@Override
public TestDescriptor discover(EngineDiscoveryRequest discoveryRequest, UniqueId uniqueId) {
JupiterConfiguration configuration = new CachingJupiterConfiguration(new DefaultJupiterConfiguration(discoveryRequest.getConfigurationParameters()));
final ContainerMatrixEngineDescriptor engineDescriptor = new ContainerMatrixEngineDescriptor(uniqueId, "Graylog Container Matrix Tests", configuration);
Reflections reflections = new Reflections("org.graylog", "org.graylog2");
final Set<Class<?>> annotated = reflections.getTypesAnnotatedWith(ContainerMatrixTestsConfiguration.class);
final Set<Integer> extraPorts = getExtraPorts(annotated);
final List<URL> mongoDBFixtures = getMongoDBFixtures(annotated);
if (testAgainstRunningESMongoDB()) {
// if you test from inside an IDE against running containers
ContainerMatrixTestsDescriptor testsDescriptor = new ContainerMatrixTestWithRunningESMongoTestsDescriptor(engineDescriptor, extraPorts, mongoDBFixtures);
new ContainerMatrixTestsDiscoverySelectorResolver(engineDescriptor).resolveSelectors(discoveryRequest, testsDescriptor);
engineDescriptor.addChild(testsDescriptor);
} else {
// for full tests, create all combinations of tests. First differentiate for maven builds.
getMavenProjectDirProvider(annotated).forEach(mavenProjectDirProvider -> getPluginJarsProvider(annotated).forEach(pluginJarsProvider -> {
MavenProjectDirProvider mpdp = instantiateFactory(mavenProjectDirProvider);
PluginJarsProvider pjp = instantiateFactory(pluginJarsProvider);
// now add all grouped tests for Lifecycle.VM
getSearchServerVersions(annotated).stream().map(SearchServer::getSearchVersion).forEach(searchVersion -> getMongoVersions(annotated).forEach(mongoVersion -> {
ContainerMatrixTestsDescriptor testsDescriptor = new ContainerMatrixTestsDescriptor(engineDescriptor, Lifecycle.VM, mavenProjectDirProvider, mpdp.getUniqueId(), pluginJarsProvider, pjp.getUniqueId(), searchVersion, mongoVersion, extraPorts, mongoDBFixtures);
new ContainerMatrixTestsDiscoverySelectorResolver(engineDescriptor).resolveSelectors(discoveryRequest, testsDescriptor);
engineDescriptor.addChild(testsDescriptor);
}));
// add separate test classes (Lifecycle.CLASS)
getSearchServerVersions(annotated).stream().map(SearchServer::getSearchVersion).forEach(esVersion -> getMongoVersions(annotated).forEach(mongoVersion -> {
ContainerMatrixTestsDescriptor testsDescriptor = new ContainerMatrixTestsDescriptor(engineDescriptor, Lifecycle.CLASS, mavenProjectDirProvider, mpdp.getUniqueId(), pluginJarsProvider, pjp.getUniqueId(), esVersion, mongoVersion, extraPorts, new ArrayList<>());
new ContainerMatrixTestsDiscoverySelectorResolver(engineDescriptor).resolveSelectors(discoveryRequest, testsDescriptor);
engineDescriptor.addChild(testsDescriptor);
}));
}));
}
return engineDescriptor;
}
Aggregations