use of org.junit.jupiter.engine.discovery.ContainerMatrixTestsDiscoverySelectorResolver 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