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:
Dawid Weiss 2022-03-11 19:22:17 +01:00 committed by GitHub
parent e999056c19
commit 9e9c457f80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 64 additions and 23 deletions

View File

@ -574,10 +574,10 @@ def verifyUnpacked(java, artifact, unpackPath, gitRevision, version, testArgs):
# raise RuntimeError('lucene: file "%s" is missing from artifact %s' % (fileName, artifact)) # raise RuntimeError('lucene: file "%s" is missing from artifact %s' % (fileName, artifact))
# in_root_folder.remove(fileName) # in_root_folder.remove(fileName)
expected_folders = ['analysis', 'backward-codecs', 'benchmark', 'classification', 'codecs', 'core', expected_folders = ['analysis', 'analysis.tests', 'backward-codecs', 'benchmark', 'classification', 'codecs', 'core', 'core.tests',
'demo', 'expressions', 'facet', 'grouping', 'highlighter', 'join', 'distribution.tests', 'demo', 'expressions', 'facet', 'grouping', 'highlighter', 'join',
'luke', 'memory', 'misc', 'monitor', 'queries', 'queryparser', 'replicator', '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: if isSrc:
expected_src_root_files = ['build.gradle', 'buildSrc', 'dev-docs', 'dev-tools', 'gradle', 'gradlew', expected_src_root_files = ['build.gradle', 'buildSrc', 'dev-docs', 'dev-tools', 'gradle', 'gradlew',
'gradlew.bat', 'help', 'lucene', 'settings.gradle', 'versions.lock', 'versions.props'] '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: if len(in_lucene_folder) > 0:
raise RuntimeError('lucene: unexpected files/dirs in artifact %s lucene/ folder: %s' % (artifact, in_lucene_folder)) raise RuntimeError('lucene: unexpected files/dirs in artifact %s lucene/ folder: %s' % (artifact, in_lucene_folder))
else: 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: if len(in_root_folder) > 0:
raise RuntimeError('lucene: unexpected files/dirs in artifact %s: %s' % (artifact, in_root_folder)) 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) 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 searchFilesCmd = 'java -cp "%s" org.apache.lucene.demo.SearchFiles -index index -query lucene' % cp
else: else:
# For binary release, set up classpath as modules. # For binary release, set up module path.
cp = "--module-path modules" cp = "--module-path %s" % (sep.join(["modules", "modules-thirdparty"]))
docsDir = 'docs' docsDir = 'docs'
checkIndexCmd = 'java -ea %s --module org.apache.lucene.core/org.apache.lucene.index.CheckIndex index' % cp 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) indexFilesCmd = 'java -Dsmoketester=true %s --module org.apache.lucene.demo/org.apache.lucene.demo.IndexFiles -index index -docs %s' % (cp, docsDir)

View File

@ -18,6 +18,7 @@ package org.apache.lucene.distribution;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.lang.module.Configuration;
import java.lang.module.ModuleDescriptor; import java.lang.module.ModuleDescriptor;
import java.lang.module.ModuleFinder; import java.lang.module.ModuleFinder;
import java.lang.module.ModuleReader; import java.lang.module.ModuleReader;
@ -52,11 +53,14 @@ import org.junit.Test;
* JUnit, for example). * JUnit, for example).
*/ */
public class TestModularLayer extends AbstractLuceneDistributionTest { public class TestModularLayer extends AbstractLuceneDistributionTest {
/** Only core Lucene modules, no third party modules. */ /** All Lucene modules (including the test framework), no third party modules. */
private static Set<ModuleReference> allCoreModules; private static Set<ModuleReference> allLuceneModules;
/** {@link ModuleFinder} resolving only the Lucene modules. */ /** {@link ModuleFinder} resolving only the core Lucene modules. */
private static ModuleFinder coreModulesFinder; 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 * 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()); + thirdPartyModulesPath.toAbsolutePath());
} }
coreModulesFinder = ModuleFinder.of(modulesPath, testModulesPath); allLuceneModulesFinder = ModuleFinder.of(modulesPath, testModulesPath);
allCoreModules = coreModulesFinder.findAll(); allLuceneModules = allLuceneModulesFinder.findAll();
luceneCoreAndThirdPartyModulesFinder = ModuleFinder.of(modulesPath, thirdPartyModulesPath);
} }
@AfterClass @AfterClass
public static void cleanup() { public static void cleanup() {
allCoreModules = null; allLuceneModules = null;
coreModulesFinder = null; luceneCoreAndThirdPartyModulesFinder = null;
allLuceneModulesFinder = null;
} }
/** Make sure all published module names remain constant, even if we reorganize the build. */ /** Make sure all published module names remain constant, even if we reorganize the build. */
@Test @Test
public void testExpectedDistributionModuleNames() { public void testExpectedDistributionModuleNames() {
Assertions.assertThat( Assertions.assertThat(
allCoreModules.stream().map(module -> module.descriptor().name()).sorted()) allLuceneModules.stream().map(module -> module.descriptor().name()).sorted())
.containsExactly( .containsExactly(
"org.apache.lucene.analysis.common", "org.apache.lucene.analysis.common",
"org.apache.lucene.analysis.icu", "org.apache.lucene.analysis.icu",
@ -144,10 +151,42 @@ public class TestModularLayer extends AbstractLuceneDistributionTest {
"org.apache.lucene.test_framework"); "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. */ /** Make sure we don't publish automatic modules. */
@Test @Test
public void testAllCoreModulesAreNamedModules() { public void testAllCoreModulesAreNamedModules() {
Assertions.assertThat(allCoreModules) Assertions.assertThat(allLuceneModules)
.allSatisfy( .allSatisfy(
module -> { module -> {
Assertions.assertThat(module.descriptor().isAutomatic()) Assertions.assertThat(module.descriptor().isAutomatic())
@ -161,7 +200,7 @@ public class TestModularLayer extends AbstractLuceneDistributionTest {
public void testAllModulesHaveExpectedVersion() { public void testAllModulesHaveExpectedVersion() {
String luceneBuildVersion = System.getProperty(VERSION_PROPERTY); String luceneBuildVersion = System.getProperty(VERSION_PROPERTY);
Assumptions.assumeThat(luceneBuildVersion).isNotNull(); Assumptions.assumeThat(luceneBuildVersion).isNotNull();
for (var module : allCoreModules) { for (var module : allLuceneModules) {
Assertions.assertThat(module.descriptor().rawVersion().orElse(null)) Assertions.assertThat(module.descriptor().rawVersion().orElse(null))
.as("Version of module: " + module.descriptor().name()) .as("Version of module: " + module.descriptor().name())
.isEqualTo(luceneBuildVersion); .isEqualTo(luceneBuildVersion);
@ -171,7 +210,7 @@ public class TestModularLayer extends AbstractLuceneDistributionTest {
/** Ensure SPIs are equal for the module and classpath layer. */ /** Ensure SPIs are equal for the module and classpath layer. */
@Test @Test
public void testModularAndClasspathProvidersAreConsistent() throws IOException { public void testModularAndClasspathProvidersAreConsistent() throws IOException {
for (var module : allCoreModules) { for (var module : allLuceneModules) {
TreeMap<String, TreeSet<String>> modularProviders = getModularServiceProviders(module); TreeMap<String, TreeSet<String>> modularProviders = getModularServiceProviders(module);
TreeMap<String, TreeSet<String>> classpathProviders = getClasspathServiceProviders(module); TreeMap<String, TreeSet<String>> classpathProviders = getClasspathServiceProviders(module);
@ -248,7 +287,7 @@ public class TestModularLayer extends AbstractLuceneDistributionTest {
*/ */
@Test @Test
public void testAllExportedPackagesInSync() throws IOException { public void testAllExportedPackagesInSync() throws IOException {
for (var module : allCoreModules) { for (var module : allLuceneModules) {
Set<String> jarPackages = getJarPackages(module, entry -> true); Set<String> jarPackages = getJarPackages(module, entry -> true);
Set<ModuleDescriptor.Exports> moduleExports = new HashSet<>(module.descriptor().exports()); 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. */ /** This test ensures that all analysis modules open their resources files to core. */
@Test @Test
public void testAllOpenAnalysisPackagesInSync() throws IOException { public void testAllOpenAnalysisPackagesInSync() throws IOException {
for (var module : allCoreModules) { for (var module : allLuceneModules) {
if (false == module.descriptor().name().startsWith("org.apache.lucene.analysis.")) { if (false == module.descriptor().name().startsWith("org.apache.lucene.analysis.")) {
continue; // at moment we only want to open resources inside analysis packages continue; // at moment we only want to open resources inside analysis packages
} }

View File

@ -53,10 +53,12 @@ configure(project(":lucene:distribution")) {
transitive = false transitive = false
}) })
// The third-party JARs consist of all the transitive dependencies from these modules. // The third-party JARs consist of all the transitive dependencies from a subset of
// Not sure whether we have to include all the thirdparty JARs from across all the modules. // all Lucene modules. We only include the demos and Luke. Everything else has to be downloaded
// manually or via maven POMs.
for (Project module : [ for (Project module : [
project(":lucene:luke") project(":lucene:luke"),
project(":lucene:demo")
]) { ]) {
jarsThirdParty(module, { jarsThirdParty(module, {
transitive = true transitive = true