This is an automated email from the ASF dual-hosted git repository.
mdrob pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/main by this push:
new cbe5714 SOLR-15555 Fix cache test that assumed no autowarming
cbe5714 is described below
commit cbe5714f687f1a6aa3b63e2d7eefde359071341a
Author: Mike Drob <[email protected]>
AuthorDate: Wed Sep 15 15:43:27 2021 -0500
SOLR-15555 Fix cache test that assumed no autowarming
---
.../java/org/apache/solr/query/SolrRangeQuery.java | 2 +-
.../java/org/apache/solr/util/TestInjection.java | 4 +-
.../org/apache/solr/search/TestRangeQuery.java | 57 +++++++++++++---------
3 files changed, 36 insertions(+), 27 deletions(-)
diff --git a/solr/core/src/java/org/apache/solr/query/SolrRangeQuery.java
b/solr/core/src/java/org/apache/solr/query/SolrRangeQuery.java
index c400d66..d1e5f23 100644
--- a/solr/core/src/java/org/apache/solr/query/SolrRangeQuery.java
+++ b/solr/core/src/java/org/apache/solr/query/SolrRangeQuery.java
@@ -168,7 +168,7 @@ public final class SolrRangeQuery extends ExtendedQueryBase
implements DocSetPro
}
private DocSet createDocSet(SolrIndexSearcher searcher, long cost) throws
IOException {
- assert TestInjection.injectDocSetDelay();
+ assert TestInjection.injectDocSetDelay(this);
int maxDoc = searcher.maxDoc();
BitDocSet liveDocs = searcher.getLiveDocSet();
FixedBitSet liveBits = liveDocs.size() == maxDoc ? null :
liveDocs.getBits();
diff --git a/solr/core/src/java/org/apache/solr/util/TestInjection.java
b/solr/core/src/java/org/apache/solr/util/TestInjection.java
index 0e62c99..81c2e5a 100644
--- a/solr/core/src/java/org/apache/solr/util/TestInjection.java
+++ b/solr/core/src/java/org/apache/solr/util/TestInjection.java
@@ -582,11 +582,11 @@ public class TestInjection {
return true;
}
- public static boolean injectDocSetDelay() {
+ public static boolean injectDocSetDelay(Object query) {
if (delayBeforeCreatingNewDocSet != null) {
countDocSetDelays.incrementAndGet();
try {
- log.info("Pausing DocSet for {}ms", delayBeforeCreatingNewDocSet);
+ log.info("Pausing DocSet for {}ms: {}", delayBeforeCreatingNewDocSet,
query);
if (log.isDebugEnabled()) {
log.debug("", new Exception("Stack Trace"));
}
diff --git a/solr/core/src/test/org/apache/solr/search/TestRangeQuery.java
b/solr/core/src/test/org/apache/solr/search/TestRangeQuery.java
index fc2689f..d525967 100644
--- a/solr/core/src/test/org/apache/solr/search/TestRangeQuery.java
+++ b/solr/core/src/test/org/apache/solr/search/TestRangeQuery.java
@@ -57,7 +57,8 @@ public class TestRangeQuery extends SolrTestCaseJ4 {
@BeforeClass
public static void beforeClass() throws Exception {
- initCore("solrconfig.xml", "schema11.xml");
+ // use a solrconfig that does not have autowarming
+ initCore("solrconfig_perf.xml", "schema11.xml");
}
@Override
@@ -375,8 +376,6 @@ public class TestRangeQuery extends SolrTestCaseJ4 {
@Test
public void testRangeQueryWithFilterCache() throws Exception {
- TestInjection.delayBeforeCreatingNewDocSet = 500;
-
// sometimes a very small index, sometimes a very large index
// final int numDocs = random().nextBoolean() ? random().nextInt(50) :
atLeast(1000);
final int numDocs = 99;
@@ -384,30 +383,40 @@ public class TestRangeQuery extends SolrTestCaseJ4 {
addInt(doc, 0, 0, "foo_i");
});
- ExecutorService queryService = ExecutorUtil.newMDCAwareFixedThreadPool(4,
new SolrNamedThreadFactory("TestRangeQuery"));
- try (SolrCore core = h.getCoreInc()) {
- SolrRequestHandler defaultHandler = core.getRequestHandler("");
+ // ensure delay comes after createIndex - so we don't affect/count any
cache warming from queries left over by other test methods
+ TestInjection.delayBeforeCreatingNewDocSet = TEST_NIGHTLY ? 50 : 500; //
Run more queries nightly, so use shorter delay
+
+ final int MAX_QUERY_RANGE = 222; // Arbitrary
number in the middle of the value range
+ final int QUERY_START = TEST_NIGHTLY ? 1 : MAX_QUERY_RANGE; // Either run
queries for the full range, or just the last one
+ final int NUM_QUERIES = TEST_NIGHTLY ? 101 : 10;
+ for (int j = QUERY_START ; j <= MAX_QUERY_RANGE; j++) {
+ ExecutorService queryService =
ExecutorUtil.newMDCAwareFixedThreadPool(4, new
SolrNamedThreadFactory("TestRangeQuery-" + j));
+ try (SolrCore core = h.getCoreInc()) {
+ SolrRequestHandler defaultHandler = core.getRequestHandler("");
+
+ ModifiableSolrParams params = new ModifiableSolrParams();
+ params.set("q", "*:*");
+ params.add("fq", "id:[0 TO " + j + "]"); // These should all come from
FilterCache
+
+ // Regular: 10 threads with 4 executors would be enough for 3 waves,
or approximately 1500ms of delay
+ // Nightly: 101 threads with 4 executors is 26 waves, approximately
1300ms delay
+ CountDownLatch atLeastOnceCompleted = new CountDownLatch(TEST_NIGHTLY
? 30 : 1);
+ for (int i = 0; i < NUM_QUERIES; i++) {
+ queryService.submit(() -> {
+ try (SolrQueryRequest req = req(params)) {
+ core.execute(defaultHandler, req, new SolrQueryResponse());
+ }
+ atLeastOnceCompleted.countDown();
+ });
+ }
- ModifiableSolrParams params = new ModifiableSolrParams();
- params.set("q", "*:*");
- params.add("fq", "id:[0 TO 222]"); // These should all come from
FilterCache
+ queryService.shutdown(); // No more requests will be queued up
+ atLeastOnceCompleted.await(); // Wait for the first batch of queries
to complete
+ assertTrue(queryService.awaitTermination(1, TimeUnit.SECONDS)); // All
queries after should be very fast
- // 10 threads with 4 executors would be enough for 3 waves, or
approximately 1500ms of delay
- CountDownLatch atLeastOnceCompleted = new CountDownLatch(1);
- for (int i = 0; i < 10; i++) {
- queryService.submit(() -> {
- try (SolrQueryRequest req = req(params)) {
- core.execute(defaultHandler, req, new SolrQueryResponse());
- }
- atLeastOnceCompleted.countDown();
- });
+ assertEquals("Create only one DocSet outside of cache", 1,
TestInjection.countDocSetDelays.get());
}
-
- queryService.shutdown(); // No more requests will be queued up
- atLeastOnceCompleted.await(); // Wait for the first query to complete
- assertTrue(queryService.awaitTermination(1, TimeUnit.SECONDS)); // All
queries after should be very fast
-
- assertEquals("Create only one DocSet outside of cache", 1,
TestInjection.countDocSetDelays.get());
+ TestInjection.countDocSetDelays.set(0);
}
}