Skip to content

SOLR-18150: Add SolrBackend abstraction for test/benchmark deployments#4214

Open
dsmiley wants to merge 7 commits intoapache:mainfrom
dsmiley:SOLR-18150-SolrBackend
Open

SOLR-18150: Add SolrBackend abstraction for test/benchmark deployments#4214
dsmiley wants to merge 7 commits intoapache:mainfrom
dsmiley:SOLR-18150-SolrBackend

Conversation

@dsmiley
Copy link
Contributor

@dsmiley dsmiley commented Mar 13, 2026

  • Created SolrBackend interface to abstract over different Solr deployment types
  • Added implementations:
    • EmbeddedSolrBackend: in-process CoreContainer/EmbeddedSolrServer
    • RemoteSolrBackend: CloudSolrClient connecting to remote SolrCloud cluster
    • JettySolrRunner: HTTP/Jetty + EmbeddedSolrServer
    • MiniSolrCloudCluster: embedded multi-node SolrCloud

Key features:

  • Unified API for collection/configSet management across deployment types
  • Methods throw SolrServerException & IOException
  • hasConfigSet/hasCollection methods for existence checking
  • createCollection/uploadConfigSet for resource creation
  • getBaseUrl(Random) returns URL of a node (random for cloud deployments)
  • dumpMetrics/dumpCoreInfo for diagnostics

https://issues.apache.org/jira/browse/SOLR-18150

This PR only introduces the abstraction but no callers. Follow-on is to do so with benchmarks & tests separately. I have WIP for the benchmark side already.

- Created SolrBackend interface to abstract over different Solr deployment types
- Added implementations:
  - EmbeddedSolrBackend: in-process CoreContainer/EmbeddedSolrServer
  - RemoteSolrBackend: CloudSolrClient connecting to remote SolrCloud cluster
  - JettySolrRunner: HTTP/Jetty + EmbeddedSolrServer
  - MiniSolrCloudCluster: embedded multi-node SolrCloud

Key features:
- Unified API for collection/configSet management across deployment types
- Methods throw SolrServerException & IOException
- hasConfigSet/hasCollection methods for existence checking
- createCollection/uploadConfigSet for resource creation
- getBaseUrl(Random) returns URL of a node (random for cloud deployments)
- dumpMetrics/dumpCoreInfo for diagnostics

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

/** "Mini" SolrCloud cluster to be used for testing */
public class MiniSolrCloudCluster {
public class MiniSolrCloudCluster implements SolrBackend {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's a pretty natural fit to implement directly here

* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.solr.cloud;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put into cloud package as it assumes SolrCloud

*
* <p>Data is persisted in the given {@code solrHome} directory.
*/
public class EmbeddedSolrBackend implements SolrBackend {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EmbeddedSolrServer cannot implement SolrBackend directly because the latter is in solr-core and SolrBackend is in test-framework

* @since solr 1.3
*/
public class JettySolrRunner {
public class JettySolrRunner implements SolrBackend {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this ended up being slightly awkward to implement directly. An alternative could be a new method asSolrBackend

* this client and is responsible for closing it. Callers that want a long-lived client should
* cache it themselves.
*/
SolrClient newClient(String collection); // nocommit or newSolrClient ?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nocommit; seeking feedback

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

went with newSolrClient

* this backend is {@link #close()}d. A {@link CloudSolrClient} should be returned if possible.
* nocommit
*/
SolrClient getAdminClient(); // nocommit or "getNodeClient" or getSolrClient ?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nocommit; seeking feedback

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

went with getSolrClient, thus using the same name as in MiniSolrCloudCluster

dsmiley added 2 commits March 15, 2026 11:31
MiniSolrCloudCluster:
* optimize/cleanup configSet methods
* reorg methods
@github-actions github-actions bot added documentation Improvements or additions to documentation jetty-server tests cat:search cat:index labels Mar 15, 2026
@dsmiley
Copy link
Contributor Author

dsmiley commented Mar 16, 2026

Planning to merge ~Tuesday night

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant