Increased the likelihood of leveraging inter-segment concurrency in tests (#12369)

We have recently increased the likelihood of leveraging inter-segment search
concurrency in tests when `newSearcher` is used to create the index
searcher (see #959). When parallel execution is enabled though, it is
dependent on the number of documents and segments. That means
that out of 1000 test runs that use `RandomIndexWriter` to index a random
number of docs up to 100, we will effectively parallelize only a couple
of times.

This commit increases the likelihood of running concurrent searches by
randomly forcing 1 max segments per slice as well as 1 max doc per slice.
This commit is contained in:
Luca Cavanna 2023-06-15 11:35:10 +02:00 committed by GitHub
parent af1afc8cb6
commit bb6ec50d4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 9 deletions

View File

@ -17,7 +17,6 @@
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;
@ -1965,9 +1964,9 @@ public abstract class LuceneTestCase extends Assert {
.addClosedListener(cacheKey -> TestUtil.shutdownExecutorService(ex));
}
IndexSearcher ret;
int maxDocPerSlice = random.nextBoolean() ? 1 : 1 + random.nextInt(1000);
int maxSegmentsPerSlice = random.nextBoolean() ? 1 : 1 + random.nextInt(10);
if (wrapWithAssertions) {
int maxDocPerSlice = 1 + random.nextInt(1000);
int maxSegmentsPerSlice = 1 + random.nextInt(10);
if (random.nextBoolean()) {
ret =
new AssertingIndexSearcher(random, r, ex) {
@ -1985,9 +1984,7 @@ public abstract class LuceneTestCase extends Assert {
}
};
}
} else if (frequently()) {
int maxDocPerSlice = 1 + random.nextInt(1000);
int maxSegmentsPerSlice = 1 + random.nextInt(10);
} else {
ret =
new IndexSearcher(r, ex) {
@Override
@ -1995,9 +1992,6 @@ public abstract class LuceneTestCase extends Assert {
return slices(leaves, maxDocPerSlice, maxSegmentsPerSlice);
}
};
} else {
ret =
random.nextBoolean() ? new IndexSearcher(r, ex) : new IndexSearcher(r.getContext(), ex);
}
ret.setSimilarity(classEnvRule.similarity);
ret.setQueryCachingPolicy(MAYBE_CACHE_POLICY);