mirror of https://github.com/apache/lucene.git
LUCENE-10459: Update smoke tester for 9.1 (#744)
Add demo dependencies to third party modules. Add an IT that checks whether demo classes are loadable. Co-authored-by: Tomoko Uchida <tomoko.uchida.1111@gmail.com> Co-authored-by: Julie Tibshirani <julietibs@apache.org>
This commit is contained in:
parent
e999056c19
commit
9e9c457f80
|
@ -574,10 +574,10 @@ def verifyUnpacked(java, artifact, unpackPath, gitRevision, version, testArgs):
|
|||
# raise RuntimeError('lucene: file "%s" is missing from artifact %s' % (fileName, artifact))
|
||||
# in_root_folder.remove(fileName)
|
||||
|
||||
expected_folders = ['analysis', 'backward-codecs', 'benchmark', 'classification', 'codecs', 'core',
|
||||
'demo', 'expressions', 'facet', 'grouping', 'highlighter', 'join',
|
||||
expected_folders = ['analysis', 'analysis.tests', 'backward-codecs', 'benchmark', 'classification', 'codecs', 'core', 'core.tests',
|
||||
'distribution.tests', 'demo', 'expressions', 'facet', 'grouping', 'highlighter', 'join',
|
||||
'luke', 'memory', 'misc', 'monitor', 'queries', 'queryparser', 'replicator',
|
||||
'sandbox', 'spatial-extras', 'spatial3d', 'suggest', 'test-framework', 'licenses']
|
||||
'sandbox', 'spatial-extras', 'spatial-test-fixtures', 'spatial3d', 'suggest', 'test-framework', 'licenses']
|
||||
if isSrc:
|
||||
expected_src_root_files = ['build.gradle', 'buildSrc', 'dev-docs', 'dev-tools', 'gradle', 'gradlew',
|
||||
'gradlew.bat', 'help', 'lucene', 'settings.gradle', 'versions.lock', 'versions.props']
|
||||
|
@ -588,7 +588,7 @@ def verifyUnpacked(java, artifact, unpackPath, gitRevision, version, testArgs):
|
|||
if len(in_lucene_folder) > 0:
|
||||
raise RuntimeError('lucene: unexpected files/dirs in artifact %s lucene/ folder: %s' % (artifact, in_lucene_folder))
|
||||
else:
|
||||
is_in_list(in_root_folder, ['bin', 'docs', 'licenses', 'modules', 'modules-thirdparty'])
|
||||
is_in_list(in_root_folder, ['bin', 'docs', 'licenses', 'modules', 'modules-thirdparty', 'modules-test-framework'])
|
||||
|
||||
if len(in_root_folder) > 0:
|
||||
raise RuntimeError('lucene: unexpected files/dirs in artifact %s: %s' % (artifact, in_root_folder))
|
||||
|
@ -657,8 +657,8 @@ def testDemo(run_java, isSrc, version, jdk):
|
|||
indexFilesCmd = 'java -cp "%s" -Dsmoketester=true org.apache.lucene.demo.IndexFiles -index index -docs %s' % (cp, docsDir)
|
||||
searchFilesCmd = 'java -cp "%s" org.apache.lucene.demo.SearchFiles -index index -query lucene' % cp
|
||||
else:
|
||||
# For binary release, set up classpath as modules.
|
||||
cp = "--module-path modules"
|
||||
# For binary release, set up module path.
|
||||
cp = "--module-path %s" % (sep.join(["modules", "modules-thirdparty"]))
|
||||
docsDir = 'docs'
|
||||
checkIndexCmd = 'java -ea %s --module org.apache.lucene.core/org.apache.lucene.index.CheckIndex index' % cp
|
||||
indexFilesCmd = 'java -Dsmoketester=true %s --module org.apache.lucene.demo/org.apache.lucene.demo.IndexFiles -index index -docs %s' % (cp, docsDir)
|
||||
|
|
|
@ -18,6 +18,7 @@ package org.apache.lucene.distribution;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.module.Configuration;
|
||||
import java.lang.module.ModuleDescriptor;
|
||||
import java.lang.module.ModuleFinder;
|
||||
import java.lang.module.ModuleReader;
|
||||
|
@ -52,11 +53,14 @@ import org.junit.Test;
|
|||
* JUnit, for example).
|
||||
*/
|
||||
public class TestModularLayer extends AbstractLuceneDistributionTest {
|
||||
/** Only core Lucene modules, no third party modules. */
|
||||
private static Set<ModuleReference> allCoreModules;
|
||||
/** All Lucene modules (including the test framework), no third party modules. */
|
||||
private static Set<ModuleReference> allLuceneModules;
|
||||
|
||||
/** {@link ModuleFinder} resolving only the Lucene modules. */
|
||||
private static ModuleFinder coreModulesFinder;
|
||||
/** {@link ModuleFinder} resolving only the core Lucene modules. */
|
||||
private static ModuleFinder allLuceneModulesFinder;
|
||||
|
||||
/** {@link ModuleFinder} resolving Lucene core and third party dependencies. */
|
||||
private static ModuleFinder luceneCoreAndThirdPartyModulesFinder;
|
||||
|
||||
/**
|
||||
* We accept external properties that point to the assembled set of distribution modules and to
|
||||
|
@ -94,21 +98,24 @@ public class TestModularLayer extends AbstractLuceneDistributionTest {
|
|||
+ thirdPartyModulesPath.toAbsolutePath());
|
||||
}
|
||||
|
||||
coreModulesFinder = ModuleFinder.of(modulesPath, testModulesPath);
|
||||
allCoreModules = coreModulesFinder.findAll();
|
||||
allLuceneModulesFinder = ModuleFinder.of(modulesPath, testModulesPath);
|
||||
allLuceneModules = allLuceneModulesFinder.findAll();
|
||||
|
||||
luceneCoreAndThirdPartyModulesFinder = ModuleFinder.of(modulesPath, thirdPartyModulesPath);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void cleanup() {
|
||||
allCoreModules = null;
|
||||
coreModulesFinder = null;
|
||||
allLuceneModules = null;
|
||||
luceneCoreAndThirdPartyModulesFinder = null;
|
||||
allLuceneModulesFinder = null;
|
||||
}
|
||||
|
||||
/** Make sure all published module names remain constant, even if we reorganize the build. */
|
||||
@Test
|
||||
public void testExpectedDistributionModuleNames() {
|
||||
Assertions.assertThat(
|
||||
allCoreModules.stream().map(module -> module.descriptor().name()).sorted())
|
||||
allLuceneModules.stream().map(module -> module.descriptor().name()).sorted())
|
||||
.containsExactly(
|
||||
"org.apache.lucene.analysis.common",
|
||||
"org.apache.lucene.analysis.icu",
|
||||
|
@ -144,10 +151,42 @@ public class TestModularLayer extends AbstractLuceneDistributionTest {
|
|||
"org.apache.lucene.test_framework");
|
||||
}
|
||||
|
||||
/** Try to instantiate the demo classes so that we make sure their module layer is complete. */
|
||||
@Test
|
||||
public void testDemoClassesCanBeLoaded() {
|
||||
ModuleLayer bootLayer = ModuleLayer.boot();
|
||||
Assertions.assertThatNoException()
|
||||
.isThrownBy(
|
||||
() -> {
|
||||
String demoModuleId = "org.apache.lucene.demo";
|
||||
|
||||
Configuration configuration =
|
||||
bootLayer
|
||||
.configuration()
|
||||
.resolve(
|
||||
luceneCoreAndThirdPartyModulesFinder,
|
||||
ModuleFinder.of(),
|
||||
List.of(demoModuleId));
|
||||
|
||||
ModuleLayer layer =
|
||||
bootLayer.defineModulesWithOneLoader(
|
||||
configuration, ClassLoader.getSystemClassLoader());
|
||||
|
||||
for (String className :
|
||||
List.of(
|
||||
"org.apache.lucene.demo.IndexFiles",
|
||||
"org.apache.lucene.demo.SearchFiles",
|
||||
"org.apache.lucene.index.CheckIndex")) {
|
||||
Assertions.assertThat(layer.findLoader(demoModuleId).loadClass(className))
|
||||
.isNotNull();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** Make sure we don't publish automatic modules. */
|
||||
@Test
|
||||
public void testAllCoreModulesAreNamedModules() {
|
||||
Assertions.assertThat(allCoreModules)
|
||||
Assertions.assertThat(allLuceneModules)
|
||||
.allSatisfy(
|
||||
module -> {
|
||||
Assertions.assertThat(module.descriptor().isAutomatic())
|
||||
|
@ -161,7 +200,7 @@ public class TestModularLayer extends AbstractLuceneDistributionTest {
|
|||
public void testAllModulesHaveExpectedVersion() {
|
||||
String luceneBuildVersion = System.getProperty(VERSION_PROPERTY);
|
||||
Assumptions.assumeThat(luceneBuildVersion).isNotNull();
|
||||
for (var module : allCoreModules) {
|
||||
for (var module : allLuceneModules) {
|
||||
Assertions.assertThat(module.descriptor().rawVersion().orElse(null))
|
||||
.as("Version of module: " + module.descriptor().name())
|
||||
.isEqualTo(luceneBuildVersion);
|
||||
|
@ -171,7 +210,7 @@ public class TestModularLayer extends AbstractLuceneDistributionTest {
|
|||
/** Ensure SPIs are equal for the module and classpath layer. */
|
||||
@Test
|
||||
public void testModularAndClasspathProvidersAreConsistent() throws IOException {
|
||||
for (var module : allCoreModules) {
|
||||
for (var module : allLuceneModules) {
|
||||
TreeMap<String, TreeSet<String>> modularProviders = getModularServiceProviders(module);
|
||||
TreeMap<String, TreeSet<String>> classpathProviders = getClasspathServiceProviders(module);
|
||||
|
||||
|
@ -248,7 +287,7 @@ public class TestModularLayer extends AbstractLuceneDistributionTest {
|
|||
*/
|
||||
@Test
|
||||
public void testAllExportedPackagesInSync() throws IOException {
|
||||
for (var module : allCoreModules) {
|
||||
for (var module : allLuceneModules) {
|
||||
Set<String> jarPackages = getJarPackages(module, entry -> true);
|
||||
Set<ModuleDescriptor.Exports> moduleExports = new HashSet<>(module.descriptor().exports());
|
||||
|
||||
|
@ -295,7 +334,7 @@ public class TestModularLayer extends AbstractLuceneDistributionTest {
|
|||
/** This test ensures that all analysis modules open their resources files to core. */
|
||||
@Test
|
||||
public void testAllOpenAnalysisPackagesInSync() throws IOException {
|
||||
for (var module : allCoreModules) {
|
||||
for (var module : allLuceneModules) {
|
||||
if (false == module.descriptor().name().startsWith("org.apache.lucene.analysis.")) {
|
||||
continue; // at moment we only want to open resources inside analysis packages
|
||||
}
|
||||
|
|
|
@ -53,10 +53,12 @@ configure(project(":lucene:distribution")) {
|
|||
transitive = false
|
||||
})
|
||||
|
||||
// The third-party JARs consist of all the transitive dependencies from these modules.
|
||||
// Not sure whether we have to include all the thirdparty JARs from across all the modules.
|
||||
// The third-party JARs consist of all the transitive dependencies from a subset of
|
||||
// all Lucene modules. We only include the demos and Luke. Everything else has to be downloaded
|
||||
// manually or via maven POMs.
|
||||
for (Project module : [
|
||||
project(":lucene:luke")
|
||||
project(":lucene:luke"),
|
||||
project(":lucene:demo")
|
||||
]) {
|
||||
jarsThirdParty(module, {
|
||||
transitive = true
|
||||
|
|
Loading…
Reference in New Issue