You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by ho...@apache.org on 2022/02/28 16:10:54 UTC
[solr] branch branch_9x updated: SOLR-15870: Fix TestCollectionAPI HTTP error
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 36fd50c SOLR-15870: Fix TestCollectionAPI HTTP error
36fd50c is described below
commit 36fd50cd09a9006cc23b88066e21a4bee66a7f52
Author: Houston Putman <ho...@apache.org>
AuthorDate: Mon Feb 28 10:52:20 2022 -0500
SOLR-15870: Fix TestCollectionAPI HTTP error
The error occured because the test was using a single client
to issue Admin commands before and after a server was restarted.
The HTTP Client caches connections, and didn't evict the expired
connection to the server after it restarted. SolrJ does not attempt to
retry Admin calls, therefore the test failed whenever the stale
connection was used.
(cherry picked from commit c57345b1293ba1a623a53415e4adc93104d99e9c)
---
.../cloud/api/collections/TestCollectionAPI.java | 36 +++++++++++-----------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/solr/core/src/test/org/apache/solr/cloud/api/collections/TestCollectionAPI.java b/solr/core/src/test/org/apache/solr/cloud/api/collections/TestCollectionAPI.java
index 32598ee..830030d 100644
--- a/solr/core/src/test/org/apache/solr/cloud/api/collections/TestCollectionAPI.java
+++ b/solr/core/src/test/org/apache/solr/cloud/api/collections/TestCollectionAPI.java
@@ -29,16 +29,13 @@ import com.google.common.collect.Lists;
import org.apache.solr.client.solrj.SolrRequest;
import org.apache.solr.client.solrj.SolrResponse;
import org.apache.solr.client.solrj.SolrServerException;
-import org.apache.solr.client.solrj.cloud.SolrCloudManager;
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
import org.apache.solr.client.solrj.impl.BaseHttpSolrClient;
import org.apache.solr.client.solrj.impl.CloudSolrClient;
-import org.apache.solr.client.solrj.impl.SolrClientCloudManager;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.request.QueryRequest;
import org.apache.solr.client.solrj.request.V2Request;
import org.apache.solr.client.solrj.response.CollectionAdminResponse;
-import org.apache.solr.cloud.CloudUtil;
import org.apache.solr.cloud.ZkConfigSetService;
import org.apache.solr.cloud.ZkTestServer;
import org.apache.solr.common.SolrException;
@@ -366,21 +363,24 @@ public class TestCollectionAPI extends ReplicaPropertiesBase {
// bring them up again
jetty.start();
- SolrCloudManager cloudManager = new SolrClientCloudManager(null, client);
- zkStateReader.waitForLiveNodes(30, TimeUnit.SECONDS, (o, n) -> n != null && n.contains(nodeName));
- CloudUtil.waitForState(cloudManager, COLLECTION_NAME, 30, TimeUnit.SECONDS, (liveNodes, coll) ->
- coll != null &&
- coll.getReplicas().stream()
- .allMatch(r -> r.getState().equals(Replica.State.ACTIVE)));
- rsp = request.process(client).getResponse();
- collection = (Map<String, Object>) Utils.getObjectByPath(rsp, false, "cluster/collections/" + COLLECTION_NAME);
- assertEquals("collection health", "GREEN", collection.get("health"));
- shardStatus = (Map<String, Object>) collection.get("shards");
- assertEquals(2, shardStatus.size());
- health = (String) Utils.getObjectByPath(shardStatus, false, "shard1/health");
- assertEquals("shard1 health", "GREEN", health);
- health = (String) Utils.getObjectByPath(shardStatus, false, "shard2/health");
- assertEquals("shard2 health", "GREEN", health);
+ // Need to start a new client, in case the http connections in the old client are still cached to the restarted server.
+ // If this is the case, it will throw an HTTP Exception, and we don't retry Admin requests.
+ try (CloudSolrClient newClient = createCloudClient(null)) {
+ newClient.getZkStateReader().waitForLiveNodes(30, TimeUnit.SECONDS, (o, n) -> n != null && n.contains(nodeName));
+ newClient.getZkStateReader().waitForState(COLLECTION_NAME, 30, TimeUnit.SECONDS, (liveNodes, coll) ->
+ coll != null &&
+ coll.getReplicas().stream()
+ .allMatch(r -> r.getState().equals(Replica.State.ACTIVE)));
+ rsp = request.process(newClient).getResponse();
+ collection = (Map<String, Object>) Utils.getObjectByPath(rsp, false, "cluster/collections/" + COLLECTION_NAME);
+ assertEquals("collection health", "GREEN", collection.get("health"));
+ shardStatus = (Map<String, Object>) collection.get("shards");
+ assertEquals(2, shardStatus.size());
+ health = (String) Utils.getObjectByPath(shardStatus, false, "shard1/health");
+ assertEquals("shard1 health", "GREEN", health);
+ health = (String) Utils.getObjectByPath(shardStatus, false, "shard2/health");
+ assertEquals("shard2 health", "GREEN", health);
+ }
}
}