diff --git a/gradle/testing/defaults-tests.gradle b/gradle/testing/defaults-tests.gradle index c74b5fc85c93..25a2291bc182 100644 --- a/gradle/testing/defaults-tests.gradle +++ b/gradle/testing/defaults-tests.gradle @@ -51,7 +51,7 @@ allprojects { includeInReproLine: false ], [propName: 'tests.jvmargs', - value: { -> propertyOrEnvOrDefault("tests.jvmargs", "TEST_JVM_ARGS", isCIBuild ? "" : "-XX:TieredStopAtLevel=1 -XX:+UseParallelGC -XX:ActiveProcessorCount=1") }, + value: { -> envOrDefault("TEST_JVM_ARGS", (isCIBuild || testsDefaultVectorizationRequested()) ? "" : "-XX:TieredStopAtLevel=1 -XX:+UseParallelGC -XX:ActiveProcessorCount=1") }, description: "Arguments passed to each forked JVM."], // Other settings. [propName: 'tests.neverUpToDate', value: true, @@ -66,6 +66,8 @@ allprojects { } return propertyOrDefault(option.propName, option.value) } + + testsDefaultVectorizationRequested = { -> Boolean.parseBoolean(resolvedTestOption('tests.defaultvectorization') as String) } testsCwd = file("${buildDir}/tmp/tests-cwd") testsTmpDir = file(resolvedTestOption("tests.workDir")) @@ -116,8 +118,6 @@ allprojects { ignoreFailures = resolvedTestOption("tests.haltonfailure").toBoolean() == false - jvmArgs Commandline.translateCommandline(resolvedTestOption("tests.jvmargs")) - // Up to JDK-15 we have to enforce --illegal-access=deny, because we want no code to access // JDK internals; JDK-16 and later will default to deny, see https://openjdk.java.net/jeps/396: if (rootProject.runtimeJavaVersion < JavaVersion.VERSION_16) { diff --git a/gradle/testing/randomization.gradle b/gradle/testing/randomization.gradle index bda6dfd299ba..9380b427cb74 100644 --- a/gradle/testing/randomization.gradle +++ b/gradle/testing/randomization.gradle @@ -63,6 +63,7 @@ allprojects { allprojects { plugins.withType(JavaPlugin) { ext { + String randomVectorSize = RandomPicks.randomFrom(new Random(projectSeedLong), ["default", "128", "256", "512"]) testOptions += [ // seed, repetition and amplification. [propName: 'tests.seed', value: { -> rootSeed }, description: "Sets the master randomization seed."], @@ -107,11 +108,13 @@ allprojects { [propName: 'tests.bwcdir', value: null, description: "Data for backward-compatibility indexes."], // vectorization related [propName: 'tests.vectorsize', - value: { -> - RandomPicks.randomFrom(new Random(projectSeedLong), ["128", "256", "512"]) - }, - description: "Sets preferred vector size in bits."], - [propName: 'tests.forceintegervectors', value: "true", description: "Forces use of integer vectors even when slow."], + value: { -> testsDefaultVectorizationRequested() ? 'default' : randomVectorSize }, + description: "Sets preferred vector size in bits."], + [propName: 'tests.forceintegervectors', + value: { -> testsDefaultVectorizationRequested() ? false : (randomVectorSize != 'default') }, + description: "Forces use of integer vectors even when slow."], + [propName: 'tests.defaultvectorization', value: false, + description: "Uses defaults for running tests with correct JVM settings to test Panama vectorization (tests.jvmargs, tests.vectorsize, tests.forceintegervectors)."], ] } } @@ -161,6 +164,8 @@ allprojects { // and not the test JVM itself. systemProperties testOptionsResolved + jvmArgs Commandline.translateCommandline(testOptionsResolved['tests.jvmargs']) + if (Boolean.parseBoolean(testOptionsResolved['tests.asserts'])) { jvmArgs("-ea", "-esa") } else { diff --git a/lucene/core/src/java/org/apache/lucene/internal/vectorization/VectorizationProvider.java b/lucene/core/src/java/org/apache/lucene/internal/vectorization/VectorizationProvider.java index a1f07c6a0435..32ee2aa97b3e 100644 --- a/lucene/core/src/java/org/apache/lucene/internal/vectorization/VectorizationProvider.java +++ b/lucene/core/src/java/org/apache/lucene/internal/vectorization/VectorizationProvider.java @@ -49,7 +49,7 @@ public abstract class VectorizationProvider { try { vs = Stream.ofNullable(System.getProperty("tests.vectorsize")) - .filter(Predicate.not(String::isEmpty)) + .filter(Predicate.not(Set.of("", "default")::contains)) .mapToInt(Integer::parseInt) .findAny(); } catch (