Skip to content

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

Merged
dsmiley merged 11 commits intoapache:mainfrom
dsmiley:SOLR-18150-SolrBackend
Mar 29, 2026
Merged

SOLR-18150: Add SolrBackend abstraction for test/benchmark deployments#4214
dsmiley merged 11 commits intoapache:mainfrom
dsmiley:SOLR-18150-SolrBackend

Conversation

@dsmiley
Copy link
Copy Markdown
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
Copy Markdown
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

Comment thread solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java Outdated
Comment thread solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java Outdated
Comment thread solr/test-framework/src/java/org/apache/solr/cloud/RemoteSolrBackend.java Outdated
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.solr.cloud;
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

Comment thread solr/test-framework/src/java/org/apache/solr/embedded/JettySolrRunner.java Outdated
Comment thread solr/test-framework/src/java/org/apache/solr/embedded/JettySolrRunner.java Outdated
* 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

dsmiley commented Mar 16, 2026

Planning to merge ~Tuesday night

@dsmiley dsmiley merged commit af21fef into apache:main Mar 29, 2026
5 checks passed
@dsmiley dsmiley deleted the SOLR-18150-SolrBackend branch March 29, 2026 15:23
@dsmiley
Copy link
Copy Markdown
Contributor Author

dsmiley commented Mar 29, 2026

At the last minute I found it convenient for JettySolrRunner to manage a HttpJettySolrClient to be returned when getSolrClient() is called. This is useful, even if code isn't calling JSR as a "backend". For example if a test needs a Jetty HttpClient, it can get it easily from there.

dsmiley added a commit that referenced this pull request Mar 30, 2026
#4214)

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

Created SolrBackend interface to abstract over different Solr deployment
types (embedded, remote, Jetty, MiniSolrCloudCluster) with a unified API
for collection/configSet management, diagnostics, and node URL access.
JettySolrRunner now manages a HttpJettySolrClient instance, get via getSolrClient.

This PR only introduces the abstraction; follow-on PRs will add callers
in benchmarks and tests.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
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