You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by jp...@apache.org on 2022/06/17 15:27:14 UTC

[lucene] branch main updated: Make it more likely to perform concurrent search in tests (#959)

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

jpountz 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 e78b2f2fe05 Make it more likely to perform concurrent search in tests (#959)
e78b2f2fe05 is described below

commit e78b2f2fe052d337a5f825feca09b40582d12097
Author: Luca Cavanna <ja...@users.noreply.github.com>
AuthorDate: Fri Jun 17 17:27:08 2022 +0200

    Make it more likely to perform concurrent search in tests (#959)
    
    1) Replace default useThreads value: rarely() -> randomBoolean()
    2) apply lower slices thresholds more frequently: randomBoolean() -> frequently
    3) lower maxDocsPerSlice and maxSegmentsPerSlice threshold when applied
    4) apply lower maxSegments and maxSegmentsPerSlice also when wrapWithAssertions is true
---
 .../apache/lucene/tests/util/LuceneTestCase.java   | 33 ++++++++++++++++------
 1 file changed, 25 insertions(+), 8 deletions(-)

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 7777424ff69..6fbbcaedcbb 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
@@ -17,6 +17,8 @@
 
 package org.apache.lucene.tests.util;
 
+import static com.carrotsearch.randomizedtesting.RandomizedTest.frequently;
+import static com.carrotsearch.randomizedtesting.RandomizedTest.randomBoolean;
 import static com.carrotsearch.randomizedtesting.RandomizedTest.systemPropertyAsBoolean;
 import static com.carrotsearch.randomizedtesting.RandomizedTest.systemPropertyAsInt;
 import static org.apache.lucene.search.DocIdSetIterator.NO_MORE_DOCS;
@@ -1924,7 +1926,7 @@ public abstract class LuceneTestCase extends Assert {
    */
   public static IndexSearcher newSearcher(
       IndexReader r, boolean maybeWrap, boolean wrapWithAssertions) {
-    return newSearcher(r, maybeWrap, wrapWithAssertions, rarely());
+    return newSearcher(r, maybeWrap, wrapWithAssertions, randomBoolean());
   }
 
   /**
@@ -1996,13 +1998,28 @@ public abstract class LuceneTestCase extends Assert {
       }
       IndexSearcher ret;
       if (wrapWithAssertions) {
-        ret =
-            random.nextBoolean()
-                ? new AssertingIndexSearcher(random, r, ex)
-                : new AssertingIndexSearcher(random, r.getContext(), ex);
-      } else if (random.nextBoolean()) {
-        int maxDocPerSlice = 1 + random.nextInt(100000);
-        int maxSegmentsPerSlice = 1 + random.nextInt(20);
+        int maxDocPerSlice = 1 + random.nextInt(1000);
+        int maxSegmentsPerSlice = 1 + random.nextInt(10);
+        if (random.nextBoolean()) {
+          ret =
+              new AssertingIndexSearcher(random, r, ex) {
+                @Override
+                protected LeafSlice[] slices(List<LeafReaderContext> leaves) {
+                  return slices(leaves, maxDocPerSlice, maxSegmentsPerSlice);
+                }
+              };
+        } else {
+          ret =
+              new AssertingIndexSearcher(random, r.getContext(), ex) {
+                @Override
+                protected LeafSlice[] slices(List<LeafReaderContext> leaves) {
+                  return slices(leaves, maxDocPerSlice, maxSegmentsPerSlice);
+                }
+              };
+        }
+      } else if (frequently()) {
+        int maxDocPerSlice = 1 + random.nextInt(1000);
+        int maxSegmentsPerSlice = 1 + random.nextInt(10);
         ret =
             new IndexSearcher(r, ex) {
               @Override