You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by GitBox <gi...@apache.org> on 2022/02/22 17:11:10 UTC

[GitHub] [solr] madrob commented on a change in pull request #674: SOLR-15964: Fix test; use latch instead of a sleep

madrob commented on a change in pull request #674:
URL: https://github.com/apache/solr/pull/674#discussion_r811464715



##########
File path: solr/core/src/test/org/apache/solr/core/TestLazyCores.java
##########
@@ -910,13 +914,31 @@ public void testDontEvictUsedCore() throws Exception {
         .substring("NOT evicting transient core [" + transientCoreNames[0] + "]")) {
       cc.waitForLoadingCoresToFinish(1000);
       var solr = new EmbeddedSolrServer(cc, null);
-      final var longReqTimeMs = 2000; // if lower too much, the test will fail on a slow/busy CI
+      final var longReqTimeMs = 5000; // plenty of time for a slow/busy CI
 
-      // First, start a long request on the first transient core
+      // First, start a long request on the first transient core.
+      //  We do this via relying on EmbeddedSolrServer to keep the core open as it works with
+      //  this streaming callback mechanism.
+      var longRequestLatch = new CountDownLatch(1);
       var thread = new Thread(() -> {
         try {
-          // TODO Solr ought to have a query test "latch" mechanism so we don't sleep arbitrarily
-          solr.query(transientCoreNames[0], params("q", "{!func}sleep(" + longReqTimeMs + ",1)"));
+          var req = new QueryRequest(params("q", "*:*"));
+          req.setStreamingResponseCallback(new StreamingResponseCallback() {
+            @Override
+            public void streamSolrDocument(SolrDocument doc) {
+            }
+
+            @Override
+            public void streamDocListInfo(long numFound, long start, Float maxScore) {
+              try {
+                longRequestLatch.await(); // the core remains open until the test calls countDown()
+              } catch (InterruptedException e) {
+                Thread.currentThread().interrupt();
+                throw new RuntimeException(e);
+              }
+            }
+          });
+          req.process(solr, transientCoreNames[0]);

Review comment:
       `solr.queryAndStreamResponse()`?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org