You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by dw...@apache.org on 2023/11/03 16:05:23 UTC

(lucene) branch main updated: tests.multiplier could be omitted in failed test reproduce line (#12752)

This is an automated email from the ASF dual-hosted git repository.

dweiss pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/lucene.git


The following commit(s) were added to refs/heads/main by this push:
     new d6836d3d0e5 tests.multiplier could be omitted in failed test reproduce line (#12752)
d6836d3d0e5 is described below

commit d6836d3d0e5d33a98b35c0885b9787f46c4be47e
Author: Dawid Weiss <da...@carrotsearch.com>
AuthorDate: Fri Nov 3 17:05:17 2023 +0100

    tests.multiplier could be omitted in failed test reproduce line (#12752)
    
    The default tests.multiplier passed from gradle was 1, but
    LuceneTestCase tried to compute its default value from TESTS_NIGHTLY.
    This could lead to subtle errors: nightly mode failures would not report
    tests.multipler=1 and when started from the IDE, the tests.multiplier
    would be set to 2 (leading to different randomness).
---
 gradle/testing/randomization.gradle                                | 2 +-
 lucene/CHANGES.txt                                                 | 3 +++
 .../src/java/org/apache/lucene/tests/util/LuceneTestCase.java      | 7 ++++++-
 .../apache/lucene/tests/util/RunListenerPrintReproduceInfo.java    | 3 ++-
 4 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/gradle/testing/randomization.gradle b/gradle/testing/randomization.gradle
index 30aad60e9e0..1b56044e071 100644
--- a/gradle/testing/randomization.gradle
+++ b/gradle/testing/randomization.gradle
@@ -67,7 +67,7 @@ allprojects {
           // seed, repetition and amplification.
           [propName: 'tests.seed', value: { -> rootSeed }, description: "Sets the master randomization seed."],
           [propName: 'tests.iters', value: null, description: "Duplicate (re-run) each test case N times."],
-          [propName: 'tests.multiplier', value: 1, description: "Value multiplier for randomized tests."],
+          [propName: 'tests.multiplier', value: null, description: "Value multiplier for randomized tests."],
           [propName: 'tests.maxfailures', value: null, description: "Skip tests after a given number of failures."],
           [propName: 'tests.timeoutSuite', value: null, description: "Timeout (in millis) for an entire suite."],
           [propName: 'tests.failfast', value: "false", description: "Stop the build early on failure.", buildOnly: true],
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 039afcba68d..7467b990080 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -285,6 +285,9 @@ Bug Fixes
 Build
 ---------------------
 
+* GITHUB#12752: tests.multiplier could be omitted in test failure reproduce lines (esp. in
+  nightly mode). (Dawid Weiss)
+
 * GITHUB#12742: JavaCompile tasks may be in up-to-date state when modular dependencies have changed 
   leading to odd runtime errors (Chris Hostetter, Dawid Weiss)
 
diff --git a/lucene/test-framework/src/java/org/apache/lucene/tests/util/LuceneTestCase.java b/lucene/test-framework/src/java/org/apache/lucene/tests/util/LuceneTestCase.java
index 50f87ad0a19..5b114ff9a49 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/tests/util/LuceneTestCase.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/tests/util/LuceneTestCase.java
@@ -476,7 +476,12 @@ public abstract class LuceneTestCase extends Assert {
    * of iterations to scale your tests (for nightly builds).
    */
   public static final int RANDOM_MULTIPLIER =
-      systemPropertyAsInt("tests.multiplier", TEST_NIGHTLY ? 2 : 1);
+      systemPropertyAsInt("tests.multiplier", defaultRandomMultiplier());
+
+  /** Compute the default value of the random multiplier (based on {@link #TEST_NIGHTLY}). */
+  static int defaultRandomMultiplier() {
+    return TEST_NIGHTLY ? 2 : 1;
+  }
 
   /** Leave temporary files on disk, even on successful runs. */
   public static final boolean LEAVE_TEMPORARY;
diff --git a/lucene/test-framework/src/java/org/apache/lucene/tests/util/RunListenerPrintReproduceInfo.java b/lucene/test-framework/src/java/org/apache/lucene/tests/util/RunListenerPrintReproduceInfo.java
index 9fa50a20417..753f27a15c8 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/tests/util/RunListenerPrintReproduceInfo.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/tests/util/RunListenerPrintReproduceInfo.java
@@ -189,7 +189,8 @@ public final class RunListenerPrintReproduceInfo extends RunListener {
     addVmOpt(b, "tests.seed", RandomizedContext.current().getRunnerSeedAsString());
 
     // Test groups and multipliers.
-    if (RANDOM_MULTIPLIER > 1) addVmOpt(b, "tests.multiplier", RANDOM_MULTIPLIER);
+    if (RANDOM_MULTIPLIER != LuceneTestCase.defaultRandomMultiplier())
+      addVmOpt(b, "tests.multiplier", RANDOM_MULTIPLIER);
     if (TEST_NIGHTLY) addVmOpt(b, SYSPROP_NIGHTLY, TEST_NIGHTLY);
     if (TEST_WEEKLY) addVmOpt(b, SYSPROP_WEEKLY, TEST_WEEKLY);
     if (TEST_MONSTER) addVmOpt(b, SYSPROP_MONSTER, TEST_MONSTER);