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

houston 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 17f318e2d7b SOLR-17819: Improve 
DistributedDebugComponentTest.testTolerantSearch
17f318e2d7b is described below

commit 17f318e2d7b97d11c9017fa966ef81021ec620dd
Author: Houston Putman <[email protected]>
AuthorDate: Fri Jul 18 13:47:34 2025 -0700

    SOLR-17819: Improve DistributedDebugComponentTest.testTolerantSearch
---
 .../component/DistributedDebugComponentTest.java   | 52 ++++++++++++----------
 1 file changed, 29 insertions(+), 23 deletions(-)

diff --git 
a/solr/core/src/test/org/apache/solr/handler/component/DistributedDebugComponentTest.java
 
b/solr/core/src/test/org/apache/solr/handler/component/DistributedDebugComponentTest.java
index 8ed448d5ebe..8e8c5ec88fd 100644
--- 
a/solr/core/src/test/org/apache/solr/handler/component/DistributedDebugComponentTest.java
+++ 
b/solr/core/src/test/org/apache/solr/handler/component/DistributedDebugComponentTest.java
@@ -409,29 +409,35 @@ public class DistributedDebugComponentTest extends 
SolrJettyTestBase {
     query.set("debug", "true");
     query.set("distrib", "true");
     query.setFields("id", "text");
-    query.set("shards", shard1 + "," + shard2 + "," + badShard);
-
-    // verify that the request would fail if shards.tolerant=false
-    ignoreException("Server refused connection");
-    expectThrows(SolrException.class, () -> collection1.query(query));
-
-    query.set(ShardParams.SHARDS_TOLERANT, "true");
-    QueryResponse response = collection1.query(query);
-    assertTrue(
-        (Boolean)
-            response
-                .getResponseHeader()
-                .get(SolrQueryResponse.RESPONSE_HEADER_PARTIAL_RESULTS_KEY));
-    @SuppressWarnings("unchecked")
-    NamedList<String> badShardTrack =
-        (((NamedList<NamedList<NamedList<String>>>) 
response.getDebugMap().get("track"))
-                .get("EXECUTE_QUERY"))
-            .get(badShard);
-    assertEquals("Unexpected response size for shard", 1, 
badShardTrack.size());
-    Entry<String, String> exception = badShardTrack.iterator().next();
-    assertEquals("Expected key 'Exception' not found", "Exception", 
exception.getKey());
-    assertNotNull("Exception message should not be null", 
exception.getValue());
-    unIgnoreException("Server refused connection");
+    // When the badShard is placed first, we are more likely to hit errors
+    query.set("shards", badShard + "," + shard2 + "," + shard1);
+
+    // Submit the requests enough times to get failures when code is buggy
+    for (int i = 0; i < (TEST_NIGHTLY ? 500 : 200); i++) {
+      // verify that the request would fail if shards.tolerant=false
+      query.set(ShardParams.SHARDS_TOLERANT, "false");
+      ignoreException("Server refused connection");
+      expectThrows(SolrException.class, () -> collection1.query(query));
+
+      // verify that the request would succeed if shards.tolerant=true
+      query.set(ShardParams.SHARDS_TOLERANT, "true");
+      QueryResponse response = collection1.query(query);
+      assertTrue(
+          (Boolean)
+              response
+                  .getResponseHeader()
+                  .get(SolrQueryResponse.RESPONSE_HEADER_PARTIAL_RESULTS_KEY));
+      @SuppressWarnings("unchecked")
+      NamedList<String> badShardTrack =
+          (((NamedList<NamedList<NamedList<String>>>) 
response.getDebugMap().get("track"))
+                  .get("EXECUTE_QUERY"))
+              .get(badShard);
+      assertEquals("Unexpected response size for shard", 1, 
badShardTrack.size());
+      Entry<String, String> exception = badShardTrack.iterator().next();
+      assertEquals("Expected key 'Exception' not found", "Exception", 
exception.getKey());
+      assertNotNull("Exception message should not be null", 
exception.getValue());
+      unIgnoreException("Server refused connection");
+    }
   }
 
   /** Compares the same section on the two query responses */

Reply via email to