testcontainers / testcontainers/testcontainers-java
Solr container doesn't work with cloud (cluster) Solr client
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 8.7k
- Forks
- 1.9k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 9
Description
It is not possible to use the Solr container with the cloud Solr client (CloudSolrClient, this client can be used for accessing Solr clusters), because the following exception is thrown when trying to send any request:
Tried fetching cluster state using the node names we knew of, i.e. [localhost:8983_solr]. However, succeeded in obtaining the cluster state from none of them.If you think your Solr cluster is up and is accessible, you could try re-creating a new CloudSolrClient using working solrUrl(s) or zkHost(s).
java.lang.RuntimeException: Tried fetching cluster state using the node names we knew of, i.e. [localhost:8983_solr]. However, succeeded in obtaining the cluster state from none of them.If you think your Solr cluster is up and is accessible, you could try re-creating a new CloudSolrClient using working solrUrl(s) or zkHost(s).
at org.apache.solr.client.solrj.impl.BaseHttpClusterStateProvider.getState(BaseHttpClusterStateProvider.java:105)
at org.apache.solr.client.solrj.impl.BaseCloudSolrClient.resolveAliases(BaseCloudSolrClient.java:1182)
at org.apache.solr.client.solrj.impl.BaseCloudSolrClient.requestWithRetryOnStaleState(BaseCloudSolrClient.java:894)
at org.apache.solr.client.solrj.impl.BaseCloudSolrClient.request(BaseCloudSolrClient.java:866)
at org.apache.solr.client.solrj.SolrRequest.process(SolrRequest.java:214)
at org.apache.solr.client.solrj.SolrClient.add(SolrClient.java:106)
at org.apache.solr.client.solrj.SolrClient.add(SolrClient.java:71)
at com.example.SolrQueryTest.setUp(SolrQueryTest.java:37)
...
You can see this exception after changing this line to
solrClient = new CloudSolrClient.Builder(Collections.singletonList("http://" + solrContainer.getContainerIpAddress() + ":" + solrContainer.getSolrPort() + "/solr")).build(); and running any test in SolrQueryTest.java.
The underlying issue is that the cluster will report 8983 as the port used by Solr, but the container uses a different host port, so localhost:8983 will not be available to the client.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with examples/solr-container/src/test/java/com/example/SolrQueryTest.java, especially the CloudSolrClient setup described at line 33. Trace how the Solr container reports its cluster port compared with the mapped host port. Done means CloudSolrClient requests work through the container and the SolrQueryTest tests pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, java
- Domain
- databases, testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100