This is an automated email from the ASF dual-hosted git repository.
houston pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/branch_9x by this push:
new 07b1740e315 Fix client management in TestQueryingOnDownCollection
07b1740e315 is described below
commit 07b1740e315b7e3eafb68c8ab39bd984c6a6d90c
Author: Houston Putman <[email protected]>
AuthorDate: Fri Mar 7 18:03:12 2025 -0600
Fix client management in TestQueryingOnDownCollection
(cherry picked from commit 2a8b7ab2266d0eff408fbe35e0ce44f761db2445)
---
.../solr/cloud/TestQueryingOnDownCollection.java | 70 ++++++++++++----------
1 file changed, 39 insertions(+), 31 deletions(-)
diff --git
a/solr/core/src/test/org/apache/solr/cloud/TestQueryingOnDownCollection.java
b/solr/core/src/test/org/apache/solr/cloud/TestQueryingOnDownCollection.java
index 78f165613f2..6254d3d2917 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestQueryingOnDownCollection.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestQueryingOnDownCollection.java
@@ -79,43 +79,45 @@ public class TestQueryingOnDownCollection extends
SolrCloudTestCase {
// assert all nodes as active
assertEquals(3,
cluster.getSolrClient().getClusterStateProvider().getLiveNodes().size());
- SolrClient client = cluster.getJettySolrRunner(0).newClient();
-
SolrRequest<QueryResponse> req =
new QueryRequest(new SolrQuery("*:*").setRows(0))
.setBasicAuthCredentials(USERNAME, PASSWORD);
- // Without the SOLR-13793 fix, this causes requests to "down collection"
to pile up (until the
- // nodes run out of serviceable threads, and they crash, even for other
collections hosted on
- // the
- // nodes).
- SolrException error =
- expectThrows(
- SolrException.class,
- "Request should fail after trying all replica nodes once",
- () -> client.request(req, COLLECTION_NAME));
-
- client.close();
-
- assertEquals(error.code(), SolrException.ErrorCode.INVALID_STATE.code);
- assertTrue(
- error.getMessage().contains("No active replicas found for collection:
" + COLLECTION_NAME));
+ try (SolrClient client = cluster.getJettySolrRunner(0).newClient()) {
+ // Without the SOLR-13793 fix, this causes requests to "down collection"
to pile up (until the
+ // nodes run out of serviceable threads, and they crash, even for other
collections hosted on
+ // the
+ // nodes).
+ SolrException error =
+ expectThrows(
+ SolrException.class,
+ "Request should fail after trying all replica nodes once",
+ () -> client.request(req, COLLECTION_NAME));
+
+ assertEquals(error.code(), SolrException.ErrorCode.INVALID_STATE.code);
+ assertTrue(
+ error
+ .getMessage()
+ .contains("No active replicas found for collection: " +
COLLECTION_NAME));
+ }
// run same set of tests on v2 client which uses V2HttpCall
- SolrClient v2Client =
- new
Http2SolrClient.Builder(cluster.getJettySolrRunner(0).getBaseUrl().toString()).build();
-
- error =
- expectThrows(
- SolrException.class,
- "Request should fail after trying all replica nodes once",
- () -> v2Client.request(req, COLLECTION_NAME));
-
- v2Client.close();
-
- assertEquals(error.code(), SolrException.ErrorCode.INVALID_STATE.code);
- assertTrue(
- error.getMessage().contains("No active replicas found for collection:
" + COLLECTION_NAME));
+ try (SolrClient v2Client =
+ new
Http2SolrClient.Builder(cluster.getJettySolrRunner(0).getBaseUrl().toString())
+ .build()) {
+
+ SolrException error =
+ expectThrows(
+ SolrException.class,
+ "Request should fail after trying all replica nodes once",
+ () -> v2Client.request(req, COLLECTION_NAME));
+
+ assertEquals(error.code(), SolrException.ErrorCode.INVALID_STATE.code);
+ assertTrue(
+ error
+ .getMessage()
+ .contains("No active replicas found for collection: " +
COLLECTION_NAME));
+ }
}
@SuppressWarnings({"unchecked"})
@@ -141,6 +143,12 @@ public class TestQueryingOnDownCollection extends
SolrCloudTestCase {
.getZkClient()
.setData(
"/collections/" + COLLECTION_NAME + "/state.json",
Utils.toJSON(infectedState), true);
+
+ cluster
+ .getJettySolrRunner(0)
+ .getCoreContainer()
+ .getZkController()
+ .publishAndWaitForDownStates();
}
protected static final String STD_CONF =